File: MAPanel.m

package info (click to toggle)
mysql-gui-tools 5.0r12-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 105,540 kB
  • ctags: 50,897
  • sloc: sql: 348,439; pascal: 285,780; cpp: 94,578; ansic: 90,768; objc: 33,761; sh: 25,629; xml: 10,924; yacc: 10,755; java: 9,986; php: 2,806; python: 2,068; makefile: 1,945; perl: 3
file content (148 lines) | stat: -rw-r--r-- 2,340 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//
//  MAPanel.m
//  MySQL Administrator
//
//  Created by Alfredo Kojima on Thu Jun 24 2004.
//  Copyright (c) 2004 MySQL AB. All rights reserved.
//

#import "MAPanel.h"


@implementation MAPanel

+ (NSImage*)icon
{
  return nil;
}

+ (NSString*)label
{
  return @"";
}

+ (NSString*)toolTip
{
  return @"";
}

+ (BOOL)needsConnection
{
  return YES;
}

- (id)initWithNibFile: (NSString*)file
           panelOwner: (id<MAdministratorProtocol>)owner
{
  self= [super init];
  if (!self)
    return nil;
  
  _owner= owner;
  
  if (![NSBundle loadNibNamed:file owner:self])
  {
    NSLog(@"Could not load nib file %@", file);
    [self release];
    return nil;
  }
  
  return self;
}

- (id)initWithOwner:(id<MAdministratorProtocol>)owner
{
  // must be overriden
  return nil;
}

- (NSView*)topView
{
  return topBox;
}

- (NSView*)sideView
{
  return nil;
}

- (BOOL)willShow
{
  return YES;
}

- (void)didShow
{
}

- (BOOL)willHide
{
  return YES;
}

- (void)didHide
{
}

- (BOOL)willClose
{
  return YES;
}

- (NSRect)defaultFrame
{
  return _defaultFrame;
}

- (void)setNeedsSave:(BOOL)flag
{
  _needsSave= flag;
  [[topBox window] setDocumentEdited:flag];
}

- (BOOL)needsSave
{
  return _needsSave;
}


- (id)initWithMessage:(NSString*)message owner:(id)owner
{
  NSTextField *text;

  self= [super init];
  _owner= owner;
  topBox= [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 500, 100)];
  text= [[NSTextField alloc] initWithFrame:NSMakeRect(0, 40, 500, 30)];
  _defaultFrame= [topBox frame];
  [text setBordered:NO];
  [text setDrawsBackground:NO];
  [text setEditable:NO];
  [text setAlignment:NSCenterTextAlignment];
  [text setTextColor:[NSColor grayColor]];
  [text setFont:[NSFont systemFontOfSize:18]];
  [text setStringValue:message];
  [topBox addSubview:text];
  [text setAutoresizingMask:NSViewWidthSizable|NSViewMinYMargin|NSViewMaxYMargin];

  return self;
}


- (void)showMessageSheet:(NSString*)message
                    info:(NSString*)info
{
  NSAlert *alert = [[[NSAlert alloc] init] autorelease];
  
  [alert addButtonWithTitle:@"OK"];
  [alert setMessageText:message];
  if (info)
    [alert setInformativeText:info];
  
  [alert setAlertStyle:NSWarningAlertStyle];
  
  [alert beginSheetModalForWindow:[topBox window] modalDelegate:self 
                   didEndSelector:nil contextInfo:nil];
}

@end