List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer
public ComboViewer(Composite parent, int style)
From source file:com.bdaum.zoom.ui.internal.widgets.AutoRatingGroup.java
License:Open Source License
public AutoRatingGroup(Composite parent, IAiService aiService, IDialogSettings dialogSettings) { super(parent, SWT.NONE); setLayout(new FillLayout()); this.aiService = aiService; ratingProviderIds = aiService.getRatingProviderIds(); String[] ratingProviderNames = aiService.getRatingProviderNames(); this.dialogSettings = dialogSettings; CGroup group = new CGroup(this, SWT.NONE); group.setText(Messages.AutoRatingGroup_auto_rating); group.setLayout(new GridLayout(3, false)); enableButton = WidgetFactory.createCheckButton(group, Messages.AutoRatingGroup_enable, new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1)); enableButton.addListener(new Listener() { @Override/*from w ww . j av a 2 s. c o m*/ public void handleEvent(Event event) { updateControls(); fireEvent(event); } }); Label label = new Label(group, SWT.NONE); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label.setText(Messages.AutoRatingGroup_provider); if (ratingProviderIds.length > 1) { providerViewer = new ComboViewer(group, SWT.NONE); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false); layoutData.widthHint = 100; providerViewer.getControl().setLayoutData(layoutData); providerViewer.setContentProvider(ArrayContentProvider.getInstance()); providerViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { for (int i = 0; i < ratingProviderIds.length; i++) if (ratingProviderIds[i].equals(element)) return ratingProviderNames[i]; return super.getText(element); } }); providerViewer.getCombo().addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { selectedProvider = (String) providerViewer.getStructuredSelection().getFirstElement(); updateModelViewer(); fireEvent(event); } }); } else { label = new Label(group, SWT.NONE); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label.setText(ratingProviderNames[0]); selectedProvider = ratingProviderIds[0]; } Composite modelcomp = new Composite(group, SWT.NONE); modelcomp.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); GridLayout layout = new GridLayout(2, false); layout.marginHeight = layout.marginWidth = 0; modelcomp.setLayout(layout); label = new Label(modelcomp, SWT.NONE); label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); label.setText(Messages.AutoRatingGroup_theme); modelViewer = new ComboViewer(modelcomp, SWT.NONE); GridData layoutData = new GridData(SWT.BEGINNING, SWT.CENTER, true, false); layoutData.widthHint = 80; modelViewer.getControl().setLayoutData(layoutData); modelViewer.setContentProvider(ArrayContentProvider.getInstance()); modelViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { for (int i = 0; i < modelIds.length; i++) if (modelIds[i].equals(element)) return modelLabels[i]; return super.getText(element); } }); modelViewer.getCombo().addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { fireEvent(event); } }); Composite maxGroup = new Composite(group, SWT.NONE); maxGroup.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1)); layout = new GridLayout(3, false); layout.marginHeight = layout.marginWidth = 0; maxGroup.setLayout(layout); new Label(maxGroup, SWT.NONE).setText(Messages.AutoRatingGroup_rating); maxField = new NumericControl(maxGroup, SWT.NONE); maxField.setMinimum(1); maxField.setMaximum(5); maxField.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); overwriteButton = WidgetFactory.createCheckButton(maxGroup, Messages.AutoRatingGroup_overwrite, new GridData(SWT.END, SWT.CENTER, true, false)); }
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 www . j a v a 2s . c o 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 w w.j a v a 2s .co m 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);//w w w . j ava 2 s . c o m 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.byterefinery.rmbench.dialogs.PrinterSetupDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { Composite mainComposite = (Composite) super.createDialogArea(parent); // main group final Group printersGroup = new Group(mainComposite, SWT.NONE); printersGroup.setLayout(new GridLayout(3, false)); printersGroup.setText(Messages.PrinterSetupDialog_OutlineGroup); // Label "Name:" final Label nameLabel = new Label(printersGroup, SWT.NONE); nameLabel.setText(Messages.PrintDialog_Name); // PrinterCombo printerCombo = new ComboViewer(printersGroup, SWT.DROP_DOWN | SWT.READ_ONLY); printerCombo.getControl().setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, true, false, 2, 1)); printerCombo.setContentProvider(new ArrayContentProvider()); printerCombo.setLabelProvider(new LabelProvider() { public String getText(Object element) { PrinterData printerData = (PrinterData) element; return printerData.name; }// w ww.j a v a 2 s.c o m }); initializePrinterData(); printerCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); selectedPrinter = (PrinterData) selection.getFirstElement(); updateOKButton(); } }); // Label "margin" final Label marginLabel = new Label(printersGroup, SWT.NONE); marginLabel.setText(Messages.PrintDialog_Margin); // Text "margin" marginText = new Text(printersGroup, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData(); gd.widthHint = convertWidthInCharsToPixels(5); marginText.setLayoutData(gd); marginText.setTextLimit(5); marginText.setText(new Double(margin).toString()); marginText.setToolTipText(Messages.PrintDialog_marginTextTT); marginText.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent e) { e.doit = Character.isISOControl(e.character) || Character.isDigit(e.character) || (e.character == '.'); } }); marginText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (marginText.getText().length() > 0) { try { margin = new Double(marginText.getText()).doubleValue(); } catch (NumberFormatException nfe) { margin = 0; } } else margin = 0; } }); // Label "margin unit" final Label marginUnit = new Label(printersGroup, SWT.NONE); marginUnit.setText(Messages.PrintDialog_MarginUnit); return mainComposite; }
From source file:com.byterefinery.rmbench.views.table.GeneralTab.java
License:Open Source License
public void createControl(Composite parent, IActionBars actionBars) { parent.setLayout(new FillLayout()); toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createScrolledForm(parent); Composite body = form.getBody(); GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, true); body.setLayoutData(gridData);/*from www . j ava2 s . co m*/ body.setLayout(new GridLayout(2, false)); toolkit.createLabel(body, RMBenchMessages.NameTab_FName); nameText = toolkit.createText(body, null, SWT.SINGLE | SWT.BORDER); nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); nameText.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { tableNameOperation = new TableNameOperation(table); } public void focusLost(FocusEvent e) { } }); nameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (!blockLocalEvents) { tableNameOperation.setNewName(nameText.getText()); tableNameOperation.execute(GeneralTab.this); } } }); toolkit.createLabel(body, RMBenchMessages.NameTab_FSchema); schemaCombo = new ComboViewer(body, SWT.DROP_DOWN | SWT.READ_ONLY); schemaCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); schemaCombo.setLabelProvider(new SchemaLabelProvider()); schemaCombo.setContentProvider(new SchemaContentProvider()); gridData = new GridData(); gridData.minimumWidth = DisplayUtils.computeWidth(schemaCombo.getControl(), 30); gridData.widthHint = gridData.minimumWidth; schemaCombo.getControl().setLayoutData(gridData); schemaCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (table != null && !blockLocalEvents) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); TableSchemaOperation op = new TableSchemaOperation(table); op.execute(GeneralTab.this, (Schema) selection.getFirstElement()); } } }); toolkit.createLabel(body, RMBenchMessages.NameTab_FComment); commentText = toolkit.createText(body, null, SWT.SINGLE | SWT.BORDER); gridData = new GridData(GridData.FILL_HORIZONTAL); commentText.setLayoutData(gridData); commentText.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { tableCommentOperation = new TableCommentOperation(table); } public void focusLost(FocusEvent e) { } }); commentText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (!blockLocalEvents) { tableCommentOperation.setNewComment(commentText.getText()); tableCommentOperation.execute(GeneralTab.this); } } }); toolkit.createLabel(body, RMBenchMessages.NameTab_FDescription); descriptionText = toolkit.createText(body, null, SWT.MULTI | SWT.BORDER | SWT.WRAP); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); gridData.minimumHeight = descriptionText.getLineHeight(); gridData.minimumWidth = DisplayUtils.computeWidth(descriptionText, 40); descriptionText.setLayoutData(gridData); descriptionText.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { tableDescriptionOperation = new TableDescriptionOperation(table); } public void focusLost(FocusEvent e) { } }); descriptionText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { // blockLocalEvents=true; if (!blockLocalEvents) { tableDescriptionOperation.setNewDescription(descriptionText.getText()); tableDescriptionOperation.execute(GeneralTab.this); } } }); eventListener.register(); }
From source file:com.cblformatter.views.SettingsView.java
License:Open Source License
private void createGruppoOpzioni(Composite top) { Group opzioni = new Group(top, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2;/*w w w. j a va 2 s .c o m*/ opzioni.setText("Opzioni"); opzioni.setLayout(gridLayout); Label codificaLabel = new Label(opzioni, SWT.NONE); codificaLabel.setText("Codifica"); comboCodifica = new Combo(opzioni, SWT.READ_ONLY); comboCodifica.setItems(new String[] { "ISO-8859-1", "UTF-8" }); comboCodifica.setText("ISO-8859-1"); ComboViewer comboViewer2 = new ComboViewer(comboCodifica, SWT.NULL); Label lineaCapo = new Label(opzioni, SWT.NONE); lineaCapo.setText("Linea a Capo"); comboEOL = new Combo(opzioni, SWT.READ_ONLY); comboEOL.setItems(new String[] { "DOS", "UNIX" }); comboEOL.setText("DOS"); ComboViewer comboViewer1 = new ComboViewer(comboEOL, SWT.NULL); Label stampaErrLabel = new Label(opzioni, SWT.NONE); stampaErrLabel.setText("Stampa Errori"); handleErrors = new Button(opzioni, SWT.CHECK); handleErrors.setSelection(true); Label label3 = new Label(opzioni, SWT.NONE); label3.setText("Gestisci Redefines"); handleRedefines = new Button(opzioni, SWT.CHECK); }
From source file:com.codenvy.eclipse.ui.wizard.importer.pages.ProjectWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { final Composite wizardContainer = new Composite(parent, SWT.NONE); wizardContainer.setLayout(new GridLayout(2, false)); wizardContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final Composite workspaceSelectionContainer = new Composite(wizardContainer, SWT.NONE); workspaceSelectionContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); workspaceSelectionContainer.setLayout(new GridLayout(2, false)); final Label workspaceLabel = new Label(workspaceSelectionContainer, SWT.NONE); workspaceLabel.setText("Workspace:"); workspaceComboViewer = new ComboViewer(workspaceSelectionContainer, SWT.DROP_DOWN | SWT.READ_ONLY); workspaceComboViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); workspaceComboViewer.setContentProvider(new ArrayContentProvider()); workspaceComboViewer.setLabelProvider(new LabelProvider() { @Override/*w w w .j av a 2 s . c o m*/ public String getText(Object element) { return element instanceof WorkspaceReference ? ((WorkspaceReference) element).name() : super.getText(element); } }); workspaceComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { final IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (!selection.isEmpty()) { loadWorkspaceProjects((WorkspaceReference) selection.getFirstElement()); } } }); final Label projectTableLabel = new Label(wizardContainer, SWT.NONE); projectTableLabel.setText("Projects:"); projectTableLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); projectTableViewer = newCheckList(wizardContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); final TableViewerColumn projectNameColumn = new TableViewerColumn(projectTableViewer, SWT.NONE); projectNameColumn.getColumn().setWidth(150); projectNameColumn.getColumn().setText("Name"); projectNameColumn.setLabelProvider(new ColumnLabelProviderWithGreyElement() { @Override public String getText(Object element) { return element instanceof ProjectReference ? ((ProjectReference) element).name() : super.getText(element); } }); final TableViewerColumn projectTypeNameColumn = new TableViewerColumn(projectTableViewer, SWT.NONE); projectTypeNameColumn.getColumn().setWidth(150); projectTypeNameColumn.getColumn().setText("Type"); projectTypeNameColumn.setLabelProvider(new ColumnLabelProviderWithGreyElement() { @Override public String getText(Object element) { return element instanceof ProjectReference ? ((ProjectReference) element).typeName() : super.getText(element); } }); final TableViewerColumn projectDescriptionColumn = new TableViewerColumn(projectTableViewer, SWT.NONE); projectDescriptionColumn.getColumn().setWidth(150); projectDescriptionColumn.getColumn().setText("Description"); projectDescriptionColumn.setLabelProvider(new ColumnLabelProviderWithGreyElement() { @Override public String getText(Object element) { return element instanceof ProjectReference ? ((ProjectReference) element).description() : super.getText(element); } }); projectTableViewer.setContentProvider(ArrayContentProvider.getInstance()); projectTableViewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { setCheckedProjects(); validatePage(); } }); final Table projectTable = projectTableViewer.getTable(); projectTable.getHorizontalBar().setEnabled(true); projectTable.setHeaderVisible(true); projectTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final Composite projectTableButtonsContainer = new Composite(wizardContainer, SWT.NONE); projectTableButtonsContainer.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true)); projectTableButtonsContainer.setLayout(new GridLayout()); final Button selectAll = new Button(projectTableButtonsContainer, SWT.NONE); selectAll.setText("Select All"); selectAll.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); selectAll.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { projectTableViewer.setAllChecked(true); setCheckedProjects(); validatePage(); } }); final Button deselectAll = new Button(projectTableButtonsContainer, SWT.NONE); deselectAll.setText("Deselect All"); deselectAll.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); deselectAll.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { projectTableViewer.setAllChecked(false); setCheckedProjects(); validatePage(); } }); // TODO remove when https://bugs.eclipse.org/bugs/show_bug.cgi?id=245106 is fixed final WorkingSetDescriptor[] descriptors = WorkbenchPlugin.getDefault().getWorkingSetRegistry() .getWorkingSetDescriptors(); final List<String> workingSetTypes = FluentIterable.from(Arrays.asList(descriptors)) .transform(new Function<WorkingSetDescriptor, String>() { @Override public String apply(WorkingSetDescriptor descriptor) { return descriptor.getId(); } }).toList(); workingSetGroup = new WorkingSetGroup(wizardContainer, null, workingSetTypes.toArray(new String[workingSetTypes.size()])); setControl(wizardContainer); }
From source file:com.contrastsecurity.ide.eclipse.ui.internal.model.VulnerabilityPage.java
License:Open Source License
private ComboViewer createApplicationCombo(Composite composite, String orgUuid) { ComboViewer combo = new ComboViewer(composite, SWT.READ_ONLY); combo.getControl().setFont(composite.getFont()); combo.setLabelProvider(new ContrastLabelProvider()); combo.setContentProvider(new ArrayContentProvider()); Set<ApplicationUIAdapter> contrastApplications = new LinkedHashSet<>(); int count = 0; if (orgUuid != null) { Applications applications = null; try {/* www . j a va2 s . c o m*/ applications = getSdk().getApplications(orgUuid); } catch (Exception e) { ContrastUIActivator.log(e); } if (applications != null && applications.getApplications() != null && applications.getApplications().size() > 0) { for (Application application : applications.getApplications()) { ApplicationUIAdapter app = new ApplicationUIAdapter(application, application.getName()); contrastApplications.add(app); count++; } } } ApplicationUIAdapter allApplications = new ApplicationUIAdapter(null, "All Applications(" + count + ")"); contrastApplications.add(allApplications); combo.setInput(contrastApplications); IEclipsePreferences prefs = ContrastCoreActivator.getPreferences(); String appId = prefs.get(Constants.APPLICATION_ID, Constants.ALL_APPLICATIONS); ApplicationUIAdapter selected = allApplications; for (ApplicationUIAdapter adapter : contrastApplications) { if (appId.equals(adapter.getId())) { selected = adapter; break; } } combo.setInput(contrastApplications); combo.setSelection(new StructuredSelection(selected)); return combo; }
From source file:com.contrastsecurity.ide.eclipse.ui.internal.model.VulnerabilityPage.java
License:Open Source License
private ComboViewer createServerCombo(Composite composite, String orgUuid) { ComboViewer combo = new ComboViewer(composite, SWT.READ_ONLY); combo.getControl().setFont(composite.getFont()); combo.setLabelProvider(new ContrastLabelProvider()); combo.setContentProvider(new ArrayContentProvider()); Set<ServerUIAdapter> contrastServers = new LinkedHashSet<>(); int count = 0; if (orgUuid != null) { Servers servers = null;// w w w. ja v a2s .c o m try { servers = getSdk().getServers(orgUuid, null); } catch (Exception e) { ContrastUIActivator.log(e); } if (servers != null && servers.getServers() != null) { for (Server server : servers.getServers()) { ServerUIAdapter contrastServer = new ServerUIAdapter(server, server.getName()); contrastServers.add(contrastServer); count++; } } } ServerUIAdapter allServers = new ServerUIAdapter(null, "All Servers(" + count + ")"); contrastServers.add(allServers); IEclipsePreferences prefs = ContrastCoreActivator.getPreferences(); long serverId = prefs.getLong(Constants.SERVER_ID, Constants.ALL_SERVERS); ServerUIAdapter selected = allServers; for (ServerUIAdapter adapter : contrastServers) { if (serverId == adapter.getId()) { selected = adapter; break; } } combo.setInput(contrastServers); combo.setSelection(new StructuredSelection(selected)); return combo; }