List of usage examples for org.eclipse.jface.viewers StructuredSelection EMPTY
StructuredSelection EMPTY
To view the source code for org.eclipse.jface.viewers StructuredSelection EMPTY.
Click Source Link
From source file:com.symbian.smt.gui.smtwidgets.AdvancedOptionsWidget.java
License:Open Source License
/** * Creates an AdvancedOptionsWidget composite object * /*from w w w .ja va2s . c om*/ * @return void */ public AdvancedOptionsWidget(final Composite parent, int style) { super(parent, style); this.setLayout(new FillLayout()); // The Composite that contains all widgets final Composite gridLayoutComposite = new Composite(this, SWT.NONE); final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; gridLayoutComposite.setLayout(gridLayout); final Label label = new Label(gridLayoutComposite, SWT.NONE); GridData gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1); label.setText("Additional Command-Line Parameters"); label.setLayoutData(gd); // The List that contains all assigned command line options final List list = new List(gridLayoutComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd.widthHint = 200; list.setLayoutData(gd); viewer = new ListViewer(list); viewer.setContentProvider(new AdvancedOptionsContentProvider()); viewer.setLabelProvider(new AdvancedOptionsLabelProvider()); // The Composite that contains all buttons in a vertical stack final Composite buttonsComposite = new Composite(gridLayoutComposite, SWT.NONE); final RowLayout rowLayout = new RowLayout(SWT.VERTICAL); rowLayout.spacing = 5; rowLayout.wrap = false; rowLayout.fill = true; buttonsComposite.setLayout(rowLayout); gd = new GridData(SWT.RIGHT, SWT.BEGINNING, false, true, 1, 1); buttonsComposite.setLayoutData(gd); // The "Add" button final Button addOptionButton = new Button(buttonsComposite, SWT.NONE); RowData rd = new RowData(); rd.width = 75; addOptionButton.setLayoutData(rd); // The action that backs the "Add" button final AddOptionAction addOptionAction = new AddOptionAction(addOptionButton); // When button is pressed, listener invokes the action's run() method, // then refresh // the List of assigned options and set the selection appropriately addOptionButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { addOptionAction.run(); StructuredSelection oldSel = (StructuredSelection) viewer.getSelection(); viewer.refresh(); String newOption = addOptionAction.getNewOption(); StructuredSelection newSel = (newOption == null) ? oldSel : new StructuredSelection(newOption); viewer.setSelection(newSel); } }); // The "Edit" button final Button editOptionButton = new Button(buttonsComposite, SWT.NONE); rd = new RowData(); rd.width = 75; editOptionButton.setLayoutData(rd); // The action that backs the "Edit" button final EditOptionAction editOptionAction = new EditOptionAction(editOptionButton); // When button is pressed, listener invokes the action's run() method, // then refresh // the List of assigned options and set the selection appropriately editOptionButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { editOptionAction.run(); StructuredSelection oldSel = (StructuredSelection) viewer.getSelection(); viewer.refresh(); viewer.setSelection(oldSel); } }); // The "Remove" button final Button removeOptionButton = new Button(buttonsComposite, SWT.NONE); rd = new RowData(); rd.width = 75; removeOptionButton.setLayoutData(rd); // The action that backs the "Remove" button final RemoveOptionAction removeOptionAction = new RemoveOptionAction(removeOptionButton); // When button is pressed, listener invokes the action's run() method, // then refreshes the List of assigned options and set the selection // appropriately removeOptionButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeOptionAction.run(); viewer.refresh(); // If the viewer has at least one element, we set the current // selection to that element. Object firstElement = viewer.getElementAt(0); StructuredSelection ssel = (firstElement == null) ? new StructuredSelection(StructuredSelection.EMPTY) : new StructuredSelection(firstElement); viewer.setSelection(ssel); } }); // The "Move Up" button final Button moveOptionUpButton = new Button(buttonsComposite, SWT.NONE); rd = new RowData(); rd.width = 75; moveOptionUpButton.setLayoutData(rd); // The action that backs the "Move Up" button final MoveOptionUpAction moveOptionUpAction = new MoveOptionUpAction(moveOptionUpButton); // When button is pressed, listener invokes the action's run() method, // then refreshes the List of assigned options and set the selection // appropriately moveOptionUpButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { moveOptionUpAction.run(); viewer.refresh(); StructuredSelection newSel = new StructuredSelection(moveOptionUpAction.getMovedOption()); viewer.setSelection(newSel); } }); // The "Move Down" button final Button moveOptionDownButton = new Button(buttonsComposite, SWT.NONE); rd = new RowData(); rd.width = 75; moveOptionDownButton.setLayoutData(rd); // The action that backs the "Move Down" button final MoveOptionDownAction moveOptionDownAction = new MoveOptionDownAction(moveOptionDownButton); // When button is pressed, listener invokes the action's run() method, // then refreshes the List of assigned options and set the selection // appropriately moveOptionDownButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { moveOptionDownAction.run(); viewer.refresh(); StructuredSelection newSel = new StructuredSelection(moveOptionDownAction.getMovedOption()); viewer.setSelection(newSel); } }); }
From source file:com.symbian.smt.gui.smtwidgets.resources.ResourcesWidget.java
License:Open Source License
private void addRemoveResourceButton(Composite parent) { // The "Remove" button final Button removeResourceFileButton = new Button(parent, SWT.NONE); RowData rd = new RowData(); rd.width = 75;/* w w w . j av a 2s.co m*/ removeResourceFileButton.setLayoutData(rd); // The action that backs the "Remove" button final RemoveResourceFileAction removeResourceFileAction = new RemoveResourceFileAction( removeResourceFileButton, resourceFilesViewer, resourceFilesMap, resourceTypesViewer); // When button is pressed, listener invokes the action's run() method, // then refreshes the List of assigned options and set the selection // appropriately removeResourceFileButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeResourceFileAction.run(); resourceFilesViewer.refresh(); Object firstElement = resourceFilesViewer.getElementAt(0); StructuredSelection ssel = (firstElement == null) ? new StructuredSelection(StructuredSelection.EMPTY) : new StructuredSelection(firstElement); resourceFilesViewer.setSelection(ssel); } }); }
From source file:com.symbian.smt.gui.wizard.NewSMTProjectWizardTest.java
License:Open Source License
/** * @throws java.lang.Exception/*from ww w.jav a 2s. c om*/ */ protected final void setUp() throws Exception { // Initialise the default values SmmPreferencesInitializer initialiser = new SmmPreferencesInitializer(); initialiser.initializeDefaultPreferences(); smgFolder = initialiser.getSmgFolder(); wizard = new NewSMTProjectWizard(); selection = new StructuredSelection(StructuredSelection.EMPTY); workbench = PlatformUI.getWorkbench(); shell = workbench.getActiveWorkbenchWindow().getShell(); wizard.init(workbench, selection); WizardDialog dialog = new WizardDialog(shell, wizard); dialog.setBlockOnOpen(false); dialog.open(); NewProjectCreationPageCaseInsensitive page = (NewProjectCreationPageCaseInsensitive) wizard .getPage("page1"); Composite c = (Composite) page.getControl(); wizardProjectTextField = findText(c); if (wizardProjectTextField == null) { throw new Exception("Could not find project name Text field"); } wizardProjectTextField.setText("testproject"); }
From source file:com.synflow.ngDesign.ui.internal.navigator.actions.NewSynflowProjectAction.java
License:Open Source License
public void run() { // Create wizard selection wizard. IWorkbench workbench = PlatformUI.getWorkbench(); NewProjectWizard wizard = new NewProjectWizard(); ISelection selection = window.getSelectionService().getSelection(); IStructuredSelection selectionToPass = StructuredSelection.EMPTY; if (selection instanceof IStructuredSelection) { selectionToPass = (IStructuredSelection) selection; }/* w w w. j a va 2 s.c o m*/ wizard.init(workbench, selectionToPass); wizard.setForcePreviousAndNextButtons(true); // Create wizard dialog. WizardDialog dialog = new WizardDialog(null, wizard); dialog.create(); dialog.getShell().setSize(Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), SIZING_WIZARD_HEIGHT); // Open wizard. dialog.open(); }
From source file:com.technophobia.substeps.junit.ui.component.SelectionProviderMediator.java
License:Open Source License
@Override public ISelection getSelection() { if (viewerInFocus != null) { return viewerInFocus.getSelection(); }//ww w . j a va 2 s .c om return StructuredSelection.EMPTY; }
From source file:com.toubassi.jface.Explorer.java
License:Open Source License
/** * Gets the selection from the last view that the user interacted * with that had a selection (either table or tree). * @return/*from ww w . j a v a 2 s .co m*/ */ public StructuredSelection getSelection() { StructuredSelection selection = StructuredSelection.EMPTY; if (lastSelectedViewer == tableViewer) { selection = getTableSelection(); if (selection.isEmpty()) { selection = getTreeSelection(); } } else { selection = getTreeSelection(); if (selection.isEmpty()) { selection = getTableSelection(); } } return selection; }
From source file:com.vectrace.MercurialEclipse.history.MercurialHistoryPage.java
License:Open Source License
void clearSelection() { viewer.setSelection(StructuredSelection.EMPTY); }
From source file:com.vectrace.MercurialEclipse.views.PatchQueueView.java
License:Open Source License
public void populateTable() { Job job = new SafeUiJob(Messages.getString("PatchQueueView.jobName.populateTable")) { //$NON-NLS-1$ @Override//from w w w.j av a 2 s . c o m protected IStatus runSafe(IProgressMonitor monitor) { IStatus status = Status.OK_STATUS; if (hgRoot != null && !table.isDisposed()) { try { List<Patch> patches = HgQSeriesClient.getPatchesInSeries(hgRoot); // TODO: We have to hide the popup menu if the table is empty or the team // menu will be appended. This is a side effect of the team menu's // locationURI being "popup:org.eclipse.ui.popup.any". If the team menu gets // a proper locationURI, the next line can be deleted. table.setEnabled(!patches.isEmpty()); topmostAppliedPatch = null; for (Patch patch : patches) { if (patch.isApplied()) { topmostAppliedPatch = patch; } } // Reverse so it's in the same order as the sync view patches = new ArrayList<Patch>(patches); Collections.reverse(patches); table.setItems(patches); } catch (HgException e) { if (e.getCause() instanceof InterruptedException) { // ? } else { showWarning(e.getConciseMessage()); MercurialEclipsePlugin.logError(e); status = new Status(IStatus.ERROR, MercurialEclipsePlugin.ID, Messages.getString("PatchQueueView.cannotPopulatePatchViewTable"), e); //$NON-NLS-1$ } } finally { updateEnablement(StructuredSelection.EMPTY); } } return status; } }; job.setUser(false); job.setSystem(true); job.schedule(); }
From source file:com.vmware.vfabric.ide.eclipse.tcserver.internal.ui.ExtendedTcStaticResourcesEditorSection.java
License:Open Source License
private void updateEnablement() { boolean agentEnabled = serverWorkingCopy.isAgentRedeployEnabled(); boolean jmxEnabled = serverWorkingCopy.isEnhancedRedeployEnabled(); if (!jmxEnabled) { filenamesTableViewer.setSelection(StructuredSelection.EMPTY); }//from w ww . ja va 2 s . c o m filenameTable.setEnabled(jmxEnabled); addButton.setEnabled(jmxEnabled); agentOptionsText.setEnabled(agentEnabled); enableButton.setEnabled(!agentEnabled); enableAgentButton.setEnabled(!jmxEnabled); updateButtons(); }
From source file:com.vmware.vfabric.ide.eclipse.tcserver.internal.ui.TcStaticResourcesEditorSection.java
License:Open Source License
private void updateEnablement() { boolean enabled = serverWorkingCopy.isEnhancedRedeployEnabled(); if (!enabled) { filenamesTableViewer.setSelection(StructuredSelection.EMPTY); }//from w w w. j ava 2 s .c om filenameTable.setEnabled(enabled); addButton.setEnabled(enabled); updateButtons(); }