當前位置: 首頁>>代碼示例>>Java>>正文


Java ISelectionProvider.getSelection方法代碼示例

本文整理匯總了Java中org.eclipse.jface.viewers.ISelectionProvider.getSelection方法的典型用法代碼示例。如果您正苦於以下問題:Java ISelectionProvider.getSelection方法的具體用法?Java ISelectionProvider.getSelection怎麽用?Java ISelectionProvider.getSelection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jface.viewers.ISelectionProvider的用法示例。


在下文中一共展示了ISelectionProvider.getSelection方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: selectBookmarkFromLinkedPart

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
/**
 * Select the bookmark corresponding to the selection in given
 * {@link IWorkbenchPart}
 * 
 * @param part
 */
private void selectBookmarkFromLinkedPart(IWorkbenchPart part) {
	ISelectionProvider provider = part.getSite().getSelectionProvider();
	if (provider == null) {
		updateLinkImage(true);
		return;
	}

	ISelection selection = provider.getSelection();
	if (selection == null) {
		updateLinkImage(true);
		return;
	}
	GetLinkedBookmarksOperation getLinkedBookmarksOperation = new GetLinkedBookmarksOperation(bookmarkDatabase);
	List<Bookmark> bookmarks = getLinkedBookmarksOperation.getLinkedBookmarks(part, selection);
	if (bookmarks.isEmpty()) {
		updateLinkImage(true);
		return;
	}
	updateLinkImage(false);
	Bookmark selectedBookmark = bookmarksTreeViewer.getSelectedBookmark();
	if (selectedBookmark == null || !bookmarks.contains(selectedBookmark)) {
		bookmarksTreeViewer.setSelection(new StructuredSelection(bookmarks.get(0)), true);
	}
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:31,代碼來源:ToggleLinkAction.java

示例2: doSelectionChanged

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
protected void doSelectionChanged(SelectionChangedEvent event) {
	ISelection selection = event.getSelection();
	NavigationBarItem item = null;
	Iterator iter = ((IStructuredSelection) selection).iterator();
	while (iter.hasNext()) {
		Object o = iter.next();
		if (o instanceof NavigationBarItem) {
			item = (NavigationBarItem) o;
			break;
		}
	}

	setSelection(item, !isActivePart());

	ISelectionProvider selectionProvider = getSelectionProvider();
	if (selectionProvider == null)
		return;

	ISelection textSelection = selectionProvider.getSelection();
	if (!(textSelection instanceof ITextSelection))
		return;

	fForcedMarkOccurrencesSelection = textSelection;
	updateOccurrenceAnnotations((ITextSelection) textSelection);

}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:27,代碼來源:TypeScriptEditor.java

示例3: modifyText

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
@Override
public void modifyText(final ModifyEvent e) {

	boolean wrap = true;
	final String text = find.getText();
	if (lastText.startsWith(text)) {
		wrap = false;
	}
	lastText = text;
	if (EMPTY.equals(text) || "".equals(text)) {
		adjustEnablement(false, null);
		final ISelectionProvider selectionProvider = editor.getSelectionProvider();
		if (selectionProvider != null) {
			final ISelection selection = selectionProvider.getSelection();
			if (selection instanceof TextSelection) {
				final ITextSelection textSelection = (ITextSelection) selection;
				selectionProvider.setSelection(new TextSelection(textSelection.getOffset(), 0));
			}
		}
	} else {
		find(true, true, wrap);
	}
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:24,代碼來源:EditorSearchControls.java

示例4: isEnabled

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
@Override
public boolean isEnabled() {
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (window == null) {
		return false;
	}
	IWorkbenchPartSite site = window.getActivePage().getActiveEditor().getSite();
	if (site == null) {
		return false;
	}
	ISelectionProvider selectionProvider = site.getSelectionProvider();
	if (selectionProvider == null) {
		return false;
	}
	ISelection currentSelection = selectionProvider.getSelection();
	setContext(refactoring, currentSelection);
	return refactoring.isExecutable();
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:19,代碼來源:RenameElementHandler.java

示例5: getSelectedEntries

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
protected List<EntryData> getSelectedEntries() {
	final HSSDEditor editor = getActiveHSSDEditor();
       if(editor == null) {
           return null;
       }
       
       ISelectionProvider sp = editor.getSite().getSelectionProvider();
       IStructuredSelection sel = (IStructuredSelection)sp.getSelection();
       
       List<EntryData> rv = new ArrayList<>(sel.size());
       for(Iterator<?> itr = sel.iterator(); itr.hasNext();) {
           rv.add(EntryData.of((com.insweat.hssd.lib.tree.structured.TreeNode)
                           itr.next()));
       }
       return rv;
}
 
開發者ID:insweat,項目名稱:hssd,代碼行數:17,代碼來源:AbstractCommandHandler.java

示例6: search

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
public void search() {
	final IWorkbenchPart part = WorkbenchHelper.getActivePart();
	if (part instanceof IEditorPart) {
		final IEditorPart editor = (IEditorPart) part;
		final IWorkbenchPartSite site = editor.getSite();
		if (site != null) {
			final ISelectionProvider provider = site.getSelectionProvider();
			if (provider != null) {
				final ISelection viewSiteSelection = provider.getSelection();
				if (viewSiteSelection instanceof TextSelection) {
					final TextSelection textSelection = (TextSelection) viewSiteSelection;
					text.setText(textSelection.getText());
				}
			}
		}

	}
	activate(null);
	text.setFocus();

}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:22,代碼來源:GamlSearchField.java

示例7: keyReleased

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
@Override
public void keyReleased(KeyEvent e) {
	InsertClosingBracketsSupport insertClosingBracketsSupport = getInsertionSupport(e);
	if (insertClosingBracketsSupport == null) {
		return;
	}
	/*
	 * do not use last caret start - because the listener ordering could be
	 * different
	 */
	ISelectionProvider selectionProvider = this.batchEditor.getSelectionProvider();
	if (selectionProvider == null) {
		return;
	}
	ISelection selection = selectionProvider.getSelection();
	if (!(selection instanceof ITextSelection)) {
		return;
	}
	boolean enabled = getPreferences().getBooleanPreference(P_EDITOR_AUTO_CREATE_END_BRACKETSY);
	if (!enabled) {
		return;
	}
	ITextSelection textSelection = (ITextSelection) selection;
	int offset = textSelection.getOffset();

	try {
		IDocument document = this.batchEditor.getDocument();
		if (document == null) {
			return;
		}
		insertClosingBracketsSupport.insertClosingBrackets(document, selectionProvider, offset);
	} catch (BadLocationException e1) {
		/* ignore */
		return;
	}

}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:38,代碼來源:BatchBracketInsertionCompleter.java

示例8: getCurrentSelection

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
protected final ISelection getCurrentSelection() {
    ISelectionProvider selectionProvider = getSelectionProvider();
    if (selectionProvider != null) {
        return selectionProvider.getSelection();
    }

    return null;

    // ISelectionService selectionService = getSelectionService();
    // return selectionService.getSelection();
}
 
開發者ID:baloise,項目名稱:eZooKeeper,代碼行數:12,代碼來源:BaseAction.java

示例9: update

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
@Override
public void update ()
{
    final ISelectionProvider selectionProvider = this.activeEditorPart instanceof ISelectionProvider ? (ISelectionProvider)this.activeEditorPart : this.activeEditorPart.getSite ().getSelectionProvider ();

    if ( selectionProvider != null )
    {
        final ISelection selection = selectionProvider.getSelection ();
        final IStructuredSelection structuredSelection = selection instanceof IStructuredSelection ? (IStructuredSelection)selection : StructuredSelection.EMPTY;

        this.deleteAction.updateSelection ( structuredSelection );
        this.cutAction.updateSelection ( structuredSelection );
        this.copyAction.updateSelection ( structuredSelection );
        this.pasteAction.updateSelection ( structuredSelection );

        if ( this.validateAction != null )
        {
            this.validateAction.updateSelection ( structuredSelection );
        }

        if ( this.controlAction != null )
        {
            this.controlAction.updateSelection ( structuredSelection );
        }

        if ( this.saveAsAction != null )
        {
            this.saveAsAction.selectionChanged ( structuredSelection );
        }
    }

    this.undoAction.update ();
    this.redoAction.update ();

    if ( this.loadResourceAction != null )
    {
        this.loadResourceAction.update ();
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:40,代碼來源:ChartActionBarContributor.java

示例10: keyReleased

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
@Override
public void keyReleased(KeyEvent e) {
	InsertClosingBracketsSupport insertClosingBracketsSupport = getInsertionSupport(e);
	if (insertClosingBracketsSupport == null) {
		return;
	}
	/*
	 * do not use last caret start - because the listener ordering could be
	 * different
	 */
	ISelectionProvider selectionProvider = this.bashEditor.getSelectionProvider();
	if (selectionProvider == null) {
		return;
	}
	ISelection selection = selectionProvider.getSelection();
	if (!(selection instanceof ITextSelection)) {
		return;
	}
	boolean enabled = getPreferences().getBooleanPreference(P_EDITOR_AUTO_CREATE_END_BRACKETSY);
	if (!enabled) {
		return;
	}
	ITextSelection textSelection = (ITextSelection) selection;
	int offset = textSelection.getOffset();

	try {
		IDocument document = this.bashEditor.getDocument();
		if (document == null) {
			return;
		}
		insertClosingBracketsSupport.insertClosingBrackets(document, selectionProvider, offset);
	} catch (BadLocationException e1) {
		/* ignore */
		return;
	}

}
 
開發者ID:de-jcup,項目名稱:eclipse-bash-editor,代碼行數:38,代碼來源:BashBracketInsertionCompleter.java

示例11: setSelectionProvider

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
/**
 * Sets a new {@link ISelectionProvider} for this
 * {@link SwitchingSelectionProvider}. Any {@link ISelectionChangedListener}
 * s that are registered with this {@link SwitchingSelectionProvider} will
 * receive {@link SelectionChangedEvent}s. The new
 * {@link ISelectionProvider} may be <code>null</code>.
 *
 * @param selectionProvider
 *        a new {@link ISelectionProvider} to use (may be <code>null</code>)
 */
public void setSelectionProvider(final ISelectionProvider selectionProvider) {
    synchronized (currentWrappedProviderLock) {
        if (currentWrappedProvider != null) {
            currentWrappedProvider.removeSelectionChangedListener(selectionChangedListener);
            if (currentWrappedProvider instanceof IPostSelectionProvider) {
                ((IPostSelectionProvider) currentWrappedProvider).removePostSelectionChangedListener(
                    postSelectionChangedListener);
            }
        }

        currentWrappedProvider = selectionProvider;

        if (selectionProvider != null) {
            selectionProvider.addSelectionChangedListener(selectionChangedListener);
            if (selectionProvider instanceof IPostSelectionProvider) {
                ((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(
                    postSelectionChangedListener);
            }
        }

        final ISelection selection =
            (selectionProvider != null ? selectionProvider.getSelection() : StructuredSelection.EMPTY);
        selectionChangedListener.fireChildListeners(selection);
        postSelectionChangedListener.fireChildListeners(selection);
    }
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:37,代碼來源:SwitchingSelectionProvider.java

示例12: getLine

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
private static String getLine() {
	IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
	IDocument doc;
	int offset;
	String line = "";
	// If we are dealing with a text editor. 
	if(editor instanceof ITextEditor) {
		// Get the current selection of the document (for determining what line a query is on).
		ISelectionProvider selectionProvider = ((ITextEditor)editor).getSelectionProvider();
	    if (selectionProvider.equals(null)) return "";
	    ISelection selection = selectionProvider.getSelection();
	    if (selection.equals(null)) return "";
	    ITextEditor ite = (ITextEditor)editor;
	    if (ite.equals(null)) return "";
	    // Get the current document (for isolating substring of text in document using line number from selection).
	    doc = ite.getDocumentProvider().getDocument(ite.getEditorInput());
	    if (doc.equals(null)) return "";
	    
	    if (selection instanceof ITextSelection) {
	        ITextSelection textSelection = (ITextSelection)selection;
	        try {
	        	// Get the line number we are currently on.
	        	if (textSelection.equals(null)) return "";
	        	offset = textSelection.getOffset();
	        	// Get the string on the current line and use that as the query line to be auto-completed.
	        	if (offset > doc.getLength() || offset < 0) return "";
				line = doc.get(doc.getLineOffset(doc.getLineOfOffset(offset)), doc.getLineLength(doc.getLineOfOffset(offset)));
			} catch (BadLocationException e) {
				System.out.println("Error with getting input query.");
				e.printStackTrace();
				return "";
			}
	    }
	} else {
		// If we are not dealing with a text editor.
		return "";
	}
	return line;
}
 
開發者ID:ctreude,項目名稱:nlp2code,代碼行數:40,代碼來源:QueryDocListener.java

示例13: setFields

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
private boolean setFields(boolean reallySet)
{
    // The following code copied with minor modifications from BoxedCommentHandler
    TLAEditor editor;
    editor = EditorUtil.getTLAEditorWithFocus();
    // gets the editor to which command applies
    if (editor == null)
    {
        return false;
    }
    IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
    String text = doc.get();
    ISelectionProvider selectionProvider = editor.getSelectionProvider();
    TextSelection selection = (TextSelection) selectionProvider.getSelection();
    TheoremNode node = EditorUtil.getCurrentTheoremNode();
    if (node == null)
    {
        return false;
    }
    ProofNode pf = node.getProof();
    if (pf instanceof NonLeafProofNode)
    {
        pfNode = (NonLeafProofNode) pf;
    } else
    {
        return false;
    }
    if (reallySet)
    {
        this.doc = doc;
        this.text = text;
        this.selectionProvider = selectionProvider;
        this.selection = selection;
        this.node = node;
        

    }
    return true;
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:40,代碼來源:RenumberProofHandler.java

示例14: getCurrentTheoremNode

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
/**
 * If there is currently a TLAEditor with focus, 
 * and that editor is unmodified and is currently parsed,
 * and its cursor is "at" a TheoremNode, then it returns
 * that TheoremNode.  Otherwise, it returns null.
 */
public static TheoremNode getCurrentTheoremNode()
{
    // get editor and return null if it doesn't exist or
    // is dirty.
    TLAEditor editor = getTLAEditorWithFocus();
    if ((editor == null) || (editor.isDirty()))
    {
        return null;
    }
    ISelectionProvider selectionProvider = editor.getSelectionProvider();
    Assert.isNotNull(selectionProvider, "Active editor does not have a selection provider. This is a bug.");
    ISelection selection = selectionProvider.getSelection();
    if (!(selection instanceof ITextSelection))
    {
        return null;
    }
    ITextSelection textSelection = (ITextSelection) selection;
    IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());

    // check if editor's file is currently parsed.
    IFile file = ((FileEditorInput) editor.getEditorInput()).getFile();
    String moduleName = ResourceHelper.getModuleName(file);

    ParseResult parseResult = ResourceHelper.getValidParseResult(file);

    return ResourceHelper.getTheoremNodeWithCaret(parseResult, moduleName, textSelection, document);
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:34,代碼來源:EditorUtil.java

示例15: initialize

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
private void initialize(ISelectionProvider provider) {
	ISelection selection = provider.getSelection();
	if (!fEditorIsOwner) {
		if (fShowOpenPropertiesAction) {
			if (selection instanceof IStructuredSelection) {
				fOpenPropertiesDialog.selectionChanged((IStructuredSelection) selection);
			} else {
				fOpenPropertiesDialog.selectionChanged(selection);
			}
		}
	}
}
 
開發者ID:grosenberg,項目名稱:fluentmark,代碼行數:13,代碼來源:OpenViewActionGroup.java


注:本文中的org.eclipse.jface.viewers.ISelectionProvider.getSelection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。