List of usage examples for org.eclipse.jface.viewers ComboViewer getCombo
public Combo getCombo()
From source file:au.gov.ansto.bragg.nbi.ui.core.commands.SinglePositionParameter.java
License:Open Source License
@Override public void createParameterUI(Composite parent, final AbstractScanCommandView commandView, final FormToolkit toolkit) { GridLayoutFactory.swtDefaults().margins(0, 0).spacing(6, 4).numColumns(4).applyTo(parent); // GridLayoutFactory.swtDefaults().numColumns(6).applyTo(parent); final ComboViewer scanVariableCombo = new ComboViewer(parent, SWT.READ_ONLY); scanVariableCombo.setContentProvider(new ArrayContentProvider()); scanVariableCombo.setLabelProvider(new LabelProvider()); scanVariableCombo.setSorter(new ViewerSorter()); String[] ids = SicsBatchUIUtils.getSicsDrivableIds(); for (int i = 0; i < ids.length; i++) { if (ids[i] == null) { ids[i] = ""; }/*from w w w . jav a2 s. c o m*/ } scanVariableCombo.setInput(ids); GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).hint(WIDTH_COMBO, SWT.DEFAULT) .applyTo(scanVariableCombo.getCombo()); // GridDataFactory.fillDefaults().grab(true, false).applyTo(scanVariableCombo.getCombo()); // GridDataFactory.swtDefaults().hint(WIDTH_COMBO, SWT.DEFAULT).applyTo(scanVariableCombo.getCombo()); final Text positionText = toolkit.createText(parent, ""); // GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER, SWT.DEFAULT).applyTo(startPositionText); // GridData data = new GridData(); // data.grabExcessHorizontalSpace = true; // data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING; // data.heightHint = SWT.DEFAULT; // startPositionText.setLayoutData(data); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER_LONG, SWT.DEFAULT) .applyTo(positionText); addValidator(positionText, ParameterValidator.floatValidator); Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(ViewersObservables.observeSingleSelection(scanVariableCombo), BeansObservables.observeValue(getInstance(), "scanVariable"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(positionText, SWT.Modify), BeansObservables.observeValue(getInstance(), "position"), new UpdateValueStrategy(), new UpdateValueStrategy()); } }); final AbstractScanCommand command = commandView.getCommand(); Button addButton = toolkit.createButton(parent, "", SWT.PUSH); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(18, 18).applyTo(addButton); try { addButton.setImage(SicsBatchUIUtils.getBatchEditorImage("ADD")); } catch (FileNotFoundException e2) { LoggerFactory.getLogger(this.getClass()).error("can not find ADD image", e2); } addButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addNewParameter(command); commandView.refreshParameterComposite(); // notifyPropertyChanged(newCommand, null); } }); Button removeButton = toolkit.createButton(parent, "", SWT.PUSH); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(18, 18).applyTo(removeButton); try { removeButton.setImage(SicsBatchUIUtils.getBatchEditorImage("REMOVE")); } catch (FileNotFoundException e1) { LoggerFactory.getLogger(this.getClass()).error("can not find REMOVE image", e1); } removeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeParameter(command); commandView.refreshParameterComposite(); } }); }
From source file:ch.elexis.core.ui.contacts.dialogs.AdvancedFilterDialog.java
License:Open Source License
/** * Create contents of the dialog./*from w w w.j a v a 2 s . c o m*/ * * @param parent */ @Override protected Control createDialogArea(Composite parent) { setMessage("Konfiguration des erweiterten Filters"); setTitle("Erweiterter Filter"); Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(2, false)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); Label lblGespeichertenFilterLaden = new Label(container, SWT.NONE); lblGespeichertenFilterLaden.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGespeichertenFilterLaden.setText("Gespeicherten Filter laden"); ComboViewer comboViewer = new ComboViewer(container, SWT.NONE); Combo combo = comboViewer.getCombo(); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblNewLabel = new Label(container, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); Button btnFilterSticker = new Button(container, SWT.CHECK); btnFilterSticker.setText("nach Sticker filtern"); new Label(container, SWT.NONE); Button btnFilterField = new Button(container, SWT.CHECK); btnFilterField.setText("nach Feldwerten filtern"); new Label(container, SWT.NONE); Button btnBtnfilterproperties = new Button(container, SWT.CHECK); btnBtnfilterproperties.setText("nach Eigenschaften filtern"); new Label(container, SWT.NONE); Label lblNewLabel_1 = new Label(container, SWT.NONE); lblNewLabel_1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); Label lblFilterSpeichernAls = new Label(container, SWT.NONE); lblFilterSpeichernAls.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblFilterSpeichernAls.setText("Filter speichern als"); text = new Text(container, SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); return area; }
From source file:ch.elexis.data.TarmedImporter.java
License:Open Source License
@Override public Composite createPage(final Composite parent) { FileBasedImporter fis = new ImporterPage.FileBasedImporter(parent, this); fis.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); Composite updateIDsComposite = new Composite(fis, SWT.NONE); updateIDsComposite.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); updateIDsComposite.setLayout(new FormLayout()); Label lbl = new Label(updateIDsComposite, SWT.NONE); lbl.setText("Gesetz des Datensatz (relevant ab Tarmed 1.09)"); final ComboViewer lawCombo = new ComboViewer(updateIDsComposite, SWT.BORDER); lawCombo.setContentProvider(ArrayContentProvider.getInstance()); lawCombo.setInput(availableLaws);// w ww .ja v a2 s. com lawCombo.setSelection(new StructuredSelection(selectedLaw)); lawCombo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); if (selection != null && !selection.isEmpty()) { selectedLaw = (String) selection.getFirstElement(); } else { selectedLaw = ""; } } }); FormData fd = new FormData(); fd.top = new FormAttachment(0, 5); fd.left = new FormAttachment(0, 0); lbl.setLayoutData(fd); fd = new FormData(); fd.top = new FormAttachment(0, 0); fd.left = new FormAttachment(lbl, 5); lawCombo.getCombo().setLayoutData(fd); lbl = new Label(updateIDsComposite, SWT.NONE); lbl.setText(Messages.TarmedImporter_updateOldIDEntries); final Button updateIDsBtn = new Button(updateIDsComposite, SWT.CHECK); fd = new FormData(); fd.top = new FormAttachment(lawCombo.getControl(), 5); fd.left = new FormAttachment(0, 0); lbl.setLayoutData(fd); fd = new FormData(); fd.top = new FormAttachment(lawCombo.getControl(), 5); fd.left = new FormAttachment(lbl, 5); updateIDsBtn.setLayoutData(fd); updateIDsBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { updateIDs = updateIDsBtn.getSelection(); } @Override public void widgetDefaultSelected(SelectionEvent e) { updateIDs = updateIDsBtn.getSelection(); } }); return fis; }
From source file:com.atlassian.connector.eclipse.internal.crucible.ui.dialogs.CrucibleAddCommentDialog.java
License:Open Source License
protected void createCombo(Composite parent, final CustomFieldDef customField, int selection) { ((GridLayout) parent.getLayout()).numColumns++; Label label = new Label(parent, SWT.NONE); label.setText("Select " + customField.getName()); ((GridLayout) parent.getLayout()).numColumns++; ComboViewer comboViewer = new ComboViewer(parent); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setLabelProvider(new LabelProvider() { @Override//from w w w . ja v a 2s .com public String getText(Object element) { CustomFieldValue fieldValue = (CustomFieldValue) element; return fieldValue.getName(); } }); comboViewer.setInput(customField.getValues()); comboViewer.getCombo().setEnabled(false); customCombos.put(customField, comboViewer); }
From source file:com.bdaum.zoom.ui.internal.views.DataEntryView.java
License:Open Source License
private Object createField(final Composite parent, final QueryField qfield, int style, int horSpan, int widthHint) { Label label = new Label(parent, SWT.NONE); label.setText(qfield.getLabelWithUnit()); label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); GridData layoutData = new GridData(SWT.LEFT, SWT.CENTER, true, false, Math.abs(horSpan), 1); layoutData.horizontalIndent = 12;//from w w w .j a va 2 s . co m final int qtype = qfield.getType(); switch (qtype) { case QueryField.T_BOOLEAN: final Button checkButton = new Button(parent, SWT.CHECK); checkButton.setData(UiConstants.LABEL, label); layoutData.grabExcessHorizontalSpace = false; checkButton.setLayoutData(layoutData); widgetMap.put(qfield, checkButton); checkButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!updateSet.contains(qfield)) putValue(qfield, checkButton.getSelection()); } }); return checkButton; case QueryField.T_DATE: { final DateComponent dateField = new DateComponent(parent, SWT.NONE); dateField.setData(UiConstants.LABEL, label); layoutData.widthHint = widthHint; dateField.setLayoutData(layoutData); dateField.addListener(new Listener() { @Override public void handleEvent(Event event) { if (!updateSet.contains(qfield)) putValue(qfield, dateField.getSelection()); } }); widgetMap.put(qfield, dateField); return dateField; } case QueryField.T_CURRENCY: { IFormatter formatter = qfield.getFormatter(); if (formatter != null) { final Text textField = new Text(parent, SWT.BORDER | style); textField.setData(UiConstants.LABEL, label); layoutData.widthHint = widthHint; textField.setLayoutData(layoutData); widgetMap.put(qfield, textField); textField.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { if (!updateSet.contains(qfield)) { Object text = textField.getText(); if (!QueryField.VALUE_MIXED.equals(text)) { try { putValue(qfield, text = qfield.getFormatter().fromString((String) text)); hideFieldDeco(textField); } catch (ParseException e) { showError(textField, e.getMessage()); } } } } }); return textField; } final SpinnerComponent spinner = new SpinnerComponent(parent, SWT.BORDER); spinner.setData(UiConstants.LABEL, label); spinner.setDigits(Format.getCurrencyDigits()); spinner.setIncrement(1); spinner.setPageIncrement((int) Math.pow(10, Format.getCurrencyDigits())); spinner.setMinimum(0); spinner.setMaximum(Integer.MAX_VALUE); spinner.setLayoutData(layoutData); spinner.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { putCurrencyValue(qfield, spinner); } }); spinner.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent keyEvent) { switch (keyEvent.character) { case '+': spinner.setSelection(spinner.getSelection() + 1); putCurrencyValue(qfield, spinner); break; case '-': spinner.setSelection(spinner.getSelection() - 1); putCurrencyValue(qfield, spinner); break; } } }); widgetMap.put(qfield, spinner); return spinner; } case QueryField.T_FLOAT: case QueryField.T_FLOATB: case QueryField.T_POSITIVEFLOAT: { final Text textField = new Text(parent, SWT.BORDER | style); textField.setData(UiConstants.LABEL, label); layoutData.horizontalAlignment = widthHint == SWT.DEFAULT ? SWT.FILL : SWT.LEFT; layoutData.widthHint = widthHint; textField.setLayoutData(layoutData); textField.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { if (!updateSet.contains(qfield)) { String text = textField.getText().trim(); if (text.isEmpty()) { putValue(qfield, Double.NaN); hideFieldDeco(textField); } else { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(8); try { double value = nf.parse(text).doubleValue(); if (qtype == QueryField.T_POSITIVEFLOAT && value < 0) showError(textField, Messages.getString("DataEntryView.must_be_positive")); //$NON-NLS-1$ else { putValue(qfield, value); hideFieldDeco(textField); } } catch (ParseException e) { showError(textField, Messages.getString("DataEntryView.bad_fp")); //$NON-NLS-1$ } } } } }); widgetMap.put(qfield, textField); return textField; } case QueryField.T_INTEGER: case QueryField.T_POSITIVEINTEGER: case QueryField.T_LONG: case QueryField.T_POSITIVELONG: if (qfield.getEnumeration() instanceof int[]) { final ComboViewer comboViewer = new ComboViewer(parent, SWT.NONE); comboViewer.getControl().setData(UiConstants.LABEL, label); layoutData.horizontalAlignment = widthHint == SWT.DEFAULT ? SWT.FILL : SWT.LEFT; comboViewer.getCombo().setLayoutData(layoutData); comboViewer.setLabelProvider(new IntArrayLabelProvider(qfield)); comboViewer.setContentProvider(new IntArrayContentProvider(qfield)); comboViewer.setInput(this); comboViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (!comboViewer.getControl().isDisposed() && !updateSet.contains(qfield) && !QueryField.VALUE_MIXED.equals(comboViewer.getCombo().getText())) putValue(qfield, comboViewer.getStructuredSelection().getFirstElement()); } }); widgetMap.put(qfield, comboViewer); return comboViewer; } final SpinnerComponent spinner = new SpinnerComponent(parent, SWT.BORDER); spinner.setData(UiConstants.LABEL, label); spinner.setLayoutData(layoutData); spinner.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { putIntegerValue(qfield, spinner); } }); spinner.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent keyEvent) { switch (keyEvent.character) { case '+': spinner.setSelection(spinner.getSelection() + 1); putIntegerValue(qfield, spinner); break; case '-': spinner.setSelection(spinner.getSelection() - 1); putIntegerValue(qfield, spinner); break; } } }); widgetMap.put(qfield, spinner); return spinner; case QueryField.T_OBJECT: case QueryField.T_LOCATION: case QueryField.T_CONTACT: case QueryField.T_STRING: { layoutData.horizontalAlignment = widthHint == SWT.DEFAULT ? SWT.FILL : SWT.LEFT; if (qfield.getEnumeration() instanceof String[]) { final ComboViewer comboViewer = new ComboViewer(parent, SWT.NONE); comboViewer.getControl().setData(UiConstants.LABEL, label); comboViewer.getCombo().setLayoutData(layoutData); widgetMap.put(qfield, comboViewer); comboViewer.setContentProvider(ArrayContentProvider.getInstance()); comboViewer.setLabelProvider(new StringArrayLabelProvider(qfield)); comboViewer.setInput(qfield.getEnumeration()); comboViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (!updateSet.contains(qfield) && !QueryField.VALUE_MIXED.equals(comboViewer.getCombo().getText())) putValue(qfield, ((IStructuredSelection) comboViewer.getSelection()).getFirstElement()); } }); return comboViewer; } if (qfield.getSpellingOptions() == ISpellCheckingService.NOSPELLING || horSpan < 0) { final Text textField = new Text(parent, SWT.BORDER | style | (horSpan < 0 ? SWT.READ_ONLY : SWT.NONE)); textField.setData(UiConstants.LABEL, label); layoutData.widthHint = widthHint; if ((style & SWT.MULTI) != 0) layoutData.heightHint = 50; textField.setLayoutData(layoutData); widgetMap.put(qfield, textField); if (horSpan < 0) { Button editButton = new Button(parent, SWT.PUSH); textField.setData(EDITBUTTON, editButton); editButton.setToolTipText(NLS.bind(Messages.getString("DataEntryView.edit"), //$NON-NLS-1$ qfield.getLabel())); editButton.setText("..."); //$NON-NLS-1$ editButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Object result = handleEditButton(parent, qfield, valueMap.get(qfield)); if (result != null) { if (result instanceof BagChange) result = ((BagChange<?>) result).getDisplay(); putValue(qfield, result); String text = qfield.value2text(result, CLICK_TO_VIEW_DETAILS); textField.setText(text); updateActions(false); } } }); } else { textField.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { if (!updateSet.contains(qfield)) { Object text = textField.getText(); if (!QueryField.VALUE_MIXED.equals(text)) { if (qfield.getFormatter() != null) try { text = qfield.getFormatter().fromString((String) text); putValue(qfield, text); hideFieldDeco(textField); } catch (ParseException e) { showError(textField, e.getMessage()); } else { putValue(qfield, text); hideFieldDeco(textField); } } } } }); } return textField; } final CheckedText checkedTextField = new CheckedText(parent, SWT.BORDER | style); checkedTextField.setData(UiConstants.LABEL, label); checkedTextField.setSpellingOptions(10, qfield.getSpellingOptions()); layoutData.horizontalAlignment = widthHint == SWT.DEFAULT ? SWT.FILL : SWT.LEFT; layoutData.widthHint = widthHint; if ((style & SWT.MULTI) != 0) layoutData.heightHint = 50; checkedTextField.setLayoutData(layoutData); checkedTextField.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (!updateSet.contains(qfield)) { String text = checkedTextField.getText(); if (!QueryField.VALUE_MIXED.equals(text)) { putValue(qfield, text); hideFieldDeco(checkedTextField); } } } }); widgetMap.put(qfield, checkedTextField); return checkedTextField; } } return null; }
From source file:com.byterefinery.rmbench.dialogs.DDLExportWizardPage1.java
License:Open Source License
public void createControl(Composite parent) { final DDLExportWizard ddlWizard = (DDLExportWizard) getWizard(); GridLayout layout;//from ww w . j a va 2 s.co m GridData gd; final Composite composite = new Composite(parent, SWT.NONE); layout = new GridLayout(); layout.verticalSpacing = 10; composite.setLayout(layout); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final Composite connectionGroup = new Composite(composite, SWT.NONE); connectionGroup.setLayout(new GridLayout()); connectionGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final Button diffCheck = new Button(connectionGroup, SWT.CHECK); diffCheck.setText(Messages.DDLExportWizard1_generateDiff_label); diffCheck.setSelection(generateDiff); diffCheck.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!generateDiff) { if (dbmodels.length == 0) { MessageDialog.openInformation(getShell(), RMBenchMessages.ModelView_ExportDialog_Title, Messages.DDLExportWizard1_NoConnection); diffCheck.setSelection(false); return; } } generateDiff = diffCheck.getSelection(); connectionsViewer.getControl().setEnabled(generateDiff); checkCompleteState(); } }); connectionsViewer = new ListViewer(connectionGroup, SWT.SINGLE | SWT.BORDER); gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.minimumHeight = convertHeightInCharsToPixels(4); connectionsViewer.getList().setLayoutData(gd); connectionsViewer.setContentProvider(new ArrayContentProvider()); connectionsViewer.setLabelProvider(new LabelProvider() { public String getText(Object element) { return ((DBModel) element).getName(); } }); connectionsViewer.setInput(dbmodels); if (dbmodel != null) connectionsViewer.setSelection(new StructuredSelection(dbmodel)); connectionsViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); dbmodel = (DBModel) selection.getFirstElement(); checkCompleteState(); } }); connectionsViewer.getControl().setEnabled(generateDiff); final Button generateDropCheck = new Button(composite, SWT.CHECK); generateDropCheck.setText(Messages.DDLExportWizard1_generateDrop_text); generateDropCheck.setSelection(generateDrop); generateDropCheck.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { generateDrop = generateDropCheck.getSelection(); } }); final Composite generatorGroup = new Composite(composite, SWT.NONE); generatorGroup.setLayout(new GridLayout()); generatorGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); final Label generatorLabel = new Label(generatorGroup, SWT.NONE); generatorLabel.setText(Messages.DDLExportWizard1_generator_label); generatorLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); final ComboViewer generatorsViewer = new ComboViewer(generatorGroup, SWT.DROP_DOWN | SWT.READ_ONLY); generatorsViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); generatorsViewer.setContentProvider(new ArrayContentProvider()); generatorsViewer.setLabelProvider(new LabelProvider() { public String getText(Object element) { return ((DDLGeneratorExtension) element).getName(); } }); generatorsViewer.setInput(generators); generatorsViewer.setSelection(new StructuredSelection(generatorExtension)); generatorsViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); DDLGeneratorExtension genExt = (DDLGeneratorExtension) selection.getFirstElement(); setGenerator(genExt); ddlWizard.setDDLGeneratorWizardPage(genExt.createGeneratorWizardPage(generator)); checkCompleteState(); } }); setControl(composite); checkCompleteState(); }
From source file:com.byterefinery.rmbench.dialogs.ModelPropertiesDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { Composite mainComposite = (Composite) super.createDialogArea(parent); final Composite localComposite = new Composite(mainComposite, SWT.NONE); localComposite.setLayout(new GridLayout(2, false)); Label label;//from w ww .j ava 2 s . c om GridData gd; if (storageKey != null) { Composite storageComposite = new Composite(localComposite, SWT.NONE); gd = new GridData(SWT.FILL, SWT.NONE, true, false); gd.horizontalSpan = 2; storageComposite.setLayoutData(gd); GridLayout layout = new GridLayout(); layout.marginWidth = 0; storageComposite.setLayout(layout); label = new Label(storageComposite, SWT.NONE); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.BOTTOM, false, false)); label.setText(Messages.ModelPropertiesDialog_Location + " " + storageKey); label = new Label(storageComposite, SWT.SEPARATOR | SWT.HORIZONTAL); gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false); gd.horizontalSpan = 2; label.setLayoutData(gd); } label = new Label(localComposite, SWT.NONE); label.setText(Messages.ModelPropertiesDialog_Name); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); final Text nameText = new Text(localComposite, SWT.BORDER | SWT.SINGLE); gd = new GridData(SWT.LEFT, SWT.FILL, false, true); gd.widthHint = convertWidthInCharsToPixels(MODEL_NAME_CHARS); nameText.setLayoutData(gd); nameText.setTextLimit(MODEL_NAME_CHARS); nameText.setText(modelName); nameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validateName(nameText.getText()); updateOKButton(); } }); label = new Label(localComposite, SWT.NONE); label.setText(Messages.ModelPropertiesDialog_Database); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); final ComboViewer dbCombo = new ComboViewer(localComposite, SWT.READ_ONLY | SWT.DROP_DOWN); dbCombo.getCombo().setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); dbCombo.setContentProvider(new ArrayContentProvider()); dbCombo.setLabelProvider(new LabelProvider() { public String getText(Object element) { DatabaseExtension dbExt = (DatabaseExtension) element; return dbExt.getName(); } }); dbCombo.setInput(RMBenchPlugin.getExtensionManager().getDatabaseExtensions()); dbCombo.setSelection(new StructuredSelection(databaseExtension)); dbCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); DatabaseExtension dbext = (DatabaseExtension) selection.getFirstElement(); if (dbext != databaseExtension) { boolean proceed = model.isEmpty() || MessageDialog.openQuestion(getShell(), Messages.ModelPropertiesDialog_ChangeModel_Title, Messages.ModelPropertiesDialog_ChangeModel_Message); if (proceed) { databaseExtension = dbext; updateOKButton(); } else { dbCombo.setSelection(new StructuredSelection(databaseExtension), true); } } } }); label = new Label(localComposite, SWT.NONE); label.setText(Messages.ModelPropertiesDialog_NameGenerator); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); final ComboViewer generatorCombo = new ComboViewer(localComposite, SWT.READ_ONLY | SWT.DROP_DOWN); generatorCombo.getCombo().setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); generatorCombo.setContentProvider(new ArrayContentProvider()); generatorCombo.setLabelProvider(new LabelProvider() { public String getText(Object element) { NameGeneratorExtension genext = (NameGeneratorExtension) element; return genext.getName(); } }); generatorCombo.setInput(RMBenchPlugin.getExtensionManager().getNameGeneratorExtensions()); generatorCombo.setSelection(new StructuredSelection(generatorExtension)); generatorCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); generatorExtension = (NameGeneratorExtension) selection.getFirstElement(); updateOKButton(); } }); return mainComposite; }
From source file:com.byterefinery.rmbench.dialogs.NewDiagramDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { Composite mainComposite = (Composite) super.createDialogArea(parent); final Composite localComposite = new Composite(mainComposite, SWT.NONE); localComposite.setLayout(new GridLayout(2, false)); final Label nameLabel = new Label(localComposite, SWT.NONE); nameLabel.setText(Messages.NewDiagramDialog_Name); nameLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); final Text nameText = new Text(localComposite, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData(SWT.LEFT, SWT.FILL, false, true); gd.widthHint = convertWidthInCharsToPixels(DIAGRAM_NAME_CHARS); nameText.setLayoutData(gd);//from w ww . ja v a 2 s .com nameText.setTextLimit(DIAGRAM_NAME_CHARS); nameText.setText(diagramName); nameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validateName(nameText.getText()); updateOKButton(); } }); final Label schemaLabel = new Label(localComposite, SWT.NONE); schemaLabel.setText(Messages.NewDiagramDialog_TargetSchema); schemaLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); final ComboViewer schemaCombo = new ComboViewer(localComposite, SWT.READ_ONLY | SWT.DROP_DOWN); schemaCombo.getCombo().setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); schemaCombo.setContentProvider(new ArrayContentProvider()); schemaCombo.setLabelProvider(new LabelProvider() { public String getText(Object element) { Schema schema = (Schema) element; return schema.getName(); } }); Schema[] schemas = model.getSchemasArray(); schemaCombo.setInput(schemas); selectedSchema = schemas[0]; schemaCombo.setSelection(new StructuredSelection(selectedSchema), true); schemaCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); selectedSchema = (Schema) selection.getFirstElement(); } }); errorMessageLabel = new Label(localComposite, SWT.NONE); errorMessageLabel.setForeground(ColorConstants.red); gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.horizontalSpan = 2; errorMessageLabel.setLayoutData(gd); return mainComposite; }
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;/* w w w .ja v a 2s . 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;/*w ww .j av a 2s .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 --"); } }