Skip to content

Commit 90c639c

Browse files
Preference page UI reconciliation hook
The new method makes it easy to set inter-dependent control states (typically conditional enabling).
1 parent f461d66 commit 90c639c

File tree

6 files changed

+29
-43
lines changed

6 files changed

+29
-43
lines changed

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/preferences/ATAConfigurationBlock.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* Contributors:
99
* Angelo Zerr <[email protected]> - initial API and implementation
10+
* Lorenzo Dalla Vecchia <[email protected]> - added reconcileControls hook
1011
*/
1112
package ts.eclipse.ide.internal.ui.preferences;
1213

@@ -17,8 +18,6 @@
1718
import org.eclipse.swt.layout.GridLayout;
1819
import org.eclipse.swt.widgets.Button;
1920
import org.eclipse.swt.widgets.Composite;
20-
import org.eclipse.swt.widgets.Control;
21-
import org.eclipse.swt.widgets.Group;
2221
import org.eclipse.swt.widgets.Label;
2322
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
2423

@@ -69,13 +68,7 @@ public void enablePreferenceContent(boolean enable) {
6968
}
7069

7170
@Override
72-
protected Control createContents(Composite parent) {
73-
Composite nodejsComposite = createUI(parent);
74-
validateSettings(null, null, null);
75-
return nodejsComposite;
76-
}
77-
78-
private Composite createUI(Composite parent) {
71+
protected Composite createUI(Composite parent) {
7972
final ScrolledPageContent pageContent = new ScrolledPageContent(parent);
8073
Composite composite = pageContent.getBody();
8174
GridLayout layout = new GridLayout();

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/preferences/AbstractTypeScriptRepositoryConfigurationBlock.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* Contributors:
99
* Angelo Zerr <[email protected]> - initial API and implementation
10+
* Lorenzo Dalla Vecchia <[email protected]> - added reconcileControls hook
1011
*/
1112
package ts.eclipse.ide.internal.ui.preferences;
1213

@@ -23,7 +24,6 @@
2324
import org.eclipse.swt.widgets.Button;
2425
import org.eclipse.swt.widgets.Combo;
2526
import org.eclipse.swt.widgets.Composite;
26-
import org.eclipse.swt.widgets.Control;
2727
import org.eclipse.swt.widgets.Group;
2828
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
2929

@@ -55,13 +55,7 @@ public AbstractTypeScriptRepositoryConfigurationBlock(IStatusChangeListener cont
5555
}
5656

5757
@Override
58-
protected Control createContents(Composite parent) {
59-
Composite contents = createUI(parent);
60-
validateSettings(null, null, null);
61-
return contents;
62-
}
63-
64-
private Composite createUI(Composite parent) {
58+
protected Composite createUI(Composite parent) {
6559
final ScrolledPageContent pageContent = new ScrolledPageContent(parent);
6660
Composite composite = pageContent.getBody();
6761
GridLayout layout = new GridLayout();

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/preferences/FormatterConfigurationBlock.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* Contributors:
99
* Angelo Zerr <[email protected]> - initial API and implementation
10+
* Lorenzo Dalla Vecchia <[email protected]> - added reconcileControls hook
1011
*/
1112
package ts.eclipse.ide.internal.ui.preferences;
1213

@@ -16,7 +17,6 @@
1617
import org.eclipse.swt.layout.GridData;
1718
import org.eclipse.swt.layout.GridLayout;
1819
import org.eclipse.swt.widgets.Composite;
19-
import org.eclipse.swt.widgets.Control;
2020
import org.eclipse.swt.widgets.Group;
2121
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
2222

@@ -97,13 +97,7 @@ public void enablePreferenceContent(boolean enable) {
9797
}
9898

9999
@Override
100-
protected Control createContents(Composite parent) {
101-
Composite nodejsComposite = createUI(parent);
102-
validateSettings(null, null, null);
103-
return nodejsComposite;
104-
}
105-
106-
private Composite createUI(Composite parent) {
100+
protected Composite createUI(Composite parent) {
107101
final ScrolledPageContent pageContent = new ScrolledPageContent(parent);
108102
Composite composite = pageContent.getBody();
109103
GridLayout layout = new GridLayout();

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/preferences/NodejsConfigurationBlock.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* Contributors:
99
* Angelo Zerr <[email protected]> - initial API and implementation
10+
* Lorenzo Dalla Vecchia <[email protected]> - added reconcileControls hook
1011
*/
1112
package ts.eclipse.ide.internal.ui.preferences;
1213

@@ -22,7 +23,6 @@
2223
import org.eclipse.swt.widgets.Button;
2324
import org.eclipse.swt.widgets.Combo;
2425
import org.eclipse.swt.widgets.Composite;
25-
import org.eclipse.swt.widgets.Control;
2626
import org.eclipse.swt.widgets.FileDialog;
2727
import org.eclipse.swt.widgets.Group;
2828
import org.eclipse.swt.widgets.Label;
@@ -91,13 +91,7 @@ public void enablePreferenceContent(boolean enable) {
9191
}
9292

9393
@Override
94-
protected Control createContents(Composite parent) {
95-
Composite nodejsComposite = createUI(parent);
96-
validateSettings(null, null, null);
97-
return nodejsComposite;
98-
}
99-
100-
private Composite createUI(Composite parent) {
94+
protected Composite createUI(Composite parent) {
10195
final ScrolledPageContent pageContent = new ScrolledPageContent(parent);
10296
Composite composite = pageContent.getBody();
10397
GridLayout layout = new GridLayout();

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/preferences/TextMateConfigurationBlock.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* Contributors:
99
* Angelo Zerr <[email protected]> - initial API and implementation
10+
* Lorenzo Dalla Vecchia <[email protected]> - added reconcileControls hook
1011
*/
1112
package ts.eclipse.ide.internal.ui.preferences;
1213

@@ -16,7 +17,6 @@
1617
import org.eclipse.swt.layout.GridData;
1718
import org.eclipse.swt.layout.GridLayout;
1819
import org.eclipse.swt.widgets.Composite;
19-
import org.eclipse.swt.widgets.Control;
2020
import org.eclipse.swt.widgets.Group;
2121
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
2222

@@ -65,13 +65,7 @@ public void enablePreferenceContent(boolean enable) {
6565
}
6666

6767
@Override
68-
protected Control createContents(Composite parent) {
69-
Composite nodejsComposite = createUI(parent);
70-
validateSettings(null, null, null);
71-
return nodejsComposite;
72-
}
73-
74-
private Composite createUI(Composite parent) {
68+
protected Composite createUI(Composite parent) {
7569
final ScrolledPageContent pageContent = new ScrolledPageContent(parent);
7670
Composite composite = pageContent.getBody();
7771
GridLayout layout = new GridLayout();

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/preferences/OptionsConfigurationBlock.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* http://www.eclipse.org/legal/epl-v10.html
77
*
88
* Contributors:
9-
* IBM Corporation - initial API and implementation
9+
* IBM Corporation - initial API and implementation
10+
* Lorenzo Dalla Vecchia <[email protected]> - added reconcileControls hook
1011
*******************************************************************************/
1112
package ts.eclipse.ide.ui.preferences;
1213

@@ -318,7 +319,14 @@ protected void setShell(Shell shell) {
318319
fShell = shell;
319320
}
320321

321-
protected abstract Control createContents(Composite parent);
322+
public final Composite createContents(Composite parent) {
323+
Composite contentsComposite = createUI(parent);
324+
reconcileControls();
325+
validateSettings(null, null, null);
326+
return contentsComposite;
327+
}
328+
329+
protected abstract Composite createUI(Composite parent);
322330

323331
protected Button addCheckBox(Composite parent, String label, Key key, String[] values, int indent) {
324332
ControlData data = new ControlData(key, values);
@@ -630,20 +638,23 @@ protected void controlChanged(Widget widget) {
630638
return;
631639
}
632640
String oldValue = setValue(data.getKey(), newValue);
641+
reconcileControls();
633642
validateSettings(data.getKey(), oldValue, newValue);
634643
}
635644

636645
protected void textChanged(Text textControl) {
637646
Key key = (Key) textControl.getData();
638647
String number = textControl.getText();
639648
String oldValue = setValue(key, number);
649+
reconcileControls();
640650
validateSettings(key, oldValue, number);
641651
}
642652

643653
protected void textChanged(Combo comboControl) {
644654
Key key = (Key) comboControl.getData();
645655
String number = comboControl.getText();
646656
String oldValue = setValue(key, number);
657+
reconcileControls();
647658
validateSettings(key, oldValue, number);
648659
}
649660

@@ -732,6 +743,7 @@ public void useProjectSpecificSettings(boolean enable) {
732743
}
733744
fDisabledProjectSettings = null;
734745
updateControls();
746+
reconcileControls();
735747
validateSettings(null, null, null);
736748
} else {
737749
fDisabledProjectSettings = new IdentityHashMap();
@@ -825,6 +837,7 @@ public void performDefaults() {
825837

826838
settingsUpdated();
827839
updateControls();
840+
reconcileControls();
828841
validateSettings(null, null, null);
829842
}
830843

@@ -840,12 +853,16 @@ public void performRevert() {
840853

841854
settingsUpdated();
842855
updateControls();
856+
reconcileControls();
843857
validateSettings(null, null, null);
844858
}
845859

846860
public void dispose() {
847861
}
848862

863+
protected void reconcileControls() {
864+
}
865+
849866
protected void updateControls() {
850867
// update the UI
851868
for (int i = fCheckBoxes.size() - 1; i >= 0; i--) {

0 commit comments

Comments
 (0)