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


Java ISelectionProvider.setSelection方法代碼示例

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


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

示例1: insertMultiLiner

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
private void insertMultiLiner(BracketInsertion data, ISelectionProvider selectionProvider, int offset,
		IDocument document) throws BadLocationException {
	IRegion region = document.getLineInformationOfOffset(offset);
	if (region == null) {
		return;
	}
	int length = region.getLength();

	String textBeforeColumn = document.get(offset - length, length-1); //-1 to get not he bracket itself
	String relevantColumnsBefore = TextUtil.trimRightWhitespaces(textBeforeColumn);
	InsertionData result = support.prepareInsertionString(
			data.createMultiLineTemplate(SourceCodeInsertionSupport.CURSOR_VARIABLE), relevantColumnsBefore);

	document.replace(offset - 1, 1, result.getSourceCode());
	selectionProvider.setSelection(new TextSelection(offset + result.getCursorOffset() - 1, 0));

}
 
開發者ID:de-jcup,項目名稱:egradle,代碼行數:18,代碼來源:GroovyBracketInsertionCompleter.java

示例2: testSetCurrentSelectionProvider

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
@Test
public void testSetCurrentSelectionProvider() {
	// Given
	ISelectionProvider selectionProvider = new TestSelectionProvider();
	ISelectionChangedListener listener1 = mock(ISelectionChangedListener.class);
	ISelectionChangedListener listener2 = mock(ISelectionChangedListener.class);
	proxySelectionProvider.addSelectionChangedListener(listener1);

	// When
	proxySelectionProvider.setCurrentSelectionProvider(selectionProvider);
	proxySelectionProvider.addSelectionChangedListener(listener2);
	selectionProvider.setSelection(new StructuredSelection("my selection"));

	// Then
	ArgumentCaptor<SelectionChangedEvent> captor = ArgumentCaptor.forClass(SelectionChangedEvent.class);
	verify(listener1).selectionChanged(captor.capture());
	assertThat(captor.getValue().getSelection()).isEqualTo(new StructuredSelection("my selection"));
	verify(listener2).selectionChanged(captor.capture());
	assertThat(captor.getValue().getSelection()).isEqualTo(new StructuredSelection("my selection"));

}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:22,代碼來源:ProxySelectionProviderTest.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: insertClosingBrackets

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
@Override
protected void insertClosingBrackets(IDocument document, ISelectionProvider selectionProvider, int offset)
		throws BadLocationException {
	document.replace(offset - 1, 1, "[ ]");
	selectionProvider.setSelection(new TextSelection(offset + 1, 0));

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

示例5: setSelection

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
public void setSelection(ISelection selection) {
	IEditorPart activeEditor = multiPageEditor.getActiveEditor();
	if (activeEditor != null) {
		ISelectionProvider selectionProvider = activeEditor.getSite().getSelectionProvider();
		if (selectionProvider != null) {
			selectionProvider.setSelection(selection);
		}
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:10,代碼來源:MultiPageToolbarSelectionProvider.java

示例6: modifyText

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
public void modifyText(ModifyEvent e)
{
	adjustEnablement();
	if (ignore > 0 || !searchOnModifyText)
	{
		return;
	}
	IPreferenceStore preferenceStore = FindBarPlugin.getDefault().getPreferenceStore();
	if (!preferenceStore.getBoolean(IPreferencesConstants.INCREMENTAL_SEARCH_ON_FIND_BAR))
	{
		return;
	}

	textFind.setBackground(null);
	boolean wrap = true;
	String text = textFind.getText();
	if (lastText.startsWith(text))
	{
		wrap = false;
	}
	lastText = text;
	if (StringUtil.EMPTY.equals(text))
	{
		ISelectionProvider selectionProvider = textEditor.getSelectionProvider();
		ISelection selection = selectionProvider.getSelection();
		if (selection instanceof TextSelection)
		{
			ITextSelection textSelection = (ITextSelection) selection;
			selectionProvider.setSelection(new TextSelection(textSelection.getOffset(), 0));
		}
	}
	else
	{
		findBarFinder.find(true, true, wrap);
	}
	showCountTotal();
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:38,代碼來源:FindBarDecorator.java

示例7: insertOneLiner

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
private void insertOneLiner(BracketInsertion data, ISelectionProvider selectionProvider, int offset,
		IDocument document) throws BadLocationException {
	document.replace(offset - 1, 1, data.createOneLineTemplate());
	selectionProvider.setSelection(new TextSelection(data.createOneLineNewOffset(offset), 0));
}
 
開發者ID:de-jcup,項目名稱:egradle,代碼行數:6,代碼來源:GroovyBracketInsertionCompleter.java

示例8: ContextMenuSupport

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
/** Create SWT context menu
 *  @param site RCP site
 *  @param parent Parent SWT widget
 *  @param representation Representation
 */
public ContextMenuSupport(final RuntimeViewPart view, final Control parent, final RCP_JFXRepresentation representation)
{
    this.view = view;
    final IWorkbenchPartSite site = view.getSite();
    shell = site.getShell();

    // Tried to use a JFX context menu on the individual items,
    // but adding the existing PV contributions requires parsing
    // the registry and creating suitable JFX menu entries.
    // Finally, it was unclear how to set the "activeMenuSelection"
    // required by existing object contributions.
    //
    // So using SWT context menu, automatically populated with PV contributions.

    // Selection provider to inform RCP about PV for the context menu
    final ISelectionProvider sel_provider = new RCPSelectionProvider();
    site.setSelectionProvider(sel_provider);

    // RCP context menu w/ "additions" placeholder for contributions
    final MenuManager mm = new MenuManager();
    mm.setRemoveAllWhenShown(true);
    mm.addMenuListener(manager -> fillContextMenu(manager));
    site.registerContextMenu(mm, sel_provider);

    // Create menu ..
    final Menu menu = mm.createContextMenu(parent);
    // .. but _don't_ attach to SWT control
    //     parent.setMenu(menu);

    // Menu is shown by representation listener _after_
    // setting the selection to widget's PV
    final ToolkitListener tkl = new ToolkitListener()
    {
        @Override
        public void handleContextMenu(final Widget widget)
        {
            IStructuredSelection sel = StructuredSelection.EMPTY;
            final Optional<WidgetProperty<String>> name_prop = widget.checkProperty(propPVName);
            if (name_prop.isPresent())
            {
                final String pv_name = name_prop.get().getValue();
                if (!pv_name.isEmpty())
                    sel = new StructuredSelection(new ProcessVariable(pv_name));
            }
            sel_provider.setSelection(sel);

            // Show the menu
            view.setActiveWidget(widget);
            menu.setVisible(true);
        }
    };
    representation.addListener(tkl);
    parent.addDisposeListener(event -> representation.removeListener(tkl));
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:60,代碼來源:ContextMenuSupport.java

示例9: replace

import org.eclipse.jface.viewers.ISelectionProvider; //導入方法依賴的package包/類
private void replace(boolean newFind)
{
	ISelectionProvider selectionProvider = this.textEditor.getSelectionProvider();
	ISelection selection = selectionProvider.getSelection();
	if (!(selection instanceof ITextSelection))
	{
		FindBarPlugin.log(new AssertionError("Expected text editor selection to be an ITextSelection. Was: " //$NON-NLS-1$
				+ selection));
		return;
	}
	ITextSelection textSelection = (ITextSelection) selection;
	String comboText = textFind.getText();
	if (comboText.length() == 0)
	{
		return;
	}
	setFindText(comboText);
	setFindTextOnReplace(getReplaceText());

	selectionProvider.setSelection(new TextSelection(this.textEditor.getDocumentProvider().getDocument(
			this.textEditor.getEditorInput()), textSelection.getOffset(), 0));

	// Do initial search before replace (always forward search as we just selected the initial offset).
	if (!findBarFinder.find(true, false, false))
	{
		return; // The messages (why the find didn't work) should be set already.
	}
	try
	{
		getFindReplaceDialog().replaceSelection(getReplaceText(), getConfiguration().getRegularExpression());
		showCountTotal();
	}
	catch (Exception e1)
	{
		statusLineManager.setMessage(true,
				MessageFormat.format(Messages.FindBarDecorator_ReplaceError, e1.getMessage()), null);
		FindBarPlugin.log(e1);
		return;
	}

	if (newFind)
	{
		if (getConfiguration().getSearchBackward())
		{
			findBarFinder.find(false);
		}
		else
		{
			findBarFinder.find(true);
		}
	}
	else
	{
		statusLineManager.setMessage(false, StringUtil.EMPTY, null);
	}
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:57,代碼來源:FindBarDecorator.java


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