List of usage examples for org.eclipse.jface.viewers IStructuredSelection size
public int size();
From source file:com.aptana.js.debug.ui.internal.actions.EditDetailFormatterAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *//*from w w w . jav a 2 s . c om*/ public void run(IAction action) { IStructuredSelection selection = getCurrentSelection(); if (selection == null || selection.size() != 1) { return; } Object element = selection.getFirstElement(); String typeName; try { if (element instanceof IJSVariable) { typeName = ((IJSVariable) element).getReferenceTypeName(); } else { return; } } catch (DebugException e) { IdeLog.logError(JSDebugUIPlugin.getDefault(), e); return; } DebugOptionsManager detailFormattersManager = JSDebugPlugin.getDefault().getDebugOptionsManager(); DetailFormatter detailFormatter = detailFormattersManager.getAssociatedDetailFormatter(typeName); if (new DetailFormatterDialog(UIUtils.getActiveShell(), detailFormatter, null, false, true) .open() == Window.OK) { detailFormattersManager.setAssociatedDetailFormatter(detailFormatter); refreshCurrentSelection(); } }
From source file:com.aptana.js.debug.ui.internal.actions.NewDetailFormatterAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */// ww w . j a v a 2 s . c o m public void run(IAction action) { IStructuredSelection selection = getCurrentSelection(); if (selection == null || selection.size() != 1) { return; } Object element = selection.getFirstElement(); String typeName; try { if (element instanceof IJSVariable) { typeName = ((IJSVariable) element).getReferenceTypeName(); } else { return; } } catch (DebugException e) { IdeLog.logError(JSDebugUIPlugin.getDefault(), e); return; } DebugOptionsManager detailFormattersManager = JSDebugPlugin.getDefault().getDebugOptionsManager(); DetailFormatter detailFormatter = new DetailFormatter(typeName, StringUtil.EMPTY, true); if (new DetailFormatterDialog(UIUtils.getActiveShell(), detailFormatter, null, true, false) .open() == Window.OK) { detailFormattersManager.setAssociatedDetailFormatter(detailFormatter); refreshCurrentSelection(); } }
From source file:com.aptana.js.debug.ui.internal.actions.NewWatchpointAction.java
License:Open Source License
public void run(IAction action) { IStructuredSelection selection = getCurrentSelection(); if (selection == null || selection.size() != 1) { return;/* ww w .j av a2 s.co m*/ } Object element = selection.getFirstElement(); try { if (element instanceof IJSVariable) { JSDebugModel.createWatchpoint((IJSVariable) element); refreshCurrentSelection(); } } catch (CoreException e) { IdeLog.logError(JSDebugUIPlugin.getDefault(), e); return; } }
From source file:com.aptana.js.debug.ui.internal.actions.OpenScriptSourceAction.java
License:Open Source License
/** * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection) *///from w ww.ja va 2 s.co m public void selectionChanged(IStructuredSelection selection) { if (selection.size() == 1) { Object element = selection.getFirstElement(); if (element instanceof IJSScriptElement) { scriptElement = (IJSScriptElement) element; URI location = scriptElement.getLocation(); if (location != null) { setEnabled(true); int lineNumber = scriptElement.getBaseLine(); Object sourceElement = DebugUITools.lookupSource(scriptElement, getSourceLocator(scriptElement)) .getSourceElement(); IEditorInput editorInput = SourceDisplayUtil.getEditorInput(sourceElement); if (editorInput != null) { IEditorPart editorPart = SourceDisplayUtil.findEditor(editorInput); if (editorPart != null) { SourceDisplayUtil.revealLineInEditor(editorPart, lineNumber); } } return; } } } else { scriptElement = null; } setEnabled(false); }
From source file:com.aptana.js.debug.ui.internal.actions.RemoveDetailFormatterAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *//* w ww .ja v a 2s . c o m*/ public void run(IAction action) { IStructuredSelection selection = getCurrentSelection(); if (selection == null || selection.size() != 1) { return; } Object element = selection.getFirstElement(); String typeName; try { if (element instanceof IJSVariable) { typeName = ((IJSVariable) element).getReferenceTypeName(); } else { return; } } catch (DebugException e) { IdeLog.logError(JSDebugUIPlugin.getDefault(), e); return; } DebugOptionsManager detailFormattersManager = JSDebugPlugin.getDefault().getDebugOptionsManager(); DetailFormatter detailFormatter = detailFormattersManager.getAssociatedDetailFormatter(typeName); detailFormattersManager.removeAssociatedDetailFormatter(detailFormatter); refreshCurrentSelection(); }
From source file:com.aptana.js.debug.ui.internal.actions.WatchAction.java
License:Open Source License
@SuppressWarnings("rawtypes") public void selectionChanged(IAction action, ISelection selection) { fSelection = null;//from www. ja v a2 s . co m if (!action.isEnabled()) { return; } int enabled = 0; int size = -1; if (selection instanceof IStructuredSelection) { fSelection = selection; IStructuredSelection sSelection = (IStructuredSelection) selection; size = sSelection.size(); IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager(); IVariable variable; for (Iterator iterator = sSelection.iterator(); iterator.hasNext();) { variable = (IVariable) iterator.next(); if (manager.hasWatchExpressionDelegate(variable.getModelIdentifier())) { enabled++; } else { break; } } if (enabled != size) { action.setEnabled(false); } } else if (selection instanceof ITextSelection) { fSelection = selection; ITextSelection tSelection = (ITextSelection) selection; if (tSelection.getLength() == 0) { action.setEnabled(false); } } }
From source file:com.aptana.js.debug.ui.internal.preferences.JSDetailFormattersPreferencePage.java
License:Open Source License
private void updatePage(IStructuredSelection selection) { removeFormatterButton.setEnabled(!selection.isEmpty()); editFormatterButton.setEnabled(selection.size() == 1); sourceViewer.getDocument()//w w w . j a va2s .c o m .set((selection.size() == 1) ? ((DetailFormatter) selection.getFirstElement()).getSnippet() : StringUtil.EMPTY); }
From source file:com.aptana.js.debug.ui.internal.preferences.JSDetailFormattersPreferencePage.java
License:Open Source License
@SuppressWarnings("unchecked") private void removeTypes() { Object[] list = formatters.toArray(); IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); Object first = selection.getFirstElement(); int index = -1; for (int i = 0; i < list.length; i++) { if (list[i].equals(first)) { index = i;/*from ww w. j a v a2 s.co m*/ break; } } removeDetailFormatters( (DetailFormatter[]) selection.toList().toArray(new DetailFormatter[selection.size()])); list = formatters.toArray(); if (index > list.length - 1) { index = list.length - 1; } if (index >= 0) { listViewer.setSelection(new StructuredSelection(list[index])); } }
From source file:com.aptana.ruby.internal.debug.ui.breakpoints.AbstractDetailPane.java
License:Open Source License
public void display(IStructuredSelection selection) { // clear status line IStatusLineManager statusLine = getStatusLine(); if (statusLine != null) { statusLine.setErrorMessage(null); }//from ww w.j a v a 2s.com AbstractRubyBreakpointEditor editor = getEditor(); Object input = null; if (selection != null && selection.size() == 1) { input = selection.getFirstElement(); // update even if the same in case attributes have changed } try { editor.setInput(input); } catch (CoreException e) { IdeLog.logError(RubyDebugUIPlugin.getDefault(), e); } }
From source file:com.aptana.ruby.internal.debug.ui.breakpoints.BreakpointDetailPaneFactory.java
License:Open Source License
@SuppressWarnings("rawtypes") public Set getDetailPaneTypes(IStructuredSelection selection) { HashSet<String> set = new HashSet<String>(); if (selection.size() == 1) { IBreakpoint b = (IBreakpoint) selection.getFirstElement(); try {/*ww w. j a v a 2 s . com*/ String type = b.getMarker().getType(); if (RubyLineBreakpoint.RUBY_LINE_BREAKPOINT.equals(type)) { set.add(LineBreakpointDetailPane.DETAIL_PANE_LINE_BREAKPOINT); } else { set.add(StandardBreakpointDetailPane.DETAIL_PANE_STANDARD); } } catch (CoreException e) { } } return set; }