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,58 +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 .setTitleBarForeground (workArea .getForeground ());
132- copySettingsExpandable .setToggleColor (workArea .getForeground ());
133- copySettingsExpandable .setActiveToggleColor (workArea .getForeground ());
134- copySettingsExpandable .setLayout (new GridLayout ());
135- copySettingsExpandable .setLayoutData (new GridData (SWT .FILL , SWT .FILL , true , false ));
136- copySettingsExpandable .addExpansionListener (new IExpansionListener () {
137-
138- @ Override
139- public void expansionStateChanged (ExpansionEvent e ) {
140- form .reflow (true );
141- Point size = getInitialSize ();
142- Shell shell = getShell ();
143- shell .setBounds (getConstrainedShellBounds (
144- new Rectangle (shell .getLocation ().x , shell .getLocation ().y , size .x , size .y )));
145- }
146-
147- @ Override
148- public void expansionStateChanging (ExpansionEvent e ) {
149- // Nothing to do here
150-
151- }
152- });
153-
154- 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 );
155147 sectionClient .setBackground (workArea .getBackground ());
156-
157- if (createButtons (toolkit , sectionClient )) {
158- copySettingsExpandable .setExpanded (true );
159- }
160-
161- copySettingsExpandable .setClient (sectionClient );
162-
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 ));
163176 }
164177
165178 /**
166179 * Create the buttons for the settings transfer.
167180 *
168181 * @return boolean <code>true</code> if any were selected
169182 */
170- private boolean createButtons (FormToolkit toolkit , Composite sectionClient ) {
183+ private boolean createButtons (Composite sectionClient ) {
171184 String [] enabledSettings = getEnabledSettings (
172185 PlatformUI .getDialogSettingsProvider (FrameworkUtil .getBundle (ChooseWorkspaceWithSettingsDialog .class ))
173186 .getDialogSettings ()
@@ -179,8 +192,9 @@ private boolean createButtons(FormToolkit toolkit, Composite sectionClient) {
179192 sectionClient .setLayout (layout );
180193
181194 for (final IConfigurationElement settingsTransfer : SettingsTransfer .getSettingsTransfers ()) {
182- final Button button = toolkit .createButton (sectionClient ,
183- 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 ());
184198
185199 ControlDecoration deco = new ControlDecoration (button , SWT .TOP | SWT .RIGHT );
186200 Image image = FieldDecorationRegistry .getDefault ().getFieldDecoration (FieldDecorationRegistry .DEC_WARNING )
@@ -209,7 +223,6 @@ private boolean createButtons(FormToolkit toolkit, Composite sectionClient) {
209223 }
210224 }
211225
212- button .setBackground (sectionClient .getBackground ());
213226 button .addSelectionListener (new SelectionAdapter () {
214227
215228 @ Override
0 commit comments