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.rawpixil.eclipse.launchpad.internal.ui.component.dialog.AbstractCheckboxSelectionDialog.java
License:Open Source License
@Override protected void initializeControls() { List<?> selectedElements = getInitialElementSelections(); if (selectedElements != null && !selectedElements.isEmpty()) { getCheckBoxTableViewer().setCheckedElements(selectedElements.toArray()); getCheckBoxTableViewer().setSelection(StructuredSelection.EMPTY); }/*w w w. ja v a 2 s . c o m*/ super.initializeControls(); }
From source file:com.rcpcompany.uibindings.internal.observables.properties.MySelectionProviderSingleSelectionProperty.java
License:Open Source License
@Override protected void doSetValue(Object source, Object value) { final IStructuredSelection selection = value == null ? StructuredSelection.EMPTY : new StructuredSelection(value); if (source instanceof Viewer) { ((Viewer) source).setSelection(selection, true); } else {/*from w w w . j a va 2 s .c om*/ ((ISelectionProvider) source).setSelection(selection); } }
From source file:com.rcpcompany.uibindings.navigator.internal.views.BaseEditorView.java
License:Open Source License
@Override public ISelection getCurrentSelection() { if (myCurrentValue == null) return StructuredSelection.EMPTY; return new StructuredSelection(myCurrentValue.getValue()); }
From source file:com.rcpcompany.utils.selection.ControlSelectionProvider.java
License:Open Source License
@Override public ISelection getSelection() { final ISelectionProvider provider = getCurrentSelectionProvider(); if (provider == null) return StructuredSelection.EMPTY; final ISelection selection = provider.getSelection(); debug("getSelection()=" + selection); //$NON-NLS-1$ return selection; }
From source file:com.redhat.ceylon.eclipse.code.open.FilteredItemsSelectionDialog.java
License:Open Source License
/** * Refreshes the dialog - has to be called in UI thread. */// ww w. j ava2 s. c o m public void refresh() { if (list != null) { Table table = list.getTable(); if (!table.isDisposed()) { List lastRefreshSelection = ((StructuredSelection) list.getSelection()).toList(); table.deselectAll(); list.setItemCount(contentProvider.getNumberOfElements()); list.refresh(); if (table.getItemCount() > 0) { // preserve previous selection if (refreshWithLastSelection && lastRefreshSelection != null && lastRefreshSelection.size() > 0) { list.setSelection(new StructuredSelection(lastRefreshSelection)); } else { refreshWithLastSelection = true; table.setSelection(0); table.notifyListeners(SWT.Selection, new Event()); } } else { list.setSelection(StructuredSelection.EMPTY); } } } scheduleProgressMessageRefresh(); }
From source file:com.redhat.ceylon.eclipse.code.outline.TreeViewPopup.java
License:Open Source License
/** * Selects the first element in the tree which * matches the current filter pattern.//ww w .jav a2s . c o m */ protected void selectFirstMatch() { //Object selectedElement= fTreeViewer.testFindItem(fInitiallySelectedType); TreeItem element; final Tree tree = fTreeViewer.getTree(); /*if (selectedElement instanceof TreeItem) element= findElement(new TreeItem[] { (TreeItem)selectedElement }); else*/ element = findElement(tree.getItems()); if (element != null) { tree.setSelection(element); tree.showItem(element); } else fTreeViewer.setSelection(StructuredSelection.EMPTY); }
From source file:com.reprezen.swagedit.core.editor.outline.QuickOutline.java
License:Open Source License
@Override protected Control createTitleControl(Composite parent) { filterText = new Text(parent, SWT.NONE); Dialog.applyDialogFont(filterText); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.CENTER; filterText.setLayoutData(data);/*from www .j a va 2 s .c o m*/ filterText.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (isInvocationEvent(e)) { e.doit = false; handleMultiView(); } else if (e.keyCode == SWT.CR) { handleSelection(); QuickOutline.this.close(); } else if (e.keyCode == SWT.ARROW_DOWN) { treeViewer.getTree().setFocus(); } else if (e.keyCode == SWT.ARROW_UP) { treeViewer.getTree().setFocus(); } else if (e.character == SWT.ESC) { QuickOutline.this.close(); } } public void keyReleased(KeyEvent e) { // do nothing } }); filterText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { // refresh tree to apply filter if (filterTimer != null) { filterTimer.cancel(); } // reset the timer each time there is a // text modification, so that only the last // one will be executed. filterTimer = new Timer(); filterTimer.schedule(new TimerTask() { @Override public void run() { if (filterText.isDisposed()) { return; } // Make sure we access the text in the correct thread. filterText.getDisplay().asyncExec(new Runnable() { @Override public void run() { // refreshing the tree will execute the filter. if (StringUtils.emptyToNull(filterText.getText()) == null) { treeViewer.refresh(); treeViewer.collapseAll(); } else { treeViewer.refresh(); TreeItem[] items = treeViewer.getTree().getItems(); if (items != null && items.length > 0) { treeViewer.getTree().setSelection(items[0]); treeViewer.getTree().showItem(items[0]); } else { treeViewer.setSelection(StructuredSelection.EMPTY); } treeViewer.expandAll(); } } }); } }, 500); } }); return filterText; }
From source file:com.reprezen.swagedit.editor.outline.QuickOutline.java
License:Open Source License
@Override protected Control createTitleControl(Composite parent) { filterText = new Text(parent, SWT.NONE); Dialog.applyDialogFont(filterText); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.CENTER; filterText.setLayoutData(data);/*w w w . ja v a 2 s .c o m*/ filterText.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (isInvocationEvent(e)) { e.doit = false; handleMultiView(); } else if (e.keyCode == SWT.CR) { handleSelection(); QuickOutline.this.close(); } else if (e.keyCode == SWT.ARROW_DOWN) { treeViewer.getTree().setFocus(); } else if (e.keyCode == SWT.ARROW_UP) { treeViewer.getTree().setFocus(); } else if (e.character == SWT.ESC) { QuickOutline.this.close(); } } public void keyReleased(KeyEvent e) { // do nothing } }); filterText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { // refresh tree to apply filter if (filterTimer != null) { filterTimer.cancel(); } // reset the timer each time there is a // text modification, so that only the last // one will be executed. filterTimer = new Timer(); filterTimer.schedule(new TimerTask() { @Override public void run() { if (filterText.isDisposed()) { return; } // Make sure we access the text in the correct thread. filterText.getDisplay().asyncExec(new Runnable() { @Override public void run() { // refreshing the tree will execute the filter. if (Strings.emptyToNull(filterText.getText()) == null) { treeViewer.refresh(); treeViewer.collapseAll(); } else { treeViewer.refresh(); TreeItem[] items = treeViewer.getTree().getItems(); if (items != null && items.length > 0) { treeViewer.getTree().setSelection(items[0]); treeViewer.getTree().showItem(items[0]); } else { treeViewer.setSelection(StructuredSelection.EMPTY); } treeViewer.expandAll(); } } }); } }, 500); } }); return filterText; }
From source file:com.rinke.solutions.pinball.PinDmdEditor.java
void keyFrameChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.size() > 0) { if (((PalMapping) selection.getFirstElement()).equals(selectedPalMapping)) { keyframeTableViewer.setSelection(StructuredSelection.EMPTY); selectedPalMapping = null;// www . ja v a 2 s .com return; } // set new mapping selectedPalMapping = (PalMapping) selection.getFirstElement(); log.debug("selected new palMapping {}", selectedPalMapping); selectedHashIndex = selectedPalMapping.hashIndex; // current firmware always checks with and w/o mask // btnMask.setSelection(selectedPalMapping.withMask); // btnMask.notifyListeners(SWT.Selection, new Event()); txtDuration.setText(selectedPalMapping.durationInMillis + ""); paletteComboViewer .setSelection(new StructuredSelection(project.palettes.get(selectedPalMapping.palIndex))); for (int j = 0; j < numberOfHashes; j++) { btnHash[j].setSelection(j == selectedHashIndex); } selectedAnimation = Optional.of(animations.get(selectedPalMapping.animationName)); aniListViewer.setSelection(new StructuredSelection(selectedAnimation.get())); if (selectedPalMapping.frameSeqName != null) frameSeqViewer .setSelection(new StructuredSelection(animations.get(selectedPalMapping.frameSeqName))); animationHandler.setPos(selectedPalMapping.frameIndex); if (selectedPalMapping.withMask) { String txt = btnHash[selectedHashIndex].getText(); btnHash[selectedHashIndex].setText("M" + selectedPalMapping.maskNumber + " " + txt); } saveTimeCode = (int) selectedAnimation.get().getTimeCode(selectedPalMapping.frameIndex); } else { selectedPalMapping = null; } btnDeleteKeyframe.setEnabled(selection.size() > 0); btnFetchDuration.setEnabled(selection.size() > 0); }
From source file:com.safi.workshop.NewSafiProjectAction.java
License:Open Source License
@Override public void run() { // Create wizard selection wizard. IWorkbench workbench = PlatformUI.getWorkbench(); ISelection selection = window.getSelectionService().getSelection(); IStructuredSelection selectionToPass = StructuredSelection.EMPTY; if (selection instanceof IStructuredSelection) { selectionToPass = (IStructuredSelection) selection; }/*from ww w . j ava2 s. c o m*/ SafiBasicNewProjectResourceWizard wizard = new SafiBasicNewProjectResourceWizard(); wizard.init(workbench, selectionToPass); WizardDialog dialog = new WizardDialog(null, wizard); dialog.setTitle("New Safi Project Wizard"); dialog.setTitleImage(AsteriskDiagramEditorPlugin.getInstance() .getBundledImage("icons/server/resource/ServerResources.gif")); dialog.open(); /* * SafiNewWizard wizard = new SafiNewWizard(); wizard.setProjectsOnly(true); * ISelection selection = window.getSelectionService().getSelection(); * IStructuredSelection selectionToPass = StructuredSelection.EMPTY; if (selection * instanceof IStructuredSelection) { selectionToPass = (IStructuredSelection) * selection; } wizard.init(workbench, selectionToPass); IDialogSettings * workbenchSettings = IDEWorkbenchPlugin.getDefault() .getDialogSettings(); * IDialogSettings wizardSettings = workbenchSettings * .getSection("NewWizardAction");//$NON-NLS-1$ if (wizardSettings == null) { * wizardSettings = workbenchSettings.addNewSection("NewWizardAction");//$NON-NLS-1$ } * wizard.setDialogSettings(wizardSettings); * 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); * PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), * IIDEHelpContextIds.NEW_PROJECT_WIZARD); * * // Open wizard. dialog.open(); */ }