List of usage examples for org.eclipse.jface.viewers ISelection ISelection
ISelection
From source file:at.rc.tacos.client.ui.custom.DatePickerPanel.java
License:Open Source License
public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.ESC) { SelectionChangedEvent changeEvent = new SelectionChangedEvent(this, new ISelection() { public boolean isEmpty() { return true; }// ww w. jav a 2s . c o m }); notifyListeners(changeEvent); } }
From source file:com.onpositive.richtexteditor.dialogs.FontConfigurationDialog.java
License:Open Source License
/** (non-Javadoc) * @see org.eclipse.jface.window.Window#open() *//*from ww w . j a va 2 s. co m*/ public int open() { selectionChanged(new SelectionChangedEvent(viewer, new ISelection() { public boolean isEmpty() { return true; } })); return super.open(); }
From source file:com.siteview.mde.internal.ui.editor.EmptyOutlinePage.java
License:Open Source License
public ISelection getSelection() { return new ISelection() { public boolean isEmpty() { return true; }//from www . j ava 2s . c o m }; }
From source file:de.innot.avreclipse.ui.editors.AbstractActionPart.java
License:Open Source License
/** * Notify other Part of the ManagedForm that the values in the source <code>ByteValues</code> * has changed.//from ww w . ja v a 2 s .co m * <p> * The other parts must implement the <code>IPartSelectionListener</code> interface to receive * the notification. The <code>ISelection</code> required by the ManagedForm is not used and * is just an empty implementation. * </p> */ protected void notifyForm() { getManagedForm().fireSelectionChanged(this, new ISelection() { public boolean isEmpty() { return false; } }); }
From source file:gov.redhawk.ui.editor.EmptyOutlinePage.java
License:Open Source License
/** * Gets the selection./*from w ww.j a v a 2s . c o m*/ * * @return the selection */ @Override public ISelection getSelection() { return new ISelection() { @Override public boolean isEmpty() { return true; } }; }
From source file:org.eclipse.compare.codereview.compareEditor.RefacContentMergeViewer.java
License:Open Source License
/** * The <code>ContentMergeViewer</code> implementation of this * <code>Viewer</code> method returns the empty selection. Subclasses may override. * @return empty selection./*from w ww.ja va 2 s. c o m*/ */ public ISelection getSelection() { return new ISelection() { public boolean isEmpty() { return true; } }; }
From source file:org.eclipse.ice.client.widgets.reactoreditor.test.SelectionProviderTester.java
License:Open Source License
/** * Checks the ISelectionProvider implementation in SelectionProvider. */// w ww. j av a 2 s . com @Test public void checkISelectionProvider() { // Create a SelectionProvider to test. SelectionProvider provider = new SelectionProvider(); // Create some listeners. SelectionChangedListener listener1 = new SelectionChangedListener(); SelectionChangedListener listener2 = new SelectionChangedListener(); // The initial selection should be null. assertNull(provider.getSelection()); // Add a listener. provider.addSelectionChangedListener(listener1); // Set a selection. ISelection selection = new StructuredSelection(0); provider.setSelection(selection); // The listener should have been notified. assertTrue(listener1.selectionChanged()); assertFalse(listener2.selectionChanged()); // Check the current selection. assertSame(selection, provider.getSelection()); // Try it again with a new selection. selection = new StructuredSelection(2); provider.setSelection(selection); // The listener should have been notified. assertTrue(listener1.selectionChanged()); assertFalse(listener2.selectionChanged()); // Check the current selection. assertSame(selection, provider.getSelection()); // Now add a second listener. provider.addSelectionChangedListener(listener2); // Set a selection. selection = new ISelection() { @Override public boolean isEmpty() { return false; } }; provider.setSelection(selection); // Both listeners should have been notified. assertTrue(listener1.selectionChanged()); assertTrue(listener2.selectionChanged()); // Check the current selection. assertSame(selection, provider.getSelection()); // Try setting the same selection. No notification should occur. provider.setSelection(selection); // Neither listeners should have been notified. assertFalse(listener1.selectionChanged()); assertFalse(listener2.selectionChanged()); // Check the current selection. assertSame(selection, provider.getSelection()); // Now remove a listener. provider.removeSelectionChangedListener(listener1); // Set a selection. selection = new ISelection() { @Override public boolean isEmpty() { return false; } }; provider.setSelection(selection); // Only one listener should have been notified. assertFalse(listener1.selectionChanged()); assertTrue(listener2.selectionChanged()); // Check the current selection. assertSame(selection, provider.getSelection()); return; }
From source file:org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.editor.EditorTest.java
License:Open Source License
@Test public void testSelectionChangedTextSelection() { JPADiagramEditor editor = createEditor(null, null); editor.selectionChanged(null, new ISelection() { public boolean isEmpty() { return false; }/*from ww w. j av a 2 s . co m*/ }); }
From source file:org.eclipse.mylyn.commons.workbench.forms.DatePickerPanel.java
License:Open Source License
public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.ESC) { SelectionChangedEvent changeEvent = new SelectionChangedEvent(this, new ISelection() { public boolean isEmpty() { return true; }/*w ww .ja va2s.c o m*/ }); notifyListeners(changeEvent); } }
From source file:org.eclipse.remote.ui.widgets.RemoteResourceBrowserWidget.java
License:Open Source License
public RemoteResourceBrowserWidget(Composite parent, int style, int flags) { super(parent, style); setTitle(Messages.RemoteResourceBrowser_resourceTitle); if (flags != 0) { fOptionFlags = flags;/*from w w w . j a v a 2s . c o m*/ } setType(); GridLayout layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; setLayout(layout); final Composite mainComp = new Composite(this, SWT.NONE); mainComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); mainComp.setLayout(new GridLayout(1, false)); if ((fOptionFlags & SHOW_CONNECTIONS) != 0) { fRemoteConnectionWidget = new RemoteConnectionWidget(mainComp, SWT.NONE, "", //$NON-NLS-1$ (fOptionFlags & SHOW_LOCAL_SELECTION) == 0 ? RemoteConnectionWidget.FLAG_NO_LOCAL_SELECTION : 0); fRemoteConnectionWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); // Must happen before adding selection listener as this will trigger selection event fRemoteConnectionWidget.filterConnections(IRemoteFileService.class); fRemoteConnectionWidget.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { try { connectionSelected(); } catch (CoreException e) { RemoteUIPlugin.log(e.getStatus()); } updateEnablement(); notifySelectionChangedListeners(new SelectionChangedEvent(fTreeViewer, new ISelection() { @Override public boolean isEmpty() { return true; } })); } }); } Composite textComp = new Composite(mainComp, SWT.NONE); layout = new GridLayout(4, false); layout.marginHeight = 0; layout.marginWidth = 0; textComp.setLayout(layout); textComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Label label = new Label(textComp, SWT.NONE); label.setText(fDialogLabel); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); fRemotePathText = new Text(textComp, SWT.BORDER | SWT.SINGLE); fRemotePathText.addTraverseListener(new TraverseListener() { @Override public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_RETURN) { e.doit = false; } } }); fRemotePathText.addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent e) { fRemotePathText.setSelection(fRemotePathText.getText().length()); setRoot(fRemotePathText.getText()); } }); fRemotePathText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { fResource = fRemotePathText.getText().trim(); } }); GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); // gd.minimumWidth = minimumWidth; fRemotePathText.setLayoutData(gd); fUpButton = new Button(textComp, SWT.PUSH | SWT.FLAT); fUpButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); fUpButton.setImage(RemoteUIImages.get(RemoteUIImages.IMG_ELCL_UP_NAV)); fUpButton.setToolTipText(Messages.RemoteResourceBrowser_UpOneLevel); fUpButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!fRootPath.isRoot()) { setRoot(fRootPath.removeLastSegments(1).toString()); } } }); if ((fOptionFlags & SHOW_NEW_FOLDER_BUTTON) != 0) { // new folder: See Bug 396334 fNewFolderButton = new Button(textComp, SWT.PUSH | SWT.FLAT); fNewFolderButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); fNewFolderButton.setImage(RemoteUIImages.get(RemoteUIImages.IMG_ELCL_NEW_FOLDER)); fNewFolderButton.setToolTipText(Messages.RemoteResourceBrowser_NewFolder); fNewFolderButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ISelection selection = fTreeViewer.getSelection(); if (!selection.isEmpty()) { if (selection instanceof TreeSelection) { TreePath[] treePaths = ((TreeSelection) selection).getPaths(); /* * There should only be one path */ if (treePaths.length > 0) { TreePath treePath = treePaths[0]; if (treePath.getLastSegment() instanceof DeferredFileStore) { DeferredFileStore element = ((DeferredFileStore) treePath.getLastSegment()); String path = toPath(element.getFileStore().toURI()); String newPath = createNewFolder(path); if (newPath != null) { fTreeViewer.expandToLevel(element, 1); fTreeViewer.refresh(element); Object[] children = element.getChildren(null); for (Object child : children) { if (child instanceof DeferredFileStore && newPath .equals(((DeferredFileStore) child).getFileStore().getName())) { fTreeViewer.deferSelection(new StructuredSelection(child)); } } } } } } } else { DeferredFileStore root = (DeferredFileStore) fTreeViewer.getInput(); String path = toPath(root.getFileStore().toURI()); String newPath = createNewFolder(path); if (newPath != null) { fTreeViewer.refresh(); fTreeViewer.getTree().setFocus(); Object[] children = root.getChildren(null); for (Object child : children) { if (child instanceof DeferredFileStore && newPath.equals(((DeferredFileStore) child).getFileStore().getName())) { fTreeViewer.deferSelection(new StructuredSelection(child)); } } } } } }); } else { gd = new GridData(SWT.LEFT, SWT.CENTER, false, false); gd.horizontalSpan = 2; fUpButton.setLayoutData(gd); } if ((style & SWT.MULTI) == SWT.MULTI) { fTreeViewer = new RemoteTreeViewer(mainComp, SWT.MULTI | SWT.BORDER); } else { fTreeViewer = new RemoteTreeViewer(mainComp, SWT.SINGLE | SWT.BORDER); } gd = new GridData(SWT.FILL, SWT.FILL, true, true); // see bug 158380 gd.heightHint = Math.max(parent.getSize().y, heightHint); fTreeViewer.getTree().setLayoutData(gd); fTreeViewer.setUseHashlookup(true); fTreeViewer.setComparer(new DeferredFileStoreComparer()); fTreeViewer.setComparator(new RemoteResourceComparator()); fTreeViewer.setContentProvider(new RemoteContentProvider()); fTreeViewer.setLabelProvider(new WorkbenchLabelProvider()); fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (!selection.isEmpty() && selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; fResources.clear(); for (Object currentSelection : ss.toArray()) { if (currentSelection instanceof DeferredFileStore) { IFileStore store = ((DeferredFileStore) currentSelection).getFileStore(); fResources.add(store); } } if (fResources.size() > 0) { fRemotePathText.setText(toPath(fResources.get(0).toURI())); } updateEnablement(); notifySelectionChangedListeners(event); } } }); fTreeViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { IStructuredSelection s = (IStructuredSelection) event.getSelection(); Object o = s.getFirstElement(); if (fTreeViewer.isExpandable(o)) { fTreeViewer.setExpandedState(o, !fTreeViewer.getExpandedState(o)); } } }); /* * Only add filter if we are a directory browser. File and resource browsers show everything. */ int mask = FILE_BROWSER | DIRECTORY_BROWSER; if ((fOptionFlags & mask) != mask // Avoid filter on resource browsers. && (fOptionFlags & DIRECTORY_BROWSER) != 0) { fTreeViewer.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if ((element instanceof DeferredFileStore)) { return ((DeferredFileStore) element).isContainer(); } return element instanceof PendingUpdateAdapter; } }); } if ((fOptionFlags & SHOW_HIDDEN_CHECKBOX) != 0) { fShowHiddenButton = new Button(mainComp, SWT.CHECK); fShowHiddenButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); fShowHiddenButton.setText(Messages.RemoteResourceBrowser_Show_hidden_files); fShowHiddenButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { fShowHidden = fShowHiddenButton.getSelection(); setRoot(fRootPath.toString()); } }); } updateEnablement(); }