List of usage examples for org.eclipse.jface.viewers LabelProvider LabelProvider
public LabelProvider()
From source file:com.ebmwebsourcing.petals.common.internal.provisional.emf.EObjectUIHelper.java
License:Open Source License
/** * Produces the widgets.// w w w .jav a2s .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.swt.ListWithButtonComposite.java
License:Open Source License
/** * Constructor./*w w w . jav a 2s . c om*/ * <p> * The list and the button are created, but no property or layout data is set. * </p> * * @param parent the parent */ public ListWithButtonComposite(Composite parent) { super(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = layout.marginHeight = 0; setLayout(layout); Table table = new Table(this, SWT.MULTI | SWT.BORDER); table.setLayoutData(new GridData(GridData.FILL_BOTH)); this.viewer = new TableViewer(table); this.viewer.setContentProvider(new ArrayContentProvider()); this.viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof File) return ((File) element).getAbsolutePath(); return super.getText(element); } }); Composite buttons = new Composite(this, SWT.NONE); layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; buttons.setLayout(layout); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); // ADD button this.addButton = new Button(buttons, SWT.PUSH); this.addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // REMOVE button this.removeButton = new Button(buttons, SWT.PUSH); this.removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); }
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 w ww .j a v a 2 s.c om*/ * @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.common.internal.provisional.utils.SwtFactory.java
License:Open Source License
/** * Creates a file list with a browser to open a file dialog. * <p>//from ww w . j a v a 2s .c o m * When a file is added or removed, a selection listener is invoked. * </p> * * @param parent the parent * @param filterNames the filter names * @param fileExtensions the file extensions * @param files a non-null collection of files (can be empty) * @return the tree viewer that displays the selected files */ public static ListWithButtonComposite createFileListViewer(final Composite parent, final String[] filterNames, final String[] fileExtensions, final Collection<File> files) { final ListWithButtonComposite lbc = new ListWithButtonComposite(parent); lbc.setLayoutData(new GridData(GridData.FILL_BOTH)); final TableViewer viewer = lbc.getViewer(); viewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof File) return ((File) element).getAbsolutePath(); return super.getText(element); } }); // ADD button lbc.getAddButton().setText("Add"); lbc.getAddButton().setImage(PetalsImages.INSTANCE.getAdd()); lbc.getAddButton().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dlg = new FileDialog(parent.getShell(), SWT.MULTI); dlg.setText("Select one or several files"); dlg.setFilterNames(filterNames); dlg.setFilterExtensions(fileExtensions); String path = PreferencesManager.getSavedLocation(); if (path.trim().length() > 0) dlg.setFilterPath(path); String fn = dlg.open(); if (fn == null) return; // Process the files path = dlg.getFilterPath(); PreferencesManager.setSavedLocation(path); File parent = new File(path); for (String filename : dlg.getFileNames()) { File chosenFile = new File(parent, filename); files.add(chosenFile); } viewer.setInput(files); viewer.refresh(); lbc.notifyListeners(); } }); // REMOVE button lbc.getRemoveButton().setText("Remove"); lbc.getRemoveButton().setImage(PetalsImages.INSTANCE.getDelete()); lbc.getRemoveButton().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Iterator<?> it = ((IStructuredSelection) viewer.getSelection()).iterator(); while (it.hasNext()) { File f = (File) it.next(); files.remove(f); } viewer.setInput(files); viewer.refresh(); lbc.notifyListeners(); } }); return lbc; }
From source file:com.ebmwebsourcing.petals.components.wizards.ComponentNewWizardPage.java
License:Open Source License
/** * @see IDialogPage#createControl(Composite) *//*from w w w . j a v a 2s .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 ww. j ava 2 s. c om @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 ava 2s . 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.eip.designer.tabbedproperties.EipSpecificSection.java
License:Open Source License
@Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { // Create the container super.createControls(parent, aTabbedPropertySheetPage); Composite container = getWidgetFactory().createPlainComposite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginTop = 10;/*w w w. j a va 2 s. c om*/ container.setLayout(layout); // Add the other widgets Label l = getWidgetFactory().createLabel(container, "Enterprise Integration Pattern:"); l.setToolTipText("The Enterprise Integration Pattern"); CCombo combo = getWidgetFactory().createCCombo(container, SWT.READ_ONLY | SWT.FLAT | SWT.NO_FOCUS); GridData layoutData = new GridData(); layoutData.widthHint = 240; layoutData.horizontalIndent = 5; combo.setLayoutData(layoutData); this.patternViewer = new ComboViewer(combo); this.patternViewer.setContentProvider(new ArrayContentProvider()); this.patternViewer.setLabelProvider(new LabelProvider()); this.patternViewer.setInput(EIPtype.values()); this.patternViewer.getCCombo().setVisibleItemCount(EIPtype.values().length); this.subContainer = getWidgetFactory().createComposite(container); layout = new GridLayout(2, false); layout.marginWidth = 0; this.subContainer.setLayout(layout); layoutData = new GridData(GridData.FILL_BOTH); layoutData.horizontalSpan = 2; layoutData.verticalIndent = 5; this.subContainer.setLayoutData(layoutData); if (this.eip != null) { this.patternViewer.setSelection(new StructuredSelection(this.eip.getEipType())); buildPatternWidgets(); } // Listeners this.patternViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { // Notify the change if (EipSpecificSection.this.notifyChanges) { EipNodeSetAttributeCommand cmd = new EipNodeSetAttributeCommand(EipNode.PROPERTY_EIP_TYPE); cmd.setEipNode(EipSpecificSection.this.eip); Object o = ((IStructuredSelection) event.getSelection()).getFirstElement(); cmd.setNewValue(o); executeCommand(cmd); } } }); }
From source file:com.ebmwebsourcing.petals.services.pojo.wizards.PojoProvideSpecificPage22.java
License:Open Source License
/** * Opens a dialog to select a class contained in the JAR files. * @return the selected class name, or null if CANCEL was clicked *///from w w w. ja v a 2s. c o m private String openClassSelectionDialog() { // Get all the classes in the JAR List<String> classNames = new ArrayList<String>(); for (File f : this.jarFiles) { JarFile jarFile = null; try { jarFile = new JarFile(f); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { String entryName = entries.nextElement().getName(); if (entryName.endsWith(".class") && !entryName.contains("$")) { entryName = entryName.substring(0, entryName.length() - 6); entryName = entryName.replaceAll("/", "."); classNames.add(entryName); } } } catch (IOException e) { continue; } finally { if (jarFile != null) { try { jarFile.close(); } catch (IOException e1) { // nothing } } } } // Display them in a dialog ElementListSelectionDialog dlg = new ElementListSelectionDialog(getShell(), new LabelProvider()); dlg.setTitle("Class Selection"); dlg.setElements(classNames.toArray()); dlg.setMessage("Select the POJO class."); dlg.setFilter(this.className != null ? this.className : "*"); dlg.setAllowDuplicates(false); dlg.setIgnoreCase(false); dlg.setMultipleSelection(false); String result = null; if (dlg.open() == Window.OK) result = (String) dlg.getFirstResult(); return result; }
From source file:com.ebmwebsourcing.petals.services.sa.wizards.PetalsSaSusWizardPage.java
License:Open Source License
public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginLeft = layout.marginRight = 15; layout.marginTop = 10;//from w ww. j av a 2 s . com layout.horizontalSpacing = 15; container.setLayout(layout); container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(container, SWT.NONE).setText("Select the SU projects to include:"); final CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(container, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL); GridData layoutData = new GridData(GridData.FILL_BOTH); layoutData.heightHint = 200; viewer.getTable().setLayoutData(layoutData); viewer.setContentProvider(new ArrayContentProvider() { @Override public Object[] getElements(Object inputElement) { return ServiceProjectRelationUtils.getAllSuProjects().toArray(); } }); viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { String text = ""; if (element instanceof IProject) text = ((IProject) element).getName(); return text; } }); viewer.setComparator(new ResourceComparator(ResourceComparator.NAME)); viewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { IProject p = (IProject) event.getElement(); if (event.getChecked()) PetalsSaSusWizardPage.this.suProjects.add(p); else PetalsSaSusWizardPage.this.suProjects.remove(p); validate(); } }) ; viewer.setInput(new Object()); setControl(container); }