Java Code Examples for org.eclipse.swt.widgets.Tree#setRedraw()

The following examples show how to use org.eclipse.swt.widgets.Tree#setRedraw() . 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: JavaOutlineInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void toggleShowInheritedMembers() {
	Tree tree= getTreeViewer().getTree();

	tree.setRedraw(false);
	fShowInheritedMembers= !fShowInheritedMembers;
	getTreeViewer().refresh();
	getTreeViewer().expandToLevel(2);

	// reveal selection
	Object selectedElement= getSelectedElement();
	if (selectedElement != null)
		getTreeViewer().reveal(selectedElement);
	else
		selectFirstMatch();

	tree.setRedraw(true);
}
 
Example 2
Source File: JavaOutlineInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void setTopLevelTypeOnly(boolean show) {
	fShowOnlyMainType= show;
	setChecked(show);

	Tree tree= fOutlineViewer.getTree();
	tree.setRedraw(false);

	fOutlineViewer.refresh(false);
	if (!fShowOnlyMainType)
		fOutlineViewer.expandToLevel(2);


	// reveal selection
	Object selectedElement= getSelectedElement();
	if (selectedElement != null)
		fOutlineViewer.reveal(selectedElement);

	tree.setRedraw(true);

	getDialogSettings().put(STORE_GO_INTO_TOP_LEVEL_TYPE_CHECKED, show);
}
 
Example 3
Source File: BreadcrumbItemDropDown.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void toggleExpansionState( Object element )
{
	Tree tree = fDropDownViewer.getTree( );
	if ( fDropDownViewer.getExpandedState( element ) )
		fDropDownViewer.collapseToLevel( element, 1 );
	else
	{
		tree.setRedraw( false );
		try
		{
			fDropDownViewer.expandToLevel( element, 1 );
			resizeShell( fShell );
		}
		finally
		{
			tree.setRedraw( true );
		}
	}
}
 
Example 4
Source File: CommitDiffViewer.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
public void setSelection(Set<FileReference> initialSelection) {
	selected = findNodes(initialSelection, root);
	Set<String> expanded = new HashSet<>();
	Tree tree = getViewer().getTree();
	for (DiffNode node : selected) {
		if (!node.isModelNode() && !node.isCategoryNode())
			continue;
		String cId = node.getContent().getDataset().categoryRefId;
		if (cId == null)
			cId = node.getModelType().name();
		if (expanded.contains(cId))
			continue;
		expanded.add(cId);
		getViewer().reveal(node);
	}
	tree.setRedraw(false);
	setChecked(initialSelection, tree.getItems());
	tree.setRedraw(true);
}
 
Example 5
Source File: AbstractTmfTreeViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void refresh() {
    Tree tree = fTreeViewer.getTree();
    tree.setRedraw(false);
    fTreeViewer.refresh();
    tree.setRedraw(true);
}
 
Example 6
Source File: BreadcrumbItemDropDown.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void toggleExpansionState(Object element) {
  Tree tree = fDropDownViewer.getTree();
  if (fDropDownViewer.getExpandedState(element))
    fDropDownViewer.collapseToLevel(element, 1);
  else {
    tree.setRedraw(false);
    try {
      fDropDownViewer.expandToLevel(element, 1);
      resizeShell(fShell);
    } finally {
      tree.setRedraw(true);
    }
  }
}
 
Example 7
Source File: BreadcrumbItemDropDown.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void toggleExpansionState(Object element) {
	Tree tree= fDropDownViewer.getTree();
	if (fDropDownViewer.getExpandedState(element))
		fDropDownViewer.collapseToLevel(element, 1);
	else {
		tree.setRedraw(false);
		try {
			fDropDownViewer.expandToLevel(element, 1);
			resizeShell(fShell);
		} finally {
			tree.setRedraw(true);
		}
	}
}
 
Example 8
Source File: LanguageCodesPreferencePage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
protected void removeLanguage(List<?> languages) {
	try {
		String bundlePath = FileLocator.toFileURL(Activator.getDefault().getBundle().getEntry("")).getPath();
		for (Object object : languages) {
			if (object instanceof Language) {
				Language lang = (Language) object;
				languageModel.removeLanguage(lang);
				LocaleService.getLanguageConfiger().deleteLanguageByCode(lang.getCode());
				String imgPath = lang.getImagePath();
				if (!imgPath.equals("")) {
					File file = new File(bundlePath + imgPath);
					if (file.exists()) {
						file.delete();
					}
				}
			}
		}
	} catch (IOException e) {
		logger.error(Messages.getString("languagecode.LanguageCodesPreferencePage.logger4"), e);
		e.printStackTrace();
	}
	// refresh the viewer
	Tree tree = fFilteredTree.getViewer().getTree();
	try {
		tree.setRedraw(false);
		fFilteredTree.getViewer().refresh();
	} finally {
		tree.setRedraw(true);
	}

}
 
Example 9
Source File: LanguageCodesPreferencePage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
protected void addLanguage() {
	AddOrUpdateLanguageDialog dialog = new AddOrUpdateLanguageDialog(fFilteredTree.getShell(),
			AddOrUpdateLanguageDialog.DIALOG_ADD);
	dialog.setLanguageModel(languageModel);
	if (dialog.open() == IDialogConstants.OK_ID) {
		String strCode = dialog.getStrCode();
		String imagePath = dialog.getImagePath();
		String resultImagePath = "";
		if (!imagePath.equals("")) {
			File imgFile = new File(imagePath);
			if (imgFile.exists()) {
				try {
					String bundlePath = FileLocator.toFileURL(Activator.getDefault().getBundle().getEntry(""))
							.getPath();
					String rsImagePath = bundlePath + "images/lang/" + strCode + ".png";
					File rsImgFile = new File(rsImagePath);
					if (!rsImgFile.exists()) {
						rsImgFile.createNewFile();
					}
					ResourceUtils.copyFile(imgFile, rsImgFile);
				} catch (IOException e) {
					logger.error(Messages.getString("languagecode.LanguageCodesPreferencePage.logger2"), e);
					e.printStackTrace();
				}
			}
			resultImagePath = "images/lang/" + strCode + ".png";
		}
		Language language = new Language(strCode, dialog.getStrName(), resultImagePath, dialog.isBlnIsBidi());
		LocaleService.getLanguageConfiger().addLanguage(language);
		languageModel.getLanguages().add(language);
		languageModel.getLanguagesMap().put(strCode, language);
	}
	Tree tree = fFilteredTree.getViewer().getTree();
	try {
		tree.setRedraw(false);
		fFilteredTree.getViewer().refresh();
	} finally {
		tree.setRedraw(true);
	}
}
 
Example 10
Source File: LanguageCodesPreferencePage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
protected void removeLanguage(List<?> languages) {
	try {
		String bundlePath = FileLocator.toFileURL(Activator.getDefault().getBundle().getEntry("")).getPath();
		for (Object object : languages) {
			if (object instanceof Language) {
				Language lang = (Language) object;
				languageModel.removeLanguage(lang);
				LocaleService.getLanguageConfiger().deleteLanguageByCode(lang.getCode());
				String imgPath = lang.getImagePath();
				if (!imgPath.equals("")) {
					File file = new File(bundlePath + imgPath);
					if (file.exists()) {
						file.delete();
					}
				}
			}
		}
	} catch (IOException e) {
		logger.error(Messages.getString("languagecode.LanguageCodesPreferencePage.logger4"), e);
		e.printStackTrace();
	}
	// refresh the viewer
	Tree tree = fFilteredTree.getViewer().getTree();
	try {
		tree.setRedraw(false);
		fFilteredTree.getViewer().refresh();
	} finally {
		tree.setRedraw(true);
	}

}
 
Example 11
Source File: LanguageCodesPreferencePage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
protected void addLanguage() {
	AddOrUpdateLanguageDialog dialog = new AddOrUpdateLanguageDialog(fFilteredTree.getShell(),
			AddOrUpdateLanguageDialog.DIALOG_ADD);
	dialog.setLanguageModel(languageModel);
	if (dialog.open() == IDialogConstants.OK_ID) {
		String strCode = dialog.getStrCode();
		String imagePath = dialog.getImagePath();
		String resultImagePath = "";
		if (!imagePath.equals("")) {
			File imgFile = new File(imagePath);
			if (imgFile.exists()) {
				try {
					String bundlePath = FileLocator.toFileURL(Activator.getDefault().getBundle().getEntry(""))
							.getPath();
					String rsImagePath = bundlePath + "images/lang/" + strCode + ".png";
					File rsImgFile = new File(rsImagePath);
					if (!rsImgFile.exists()) {
						rsImgFile.createNewFile();
					}
					ResourceUtils.copyFile(imgFile, rsImgFile);
				} catch (IOException e) {
					logger.error(Messages.getString("languagecode.LanguageCodesPreferencePage.logger2"), e);
					e.printStackTrace();
				}
			}
			resultImagePath = "images/lang/" + strCode + ".png";
		}
		Language language = new Language(strCode, dialog.getStrName(), resultImagePath, dialog.isBlnIsBidi());
		LocaleService.getLanguageConfiger().addLanguage(language);
		languageModel.getLanguages().add(language);
		languageModel.getLanguagesMap().put(strCode, language);
	}
	Tree tree = fFilteredTree.getViewer().getTree();
	try {
		tree.setRedraw(false);
		fFilteredTree.getViewer().refresh();
	} finally {
		tree.setRedraw(true);
	}
}
 
Example 12
Source File: ChartExamples.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Fill in the tree items.
 * 
 * @param tree
 *            The selection tree.
 */
private void fillTree( Tree tree )
{
	ArrayList<String> cTypes = icp.getCategoryTypes( );
	Iterator<String> iter = cTypes.iterator( );
	tree.setRedraw( false );
	
	while ( iter.hasNext( ) )
	{
		TreeItem cItem = new TreeItem( tree, SWT.NONE ); // For
		// Categories
		String sKeyCate = iter.next( );
		cItem.setText( Messages.getString( sKeyCate ) );

		ArrayList<String> iTypes = icp.getItemTypes( sKeyCate );
		Iterator<String> iter2 = iTypes.iterator( );
		
		while ( iter2.hasNext( ) )
		{
			TreeItem iItem = new TreeItem( cItem, SWT.NONE ); // For Items
			String sKey = iter2.next( );
			iItem.setText( Messages.getString( sKey ) );
			hmItemToKey.put( iItem, sKey );
		}
	}
	
	tree.setRedraw( true );
}
 
Example 13
Source File: TreeSelectionDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
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 14
Source File: JavaSynchronizationContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * 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);
		}
	}
}