当前位置: 首页>>代码示例>>Java>>正文


Java ISelection类代码示例

本文整理汇总了Java中org.eclipse.jface.viewers.ISelection的典型用法代码示例。如果您正苦于以下问题:Java ISelection类的具体用法?Java ISelection怎么用?Java ISelection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ISelection类属于org.eclipse.jface.viewers包,在下文中一共展示了ISelection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setInput

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
public void setInput(IWorkbenchPart part, ISelection selection) {
	super.setInput(part, selection);
	txtNameDecorator.hide();
	txtSharedNameDecorator.hide();
	Object input = ((IStructuredSelection) selection).getFirstElement();
	this.sectionProvider = (SectionProvider) input;
	AbstractGW4EEditPartProperties properties = (AbstractGW4EEditPartProperties) sectionProvider
			.getAdapter(IPropertySource.class);
	textName.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_NAME));
	btnCheckShrd.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_VERTEX_SHARED));
	btnCheckBlocked.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_BLOCKED));
	textDescription.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_DESCRIPTION));
	textRequirements.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_VERTEX_REQUIREMENTS));
	textSharedName.setEnabled(properties.isUpdatable(ModelProperties.PROPERTY_VERTEX_SHAREDNAME));
	((GWNode) this.sectionProvider.getModel()).removePropertyChangeListener(this);
	((GWNode) this.sectionProvider.getModel()).addPropertyChangeListener(this);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:18,代码来源:VertexDefaultSection.java

示例2: selectionChanged

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
@Override
public void selectionChanged(SelectionChangedEvent event) {
    super.selectionChanged(event);

    ISelection selection = event.getSelection();
    if (selection.isEmpty()) {
        sqlEditor.resetHighlightRange();
    } else {
        Segments segment = (Segments) ((IStructuredSelection) selection)
                .getFirstElement();
        int start = segment.getOffset();
        int length = segment.getLength();
        try {
            sqlEditor.setHighlightRange(start, length, true);
            sqlEditor.selectAndReveal(start, length);
        } catch (IllegalArgumentException x) {
            sqlEditor.resetHighlightRange();
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:21,代码来源:SQLEditorContentOutlinePage.java

示例3: openSelectedTreeItemInEditor

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
public void openSelectedTreeItemInEditor(ISelection selection, boolean grabFocus) {
	if (selection instanceof IStructuredSelection) {
		IStructuredSelection ss = (IStructuredSelection) selection;
		Object firstElement = ss.getFirstElement();
		if (firstElement instanceof Item) {
			Item item = (Item) firstElement;
			int offset = item.getOffset();
			int length = item.getLength();
			if (length == 0) {
				/* fall back */
				length = 1;
			}
			ignoreNextCaretMove = true;
			selectAndReveal(offset, length);
			if (grabFocus) {
				setFocus();
			}
		}
	}
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:21,代码来源:BatchEditor.java

示例4: getSelection

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
/**
 * Get all {@link Item} instances from the current selection
 * 
 * @param selection
 *            the selection
 * @return the item instances
 */
public static Collection<Item> getSelection ( final ISelection selection )
{
    final Collection<Item> items = new LinkedList<Item> ();

    if ( selection == null || selection.isEmpty () )
    {
        return items;
    }

    if ( selection instanceof IStructuredSelection )
    {
        final Iterator<?> i = ( (IStructuredSelection)selection ).iterator ();
        while ( i.hasNext () )
        {
            final Item item = AdapterHelper.adapt ( i.next (), Item.class );
            if ( item != null )
            {
                items.add ( item );
            }
        }
    }

    return items;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:32,代码来源:ItemSelectionHelper.java

示例5: list

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
public static List<?> list ( final ISelection selection )
{
    final List<Object> result = new LinkedList<Object> ();

    if ( selection instanceof IStructuredSelection )
    {
        final Iterator<?> i = ( (IStructuredSelection)selection ).iterator ();
        while ( i.hasNext () )
        {
            final Object o = i.next ();
            if ( o == null )
            {
                continue;
            }

            result.add ( o );
        }
    }
    return result;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:21,代码来源:SelectionHelper.java

示例6: handleContentOutlineSelection

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
/**
 * This deals with how we want selection in the outliner to affect the other views.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void handleContentOutlineSelection ( ISelection selection )
{
    if ( currentViewerPane != null && !selection.isEmpty () && selection instanceof IStructuredSelection )
    {
        Iterator<?> selectedElements = ( (IStructuredSelection)selection ).iterator ();
        if ( selectedElements.hasNext () )
        {
            // Get the first selected element.
            //
            Object selectedElement = selectedElements.next ();

            // If it's the selection viewer, then we want it to select the same selection as this selection.
            //
            if ( currentViewerPane.getViewer () == selectionViewer )
            {
                ArrayList<Object> selectionList = new ArrayList<Object> ();
                selectionList.add ( selectedElement );
                while ( selectedElements.hasNext () )
                {
                    selectionList.add ( selectedElements.next () );
                }

                // Set the selection to the widget.
                //
                selectionViewer.setSelection ( new StructuredSelection ( selectionList ) );
            }
            else
            {
                // Set the input to the widget.
                //
                if ( currentViewerPane.getViewer ().getInput () != selectedElement )
                {
                    currentViewerPane.getViewer ().setInput ( selectedElement );
                    currentViewerPane.setTitle ( selectedElement );
                }
            }
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:46,代码来源:ItemEditor.java

示例7: launch

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
@Override
public void launch(ISelection selection, String mode) {
	try {
		Object selectObj = ((IStructuredSelection) selection).getFirstElement();
		if (selectObj instanceof IFile) {
			launchFile((IFile) selectObj, mode);
		} else {
			showDialogNotImplemented(selection.getClass().getName());
		}
	} catch (CoreException e) {
		System.out.println(e.getLocalizedMessage() + "\n");
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:14,代码来源:LaunchXpectShortcut.java

示例8: launch

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
@Override
public void launch(ISelection selection, String mode) {
	Object selectObj = ((IStructuredSelection) selection).getFirstElement();
	if (selectObj instanceof IFile) {
		generateBug((IFile) selectObj);
	} else {
		showDialogNotImplemented(selection.getClass().getName());
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:10,代码来源:GenerateXpectReportShortcut.java

示例9: getActiveTreeResourceSelection

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
/**
 * Returns the active tree resource selection if there is one.
 *
 * Examines the active workspace selection and if it is a resource inside of a tree returns it.
 *
 * @param event
 *            The execution event
 * @returns The resource or {@code null} on failure.
 *
 */
private static IResource getActiveTreeResourceSelection(ExecutionEvent event) {

	ISelection activeSelection = HandlerUtil.getCurrentSelection(event);

	if (activeSelection instanceof TreeSelection) {
		Object firstElement = ((TreeSelection) activeSelection).getFirstElement();

		if (firstElement instanceof IResource) {
			return (IResource) firstElement;
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:CreateNewN4JSElementInModuleHandler.java

示例10: handleMoveUpButtonSelection

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
/**
 * Selection handler for moving up an external library location in the list.
 */
private void handleMoveUpButtonSelection(@SuppressWarnings("unused") final SelectionEvent e) {
	final ISelection selection = viewer.getSelection();
	if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
		final Object element = ((IStructuredSelection) selection).getFirstElement();
		if (element instanceof URI) {
			store.moveUp((URI) element);
			updateInput(viewer, store.getLocations());
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:14,代码来源:ExternalLibraryPreferencePage.java

示例11: setSelection

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
/**
 * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
 * Calling this result will notify the listeners.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setSelection ( ISelection selection )
{
    editorSelection = selection;

    for ( ISelectionChangedListener listener : selectionChangedListeners )
    {
        listener.selectionChanged ( new SelectionChangedEvent ( this, selection ) );
    }
    setStatusLineManager ( selection );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:RecipeEditor.java

示例12: generateCreateChildActions

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
/**
 * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>,
 * and returns the collection of these actions.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected Collection<IAction> generateCreateChildActions ( Collection<?> descriptors, ISelection selection )
{
    Collection<IAction> actions = new ArrayList<IAction> ();
    if ( descriptors != null )
    {
        for ( Object descriptor : descriptors )
        {
            actions.add ( new CreateChildAction ( activeEditorPart, selection, descriptor ) );
        }
    }
    return actions;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:20,代码来源:ItemActionBarContributor.java

示例13: selectionChanged

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
public void selectionChanged(IAction action, ISelection selection) {
	try {
		boolean enable = false;
		super.selectionChanged(action, selection);
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
		if (treeObject instanceof DatabaseObjectTreeObject) {
			DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
			ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
			enable = actionModel.isEnabled;
		}
		action.setEnabled(enable);
	}
	catch (Exception e) {}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:16,代码来源:ChangeToAttributeStepAction.java

示例14: doubleClick

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
@Override
public void doubleClick(DoubleClickEvent event) {
	if (editor == null) {
		return;
	}
	if (linkingWithEditorEnabled) {
		editor.setFocus();
		// selection itself is already handled by single click
		return;
	}
	ISelection selection = event.getSelection();
	editor.openSelectedTreeItemInEditor(selection, true);
}
 
开发者ID:de-jcup,项目名称:eclipse-bash-editor,代码行数:14,代码来源:BashEditorContentOutlinePage.java

示例15: onDoubleClick

import org.eclipse.jface.viewers.ISelection; //导入依赖的package包/类
/**
 * Invoked when user double-clicks a result node in the UI.
 */
protected void onDoubleClick() {
	final ISelection selection = testTreeViewer.getSelection();
	final ResultNode resultNode = (ResultNode) ((IStructuredSelection) selection).getFirstElement();

	if (resultNode == null) {
		return;
	}

	TestElement testElement = resultNode.getElement();
	if (testElement instanceof TestCase) {

		final URI testCaseURI = ((TestCase) testElement).getURI();
		if (testCaseURI == null) {
			return;
		}

		final IN4JSEclipseProject project = core.findProject(testCaseURI).orNull();
		if (null != project && project.exists()) {
			final URI moduleLocation = testCaseURI.trimFragment();
			final String[] projectRelativeSegments = moduleLocation.deresolve(project.getLocation()).segments();
			final String path = Joiner.on(SEPARATOR)
					.join(copyOfRange(projectRelativeSegments, 1, projectRelativeSegments.length));
			final IFile module = project.getProject().getFile(path);
			if (null != module && module.isAccessible()) {
				uriOpener.open(testCaseURI, true);
			} else {
				openError(getShell(), "Cannot open editor", "Test class not found in selected project.");
			}
		} else {
			openError(getShell(), "Cannot open editor", "The container project not found in the workspace.");
		}

	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:38,代码来源:TestResultsView.java


注:本文中的org.eclipse.jface.viewers.ISelection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。