3333import org .eclipse .jface .dialogs .IDialogSettings ;
3434import org .eclipse .jface .fieldassist .ControlDecoration ;
3535import org .eclipse .jface .fieldassist .FieldDecorationRegistry ;
36+ import org .eclipse .jface .resource .JFaceResources ;
3637import org .eclipse .osgi .util .NLS ;
3738import org .eclipse .swt .SWT ;
39+ import org .eclipse .swt .custom .ScrolledComposite ;
3840import org .eclipse .swt .events .SelectionAdapter ;
3941import org .eclipse .swt .events .SelectionEvent ;
4042import org .eclipse .swt .graphics .Image ;
4648import org .eclipse .swt .widgets .Button ;
4749import org .eclipse .swt .widgets .Composite ;
4850import org .eclipse .swt .widgets .Control ;
51+ import org .eclipse .swt .widgets .Label ;
52+ import org .eclipse .swt .widgets .Listener ;
4953import org .eclipse .swt .widgets .Shell ;
5054import org .eclipse .ui .PlatformUI ;
51- import org .eclipse .ui .forms .events .ExpansionEvent ;
52- import org .eclipse .ui .forms .events .IExpansionListener ;
53- import org .eclipse .ui .forms .widgets .ExpandableComposite ;
54- import org .eclipse .ui .forms .widgets .FormToolkit ;
55- import org .eclipse .ui .forms .widgets .ScrolledForm ;
5655import org .eclipse .ui .internal .WorkbenchPlugin ;
5756import org .eclipse .ui .preferences .SettingsTransfer ;
5857import org .osgi .framework .FrameworkUtil ;
@@ -116,55 +115,72 @@ protected Control createDialogArea(Composite parent) {
116115 * Create the controls for selecting the controls we are going to export.
117116 */
118117 private void createSettingsControls (Composite workArea ) {
119- final FormToolkit toolkit = new FormToolkit (workArea .getDisplay ());
120- workArea .addDisposeListener (e -> toolkit .dispose ());
121- final ScrolledForm form = toolkit .createScrolledForm (workArea );
122- form .getBody ().setBackground (workArea .getBackground ());
123- form .getBody ().setLayout (new GridLayout ());
124- form .setLayoutData (new GridData (SWT .FILL , SWT .FILL , true , true ));
125-
126- final ExpandableComposite copySettingsExpandable =
127- toolkit .createExpandableComposite (form .getBody (), ExpandableComposite .TWISTIE );
128-
129- copySettingsExpandable .setText (IDEWorkbenchMessages .ChooseWorkspaceWithSettingsDialog_SettingsGroupName );
130- copySettingsExpandable .setBackground (workArea .getBackground ());
131- copySettingsExpandable .setLayout (new GridLayout ());
132- copySettingsExpandable .setLayoutData (new GridData (SWT .FILL , SWT .FILL , true , false ));
133- copySettingsExpandable .addExpansionListener (new IExpansionListener () {
134-
135- @ Override
136- public void expansionStateChanged (ExpansionEvent e ) {
137- form .reflow (true );
138- Point size = getInitialSize ();
139- Shell shell = getShell ();
140- shell .setBounds (getConstrainedShellBounds (
141- new Rectangle (shell .getLocation ().x , shell .getLocation ().y , size .x , size .y )));
142- }
143-
144- @ Override
145- public void expansionStateChanging (ExpansionEvent e ) {
146- // Nothing to do here
147-
148- }
149- });
150-
151- Composite sectionClient = toolkit .createComposite (copySettingsExpandable );
118+ final ScrolledComposite sc = new ScrolledComposite (workArea , SWT .V_SCROLL | SWT .H_SCROLL );
119+ sc .setExpandHorizontal (true );
120+ sc .setExpandVertical (true );
121+ sc .setLayoutData (new GridData (SWT .FILL , SWT .FILL , true , true ));
122+
123+ Composite body = new Composite (sc , SWT .NONE );
124+ body .setBackground (workArea .getBackground ());
125+ body .setLayout (new GridLayout ());
126+ sc .setContent (body );
127+
128+ Composite header = new Composite (body , SWT .NONE );
129+ header .setLayoutData (new GridData (SWT .FILL , SWT .FILL , true , false ));
130+ GridLayout headerLayout = new GridLayout (2 , false );
131+ headerLayout .marginWidth = 0 ;
132+ headerLayout .marginHeight = 0 ;
133+ header .setLayout (headerLayout );
134+ header .setBackground (workArea .getBackground ());
135+
136+ Label toggle = new Label (header , SWT .NONE );
137+ toggle .setBackground (workArea .getBackground ());
138+ toggle .setCursor (workArea .getDisplay ().getSystemCursor (SWT .CURSOR_HAND ));
139+
140+ Label label = new Label (header , SWT .NONE );
141+ label .setText (IDEWorkbenchMessages .ChooseWorkspaceWithSettingsDialog_SettingsGroupName );
142+ label .setBackground (workArea .getBackground ());
143+ label .setFont (JFaceResources .getFontRegistry ().getBold (JFaceResources .DIALOG_FONT ));
144+ label .setCursor (workArea .getDisplay ().getSystemCursor (SWT .CURSOR_HAND ));
145+
146+ Composite sectionClient = new Composite (body , SWT .NONE );
152147 sectionClient .setBackground (workArea .getBackground ());
153-
154- if (createButtons (toolkit , sectionClient )) {
155- copySettingsExpandable .setExpanded (true );
156- }
157-
158- copySettingsExpandable .setClient (sectionClient );
159-
148+ GridData clientData = new GridData (SWT .FILL , SWT .FILL , true , false );
149+ sectionClient .setLayoutData (clientData );
150+
151+ boolean expanded = createButtons (sectionClient );
152+ sectionClient .setVisible (expanded );
153+ clientData .exclude = !expanded ;
154+ toggle .setText (expanded ? "\u25BE " : "\u25B8 " ); //$NON-NLS-1$ //$NON-NLS-2$
155+
156+ Listener toggleListener = e -> {
157+ boolean newState = !sectionClient .getVisible ();
158+ sectionClient .setVisible (newState );
159+ ((GridData ) sectionClient .getLayoutData ()).exclude = !newState ;
160+ toggle .setText (newState ? "\u25BE " : "\u25B8 " ); //$NON-NLS-1$ //$NON-NLS-2$
161+
162+ body .layout (true );
163+ sc .setMinSize (body .computeSize (SWT .DEFAULT , SWT .DEFAULT ));
164+
165+ Point size = getInitialSize ();
166+ Shell shell = getShell ();
167+ shell .setBounds (getConstrainedShellBounds (
168+ new Rectangle (shell .getLocation ().x , shell .getLocation ().y , size .x , size .y )));
169+ };
170+
171+ toggle .addListener (SWT .MouseDown , toggleListener );
172+ label .addListener (SWT .MouseDown , toggleListener );
173+
174+ body .layout (true );
175+ sc .setMinSize (body .computeSize (SWT .DEFAULT , SWT .DEFAULT ));
160176 }
161177
162178 /**
163179 * Create the buttons for the settings transfer.
164180 *
165181 * @return boolean <code>true</code> if any were selected
166182 */
167- private boolean createButtons (FormToolkit toolkit , Composite sectionClient ) {
183+ private boolean createButtons (Composite sectionClient ) {
168184 String [] enabledSettings = getEnabledSettings (
169185 PlatformUI .getDialogSettingsProvider (FrameworkUtil .getBundle (ChooseWorkspaceWithSettingsDialog .class ))
170186 .getDialogSettings ()
@@ -176,8 +192,9 @@ private boolean createButtons(FormToolkit toolkit, Composite sectionClient) {
176192 sectionClient .setLayout (layout );
177193
178194 for (final IConfigurationElement settingsTransfer : SettingsTransfer .getSettingsTransfers ()) {
179- final Button button = toolkit .createButton (sectionClient ,
180- settingsTransfer .getAttribute (ATT_NAME ), SWT .CHECK );
195+ final Button button = new Button (sectionClient , SWT .CHECK );
196+ button .setText (settingsTransfer .getAttribute (ATT_NAME ));
197+ button .setBackground (sectionClient .getBackground ());
181198
182199 ControlDecoration deco = new ControlDecoration (button , SWT .TOP | SWT .RIGHT );
183200 Image image = FieldDecorationRegistry .getDefault ().getFieldDecoration (FieldDecorationRegistry .DEC_WARNING )
@@ -206,7 +223,6 @@ private boolean createButtons(FormToolkit toolkit, Composite sectionClient) {
206223 }
207224 }
208225
209- button .setBackground (sectionClient .getBackground ());
210226 button .addSelectionListener (new SelectionAdapter () {
211227
212228 @ Override
0 commit comments