org.eclipse.jface.viewers.StructuredViewer Java Examples

The following examples show how to use org.eclipse.jface.viewers.StructuredViewer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecipeEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example #2
Source File: ProtocolEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example #3
Source File: SimpleWidgetProvider.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public StructuredViewer createViewer(Composite parent){
	switch (type) {
	case TYPE_TREE:
		return new TreeViewer(parent, style);
	case TYPE_LIST:
		return new ListViewer(parent, style);
	case TYPE_TABLE:
		return new TableViewer(parent, style);
	case TYPE_LAZYLIST:
		TableViewer ret = new TableViewer(parent, style | SWT.VIRTUAL);
		
		// ret.getTable().setItemCount(0);
		return ret;
	}
	return null;
}
 
Example #4
Source File: ChartConfiguratorView.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well
 * registering the menu for extension. <!-- begin-user-doc --> <!--
 * end-user-doc -->
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" );
    contextMenu.add ( new Separator ( "additions" ) );
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( this.editingDomain, viewer ) );
}
 
Example #5
Source File: DetailViewEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example #6
Source File: MarkerStatsView.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Adds the actions to the tableviewer context menu.
 *
 * @param actions
 *          a collection of IAction objets
 */
private void hookContextMenu(final Collection<Object> actions, StructuredViewer viewer) {
  MenuManager menuMgr = new MenuManager();
  menuMgr.setRemoveAllWhenShown(true);
  menuMgr.addMenuListener(new IMenuListener() {
    @Override
    public void menuAboutToShow(IMenuManager manager) {
      for (Iterator<Object> iter = actions.iterator(); iter.hasNext();) {
        Object item = iter.next();
        if (item instanceof IContributionItem) {
          manager.add((IContributionItem) item);
        } else if (item instanceof IAction) {
          manager.add((IAction) item);
        }
      }
      manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    }
  });
  Menu menu = menuMgr.createContextMenu(viewer.getControl());
  viewer.getControl().setMenu(menu);

  getSite().registerContextMenu(menuMgr, viewer);
}
 
Example #7
Source File: DeploymentEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example #8
Source File: TypeHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void revealElementInEditor(Object elem, StructuredViewer originViewer) {
	// only allow revealing when the type hierarchy is the active page
	// no revealing after selection events due to model changes

	if (getSite().getPage().getActivePart() != this) {
		return;
	}

	if (fSelectionProviderMediator.getViewerInFocus() != originViewer) {
		return;
	}

	IEditorPart editorPart= EditorUtility.isOpenInEditor(elem);
	if (editorPart != null && (elem instanceof IJavaElement)) {
		getSite().getPage().removePartListener(fPartListener);
		getSite().getPage().bringToTop(editorPart);
		EditorUtility.revealInEditor(editorPart, (IJavaElement) elem);
		getSite().getPage().addPartListener(fPartListener);
	}
}
 
Example #9
Source File: OsgiEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example #10
Source File: ViewerUtils.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Updates a viewer's element and makes sure it runs in the SWT thread. Runs a refresh in case the
 * viewer does not support updates.
 *
 * @param viewer
 * @param element
 * @param properties
 * @see StructuredViewer#update(Object, String[])
 */
public static void update(final Viewer viewer, final Object element, final String[] properties) {
  Display.getDefault()
      .asyncExec(
          new Runnable() {
            @Override
            public void run() {
              if (viewer == null || viewer.getControl().isDisposed()) return;

              if (viewer instanceof StructuredViewer) {
                StructuredViewer structuredViewer = (StructuredViewer) viewer;
                structuredViewer.update(element, properties);
              } else {
                viewer.refresh();
              }
            }
          });
}
 
Example #11
Source File: InfrastructureEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example #12
Source File: SecurityEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example #13
Source File: GlobalizeEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example #14
Source File: ComponentEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well
 * registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance (), ItemTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) );
}
 
Example #15
Source File: GenconfEditor.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menu = contextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] {LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(),
        FileTransfer.getInstance()};
    viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
 
Example #16
Source File: CreateCamelBean.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
private void selectRootObject(Properties params) {

        IRepositoryView view = RepositoryManagerHelper.getRepositoryView();
        if (view != null) {
            Object type = params.get("type");
            if (CamelRepositoryNodeType.repositoryBeansType.name().equals(type)) {
                IRepositoryNode processNode = ((ProjectRepositoryNode) view.getRoot())
                        .getRootRepositoryNode(ERepositoryObjectType.PROCESS);
                if (processNode != null) {
                    setWorkbenchPart(view);
                    final StructuredViewer viewer = view.getViewer();
                    if (viewer instanceof TreeViewer) {
                        ((TreeViewer) viewer).expandToLevel(processNode, 1);
                    }
                    viewer.setSelection(new StructuredSelection(processNode));
                }

            }
        }

    }
 
Example #17
Source File: TypeScriptSearchResultPage.java    From typescript.java with MIT License 6 votes vote down vote up
public String getLabel() {
	String label= super.getLabel();
	StructuredViewer viewer= getViewer();
	if (viewer instanceof TableViewer) {
		TableViewer tv= (TableViewer) viewer;

		AbstractTextSearchResult result= getInput();
		if (result != null) {
			int itemCount= ((IStructuredContentProvider) tv.getContentProvider()).getElements(getInput()).length;
			if (showLineMatches()) {
				int matchCount= getInput().getMatchCount();
				if (itemCount < matchCount) {
					return Messages.format(SearchMessages.FileSearchPage_limited_format_matches, new Object[]{label, new Integer(itemCount), new Integer(matchCount)});
				}
			} else {
				int fileCount= getInput().getElements().length;
				if (itemCount < fileCount) {
					return Messages.format(SearchMessages.FileSearchPage_limited_format_files, new Object[]{label, new Integer(itemCount), new Integer(fileCount)});
				}
			}
		}
	}
	return label;
}
 
Example #18
Source File: LabItemTreeSelectionComposite.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean select(Viewer viewer, Object parentElement, Object element){
	if (searchString == null || searchString.length() == 0) {
		return true;
	}
	
	StructuredViewer sviewer = (StructuredViewer) viewer;
	ITreeContentProvider provider = (ITreeContentProvider) sviewer.getContentProvider();
	Object[] children = provider.getChildren(element);
	if (children != null && children.length > 0) {
		for (Object child : children) {
			if (select(viewer, element, child)) {
				return true;
			}
		}
	}
	return isSelect(element);
}
 
Example #19
Source File: ViewerUtils.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Refreshes a viewer's display and makes sure it runs in the SWT thread.
 *
 * @param viewer
 * @param updateLabels
 * @see Viewer#refresh()
 * @see StructuredViewer#refresh(boolean)
 */
public static void refresh(final Viewer viewer, final boolean updateLabels) {
  Display.getDefault()
      .asyncExec(
          new Runnable() {
            @Override
            public void run() {
              if (viewer == null || viewer.getControl().isDisposed()) return;

              if (viewer instanceof StructuredViewer) {
                StructuredViewer structuredViewer = (StructuredViewer) viewer;
                structuredViewer.refresh(updateLabels);
              } else {
                viewer.refresh();
              }
            }
          });
}
 
Example #20
Source File: CallHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void addDragAdapters(StructuredViewer viewer) {
	int ops= DND.DROP_COPY | DND.DROP_LINK;

	Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance()};

	DelegatingDragAdapter dragAdapter= new DelegatingDragAdapter() {
		@Override
		public void dragStart(DragSourceEvent event) {
			IStructuredSelection selection= (IStructuredSelection) fSelectionProviderMediator.getSelection();
			if (selection.isEmpty()) {
				event.doit= false;
				return;
			}
			super.dragStart(event);
		}
	};
	dragAdapter.addDragSourceListener(new SelectionTransferDragAdapter(fSelectionProviderMediator));
	dragAdapter.addDragSourceListener(new EditorInputTransferDragAdapter(fSelectionProviderMediator));
	dragAdapter.addDragSourceListener(new ResourceTransferDragAdapter(fSelectionProviderMediator));
	dragAdapter.addDragSourceListener(new FileTransferDragAdapter(fSelectionProviderMediator));

	viewer.addDragSupport(ops, transfers, dragAdapter);
}
 
Example #21
Source File: GroupsWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void configureViewer(final StructuredViewer viewer) {
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(final Object element) {
            final String displayName = ((org.bonitasoft.studio.actors.model.organization.Group) element).getDisplayName();
            if (displayName == null || displayName.isEmpty()) {
                return ((org.bonitasoft.studio.actors.model.organization.Group) element).getName();
            }
            return displayName;
        }
    });

    if (groupList != null && getViewer() != null) {
        getViewer().setInput(groupList);
        ((TreeViewer) getViewer()).expandAll();
    }
}
 
Example #22
Source File: FileTransferDropAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public FileTransferDropAdapter(StructuredViewer viewer) {
	super(viewer);

	setScrollEnabled(true);
	setExpandEnabled(true);
	setFeedbackEnabled(false);
}
 
Example #23
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void updateGroupWith(StructuredViewer viewer) {
    if (viewer != null) {
        IContentProvider contentProvider = viewer.getContentProvider();
        if (contentProvider instanceof ISearchIndexContentProvider) {
            ISearchIndexContentProvider searchIndexTreeContentProvider = (ISearchIndexContentProvider) contentProvider;
            searchIndexTreeContentProvider.setGroupWith(groupWithConfiguration);
        }
    }
}
 
Example #24
Source File: PatternFilter.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Check if the current (leaf) element is a match with the filter text. The default behavior checks that the label of
 * the element is a match. Subclasses should override this method.
 *
 * @param viewer the viewer that contains the element
 * @param element the tree element to check
 * @return true if the given element's label matches the filter text
 */
public boolean isLeafMatch(Viewer viewer, Object element) {
   String labelText = ((ILabelProvider) ((StructuredViewer) viewer).getLabelProvider()).getText(element);

   if (labelText == null) {
      return false;
   }
   return wordMatches(labelText);
}
 
Example #25
Source File: ViewActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void fillFilters(StructuredViewer viewer) {
	ViewerFilter workingSetFilter= fFilterActionGroup.getWorkingSetFilter();
	if (fMode == SHOW_PROJECTS) {
		viewer.addFilter(workingSetFilter);
	} else {
		viewer.removeFilter(workingSetFilter);
	}
}
 
Example #26
Source File: GraphStatsView.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Specifies which action will be run when double clicking on the viewer.
 *
 * @param action
 *          the IAction to add
 */
private void hookDoubleClickAction(final IAction action, StructuredViewer viewer) {
  viewer.addDoubleClickListener(new IDoubleClickListener() {
    @Override
    public void doubleClick(DoubleClickEvent event) {
      action.run();
    }
  });
}
 
Example #27
Source File: PShelfViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @see org.eclipse.jface.viewers.StructuredViewer#doFindInputItem(java.lang.Object)
 */
protected Widget doFindInputItem(Object element) {
	Viewer viewer = getViewerForItem(pshelf.getSelection());
	if (viewer instanceof StructuredViewer) {
		return (Widget) ReflectionUtils.callMethod(viewer, "doFindInputItem", element);
	}
	return null;
}
 
Example #28
Source File: JdtViewerDropSupport.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public JdtViewerDropSupport(StructuredViewer viewer) {
	fViewer= viewer;

	fDelegatingDropAdapter= new DelegatingDropAdapter();
	fReorgDropListener= new SelectionTransferDropAdapter(fViewer);
	fDelegatingDropAdapter.addDropTargetListener(fReorgDropListener);
	fDelegatingDropAdapter.addDropTargetListener(new FileTransferDropAdapter(fViewer));
	fDelegatingDropAdapter.addDropTargetListener(new PluginTransferDropAdapter(fViewer));

	fStarted= false;
}
 
Example #29
Source File: ExtensionsEditor.java    From ifml-editor with MIT License 5 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
	MenuManager contextMenu = new MenuManager("#PopUp");
	contextMenu.add(new Separator("additions"));
	contextMenu.setRemoveAllWhenShown(true);
	contextMenu.addMenuListener(this);
	Menu menu= contextMenu.createContextMenu(viewer.getControl());
	viewer.getControl().setMenu(menu);
	getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));

	int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
	Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
	viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
	viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
 
Example #30
Source File: ProjectsView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected StructuredViewer createViewer(Composite parent) {
	ProblemTreeViewer result= new ProblemTreeViewer(parent, SWT.MULTI);
	fFilterUpdater= new FilterUpdater(result);
	ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater);
	return result;
}