List of usage examples for org.eclipse.jface.viewers IStructuredSelection size
public int size();
From source file:com.nokia.s60ct.gui.actions.DefaultToValue.java
License:Open Source License
@Override public void selectionChanged(IAction action, ISelection selection) { EObject selectedObject = null;/*w ww.j av a2 s . c o m*/ if (selection instanceof IStructuredSelection) { IStructuredSelection structedSelection = (IStructuredSelection) selection; if (structedSelection.size() > 0) { selectedObject = (EObject) structedSelection.getFirstElement(); } } if (selectedObject instanceof ParentSetting) { action.setText("Use Default Value"); setting = (ParentSetting) selectedObject; if (setting != null && !setting.isReadOnly() && setting.getType() != TYPE.SEQUENCE) action.setEnabled(true); else action.setEnabled(false); } else if (selectedObject instanceof LeafSettingDelegator) { action.setText("Use Template Value"); lsd = (LeafSettingDelegator) selectedObject; Frame frame = (Frame) lsd.eContainer(); if (lsd != null && lsd.canModifyValue() && !lsd.getLeafSetting().isReadOnly() && !frame.isTemplate()) action.setEnabled(true); else action.setEnabled(false); } else { setting = null; lsd = null; action.setEnabled(false); } }
From source file:com.nokia.s60ct.search.actions.JumpToKey.java
License:Open Source License
@Override public void selectionChanged(IAction action, ISelection selection) { selectedObject = null;//from w ww . j av a 2s . co m ref = null; if (selection instanceof IStructuredSelection) { IStructuredSelection structedSelection = (IStructuredSelection) selection; if (structedSelection.size() > 0) { selectedObject = (EObject) structedSelection.getFirstElement(); } } if (selectedObject != null) { if (selectedObject instanceof Setting) { Setting setting = (Setting) selectedObject; ref = setting.getAbsRef(); String[] refs = ref.split("/"); if (refs[0].equals("null") || refs[1].equals("null")) ref = null; } else if (selectedObject instanceof LeafSettingDelegator) { LeafSettingDelegator lsd = (LeafSettingDelegator) selectedObject; ref = lsd.getLeafSetting().getRef(); } if (ref != null) action.setEnabled(true); else action.setEnabled(false); } else action.setEnabled(false); }
From source file:com.nokia.s60ct.search.actions.JumpToSetting.java
License:Open Source License
@Override public void selectionChanged(IAction action, ISelection selection) { selectedObject = null;/*from w w w .jav a 2s . c om*/ ref = null; if (selection instanceof IStructuredSelection) { IStructuredSelection structedSelection = (IStructuredSelection) selection; if (structedSelection.size() > 0) { selectedObject = (EObject) structedSelection.getFirstElement(); } } if (selectedObject != null) { if (selectedObject instanceof Key) { Key key = (Key) selectedObject; ref = key.getRef(); if (key.isBitmaskKey()) ref = null; } else if (selectedObject instanceof Bit) { Bit bit = (Bit) selectedObject; ref = bit.getRef(); } else if (selectedObject instanceof KeyRange) { KeyRange keyRange = (KeyRange) selectedObject; ref = keyRange.getRef(); } if (ref != null) action.setEnabled(true); else action.setEnabled(false); } else action.setEnabled(false); }
From source file:com.nokia.s60tools.compatibilityanalyser.ui.views.MainView.java
License:Open Source License
protected void fillContextMenuForFirstViewer(IMenuManager manager) { try {// w ww .j a v a 2 s . c om IStructuredSelection selection = (IStructuredSelection) tableviewer.getSelection(); if (selection != null && selection.size() > 0) { String selectedItem = selection.getFirstElement().toString(); if (!selectedItem.startsWith(Messages.getString("MainView.DoubleClickHereToStartAnalysis"))) //$NON-NLS-1$ { //Creating sub menu "Open with" MenuManager subMenuMgr = new MenuManager("Open With", "Open with"); subMenuMgr.add(openInwebBrowserAction); subMenuMgr.add(openInXmlEditorAction); manager.add(subMenuMgr); doubleClickReportAction.setText("Open"); doubleClickReportAction.setImageDescriptor(null); manager.add(doubleClickReportAction); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); manager.add(new Separator()); filterReportAction.setText(Messages.getString("MainView.Filter..")); manager.add(filterReportAction); manager.add(new Separator()); selectAllAction.setText(Messages.getString("MainView.SelectAll")); manager.add(selectAllAction); clearAction.setText(Messages.getString("MainView.ClearAll")); manager.add(clearAction); } else { doubleClickReportAction.setText(Messages.getString("MainView.OpenWizard")); //$NON-NLS-1$ manager.add(doubleClickReportAction); doubleClickReportAction.setImageDescriptor( ImageResourceManager.getImageDescriptor(ImageKeys.ANALYSIS_SMALL_ICON)); } manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } } catch (Exception e) { System.out.println("===>" + e.getMessage()); } manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); }
From source file:com.nokia.s60tools.creator.wizards.CreatorScriptNewWizardPage.java
License:Open Source License
/** * Tests if the current workbench selection is a suitable container to use. */// ww w . j a va 2s .c o m private void initialize() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) return; Object obj = ssel.getFirstElement(); if (obj instanceof IResource) { IContainer container; if (obj instanceof IContainer) container = (IContainer) obj; else container = ((IResource) obj).getParent(); containerText.setText(container.getFullPath().toString()); } } else { //If there is only one project in workspace, we can set that to container, because user has no option IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects(); if (projects.length == 1) { containerText.setText(projects[0].getFullPath().makeAbsolute().toString()); } } fileText.setText("new_file.creatorxml"); }
From source file:com.nokia.s60tools.metadataeditor.wizards.APIMetadataFileNewWizardPage.java
License:Open Source License
/** * Tests if the current workbench selection is a suitable container to use. *///from w w w . j a va 2 s .c o m private void initialize() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) return; Object obj = ssel.getFirstElement(); if (obj instanceof IResource) { IContainer container; if (obj instanceof IContainer) container = (IContainer) obj; else container = ((IResource) obj).getParent(); containerText.setText(container.getFullPath().toString()); //If container is set, setting focus to file name field fileText.setFocus(); } } else { //If there is only one project in workspace, we can set that to container, because user has no option IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects(); if (projects.length == 1) { containerText.setText(projects[0].getFullPath().makeAbsolute().toString()); } } }
From source file:com.nokia.s60tools.remotecontrol.ftp.ui.view.FtpUtils.java
License:Open Source License
/** * Gets currently selected path. This adds single folder to the path, if one folder is selected. * @param viewer Viewer//from w ww . j ava 2 s . c o m * @param contentProvider Content provider * @return Currently selected path, or <code>null</code> if root is shown. */ private static String getSelectedPath(TableViewer viewer, ViewContentProvider contentProvider) { // Getting required information. IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); String targetPath = getCurrentPath(contentProvider); if (targetPath == null) { // Can't get selected path from root. return null; } if (selection.size() == 1) { Object selectedObject = selection.getFirstElement(); if (FtpFolderObject.class.isInstance(selectedObject)) { // Selection is a folder. Adding currently selected single folder to path. targetPath = targetPath + ((FtpFolderObject) selectedObject).getName(); } } return targetPath; }
From source file:com.nokia.s60tools.remotecontrol.ftp.ui.view.FtpView.java
License:Open Source License
/** * Is selected item(s) a file(s)/*from w w w . ja va2 s .c o m*/ * @return True if file else false */ private boolean isSelectionFile() { boolean retVal = false; IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Object[] selectionArray = selection.toArray(); if (selection.size() > 0) { // Checking that all selected items are files. for (Object selectedObject : selectionArray) { if (FtpFileObject.class.isInstance(selectedObject)) { retVal = true; } else { retVal = false; break; } } } return retVal; }
From source file:com.nokia.s60tools.remotecontrol.ftp.ui.view.FtpView.java
License:Open Source License
/** * Is size of selection bigger than 1 and does it contain folder(s). * @return True if size is bigger than 1 and contains one or more folders, false otherwise. *//*from w w w . ja v a 2 s . c om*/ private boolean isSelectionMultiFolder() { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Object[] selectionArray = selection.toArray(); if (selection.size() > 1) { // Checking if there is is folder in selection. for (Object selectedObject : selectionArray) { if (FtpFolderObject.class.isInstance(selectedObject)) { return true; } } } return false; }
From source file:com.nokia.s60tools.remotecontrol.ftp.ui.view.FtpView.java
License:Open Source License
/** * Is selected item a single file/* ww w . ja v a 2s . c o m*/ * @return True if single file else false */ private boolean isSelectionSingleFile() { boolean retVal = false; IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Object selectedObject = selection.getFirstElement(); if (selection.size() == 1) { if (selectedObject != null) { if (FtpFileObject.class.isInstance(selectedObject)) { retVal = true; } } } return retVal; }