@@ -21,12 +21,11 @@ @interface FLEXSQLCommandExecutionViewController ()
21
21
@end
22
22
23
23
@implementation FLEXSQLCommandExecutionViewController
24
- @synthesize isSelectionType, dbManager, textView, submitButton, statusLabel;
25
24
26
25
- (void )viewDidLoad {
27
26
[super viewDidLoad ];
28
27
29
- self.navigationItem .title = isSelectionType ? @" Select with SQL" : @" Execute SQL" ;
28
+ self.navigationItem .title = self. isSelect ? @" Select with SQL" : @" Execute SQL" ;
30
29
[self .view addObserver: self forKeyPath: @" frame" options: 0 context: NULL ];
31
30
32
31
[self addOtherUIElementsAndPositionThem ];
@@ -37,32 +36,32 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
37
36
}
38
37
39
38
- (void )addOtherUIElementsAndPositionThem {
40
- if ( textView == nil ) {
41
- textView = [UITextView new ];
42
- textView.backgroundColor = [UIColor colorWithWhite: 0.9 alpha: 1.0 ];
43
- textView.textColor = [UIColor blackColor ];
39
+ if (!self. textView ) {
40
+ self. textView = [UITextView new ];
41
+ self. textView .backgroundColor = [UIColor colorWithWhite: 0.9 alpha: 1.0 ];
42
+ self. textView .textColor = [UIColor blackColor ];
44
43
45
- [self .view addSubview: textView];
44
+ [self .view addSubview: self . textView];
46
45
}
47
46
48
- if ( submitButton == nil ) {
49
- submitButton = [UIButton new ];
47
+ if (!self. submitButton ) {
48
+ self. submitButton = [UIButton new ];
50
49
51
- [submitButton setTitleColor: [UIColor blueColor ] forState: UIControlStateNormal];
52
- [submitButton setBackgroundColor: [UIColor colorWithWhite: 0.9 alpha: 1.0 ]];
50
+ [self . submitButton setTitleColor: [UIColor blueColor ] forState: UIControlStateNormal];
51
+ [self . submitButton setBackgroundColor: [UIColor colorWithWhite: 0.9 alpha: 1.0 ]];
53
52
54
- [submitButton setTitle: @" Submit" forState: UIControlStateNormal];
55
- [submitButton addTarget: self action: @selector (submitPressed ) forControlEvents: UIControlEventTouchUpInside];
53
+ [self . submitButton setTitle: @" Submit" forState: UIControlStateNormal];
54
+ [self . submitButton addTarget: self action: @selector (submitPressed ) forControlEvents: UIControlEventTouchUpInside];
56
55
57
- [self .view addSubview: submitButton];
56
+ [self .view addSubview: self . submitButton];
58
57
}
59
58
60
- if ( statusLabel == nil ) {
61
- statusLabel = [UILabel new ];
59
+ if (!self. statusLabel ) {
60
+ self. statusLabel = [UILabel new ];
62
61
63
- statusLabel.textAlignment = NSTextAlignmentCenter;
64
- statusLabel.textColor = [UIColor blackColor ];
65
- [self .view addSubview: statusLabel];
62
+ self. statusLabel .textAlignment = NSTextAlignmentCenter;
63
+ self. statusLabel .textColor = [UIColor blackColor ];
64
+ [self .view addSubview: self . statusLabel];
66
65
}
67
66
68
67
self.view .backgroundColor = [UIColor whiteColor ];
@@ -74,19 +73,20 @@ - (void)addOtherUIElementsAndPositionThem {
74
73
CGFloat statusLabelHeight = 70 ;
75
74
CGFloat textViewHeight = self.view .frame .size .height - startingY - submitButtonHeight - statusLabelHeight - sideMargin * 4 ;
76
75
77
- textView.frame = CGRectMake (sideMargin, startingY + sideMargin, width, textViewHeight);
78
- statusLabel.frame = CGRectMake (sideMargin, textView.frame .origin .y + textViewHeight + sideMargin, width, statusLabelHeight);
79
- submitButton.frame = CGRectMake (sideMargin, statusLabel.frame .origin .y + statusLabelHeight + sideMargin, width, submitButtonHeight);
76
+ self. textView .frame = CGRectMake (sideMargin, startingY + sideMargin, width, textViewHeight);
77
+ self. statusLabel .frame = CGRectMake (sideMargin, self. textView .frame .origin .y + textViewHeight + sideMargin, width, statusLabelHeight);
78
+ self. submitButton .frame = CGRectMake (sideMargin, self. statusLabel .frame .origin .y + statusLabelHeight + sideMargin, width, submitButtonHeight);
80
79
}
81
80
82
- - (void )submitPressed {
83
- NSString * text = textView.text == nil ? @" " : textView.text ;
81
+ - (void )submitPressed
82
+ {
83
+ NSString *text = self.textView .text == nil ? @" " : self.textView .text ;
84
84
85
- if (isSelectionType ) {
85
+ if (self. isSelect ) {
86
86
NSString *errorString;
87
- NSArray <NSDictionary <NSString *, id > *> *responce = [dbManager executeSelectionQuery: text error: &errorString];
87
+ NSArray <NSDictionary <NSString *, id > *> *response = [self . dbManager executeSelectionQuery: text error: &errorString];
88
88
89
- if (responce == nil ) {
89
+ if (!response ) {
90
90
[self presentOnErrorAlert: errorString];
91
91
return ;
92
92
}
@@ -103,31 +103,32 @@ - (void)submitPressed {
103
103
104
104
FLEXTableContentViewController *contentViewController = [FLEXTableContentViewController new ];
105
105
106
- contentViewController.contentsArray = responce ;
107
- contentViewController.columnsArray = [ tables copy ] ;
106
+ contentViewController.contentsArray = response ;
107
+ contentViewController.columnsArray = tables;
108
108
109
- contentViewController.title = @" Executed sql " ;
109
+ contentViewController.title = @" Executed SQL " ;
110
110
111
111
[self .navigationController pushViewController: contentViewController animated: YES ];
112
112
} else {
113
- NSString * errorMessage = [self .dbManager executeNonSelectQuery: text];
114
-
115
- statusLabel.text = errorMessage == nil ? @" SUCCESS" : errorMessage;
113
+ NSString *errorMessage = [self .dbManager executeNonSelectQuery: text];
114
+ self.statusLabel .text = errorMessage ?: @" SUCCESS" ;
116
115
}
117
116
}
118
117
119
118
120
- - (void )presentOnErrorAlert : (NSString *)message
119
+ - (void )presentOnErrorAlert : (NSString *)message
121
120
{
122
121
UIAlertController *alert = [UIAlertController
123
- alertControllerWithTitle: @" SQL Execution error !!!"
124
- message: message
125
- preferredStyle: UIAlertControllerStyleAlert];
122
+ alertControllerWithTitle: @" SQL Execution error !!!"
123
+ message: message
124
+ preferredStyle: UIAlertControllerStyleAlert
125
+ ];
126
126
127
127
UIAlertAction *okButton = [UIAlertAction
128
- actionWithTitle: @" Ok"
129
- style: UIAlertActionStyleDestructive
130
- handler: nil ];
128
+ actionWithTitle: @" Ok"
129
+ style: UIAlertActionStyleDestructive
130
+ handler: nil
131
+ ];
131
132
132
133
[alert addAction: okButton];
133
134
[self presentViewController: alert animated: YES completion: nil ];
0 commit comments