org.eclipse.jface.viewers.ICheckStateListener#org.eclipse.jface.viewers.ISelection源码实例Demo

下面列出了org.eclipse.jface.viewers.ICheckStateListener#org.eclipse.jface.viewers.ISelection 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ghidra   文件: GhidraProjectUtils.java
/**
 * Gets the selected project, or null if a project is not selected.  If multiple things
 * are selected, only the first selected item is considered.
 * 
 * @param selection A selection from which to get a project.
 * @return The selected project, or null if a project is not selected.
 */
public static IProject getSelectedProject(ISelection selection) {
	IProject project = null;

	if (selection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		Object firstElement = structuredSelection.getFirstElement();
		if (firstElement instanceof IResource) {
			project = ((IResource) (firstElement)).getProject();
		}
		else if (firstElement instanceof IJavaElement) {
			project = ((IJavaElement) (firstElement)).getResource().getProject();
		}
	}
	return project;
}
 
源代码2 项目: lapse-plus   文件: SuperListener.java
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
	
	if (part != this.view.fEditor && part instanceof ITextEditor && (LapseView.getJavaInput((ITextEditor) part) != null)) 
	{
		try {
			if(LapseView.TRACE) {
			    System.out.println("In selectionChanged: setting the input");
			}

			this.view.setInput((ITextEditor) part);
			
			if(this.view.fEditor == null) {
				throw new RuntimeException("Couldn't set the editor properly");
			}
			
		} catch (CoreException e) {
			JavaPlugin.logErrorMessage("Caught exception: " + e.toString());
			return;
		}				
	}
	
}
 
源代码3 项目: neoscada   文件: AbstractChartManagePart.java
protected void handleSelectionChanged ( final ISelection sel )
{
    if ( sel == null || sel.isEmpty () )
    {
        return;
    }
    if ( ! ( sel instanceof IStructuredSelection ) )
    {
        return;
    }

    final Object o = ( (IStructuredSelection)sel ).getFirstElement ();
    if ( ! ( o instanceof ChartViewer ) )
    {
        return;
    }

    setChartViewer ( (ChartViewer)o );
}
 
源代码4 项目: eclipse-cs   文件: CheckstylePropertyPage.java
@Override
public void selectionChanged(SelectionChangedEvent event) {

  Object source = event.getSource();
  if (source == mFilterList) {

    ISelection selection = event.getSelection();
    if (selection instanceof IStructuredSelection) {
      Object selectedElement = ((IStructuredSelection) selection).getFirstElement();

      if (selectedElement instanceof IFilter) {

        IFilter filterDef = (IFilter) selectedElement;

        mTxtFilterDescription.setText(filterDef.getDescription());

        // activate edit button
        mBtnEditFilter.setEnabled(PluginFilterEditors.hasEditor(filterDef));
      }
    }
  }
}
 
源代码5 项目: scava   文件: CrossflowDiagramEditor.java
/**
* @generated
*/
private ISelection getNavigatorSelection() {
	IDiagramDocument document = getDiagramDocument();
	if (document == null) {
		return StructuredSelection.EMPTY;
	}
	Diagram diagram = document.getDiagram();
	if (diagram == null || diagram.eResource() == null) {
		return StructuredSelection.EMPTY;
	}
	IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
	if (file != null) {
		CrossflowNavigatorItem item = new CrossflowNavigatorItem(diagram, file, false);
		return new StructuredSelection(item);
	}
	return StructuredSelection.EMPTY;
}
 
源代码6 项目: n4js   文件: ApiCompareView.java
private void makeActions() {
	actionUpdate = new Action() {
		@Override
		public void run() {
			updateComparison();
		}
	};
	actionUpdate.setText("Update");
	actionUpdate.setToolTipText(
			"Recompute comparison for all API project and their implementation projects in the workspace.");
	// action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
	// getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));

	actionOpenInEditor = new Action() {
		@Override
		public void run() {
			ISelection selection = viewer.getSelection();
			Object obj = ((IStructuredSelection) selection).getFirstElement();
			if (obj instanceof ProjectComparisonEntry)
				showInEditor((ProjectComparisonEntry) obj, true, true);
		}
	};
	actionOpenInEditor.setText("Open in Editor");
	actionOpenInEditor.setToolTipText(
			"Open the currently selected API element and its implementations in N4JS editors.");
}
 
源代码7 项目: neoscada   文件: RemoveAction.java
private void setSelection ( final ISelection selection )
{
    this.entries = new LinkedList<ListEntry> ();

    if ( selection instanceof IStructuredSelection )
    {
        final Iterator<?> i = ( (IStructuredSelection)selection ).iterator ();
        while ( i.hasNext () )
        {
            final Object o = i.next ();
            if ( o instanceof ListEntry )
            {
                this.entries.add ( (ListEntry)o );
            }
        }
    }
}
 
源代码8 项目: scava   文件: CrossflowDiagramUpdateCommand.java
/**
* @generated
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
			.getSelection();
	if (selection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		if (structuredSelection.size() != 1) {
			return null;
		}
		if (structuredSelection.getFirstElement() instanceof EditPart
				&& ((EditPart) structuredSelection.getFirstElement()).getModel() instanceof View) {
			EObject modelElement = ((View) ((EditPart) structuredSelection.getFirstElement()).getModel())
					.getElement();
			List editPolicies = CanonicalEditPolicy.getRegisteredEditPolicies(modelElement);
			for (Iterator it = editPolicies.iterator(); it.hasNext();) {
				CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it.next();
				nextEditPolicy.refresh();
			}

		}
	}
	return null;
}
 
源代码9 项目: ghidra   文件: LinkGhidraCommand.java
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
	ISelection selection = window.getSelectionService().getSelection();
	WizardDialog dialog =
		new WizardDialog(window.getShell(), new LinkGhidraWizard(selection));
	dialog.open();
	return null;
}
 
源代码10 项目: ghidra   文件: AbstractGhidraLaunchShortcut.java
@Override
public void launch(ISelection selection, String mode) {
	IProject project = GhidraProjectUtils.getSelectedProject(selection);
	if (project != null) {
		launch(JavaCore.create(project), mode);
	}
}
 
/**
 * 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;
}
 
源代码12 项目: neoscada   文件: DeploymentActionBarContributor.java
/**
 * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>,
 * and returns the collection of these actions.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected Collection<IAction> generateCreateSiblingActions ( Collection<?> descriptors, ISelection selection )
{
    Collection<IAction> actions = new ArrayList<IAction> ();
    if ( descriptors != null )
    {
        for ( Object descriptor : descriptors )
        {
            actions.add ( new CreateSiblingAction ( activeEditorPart, selection, descriptor ) );
        }
    }
    return actions;
}
 
源代码13 项目: neoscada   文件: AbstractQueryViewPart.java
protected void addSelectionListener ()
{
    if ( this.selectionListener == null )
    {
        getViewSite ().getWorkbenchWindow ().getSelectionService ().addSelectionListener ( this.selectionListener = new ISelectionListener () {

            public void selectionChanged ( final IWorkbenchPart part, final ISelection selection )
            {
                AbstractQueryViewPart.this.setSelection ( selection );
            }
        } );
    }
}
 
private void addLogFileSubMenu(IMenuManager menu) {
	final ICommonViewerSite viewSite = getActionSite().getViewSite();
	ISelection selection = viewSite.getSelectionProvider().getSelection();
	if (!(selection instanceof IStructuredSelection)) {
		return;
	}

	IStructuredSelection sel = (IStructuredSelection) selection;
	if (sel.size() == 1) {
		Object obj = sel.getFirstElement();
		if (obj instanceof CodewindEclipseApplication) {
			final CodewindEclipseApplication app = (CodewindEclipseApplication) obj;
			if (app.isAvailable() && app.getLogInfos() != null && !app.getLogInfos().isEmpty()) {
				MenuManager menuMgr = new MenuManager(Messages.ShowLogFilesMenu, "ShowLogFiles");
				showAllLogsAction.setApp(app);
				menuMgr.add(showAllLogsAction);
				hideAllLogsAction.setApp(app);
				menuMgr.add(hideAllLogsAction);
				menuMgr.add(new Separator());
				for (ProjectLogInfo logInfo : app.getLogInfos()) {
					menuMgr.add(new LogFileAction(app, logInfo, viewSite));
				}
				menu.add(menuMgr);
			}
		}
	}
}
 
源代码15 项目: scava   文件: CrossflowActionBarContributor.java
/**
 * 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;
}
 
源代码16 项目: neoscada   文件: MemoryEditor.java
/**
 * 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 );
}
 
源代码17 项目: neoscada   文件: WriteOperationAction.java
@Override
public void selectionChanged ( final IAction action, final ISelection selection )
{
    if ( selection == null )
    {
        return;
    }
    if ( ! ( selection instanceof IStructuredSelection ) )
    {
        return;
    }

    this.selection = (IStructuredSelection)selection;
}
 
源代码18 项目: neoscada   文件: WorldActionBarContributor.java
/**
 * 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;
}
 
源代码19 项目: dartboard   文件: LaunchShortcut.java
@Override
public void launch(ISelection selection, String mode) {
	IProject selected = null;
	if (selection instanceof StructuredSelection) {
		Object firstElement = ((StructuredSelection) selection).getFirstElement();
		if (firstElement instanceof IResource) {
			selected = ((IResource) firstElement).getProject();
		}
	}

	launchProject(selected, mode);
}
 
源代码20 项目: dartboard   文件: LaunchFileShortcut.java
@Override
public void launch(ISelection selection, String mode) {
	if (selection instanceof StructuredSelection) {
		Object firstElement = ((StructuredSelection) selection).getFirstElement();
		if (firstElement instanceof IFile) {
			IFile file = (IFile) firstElement;
			launch(file.getLocation(), null);
		}
	}
}
 
源代码21 项目: neoscada   文件: SelectionHelper.java
public static <T> T first ( final ISelection selection, final Class<T> clazz )
{
    final Iterator<T> i = iterator ( selection, clazz );
    if ( i.hasNext () )
    {
        return i.next ();
    }
    return null;
}
 
源代码22 项目: CogniCrypt   文件: Utils.java
/**
 * This method gets the project that is currently selected.
 *
 * @return Currently selected project.
 */
public static IProject getCurrentlySelectedIProject() {
	ISelection curSel = getCurrentSelection();
	Object resource = null;
	if ((resource = getIResourceFromSelection(curSel)) != null) {
		return ((IProject) resource).getProject();
	} else {
		return getJavaProjectFromSelection(curSel);
	}
}
 
源代码23 项目: neoscada   文件: DeploymentEditor.java
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setStatusLineManager ( ISelection selection )
{
    IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? contentOutlineStatusLineManager : getActionBars ().getStatusLineManager ();

    if ( statusLineManager != null )
    {
        if ( selection instanceof IStructuredSelection )
        {
            Collection<?> collection = ( (IStructuredSelection)selection ).toList ();
            switch ( collection.size () )
            {
                case 0:
                {
                    statusLineManager.setMessage ( getString ( "_UI_NoObjectSelected" ) ); //$NON-NLS-1$
                    break;
                }
                case 1:
                {
                    String text = new AdapterFactoryItemDelegator ( adapterFactory ).getText ( collection.iterator ().next () );
                    statusLineManager.setMessage ( getString ( "_UI_SingleObjectSelected", text ) ); //$NON-NLS-1$
                    break;
                }
                default:
                {
                    statusLineManager.setMessage ( getString ( "_UI_MultiObjectSelected", Integer.toString ( collection.size () ) ) ); //$NON-NLS-1$
                    break;
                }
            }
        }
        else
        {
            statusLineManager.setMessage ( "" ); //$NON-NLS-1$
        }
    }
}
 
源代码24 项目: neoscada   文件: SecurityEditor.java
/**
 * 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 );
                }
            }
        }
    }
}
 
源代码25 项目: neoscada   文件: LaunchShortcut.java
@Override
public void launch ( final ISelection selection, final String mode )
{
    final IResource resource = SelectionHelper.first ( selection, IResource.class );
    if ( resource != null )
    {
        performLanuch ( resource, mode );
    }
}
 
源代码26 项目: neoscada   文件: AbstractChartManagePart.java
protected void attachSelectionService ()
{
    getViewSite ().getWorkbenchWindow ().getSelectionService ().addPostSelectionListener ( new ISelectionListener () {

        @Override
        public void selectionChanged ( final IWorkbenchPart part, final ISelection selection )
        {
            handleSelectionChanged ( selection );
        }

    } );
    handleSelectionChanged ( getViewSite ().getWorkbenchWindow ().getSelectionService ().getSelection () );
}
 
源代码27 项目: neoscada   文件: AbstractEntryViewPart.java
protected synchronized void setSelection ( final ISelection selection )
{
    final BrowserEntryBean browserEntry = SelectionHelper.first ( selection, BrowserEntryBean.class );
    if ( browserEntry != this.entry && browserEntry != null && isSupported ( browserEntry ) )
    {
        clear ();
        if ( browserEntry != null )
        {
            setEntry ( browserEntry );
        }
    }
}
 
源代码28 项目: neoscada   文件: SelectionHelper.java
public static <T> List<T> list ( final ISelection selection, final Class<T> clazz )
{
    final List<T> result = new LinkedList<T> ();

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

            if ( clazz.isAssignableFrom ( o.getClass () ) )
            {
                result.add ( clazz.cast ( o ) );
            }

            else
            {
                final T ro = AdapterHelper.adapt ( o, clazz );
                if ( ro != null )
                {
                    result.add ( ro );
                }
            }
        }
    }
    return result;
}
 
源代码29 项目: neoscada   文件: MemoryActionBarContributor.java
/**
 * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>,
 * and returns the collection of these actions.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected Collection<IAction> generateCreateSiblingActions ( Collection<?> descriptors, ISelection selection )
{
    Collection<IAction> actions = new ArrayList<IAction> ();
    if ( descriptors != null )
    {
        for ( Object descriptor : descriptors )
        {
            actions.add ( new CreateSiblingAction ( activeEditorPart, selection, descriptor ) );
        }
    }
    return actions;
}
 
源代码30 项目: neoscada   文件: ConfigurationEditor.java
/**
 * 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 );
                }
            }
        }
    }
}