List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer
public ComboViewer(Composite parent, int style)
From source file:com.contrastsecurity.ide.eclipse.ui.internal.views.FilterDialog.java
License:Open Source License
private ComboViewer createContrastComboViewer(final Composite composite) { ComboViewer comboViewer = new ComboViewer(composite, SWT.READ_ONLY); comboViewer.getControl().setFont(composite.getFont()); comboViewer.setLabelProvider(new ContrastLabelProvider()); comboViewer.setContentProvider(new ArrayContentProvider()); return comboViewer; }
From source file:com.contrastsecurity.ide.eclipse.ui.util.UIElementUtils.java
License:Open Source License
public static ComboViewer createComboViewer(Composite composite) { ComboViewer comboViewer = new ComboViewer(composite, SWT.READ_ONLY); comboViewer.getControl().setFont(composite.getFont()); comboViewer.setLabelProvider(new LabelProvider()); comboViewer.setContentProvider(new ArrayContentProvider()); return comboViewer; }
From source file:com.ebmwebsoucing.petals.repositories.explorer.wizards.QueryApiBeanDefinitionDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite bigContainer = new Composite((Composite) super.createDialogArea(parent), SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 10;//from w w w . j a v a2 s. c o m bigContainer.setLayout(layout); bigContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); // Add the API field new Label(bigContainer, SWT.NONE).setText("Query API:"); ComboViewer viewer = new ComboViewer(bigContainer, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN); viewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { String result = ""; if (element instanceof RepositoryQueryApi) result = ((RepositoryQueryApi) element).toString(); return result; } }); viewer.setInput(RepositoryQueryApi.values()); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (!event.getSelection().isEmpty()) { QueryApiBeanDefinitionDialog.this.api = (RepositoryQueryApi) ((IStructuredSelection) event .getSelection()).getFirstElement(); validate(); } } }); // Add the URL field new Label(bigContainer, SWT.NONE).setText("Query URI:"); Text urlText = new Text(bigContainer, SWT.SINGLE | SWT.BORDER); urlText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); urlText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { QueryApiBeanDefinitionDialog.this.uriAsString = ((Text) e.widget).getText(); validate(); } }); getShell().setText("New Query API"); setTitle("Query API"); setMessage("Associate a new Query API with this repository."); return bigContainer; }
From source file:com.ebmwebsourcing.petals.common.croquis.internal.provisional.CroquisNewWizardPage.java
License:Open Source License
public void createControl(Composite parent) { // The top composite Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, true); layout.horizontalSpacing = 8;/*from w w w. j a va2 s. c o m*/ container.setLayout(layout); container.setLayoutData(new GridData(GridData.FILL_BOTH)); setControl(container); // Update the page settings setTitle("New Petals Croquis"); getShell().setText("New Petals Croquis"); setDescription("Create a new croquis for Petals ESB."); // The left part final Composite leftContainer = new Composite(container, SWT.NONE); layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginTop = 2; leftContainer.setLayout(layout); leftContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); final Label l = new Label(leftContainer, SWT.NONE); l.setText("Croquis Type:"); l.setToolTipText("Select the kind of croquis to create"); final ComboViewer croquisViewer = new ComboViewer(leftContainer, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN); croquisViewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); croquisViewer.setContentProvider(new ArrayContentProvider()); croquisViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return element instanceof String ? (String) element : ((ICroquisExtension) element).getTitle(); } }); // The right part Composite rightContainer = new Composite(container, SWT.BORDER); rightContainer.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); layout = new GridLayout(); layout.marginWidth = 12; layout.marginHeight = 12; rightContainer.setLayout(layout); rightContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); final Label screenshotLabel = new Label(rightContainer, SWT.NONE); screenshotLabel.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); final Label descriptionLabel = new Label(rightContainer, SWT.NONE); GridData layoutData = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); layoutData.verticalIndent = 7; descriptionLabel.setLayoutData(layoutData); descriptionLabel.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); // The selection change listener croquisViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { Object o = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (!(o instanceof ICroquisExtension)) return; if (o.equals(CroquisNewWizardPage.this.selectedExtension)) return; CroquisNewWizardPage.this.selectedExtension = (ICroquisExtension) o; String text = ((ICroquisExtension) o).getDescription(); descriptionLabel.setText(text); ImageDescriptor desc = ((ICroquisExtension) o).getScreenshot(); if (CroquisNewWizardPage.this.currentImage != null && CroquisNewWizardPage.this.currentImage != CroquisNewWizardPage.this.defaultImage) { CroquisNewWizardPage.this.currentImage.dispose(); CroquisNewWizardPage.this.currentImage = null; } if (desc != null) { try { CroquisNewWizardPage.this.currentImage = desc.createImage(); } catch (Exception e) { PetalsCommonPlugin.log(e, IStatus.ERROR); } } else { CroquisNewWizardPage.this.currentImage = CroquisNewWizardPage.this.defaultImage; } screenshotLabel.setImage(CroquisNewWizardPage.this.currentImage); screenshotLabel.getParent().layout(); for (Control c : leftContainer.getChildren()) { if (c != l && c != croquisViewer.getCombo()) c.dispose(); } ((ICroquisExtension) o).createControl(leftContainer, CroquisNewWizardPage.this); leftContainer.layout(); } }); // Initialize the rest List<ICroquisExtension> ext = CroquisContributionManager.INSTANCE.getCroquisData(); if (ext.size() > 0) { croquisViewer.setInput(ext); croquisViewer.getCombo().select(0); croquisViewer.getCombo().notifyListeners(SWT.Selection, new Event()); } else { croquisViewer.setInput("-- No Croquis Available --"); } }
From source file:com.ebmwebsourcing.petals.common.internal.provisional.emf.EObjectUIHelper.java
License:Open Source License
/** * Produces the widgets./*from ww w. j a va 2 s. c o m*/ * @param toolkit * @param parent * @param featuresToLabels * @return */ private static List<EntryDescription> produceWidgets(FormToolkit toolkit, Color labelColor, Composite parent, Map<EStructuralFeature, String> featuresToLabels) { List<EntryDescription> entries = new ArrayList<EntryDescription>(); for (Map.Entry<EStructuralFeature, String> entry : featuresToLabels.entrySet()) { Object widget = null; EAttribute attr = (EAttribute) entry.getKey(); String label = entry.getValue(); // The label // TODO leverage ExtendedMetaData.INSTANCE for tool tip and label if (label == null) { label = StringUtils.camelCaseToHuman(attr.getName()); label = StringUtils.capitalize(label); if (attr.getLowerBound() > 0) label += " *"; label += ":"; } Label labelWidget = toolkit.createLabel(parent, label); labelWidget.setBackground(parent.getBackground()); if (labelColor != null) labelWidget.setForeground(labelColor); // The widget Class<?> instanceClass = attr.getEType().getInstanceClass(); if (instanceClass.equals(String.class)) { String lowered = label.toLowerCase(); if (lowered.contains("password") || lowered.contains("passphrase")) widget = SwtFactory.createPasswordField(parent, false).getText(); else if (lowered.contains("folder") || lowered.contains("directory")) widget = SwtFactory.createDirectoryBrowser(parent).getText(); else widget = toolkit.createText(parent, "", SWT.BORDER); ((Text) widget).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); } else if (instanceClass.equals(Integer.class) || instanceClass.equals(int.class)) { widget = new Spinner(parent, SWT.BORDER); GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).minSize(100, SWT.DEFAULT) .applyTo((Spinner) widget); ((Spinner) widget).setMaximum(Integer.MAX_VALUE); } else if (instanceClass.isEnum()) { widget = new ComboViewer(parent, SWT.READ_ONLY | SWT.FLAT); ComboViewer viewer = (ComboViewer) widget; viewer.setContentProvider(new EEnumLiteralsProvider()); viewer.setLabelProvider(new EEnumNameLabelProvider()); viewer.setInput(attr.getEType()); viewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); } else if (instanceClass.equals(Boolean.class) || instanceClass.equals(boolean.class)) { widget = new ComboViewer(parent, SWT.READ_ONLY | SWT.FLAT); ComboViewer viewer = (ComboViewer) widget; viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); viewer.setInput(new Boolean[] { Boolean.TRUE, Boolean.FALSE }); Combo combo = ((ComboViewer) widget).getCombo(); GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).minSize(100, SWT.DEFAULT).applyTo(combo); } if (widget != null) entries.add(new EntryDescription(widget, attr)); } return entries; }
From source file:com.ebmwebsourcing.petals.common.internal.provisional.utils.SwtFactory.java
License:Open Source License
/** * Creates a combo viewer with a default label provider and an array content provider. * @param parent the parent//from ww w . java2s. c o m * @param useWholeSpace true to use the whole space horizontally * @param values the values to put in the viewer * @return the viewer */ public static ComboViewer createDefaultComboViewer(Composite parent, boolean useWholeSpace, boolean readOnly, Object[] values) { int style = SWT.SINGLE | SWT.BORDER; if (readOnly) style |= SWT.READ_ONLY; final ComboViewer viewer = new ComboViewer(parent, style); if (useWholeSpace) viewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); viewer.setInput(values); return viewer; }
From source file:com.ebmwebsourcing.petals.components.wizards.ComponentNewWizardPage.java
License:Open Source License
/** * @see IDialogPage#createControl(Composite) *//* w ww. jav a 2 s .c o m*/ @Override public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(2).extendedMargins(15, 15, 20, 0).spacing(15, 9) .applyTo(container); container.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, false)); // Component Fields new Label(container, SWT.NONE).setText("Component &type:"); final Combo componentTypeCombo = new Combo(container, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); componentTypeCombo.add("Binding Component"); componentTypeCombo.add("Service Engine"); componentTypeCombo.select(this.bc ? 0 : 1); componentTypeCombo.addSelectionListener(new DefaultSelectionListener() { @Override public void widgetSelected(SelectionEvent e) { int index = ((Combo) e.widget).getSelectionIndex(); ComponentNewWizardPage.this.bc = index == 0; // Validation is implicit, called by the name text } }); new Label(container, SWT.NONE).setText("Component &name:"); final Text componentNameText = new Text(container, SWT.BORDER | SWT.SINGLE); componentNameText.setText(this.name); componentNameText.setSelection(ComponentNewWizardPage.SELECTION_OFFSET, this.name.length()); componentNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(container, SWT.NONE).setText("&Group ID:"); final Text componentGroupIdText = new Text(container, SWT.BORDER | SWT.SINGLE); componentGroupIdText.setText(this.groupId); componentGroupIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); componentGroupIdText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { ComponentNewWizardPage.this.groupId = ((Text) e.widget).getText(); validate(); } }); new Label(container, SWT.NONE).setText("Java Root Package:"); final Text rootPckgText = new Text(container, SWT.BORDER | SWT.SINGLE); rootPckgText.setText(this.rootPackage); rootPckgText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); rootPckgText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { ComponentNewWizardPage.this.rootPackage = ((Text) e.widget).getText(); validate(); } }); new Label(container, SWT.NONE).setText("&Petals Version:"); ComboViewer containerViewer = new ComboViewer(container, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); containerViewer.setLabelProvider(new LabelProvider()); containerViewer.setContentProvider(new ArrayContentProvider()); containerViewer.setInput(PetalsContainerVersion.values()); containerViewer.setSelection(new StructuredSelection(this.petalsContainerVersion)); containerViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ComponentNewWizardPage.this.petalsContainerVersion = (PetalsContainerVersion) ((IStructuredSelection) event .getSelection()).getFirstElement(); validate(); } }); // Project location final Button useDefaultLocButton = new Button(container, SWT.CHECK); useDefaultLocButton.setText("Create the project in the default location"); GridData layoutData = new GridData(); layoutData.horizontalSpan = 2; layoutData.verticalIndent = 17; useDefaultLocButton.setLayoutData(layoutData); Composite locContainer = new Composite(container, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(3).margins(0, 0).applyTo(locContainer); layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.horizontalSpan = 2; locContainer.setLayoutData(layoutData); final Label locLabel = new Label(locContainer, SWT.NONE); locLabel.setText("Project location:"); final Text projectLocationText = new Text(locContainer, SWT.SINGLE | SWT.BORDER); projectLocationText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); projectLocationText.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); projectLocationText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { ComponentNewWizardPage.this.location = ((Text) e.widget).getText().trim(); validate(); } }); final Button browseButton = new Button(locContainer, SWT.PUSH); browseButton.setText("Browse..."); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String location = new DirectoryDialog(getShell()).open(); if (location != null) projectLocationText.setText(location); } }); useDefaultLocButton.setSelection(this.isAtDefaultLocation); useDefaultLocButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ComponentNewWizardPage.this.isAtDefaultLocation = useDefaultLocButton.getSelection(); boolean use = !ComponentNewWizardPage.this.isAtDefaultLocation; locLabel.setEnabled(use); projectLocationText.setEnabled(use); browseButton.setEnabled(use); projectLocationText.setFocus(); validate(); } }); // Listeners componentTypeCombo.addSelectionListener(new DefaultSelectionListener() { @Override public void widgetSelected(SelectionEvent e) { int selection = ((Combo) e.widget).getSelectionIndex(); String componentName = componentNameText.getText().substring(10); String newName = "petals-" + (selection == 0 ? "bc-" : "se-") + componentName; componentNameText.setText(newName); componentNameText.setSelection(newName.length()); } }); componentNameText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { int selection = componentTypeCombo.getSelectionIndex(); String componentName = componentNameText.getText().substring(10); String newGroupId = componentGroupIdText.getText(); if (newGroupId.startsWith("org.ow2.petals.")) newGroupId = "org.ow2.petals." + (selection == 0 ? "bc" : "se") + "." + componentName; ComponentNewWizardPage.this.name = ((Text) e.widget).getText().trim(); componentGroupIdText.setText(newGroupId); // Validation is implicit, called by the group ID text } }); componentNameText.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { componentNameText.setSelection(ComponentNewWizardPage.SELECTION_OFFSET, ComponentNewWizardPage.this.name.length()); } }); // Last steps in the UI definition useDefaultLocButton.notifyListeners(SWT.Selection, new Event()); componentTypeCombo.setFocus(); setControl(container); }
From source file:com.ebmwebsourcing.petals.components.wizards.SharedLibraryNewWizardPage.java
License:Open Source License
/** * @see IDialogPage#createControl(Composite) *//*from w w w . j ava 2 s. com*/ @Override public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginLeft = 15; layout.marginRight = 15; layout.marginTop = 20; layout.horizontalSpacing = 15; layout.verticalSpacing = 9; container.setLayout(layout); container.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, false)); // Name new Label(container, SWT.NONE).setText("Shared-Library &name:"); final Text slNameText = new Text(container, SWT.BORDER | SWT.SINGLE); slNameText.setText(this.name); slNameText.setSelection(SharedLibraryNewWizardPage.SELECTION_OFFSET, this.name.length()); slNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); slNameText.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { String componentName = slNameText.getText(); slNameText.setSelection(SharedLibraryNewWizardPage.SELECTION_OFFSET, componentName.length()); } }); // Group ID new Label(container, SWT.NONE).setText("&Group ID:"); final Text slGroupIdText = new Text(container, SWT.BORDER | SWT.SINGLE); slGroupIdText.setText(this.groupId); slGroupIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); slGroupIdText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { SharedLibraryNewWizardPage.this.groupId = slGroupIdText.getText().trim(); validate(); } }); // Petals version new Label(container, SWT.NONE).setText("&Petals Version:"); ComboViewer containerViewer = new ComboViewer(container, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); containerViewer.setLabelProvider(new LabelProvider()); containerViewer.setContentProvider(new ArrayContentProvider()); containerViewer.setInput(PetalsContainerVersion.values()); containerViewer.setSelection(new StructuredSelection(this.petalsContainerVersion)); containerViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { SharedLibraryNewWizardPage.this.petalsContainerVersion = (PetalsContainerVersion) ((IStructuredSelection) event .getSelection()).getFirstElement(); validate(); } }); // Project location final Button useDefaultLocButton = new Button(container, SWT.CHECK); useDefaultLocButton.setText("Create the project in the default location"); GridData layoutData = new GridData(); layoutData.horizontalSpan = 2; layoutData.verticalIndent = 17; useDefaultLocButton.setLayoutData(layoutData); Composite locContainer = new Composite(container, SWT.NONE); layout = new GridLayout(3, false); layout.marginHeight = layout.marginWidth = 0; locContainer.setLayout(layout); layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.horizontalSpan = 2; locContainer.setLayoutData(layoutData); final Label locLabel = new Label(locContainer, SWT.NONE); locLabel.setText("Project location:"); final Text projectLocationText = new Text(locContainer, SWT.SINGLE | SWT.BORDER); projectLocationText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); projectLocationText.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); projectLocationText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { SharedLibraryNewWizardPage.this.location = ((Text) e.widget).getText().trim(); validate(); } }); final Button browseButton = new Button(locContainer, SWT.PUSH); browseButton.setText("Browse..."); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String location = new DirectoryDialog(getShell()).open(); if (location != null) projectLocationText.setText(location); } }); useDefaultLocButton.setSelection(this.isAtDefaultLocation); useDefaultLocButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SharedLibraryNewWizardPage.this.isAtDefaultLocation = useDefaultLocButton.getSelection(); boolean use = !SharedLibraryNewWizardPage.this.isAtDefaultLocation; locLabel.setEnabled(use); projectLocationText.setEnabled(use); browseButton.setEnabled(use); projectLocationText.setFocus(); validate(); } }); slNameText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { SharedLibraryNewWizardPage.this.name = slNameText.getText().trim(); String slName = slNameText.getText().substring(10); String newGroupId = slGroupIdText.getText(); if (newGroupId.startsWith("org.ow2.petals.")) newGroupId = "org.ow2.petals." + slName; slGroupIdText.setText(newGroupId); // Validation is implicit, called by the group ID text } }); // Last steps in the UI definition useDefaultLocButton.notifyListeners(SWT.Selection, new Event()); setControl(container); }
From source file:com.ebmwebsourcing.petals.server.ui.wizards.PetalsRuntimeWizardFragment3x.java
License:Open Source License
@Override public Composite createComposite(Composite parent, IWizardHandle wizard) { // Wizard//from w w w .j av a 2 s . c om this.wizard = wizard; wizard.setTitle("Petals Runtime"); wizard.setDescription("Create a new Petals runtime."); wizard.setImageDescriptor(PetalsServerPlugin.getImageDescriptor("icons/wizban/pstudio_64x64.png")); // Composite Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(3, false); layout.marginTop = 10; container.setLayout(layout); container.setLayoutData(new GridData(GridData.FILL_BOTH)); // Location final Label locationLabel = new Label(container, SWT.NONE); locationLabel.setText("Location:"); this.locationText = new Text(container, SWT.SINGLE | SWT.BORDER); this.locationText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); this.locationText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { PetalsRuntimeWizardFragment3x.this.installPath = PetalsRuntimeWizardFragment3x.this.locationText .getText().trim(); validate(); } }); final Button browseButton = new Button(container, SWT.PUSH); browseButton.setText("Browse..."); browseButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dlg = new DirectoryDialog( PetalsRuntimeWizardFragment3x.this.locationText.getShell()); dlg.setMessage("Select the install directory of the Petals server."); dlg.setText("Petals server location"); dlg.setFilterPath(PetalsRuntimeWizardFragment3x.this.locationText.getText()); String path = dlg.open(); if (path != null) { PetalsRuntimeWizardFragment3x.this.locationText.setText(path); PetalsRuntimeWizardFragment3x.this.installPath = path.trim(); validate(); } } }); // JRE final Label jreLabel = new Label(container, SWT.NONE); jreLabel.setText("JRE / JDK:"); this.jreViewer = new ComboViewer(container, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); this.jreViewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); this.jreViewer.setContentProvider(new ArrayContentProvider()); this.jreViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof IVMInstall) return ((IVMInstall) element).getName(); return ""; } }); List<IVMInstall> vms = getVmInstalls(); this.jreViewer.setInput(vms); this.jreViewer.setSelection(new StructuredSelection(this.vmInstall)); this.jreViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { Object o = ((IStructuredSelection) event.getSelection()).getFirstElement(); PetalsRuntimeWizardFragment3x.this.vmInstall = (IVMInstall) o; validate(); } }); final Button installedJresButton = new Button(container, SWT.PUSH); installedJresButton.setText("Installed JRE..."); installedJresButton.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, false, false)); installedJresButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } @Override public void widgetSelected(SelectionEvent e) { String id = "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"; PreferenceDialog dlg = PreferencesUtil.createPreferenceDialogOn(new Shell(), id, null, null); if (dlg.open() == Window.OK) { List<IVMInstall> vms = getVmInstalls(); if (vms == null) vms = Collections.emptyList(); PetalsRuntimeWizardFragment3x.this.jreViewer.setInput(vms); PetalsRuntimeWizardFragment3x.this.jreViewer.refresh(); // Show the selected VM - if not null PetalsRuntimeWizardFragment3x.this.jreViewer .setSelection(new StructuredSelection(PetalsRuntimeWizardFragment3x.this.vmInstall)); } } }); // Redefine the petalsRuntimeWc name new Label(container, SWT.NONE).setText("Runtime name:"); this.runtimeNameText = new Text(container, SWT.BORDER | SWT.SINGLE); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.horizontalSpan = 2; this.runtimeNameText.setLayoutData(layoutData); this.runtimeNameText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { PetalsRuntimeWizardFragment3x.this.runtimeName = PetalsRuntimeWizardFragment3x.this.runtimeNameText .getText(); validate(); } }); return container; }
From source file:com.ebmwebsourcing.petals.services.su.ui.ServiceOperationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { // Create the parent Composite bigContainer = (Composite) super.createDialogArea(parent); GridLayout layout = new GridLayout(); layout.marginHeight = 0;// ww w. ja va 2 s. com bigContainer.setLayout(layout); bigContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite container = new Composite(bigContainer, SWT.NONE); container.setLayout(new GridLayout(2, true)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); // Put a viewer on the left final TableViewer viewer = new TableViewer(container, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); viewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new OperationLabelProvider())); viewer.setInput(this.opNameToMep.keySet()); // Add widgets on the right Composite rightPart = new Composite(container, SWT.NONE); layout = new GridLayout(2, false); layout.marginHeight = 0; rightPart.setLayout(layout); rightPart.setLayoutData(new GridData(GridData.FILL_BOTH)); final Button customOpButton = new Button(rightPart, SWT.CHECK); customOpButton.setText("Define a custom operation"); GridData layoutData = new GridData(); layoutData.horizontalSpan = 2; customOpButton.setLayoutData(layoutData); Label l = new Label(rightPart, SWT.NONE); l.setText("Name space:"); l.setToolTipText("The operation's name space"); this.nsText = new Text(rightPart, SWT.BORDER | SWT.SINGLE); this.nsText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); l = new Label(rightPart, SWT.NONE); l.setText("Name:"); l.setToolTipText("The operation's name"); this.nameText = new Text(rightPart, SWT.BORDER | SWT.SINGLE); this.nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); l = new Label(rightPart, SWT.NONE); l.setText("MEP:"); l.setToolTipText("The Message Exchange Pattern"); this.mepViewer = new ComboViewer(rightPart, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); this.mepViewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); this.mepViewer.setContentProvider(new ArrayContentProvider()); this.mepViewer.setLabelProvider(new LabelProvider()); this.mepViewer.setInput(Mep.values()); // Complete the dialog properties getShell().setText("Operation Viewer"); setTitle("Operation Viewer"); setMessage("View and edit service operations."); // Add the listeners customOpButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { widgetDefaultSelected(e); } public void widgetDefaultSelected(SelectionEvent e) { ServiceOperationDialog.this.useCustomOperation = customOpButton.getSelection(); ServiceOperationDialog.this.nsText.setEditable(customOpButton.getSelection()); ServiceOperationDialog.this.nameText.setEditable(customOpButton.getSelection()); ServiceOperationDialog.this.mepViewer.getCombo().setEnabled(customOpButton.getSelection()); validate(); } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { Object o = ((IStructuredSelection) viewer.getSelection()).getFirstElement(); ServiceOperationDialog.this.nsText.setText(((QName) o).getNamespaceURI()); ServiceOperationDialog.this.nameText.setText(((QName) o).getLocalPart()); Mep mep = ServiceOperationDialog.this.opNameToMep.get(o); ServiceOperationDialog.this.mepViewer.setSelection(new StructuredSelection(mep)); } }); customOpButton.setSelection(false); customOpButton.notifyListeners(SWT.Selection, new Event()); ModifyListener modifyListener = new ModifyListener() { public void modifyText(ModifyEvent e) { if ((((Text) e.widget).getStyle() & SWT.READ_ONLY) == 0) validate(); } }; this.nameText.addModifyListener(modifyListener); this.nsText.addModifyListener(modifyListener); this.mepViewer.getCombo().addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { if (((Combo) e.widget).isEnabled()) validate(); } }); return bigContainer; }