Java Code Examples for org.eclipse.jface.viewers.TreeViewer#refresh()
The following examples show how to use
org.eclipse.jface.viewers.TreeViewer#refresh() .
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: ReferenceSearchViewPageActions.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void run() { TreeViewer viewer = page.getViewer(); ITreeSelection selection = viewer.getStructuredSelection(); ReferenceSearchViewTreeNode[] removedNodes = Iterables.toArray( Iterables.filter(selection.toList(), ReferenceSearchViewTreeNode.class), ReferenceSearchViewTreeNode.class); page.getContentProvider().remove(removedNodes); if (searchResult instanceof ReferenceSearchResult) { List<IReferenceDescription> descriptions = new ArrayList<IReferenceDescription>(); IAcceptor<IReferenceDescription> acceptor = CollectionBasedAcceptor.of(descriptions); for (ReferenceSearchViewTreeNode removedNode : removedNodes) { removedNode.collectReferenceDescriptions(acceptor); } IReferenceDescription[] descriptionsArray = descriptions.toArray(new IReferenceDescription[descriptions.size()]); ((ReferenceSearchResult) searchResult).remove(descriptionsArray); } viewer.refresh(); }
Example 2
Source File: TexOutlinePage.java From texlipse with Eclipse Public License 1.0 | 6 votes |
private IAction createHideAction(String desc, final int nodeType, ImageDescriptor img) { IAction action = new Action(desc, IAction.AS_CHECK_BOX) { public void run() { boolean oldState = filter.isTypeVisible(nodeType); filter.toggleType(nodeType, !oldState); TreeViewer viewer = getTreeViewer(); if (oldState == false) { revealNodes(nodeType); } viewer.refresh(); } }; action.setToolTipText(desc); action.setImageDescriptor(img); return action; }
Example 3
Source File: LogicalPackagesProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (fCompoundState == isInCompoundState()) return; else fCompoundState= isInCompoundState(); if (!isInCompoundState()) { fMapToLogicalPackage.clear(); fMapToPackageFragments.clear(); } if(fViewer instanceof TreeViewer){ TreeViewer viewer= (TreeViewer) fViewer; Object[] expandedObjects= viewer.getExpandedElements(); viewer.refresh(); viewer.setExpandedElements(expandedObjects); } else fViewer.refresh(); }
Example 4
Source File: IQuickOutlineContribution.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void register(QuickOutlinePopup quickOutline, IMenuManager dialogMenu) { for (IQuickOutlineContribution contribution : contributions) contribution.register(quickOutline, dialogMenu); TreeViewer treeViewer = quickOutline.getTreeViewer(); if (!treeViewer.getTree().isDisposed()) treeViewer.refresh(); }
Example 5
Source File: FlowRefDialog.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void expand(TreeViewer viewer) { TreeItem[] items = viewer.getTree().getItems(); while (items != null && items.length > 0) { TreeItem next = items[0]; next.setExpanded(true); for (int i = 1; i < items.length; i++) items[i].setExpanded(false); items = next.getItems(); viewer.refresh(); } }
Example 6
Source File: ModelTextFilter.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void expand(TreeViewer viewer) { TreeItem[] items = viewer.getTree().getItems(); while (items != null && items.length > 0) { TreeItem next = items[0]; next.setExpanded(true); for (int i = 1; i < items.length; i++) items[i].setExpanded(false); items = next.getItems(); viewer.refresh(); } }
Example 7
Source File: TreeSelectionDialog.java From Pydev with Eclipse Public License 1.0 | 5 votes |
protected void setFilter(String text, IProgressMonitor monitor, boolean updateFilterMatcher) { synchronized (lock) { if (monitor.isCanceled()) { return; } if (updateFilterMatcher) { //just so that subclasses may already treat it. if (fFilterMatcher.lastPattern.equals(text)) { //no actual change... return; } fFilterMatcher.setFilter(text); if (monitor.isCanceled()) { return; } } TreeViewer treeViewer = getTreeViewer(); Tree tree = treeViewer.getTree(); tree.setRedraw(false); tree.getParent().setRedraw(false); try { if (monitor.isCanceled()) { return; } treeViewer.refresh(); if (monitor.isCanceled()) { return; } treeViewer.expandAll(); } finally { tree.setRedraw(true); tree.getParent().setRedraw(true); } } }
Example 8
Source File: LibraryExplorerTreeViewPage.java From birt with Eclipse Public License 1.0 | 5 votes |
public void elementValidated( DesignElementHandle targetElement, ValidationEvent ev ) { TreeViewer treeViewer = getTreeViewer( ); if ( treeViewer != null && !treeViewer.getTree( ).isDisposed( ) ) { treeViewer.refresh( ); treeViewer.setInput( getRootEntries( ) ); handleTreeViewerRefresh( ); } }
Example 9
Source File: FolderSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void newFolderButtonPressed() { NewFolderDialog dialog= new NewFolderDialog(getShell(), fSelectedContainer); if (dialog.open() == Window.OK) { TreeViewer treeViewer= getTreeViewer(); treeViewer.refresh(fSelectedContainer); Object createdFolder= dialog.getResult()[0]; treeViewer.reveal(createdFolder); treeViewer.setSelection(new StructuredSelection(createdFolder)); } }
Example 10
Source File: HierarchyInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void toggleHierarchy() { TreeViewer treeViewer= getTreeViewer(); treeViewer.getTree().setRedraw(false); Object[] expandedElements= treeViewer.getExpandedElements(); TypeHierarchyContentProvider contentProvider= (TypeHierarchyContentProvider) treeViewer.getContentProvider(); treeViewer.setContentProvider(fOtherContentProvider); treeViewer.refresh(); if (fOtherExpandedElements != null) { treeViewer.setExpandedElements(fOtherExpandedElements); } else { treeViewer.expandAll(); } // reveal selection Object selectedElement= getSelectedElement(); if (selectedElement != null) getTreeViewer().reveal(selectedElement); else selectFirstMatch(); treeViewer.getTree().setRedraw(true); fOtherContentProvider= contentProvider; fOtherExpandedElements= expandedElements; updateStatusFieldText(); }
Example 11
Source File: PackageExplorerActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void doWorkingSetChanged(PropertyChangeEvent event) { if (ViewActionGroup.MODE_CHANGED.equals(event.getProperty())) { fPart.rootModeChanged(((Integer)event.getNewValue()).intValue()); Object oldInput= null; Object newInput= null; if (fPart.getRootMode() == PackageExplorerPart.PROJECTS_AS_ROOTS) { oldInput= fPart.getWorkingSetModel(); newInput= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); } else { oldInput= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); newInput= fPart.getWorkingSetModel(); } if (oldInput != null && newInput != null) { Frame frame; for (int i= 0; (frame= fFrameList.getFrame(i)) != null; i++) { if (frame instanceof TreeFrame) { TreeFrame treeFrame= (TreeFrame)frame; if (oldInput.equals(treeFrame.getInput())) treeFrame.setInput(newInput); } } } } else { IWorkingSet workingSet= (IWorkingSet) event.getNewValue(); String workingSetLabel= null; if (workingSet != null) workingSetLabel= BasicElementLabels.getWorkingSetLabel(workingSet); fPart.setWorkingSetLabel(workingSetLabel); fPart.updateTitle(); String property= event.getProperty(); if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) { TreeViewer viewer= fPart.getTreeViewer(); viewer.getControl().setRedraw(false); viewer.refresh(); viewer.getControl().setRedraw(true); } } }
Example 12
Source File: ReorgMoveWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void doNewButtonPressed() { Object newElement= fCreateTargetQuery.getCreatedTarget(fDestination); if (newElement != null) { TreeViewer viewer= getTreeViewer(); ITreeContentProvider contentProvider= (ITreeContentProvider) viewer.getContentProvider(); viewer.refresh(contentProvider.getParent(newElement)); viewer.setSelection(new StructuredSelection(newElement), true); viewer.getTree().setFocus(); } }
Example 13
Source File: FolderSelectionDialog.java From typescript.java with MIT License | 5 votes |
protected void newFolderButtonPressed() { NewFolderDialog dialog = new NewFolderDialog(getShell(), fSelectedContainer); if (dialog.open() == Window.OK) { TreeViewer treeViewer = getTreeViewer(); treeViewer.refresh(fSelectedContainer); Object createdFolder = dialog.getResult()[0]; treeViewer.reveal(createdFolder); treeViewer.setSelection(new StructuredSelection(createdFolder)); } }
Example 14
Source File: AbstractSearchResultTreePage.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
@Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { fTreeViewer = (TreeViewer) viewer; fSearchResult = (AbstractTextSearchResult) newInput; resultModel.clearAll(); if (fSearchResult != null) { for (Object o : fSearchResult.getElements()) { resultModel.addIFile((IFile)o); } } fTreeViewer.refresh(); }
Example 15
Source File: IOutlineContribution.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void register(OutlinePage outlinePage) { for(IOutlineContribution contribution: contributions) contribution.register(outlinePage); TreeViewer treeViewer = outlinePage.getTreeViewer(); if(!treeViewer.getTree().isDisposed()) treeViewer.refresh(); }
Example 16
Source File: JavaSynchronizationContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Handles a diff change event. * * @param event * the event */ private void handleChange(final IDiffChangeEvent event) { final Set<IJavaProject> existing= getVisibleProjects(); // Get all existing and open projects that contain changes // and determine what needs to be done to the project // (i.e. add, remove or refresh) final IJavaProject[] changed= getChangedProjects(event); final List<IJavaProject> refreshes= new ArrayList<IJavaProject>(changed.length); final List<IJavaProject> additions= new ArrayList<IJavaProject>(changed.length); final List<IJavaProject> removals= new ArrayList<IJavaProject>(changed.length); for (int index= 0; index < changed.length; index++) { final IJavaProject project= changed[index]; if (hasVisibleChanges(event.getTree(), project)) { if (existing.contains(project)) refreshes.add(project); else additions.add(project); } else removals.add(project); } // Remove any java projects that correspond to deleted or closed projects final Set<IProject> removed= getDeletedProjects(event); for (final Iterator<IJavaProject> iterator= existing.iterator(); iterator.hasNext();) { final IJavaProject element= iterator.next(); if (removed.contains(element.getResource())) removals.add(element); } if (!removals.isEmpty() || !additions.isEmpty() || !refreshes.isEmpty()) { final TreeViewer viewer= (TreeViewer) getViewer(); final Tree tree= viewer.getTree(); try { tree.setRedraw(false); if (!additions.isEmpty()) viewer.add(viewer.getInput(), additions.toArray()); if (!removals.isEmpty()) viewer.remove(viewer.getInput(), removals.toArray()); if (!refreshes.isEmpty()) { for (final Iterator<IJavaProject> iter= refreshes.iterator(); iter.hasNext();) viewer.refresh(iter.next()); } } finally { tree.setRedraw(true); } } }
Example 17
Source File: H5ContentProvider.java From dawnsci with Eclipse Public License 1.0 | 4 votes |
@Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { treeViewer = (TreeViewer) viewer; treeViewer.refresh(); }
Example 18
Source File: BaseOutlinePage.java From Pydev with Eclipse Public License 1.0 | 4 votes |
/** * called when model has structural changes, refreshes all items underneath * @param items: items to refresh, or null for the whole tree * tries to preserve the scrolling */ public void refreshItems(Object[] items) { try { unlinkAll(); TreeViewer viewer = getTreeViewer(); if (viewer != null) { Tree treeWidget = viewer.getTree(); if (isDisconnectedFromTree()) { return; } ScrollBar bar = treeWidget.getVerticalBar(); int barPosition = 0; if (bar != null) { barPosition = bar.getSelection(); } if (items == null) { if (isDisconnectedFromTree()) { return; } viewer.refresh(); } else { if (isDisconnectedFromTree()) { return; } for (int i = 0; i < items.length; i++) { viewer.refresh(items[i]); } } if (barPosition != 0) { bar.setSelection(Math.min(bar.getMaximum(), barPosition)); } } } catch (Throwable e) { //things may be disposed... Log.log(e); } finally { relinkAll(); } }
Example 19
Source File: ErrorTraceTreeViewer.java From tlaplus with MIT License | 4 votes |
ErrorTraceTreeViewer(final Tree parent, final ModelEditor associatedModelEditor) { treeViewer = new TreeViewer(parent); treeViewer.setUseHashlookup(true); treeViewer.setContentProvider(new StateContentProvider()); ColumnViewerToolTipSupport.enableFor(treeViewer); final TraceDisplayResizer resizer = new TraceDisplayResizer(parent); final StateLabelProvider labelProvider = new StateLabelProvider(); for (int i = 0; i < COLUMN_TEXTS.length; i++) { final TreeViewerColumn column = new TreeViewerColumn(treeViewer, i); column.getColumn().setText(COLUMN_TEXTS[i]); column.getColumn().setWidth(COLUMN_WIDTH[i]); column.setLabelProvider(labelProvider); resizer.setColumnForIndex(column, i); column.getColumn().addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { // reverse the current trace final TLCError error = (TLCError) treeViewer.getInput(); error.reverseTrace(); // Reset the viewer's selection to the empty selection. With empty // selection, the subsequent refresh call does *not* invalidate the // StateContentProvider's lazy policy. // We know that the user clicked on the tree's column header // and the real selection is of little importance. treeViewer.setSelection(new ISelection() { public boolean isEmpty() { return true; } }); treeViewer.refresh(false); // remember the order for next trace shown final IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings(); dialogSettings.put(TLCModelLaunchDataProvider.STATESORTORDER, !dialogSettings.getBoolean(TLCModelLaunchDataProvider.STATESORTORDER)); } }); } parent.addControlListener(resizer); errorTraceFontChangeListener = (event) -> { if ((event == null) || event.getProperty().equals(ITLCPreferenceConstants.I_TLC_ERROR_TRACE_FONT)) { final Font f = JFaceResources.getFont(ITLCPreferenceConstants.I_TLC_ERROR_TRACE_FONT); JFaceResources.getFontRegistry().put(TLCErrorView.JFACE_ERROR_TRACE_ID, f.getFontData()); if (treeViewer != null) { treeViewer.refresh(true); } } }; errorTraceFontChangeListener.propertyChange(null); JFaceResources.getFontRegistry().addListener(errorTraceFontChangeListener); createContextMenu(); setModelEditor(associatedModelEditor); }