public void createControl(Composite parent) { Composite pageContent = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 3; pageContent.setLayout(layout); pageContent.setLayoutData(new GridData(GridData.FILL_BOTH)); // variable never used ... is pageContent.getLayoutData() needed? // GridData outerFrameGridData = (GridData) pageContent.getLayoutData(); // outerFrameGridData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL; // outerFrameGridData.verticalAlignment = GridData.VERTICAL_ALIGN_FILL; // WorkbenchHelp.setHelp( // pageContent, // B2BGUIContextIds.BTBG_SELECT_MULTI_FILE_PAGE); createLabels(pageContent); createSourceViewer(pageContent); createButtonPanel(pageContent); createSelectedListBox(pageContent); createImportButton(pageContent); setControl(pageContent); if (isFileMandatory) setPageComplete(false); }
private void createButtonPanel(Composite pageContent) { Composite buttonPanel = new Composite(pageContent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 1; buttonPanel.setLayout(layout); GridData gridData = new GridData(); gridData.grabExcessHorizontalSpace = false; gridData.grabExcessVerticalSpace = true; gridData.verticalAlignment = GridData.CENTER; gridData.horizontalAlignment = GridData.CENTER; buttonPanel.setLayoutData(gridData); addButton = new Button(buttonPanel, SWT.PUSH); addButton.setText(Messages._UI_ADD_BUTTON); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.CENTER; addButton.setLayoutData(gridData); addButton.addSelectionListener(new ButtonSelectListener()); addButton.setToolTipText(Messages._UI_ADD_BUTTON_TOOL_TIP); addButton.setEnabled(false); removeButton = new Button(buttonPanel, SWT.PUSH); removeButton.setText(Messages._UI_REMOVE_BUTTON); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.CENTER; removeButton.setLayoutData(gridData); removeButton.addSelectionListener(new ButtonSelectListener()); removeButton.setToolTipText(Messages._UI_REMOVE_BUTTON_TOOL_TIP); removeButton.setEnabled(false); removeAllButton = new Button(buttonPanel, SWT.PUSH); removeAllButton.setText(Messages._UI_REMOVE_ALL_BUTTON); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.CENTER; removeAllButton.setLayoutData(gridData); removeAllButton.addSelectionListener(new ButtonSelectListener()); removeAllButton.setToolTipText(Messages._UI_REMOVE_ALL_BUTTON_TOOL_TIP); removeAllButton.setEnabled(false); }
@Override public void createControl(final Composite parent) { Composite container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 3; layout.verticalSpacing = 9; Label label = new Label(container, SWT.NULL); label.setText("&Container:"); containerText = new Text(container, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData(GridData.FILL_HORIZONTAL); containerText.setLayoutData(gd); containerText.addModifyListener( new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { dialogChanged(); } }); Button button = new Button(container, SWT.PUSH); button.setText("Browse..."); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { handleBrowse(); } }); label = new Label(container, SWT.NULL); label.setText("&Choose a model:"); Composite middleComposite = new Composite(container, SWT.NULL); FillLayout fillLayout = new FillLayout(); middleComposite.setLayout(fillLayout); emptyModelButton = new Button(middleComposite, SWT.RADIO); emptyModelButton.setText("Empty"); emptyModelButton.setSelection(true); skeletonModelButton = new Button(middleComposite, SWT.RADIO); skeletonModelButton.setText("Skeleton"); exampleModelButton = new Button(middleComposite, SWT.RADIO); exampleModelButton.setText("Example"); emptyModelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { typeOfModel = "empty"; radioChanged(); } }); exampleModelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { typeOfModel = "example"; radioChanged(); } }); skeletonModelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { typeOfModel = "skeleton"; radioChanged(); } }); /* Need to add empty label so the next controls are pushed to the next line in the grid. */ label = new Label(container, SWT.NULL); label.setText(""); label = new Label(container, SWT.NULL); label.setText("&File name:"); fileText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); fileText.setLayoutData(gd); fileText.addModifyListener( new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { Text t = (Text) e.getSource(); String fname = t.getText(); int i = fname.lastIndexOf(".gaml"); if (i > 0) { // model title = filename less extension less all non alphanumeric characters titleText.setText(fname.substring(0, i).replaceAll("[^\\p{Alnum}]", "")); } /* * else if (fname.length()>0) { * int pos = t.getSelection().x; * fname = fname.replaceAll("[[^\\p{Alnum}]&&[^_-]&&[^\\x2E]]", "_"); * t.setText(fname+".gaml"); * t.setSelection(pos); * } else { * t.setText("new.gaml"); * } */ dialogChanged(); } }); /* Need to add empty label so the next two controls are pushed to the next line in the grid. */ label = new Label(container, SWT.NULL); label.setText(""); label = new Label(container, SWT.NULL); label.setText("&Author:"); authorText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); authorText.setLayoutData(gd); authorText.setText(getComputerFullName()); authorText.addModifyListener( new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { dialogChanged(); } }); /* Need to add empty label so the next two controls are pushed to the next line in the grid. */ label = new Label(container, SWT.NULL); label.setText(""); label = new Label(container, SWT.NULL); label.setText("&Model name:"); titleText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); titleText.setLayoutData(gd); titleText.setText("new"); titleText.addModifyListener( new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { dialogChanged(); } }); /* Need to add empty label so the next two controls are pushed to the next line in the grid. */ label = new Label(container, SWT.NULL); label.setText(""); label = new Label(container, SWT.NULL); label.setText("&Model description:"); descriptionText = new Text(container, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); descriptionText.setBounds(0, 0, 250, 100); gd = new GridData(SWT.FILL, SWT.FILL, true, false); gd.verticalSpan = 4; descriptionText.setLayoutData(gd); /* * Need to add seven empty labels in order to push next controls after the descriptionText * box. */ // TODO Dirty!! Change the way to do this for (int i = 0; i < 7; i++) { label = new Label(container, SWT.NULL); label.setText(""); } label = new Label(container, SWT.NULL); label.setText("&Create a html template \nfor the model description ?"); middleComposite = new Composite(container, SWT.NULL); fillLayout = new FillLayout(); middleComposite.setLayout(fillLayout); yesButton = new Button(middleComposite, SWT.RADIO); yesButton.setText("Yes"); yesButton.setSelection(true); Button noButton = new Button(middleComposite, SWT.RADIO); noButton.setText("No"); yesButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { dialogChanged(); } }); /* Finished adding the custom control */ initialize(); dialogChanged(); setControl(container); }