2828import org .eclipse .jface .wizard .WizardPage ;
2929import org .eclipse .swt .SWT ;
3030import org .eclipse .swt .graphics .Image ;
31+ import org .eclipse .swt .graphics .Point ;
32+ import org .eclipse .swt .graphics .Rectangle ;
3133import org .eclipse .swt .layout .GridData ;
3234import org .eclipse .swt .layout .GridLayout ;
3335import org .eclipse .swt .program .Program ;
3638import org .eclipse .swt .widgets .DirectoryDialog ;
3739import org .eclipse .swt .widgets .Display ;
3840import org .eclipse .swt .widgets .Label ;
41+ import org .eclipse .swt .widgets .Shell ;
3942import org .eclipse .swt .widgets .Table ;
4043import org .eclipse .swt .widgets .Text ;
4144import org .eclipse .ui .IImportWizard ;
6265 */
6366public class NewWorkspaceWizard extends Wizard implements IImportWizard , INewWizard {
6467
65-
66- static final Logger log = LoggerFactory .getLogger (NewWorkspaceWizard .class );
68+ static final Logger log = LoggerFactory .getLogger (NewWorkspaceWizard .class );
6769
6870 final Model model ;
6971 final UI <Model > ui ;
70- final NewWorkspaceWizardPage page = new NewWorkspaceWizardPage ();
71- final FragmentTemplateEngine templates ;
72+ final NewWorkspaceWizardPage page = new NewWorkspaceWizardPage ();
73+ final FragmentTemplateEngine templates ;
7274
7375 final static Image verified = Icons .image ("icons/tick.png" , false );
7476 final static Image verifiedGreyedOut = new Image (Display .getDefault (), verified , SWT .IMAGE_DISABLE );
@@ -124,8 +126,7 @@ public boolean performFinish() {
124126 // show a confirmation dialog
125127 // if there is at least one 3rd-party template selected
126128 long num3rdParty = model .selectedTemplates .stream ()
127- .filter (t -> !t
128- .isOfficial ())
129+ .filter (t -> !t .isOfficial ())
129130 .count ();
130131
131132 boolean confirmed = num3rdParty == 0 || openConfirm (getShell (), "Install 3rd-Party templates" ,
@@ -146,7 +147,6 @@ public boolean performFinish() {
146147 } else
147148 return false ;
148149
149-
150150 }
151151
152152 class NewWorkspaceWizardPage extends WizardPage {
@@ -244,12 +244,10 @@ public String getText(Object element) {
244244 @ Override
245245 public String getText (Object element ) {
246246 if (element instanceof TemplateInfo ti ) {
247- if (ti
248- .isOfficial ()) {
247+ if (ti .isOfficial ()) {
249248 return "bndtools (Official)" ;
250249
251- }
252- else {
250+ } else {
253251 return ti .id ()
254252 .organisation () + " (3rd Party)" ;
255253 }
@@ -269,9 +267,8 @@ public Image getImage(Object element) {
269267
270268 });
271269
272-
273- tableLayout .addColumnData (new ColumnWeightData (1 , 150 , false ));
274- tableLayout .addColumnData (new ColumnWeightData (10 , 400 , true ));
270+ tableLayout .addColumnData (new ColumnWeightData (1 , 200 , false ));
271+ tableLayout .addColumnData (new ColumnWeightData (10 , 460 , true ));
275272 tableLayout .addColumnData (new ColumnWeightData (20 , 100 , true ));
276273
277274 Button addButton = new Button (container , SWT .PUSH );
@@ -308,10 +305,32 @@ public Image getImage(Object element) {
308305 UI .checkbox (browseButton )
309306 .subscribe (this ::browseForLocation );
310307
311- getShell (). setSize ( 840 , 480 );
308+ centerShell ( );
312309 ui .update ();
313310 }
314311
312+ private void centerShell () {
313+ Shell shell = getShell ();
314+ shell .setSize (840 , 480 );
315+ Shell parent = (Shell ) shell .getParent ();
316+ if (parent != null ) {
317+ Rectangle parentBounds = parent .getBounds ();
318+ Point shellSize = shell .getSize ();
319+ int x = parentBounds .x + (parentBounds .width - shellSize .x ) / 2 ;
320+ int y = parentBounds .y + (parentBounds .height - shellSize .y ) / 2 ;
321+ shell .setLocation (x , y );
322+ } else {
323+ // If no parent, center on the display
324+ Rectangle displayBounds = shell .getDisplay ()
325+ .getPrimaryMonitor ()
326+ .getBounds ();
327+ Point shellSize = shell .getSize ();
328+ int x = (displayBounds .width - shellSize .x ) / 2 ;
329+ int y = (displayBounds .height - shellSize .y ) / 2 ;
330+ shell .setLocation (x , y );
331+ }
332+ }
333+
315334 List <TemplateInfo > toTemplates (Object [] selection ) {
316335 return Stream .of (selection )
317336 .map (o -> (TemplateInfo ) o )
0 commit comments