3232
3333import org .eclipse .core .runtime .CoreException ;
3434import org .eclipse .core .runtime .NullProgressMonitor ;
35- import org .eclipse .jface .dialogs .Dialog ;
36- import org .eclipse .jface .layout .GridDataFactory ;
3735import org .eclipse .jface .layout .TreeColumnLayout ;
38- import org .eclipse .jface .resource .JFaceResources ;
3936import org .eclipse .jface .viewers .CellEditor ;
4037import org .eclipse .jface .viewers .ColumnWeightData ;
4138import org .eclipse .jface .viewers .ComboBoxCellEditor ;
5249import org .eclipse .osgi .util .NLS ;
5350import org .eclipse .swt .SWT ;
5451import org .eclipse .swt .custom .CCombo ;
52+ import org .eclipse .swt .events .ExpandEvent ;
53+ import org .eclipse .swt .events .ExpandListener ;
5554import org .eclipse .swt .events .SelectionListener ;
56- import org .eclipse .swt .graphics .FontMetrics ;
57- import org .eclipse .swt .graphics .GC ;
5855import org .eclipse .swt .graphics .Image ;
56+ import org .eclipse .swt .layout .BorderData ;
57+ import org .eclipse .swt .layout .BorderLayout ;
5958import org .eclipse .swt .layout .GridData ;
6059import org .eclipse .swt .layout .GridLayout ;
6160import org .eclipse .swt .widgets .Button ;
6261import org .eclipse .swt .widgets .Composite ;
6362import org .eclipse .swt .widgets .Control ;
64- import org .eclipse .swt .widgets .Group ;
63+ import org .eclipse .swt .widgets .ExpandBar ;
64+ import org .eclipse .swt .widgets .ExpandItem ;
6565import org .eclipse .swt .widgets .Label ;
6666import org .eclipse .swt .widgets .Text ;
6767import org .eclipse .swt .widgets .Tree ;
@@ -125,8 +125,6 @@ public class LifecycleMappingPage extends WizardPage {
125125
126126 private final Set <ILifecycleMappingLabelProvider > ignoreWorkspace = new HashSet <>();
127127
128- private Label errorCountLabel ;
129-
130128 /**
131129 * Create the wizard.
132130 */
@@ -145,12 +143,55 @@ public LifecycleMappingPage() {
145143 @ Override
146144 public void createControl (Composite parent ) {
147145 Composite container = new Composite (parent , SWT .NULL );
148-
149146 setControl (container );
150- container .setLayout (new GridLayout (1 , false ));
147+ container .setLayout (new BorderLayout ());
148+ BorderData tableBorderData = new BorderData (SWT .CENTER );
149+ tableBorderData .hHint = 300 ;
150+ tableBorderData .wHint = 800 ;
151+ createMappingTree (container ).setLayoutData (tableBorderData );
152+ createDescription (container ).setLayoutData (new BorderData (SWT .BOTTOM ));
153+ }
154+
155+ private Control createDescription (Composite parent ) {
156+ ExpandBar bar = new ExpandBar (parent , SWT .NONE );
157+ Composite container = new Composite (bar , SWT .NULL );
158+ container .setLayout (new BorderLayout ());
159+ details = new Text (container , SWT .WRAP | SWT .READ_ONLY | SWT .V_SCROLL );
160+ details .setLayoutData (new BorderData (SWT .CENTER ));
161+ Composite licenseContainer = new Composite (container , SWT .NULL );
162+ new Label (licenseContainer , SWT .NONE ).setText (Messages .LifecycleMappingPage_licenseLabel );
163+ license = new Text (licenseContainer , SWT .READ_ONLY );
164+ license .setLayoutData (new GridData (SWT .FILL , SWT .CENTER , true , false ));
165+ licenseContainer .setLayout (new GridLayout (2 , false ));
166+ licenseContainer .setLayoutData (new BorderData (SWT .BOTTOM ));
167+
168+ ExpandItem expandItem = new ExpandItem (bar , SWT .NONE , 0 );
169+ expandItem .setText (Messages .LifecycleMappingPage_descriptionLabel );
170+ expandItem .setHeight (120 );
171+ expandItem .setControl (container );
172+ expandItem .setExpanded (true );
173+ //Workaround for https://github.com/eclipse-platform/eclipse.platform.swt/issues/551
174+ bar .addExpandListener (new ExpandListener () {
175+
176+ @ Override
177+ public void itemExpanded (ExpandEvent e ) {
178+ itemCollapsed (e );
179+ }
180+
181+ @ Override
182+ public void itemCollapsed (ExpandEvent e ) {
183+ bar .requestLayout ();
184+ }
185+ });
186+ return bar ;
187+ }
188+
189+ private Composite createMappingTree (Composite parent ) {
190+ Composite container = new Composite (parent , SWT .NULL );
191+ container .setLayout (new BorderLayout ());
151192
152193 Composite treeViewerContainer = new Composite (container , SWT .NULL );
153- GridDataFactory . fillDefaults (). grab ( true , false ). applyTo ( treeViewerContainer );
194+ treeViewerContainer . setLayoutData ( new BorderData ( SWT . CENTER ) );
154195 TreeColumnLayout treeColumnLayout = new TreeColumnLayout ();
155196 treeViewerContainer .setLayout (treeColumnLayout );
156197
@@ -209,7 +250,6 @@ protected void setValue(Object element, Object value) {
209250 }
210251 }
211252 getViewer ().refresh (true );
212- updateErrorCount ();
213253 getContainer ().updateButtons ();
214254 }
215255 }
@@ -466,26 +506,22 @@ public int compare(Viewer viewer, Object e1, Object e2) {
466506 }
467507 });
468508
469- Composite composite = new Composite (container , SWT .NONE );
470- composite .setLayoutData (new GridData (SWT .FILL , SWT .CENTER , true , false , 1 , 1 ));
471- composite .setLayout (new GridLayout (3 , false ));
472-
473- errorCountLabel = new Label (composite , SWT .NONE );
474- errorCountLabel .setLayoutData (new GridData (SWT .FILL , SWT .CENTER , true , false , 1 , 1 ));
475-
476- Button btnNewButton_1 = new Button (composite , SWT .NONE );
509+ Composite buttons = new Composite (container , SWT .NONE );
510+ buttons .setLayoutData (new BorderData (SWT .BOTTOM ));
511+ buttons .setLayout (new GridLayout (3 , false ));
512+ new Label (buttons , SWT .NONE ).setLayoutData (new GridData (GridData .FILL_HORIZONTAL ));
513+ Button btnNewButton_1 = new Button (buttons , SWT .NONE );
477514 btnNewButton_1 .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
478515 mappingConfiguration .clearSelectedProposals ();
479516 ignore .clear ();
480517 ignoreAtDefinition .clear ();
481518 ignoreWorkspace .clear ();
482519 treeViewer .refresh ();
483520 getWizard ().getContainer ().updateButtons (); // needed to enable/disable Finish button
484- updateErrorCount ();
485521 }));
486522 btnNewButton_1 .setText (Messages .LifecycleMappingPage_deselectAllButton );
487523
488- autoSelectButton = new Button (composite , SWT .NONE );
524+ autoSelectButton = new Button (buttons , SWT .NONE );
489525 autoSelectButton .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
490526 resetDetails ();
491527 ignore .clear ();
@@ -494,34 +530,7 @@ public int compare(Viewer viewer, Object e1, Object e2) {
494530 discoverProposals ();
495531 }));
496532 autoSelectButton .setText (Messages .LifecycleMappingPage_autoSelectButton );
497-
498- // Provide a reasonable height for the details box
499- GC gc = new GC (container );
500- gc .setFont (JFaceResources .getDialogFont ());
501- FontMetrics fontMetrics = gc .getFontMetrics ();
502- gc .dispose ();
503-
504- Group grpDetails = new Group (container , SWT .NONE );
505- grpDetails .setLayout (new GridLayout (1 , false ));
506- grpDetails .setLayoutData (new GridData (SWT .FILL , SWT .FILL , true , false , 1 , 1 ));
507- grpDetails .setText (Messages .LifecycleMappingPage_descriptionLabel );
508-
509- details = new Text (grpDetails , SWT .WRAP | SWT .READ_ONLY | SWT .V_SCROLL );
510- GridData gd = new GridData (SWT .FILL , SWT .FILL , true , true );
511- gd .heightHint = Dialog .convertHeightInCharsToPixels (fontMetrics , 3 );
512- gd .minimumHeight = Dialog .convertHeightInCharsToPixels (fontMetrics , 1 );
513- details .setLayoutData (gd );
514-
515- Group grpLicense = new Group (container , SWT .NONE );
516- grpLicense .setLayout (new GridLayout (1 , false ));
517- grpLicense .setLayoutData (new GridData (SWT .FILL , SWT .FILL , true , false , 1 , 1 ));
518- grpLicense .setText (Messages .LifecycleMappingPage_licenseLabel );
519-
520- license = new Text (grpLicense , SWT .READ_ONLY );
521- gd = new GridData (SWT .FILL , SWT .FILL , true , true );
522- gd .heightHint = Dialog .convertHeightInCharsToPixels (fontMetrics , 1 );
523- gd .minimumHeight = Dialog .convertHeightInCharsToPixels (fontMetrics , 1 );
524- license .setLayoutData (gd );
533+ return container ;
525534 }
526535
527536 /**
@@ -559,7 +568,6 @@ protected void discoverProposals() {
559568 loading = false ;
560569 treeViewer .refresh ();
561570 getWizard ().getContainer ().updateButtons (); // needed to enable/disable Finish button
562- updateErrorCount ();
563571 }
564572
565573 @ Override
@@ -574,7 +582,6 @@ public void setVisible(boolean visible) {
574582 mappingConfiguration .autoCompleteMapping ();
575583 }
576584 treeViewer .setInput (mappingConfiguration );
577- updateErrorCount ();
578585 }
579586 }
580587
@@ -634,24 +641,6 @@ public Collection<ILifecycleMappingLabelProvider> getIgnoreWorkspace() {
634641 return ignoreWorkspace ;
635642 }
636643
637- /*
638- * Update the error summary
639- */
640- private void updateErrorCount () {
641- int count = 0 ;
642- for (TreeItem item : treeViewer .getTree ().getItems ()) {
643- ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider ) item .getData ();
644- if (!isHandled (prov )) {
645- if (prov instanceof AggregateMappingLabelProvider aggProv ) {
646- count += aggProv .getChildren ().length ;
647- } else {
648- ++count ;
649- }
650- }
651- }
652- errorCountLabel .setText (NLS .bind (Messages .LifecycleMappingPage_numErrors , String .valueOf (count )));
653- }
654-
655644 /*
656645 * Only applicable for top level elements. Provider is considered handled if it is ignored, a proposal has been selected, or if it is an uninteresting phase.
657646 */
0 commit comments