當前位置: 首頁>>代碼示例>>Java>>正文


Java CheckboxTreeViewer類代碼示例

本文整理匯總了Java中org.eclipse.jface.viewers.CheckboxTreeViewer的典型用法代碼示例。如果您正苦於以下問題:Java CheckboxTreeViewer類的具體用法?Java CheckboxTreeViewer怎麽用?Java CheckboxTreeViewer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CheckboxTreeViewer類屬於org.eclipse.jface.viewers包,在下文中一共展示了CheckboxTreeViewer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkboxTreeViewerCheckStateChanged

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
private void checkboxTreeViewerCheckStateChanged(CheckStateChangedEvent event) {
	CheckboxTreeViewer viewer = (CheckboxTreeViewer) event.getSource();
	TableTreeNode node = (TableTreeNode) event.getElement();
	if (event.getChecked()) {
		viewer.setSubtreeChecked(node, true);
	} else {
		viewer.setSubtreeChecked(node, false);
		if (node.getParent() != null) {
			viewer.setChecked(node.getParent(), false);
		}
	}
	Object[] elements = viewer.getCheckedElements();
	setPageComplete(elements.length > 0 ? true : false);

	checkedTables.clear();
	TableTreeNode tableTreeNode;
	for (Object obj : elements) {
		tableTreeNode = (TableTreeNode) obj;
		if (tableTreeNode.isTable) {
			checkedTables.add(tableTreeNode.getName());
		} else {
			dbDriverMetaData.setDbSchema(tableTreeNode.getName());
		}
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:26,代碼來源:ImportFromDatabaseWizardPage.java

示例2: setChecked

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
private static void setChecked(final CheckboxTreeViewer tv, Object element) {
  // When user checks a checkbox in the tree, check all its children and mark parent as greyed
  // When a user uncheck a checkbox, mark the subtree as unchecked and ungrayed and if unique
  // sibling parent as grayed.
  DirectoryTreeContentProvider provider = (DirectoryTreeContentProvider) tv.getContentProvider();

  boolean isChecked = tv.getChecked(element);
  if (tv.getGrayed(element)) {
    isChecked = !isChecked;
  }
  tv.setChecked(element, isChecked);
  tv.setGrayed(element, false);
  if (isChecked) {
    tv.setSubtreeChecked(element, true);
  } else {
    tv.setSubtreeChecked(element, false);
  }
  setGrayed(tv, provider.getParent(element));
}
 
開發者ID:bazelbuild,項目名稱:eclipse,代碼行數:20,代碼來源:DirectoryTreeContentProvider.java

示例3: setGrayed

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
private static void setGrayed(CheckboxTreeViewer tv, Object element) {
  if (element == null) {
    return;
  }
  DirectoryTreeContentProvider provider = (DirectoryTreeContentProvider) tv.getContentProvider();
  boolean checked = tv.getChecked(element);
  boolean grayed = false;
  for (Object object : provider.getChildren(element)) {
    grayed = grayed || tv.getGrayed(object) || tv.getChecked(object);
    checked = checked && tv.getChecked(object) && !tv.getGrayed(element);
  }
  if (checked) {
    tv.setChecked(element, true);
    tv.setGrayed(element, false);
  } else if (grayed) {
    tv.setGrayChecked(element, true);
  } else {
    tv.setChecked(element, false);
    tv.setGrayed(element, false);
  }
  setGrayed(tv, provider.getParent(element));
}
 
開發者ID:bazelbuild,項目名稱:eclipse,代碼行數:23,代碼來源:DirectoryTreeContentProvider.java

示例4: getSelectPathsRelativeToRoot

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
/**
 * Returns the list of path selected in <code>tv</code>. It returns the list of checked path
 * without the children of the checked path. Each path is returned as a string giving the relative
 * path from the root of the tree.
 */
static ImmutableList<String> getSelectPathsRelativeToRoot(CheckboxTreeViewer tv) {
  DirectoryTreeContentProvider provider = (DirectoryTreeContentProvider) tv.getContentProvider();
  String root = provider.root.getAbsolutePath();
  ImmutableList.Builder<String> builder = ImmutableList.builder();
  for (Object element : tv.getCheckedElements()) {
    if (!tv.getGrayed(element)) {
      Object parent = provider.getParent(element);
      if (parent == null || tv.getGrayed(parent)) {
        // Only add this element if its parent is not selected (so it's the root).
        String path = ((File) element).getAbsolutePath();
        // Strip root from path
        if (path.startsWith(root)) {
          path = path.substring(root.length());
          if (path.startsWith("/")) {
            path = path.substring(1);
          }
          builder.add(path);
        }
      }
    }
  }
  return builder.build();
}
 
開發者ID:bazelbuild,項目名稱:eclipse,代碼行數:29,代碼來源:DirectoryTreeContentProvider.java

示例5: updateParentState

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
private void updateParentState(IResource child, boolean baseChildState) {
	if (mode == MODE_FLAT || child == null || child.getParent() == null || resourceList.contains(child.getParent())) {
		return;
	}
	CheckboxTreeViewer checkboxTreeViewer = (CheckboxTreeViewer)treeViewer;
	Object parent = resourceSelectionContentProvider.getParent(child);
	if (parent == null) return;
	boolean allSameState = true;
	Object[] children = null;
	children = resourceSelectionContentProvider.getChildren(parent);
	for (int i = children.length - 1; i >= 0; i--) {
		if (checkboxTreeViewer.getChecked(children[i]) != baseChildState || checkboxTreeViewer.getGrayed(children[i])) {
		   allSameState = false;
	       break;
		}
	}
	checkboxTreeViewer.setGrayed(parent, !allSameState);
	checkboxTreeViewer.setChecked(parent, !allSameState || baseChildState);
	updateParentState((IResource)parent, baseChildState);
}
 
開發者ID:subclipse,項目名稱:subclipse,代碼行數:21,代碼來源:ResourceSelectionTree.java

示例6: selectAll

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
/**
 * Selects or deselects all methods.
 * 
 * @param state
 * @throws JavaModelException
 */
private void selectAll(boolean state) {
	CheckboxTreeViewer checkboxTreeViewer = getGroup().getCheckboxTreeViewer();
	ITreeContentProvider contentProvider = (ITreeContentProvider) checkboxTreeViewer.getContentProvider();
	Object[] objects = contentProvider.getElements(checkboxTreeViewer.getInput());

	for (Object object : objects) {
		checkboxTreeViewer.setChecked(object, state);
	}

	for (IMethod method : getBaseClassMethods()) {
		if (viewerFilterMethods.select(null, method.getParent(), method)) {
			if (state) {
				checkedMethods.add(method);
			} else {
				checkedMethods.remove(method);
			}
		}
	}
}
 
開發者ID:junit-tools-team,項目名稱:junit-tools,代碼行數:26,代碼來源:GroupMethodSelectionCtrl.java

示例7: createTreeViewer

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
@Override
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
  int style = SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER
      | SWT.H_SCROLL | SWT.V_SCROLL;
  CheckboxTreeViewer result = new CheckboxTreeViewer(parent, style);
  result.setLabelProvider(new WorkbenchLabelProvider());
  result.setContentProvider(new BaseWorkbenchContentProvider());
  result.setComparator(new NodeWrapperTreeSorter());

  result.addCheckStateListener(new ICheckStateListener() {
    @Override
    public void checkStateChanged(CheckStateChangedEvent event) {
      if (recursiveTreeSelect) {
        tree.setSubtreeChecked(event.getElement(), event.getChecked());
      }
    }
  });

  tree = result;
  return result;
}
 
開發者ID:google,項目名稱:depan,代碼行數:22,代碼來源:CheckNodeTreeView.java

示例8: createTreeViewer

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
/**
 * Creates the tree viewer.
 *
 * @param parent the parent composite
 * @return the tree viewer
 */
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
    fViewer = new CheckboxTreeViewer(parent, SWT.BORDER);

    fViewer.setContentProvider(fContentProvider);
    fViewer.setLabelProvider(fLabelProvider);
    fViewer.addCheckStateListener(new ICheckStateListener() {
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateOKStatus();
        }
    });

    fViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
    if (fFilters != null) {
        for (int i = 0; i != fFilters.size(); i++) {
            fViewer.addFilter((ViewerFilter) fFilters.get(i));
        }
    }

    fViewer.setInput(fInput);

    return fViewer;
}
 
開發者ID:iloveeclipse,項目名稱:filesync4eclipse,代碼行數:30,代碼來源:MultipleFolderSelectionDialog.java

示例9: updateParentState

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
private void updateParentState(IResource child, boolean baseChildState) {
	if (mode == MODE_FLAT || child == null || child.getParent() == null || resourceList.contains(child.getParent())) {
		return;
	}
	CheckboxTreeViewer checkboxTreeViewer = (CheckboxTreeViewer)treeViewer;
	if (child == null) return;
	Object parent = resourceSelectionContentProvider.getParent(child);
	if (parent == null) return;
	boolean allSameState = true;
	Object[] children = null;
	children = resourceSelectionContentProvider.getChildren(parent);
	for (int i = children.length - 1; i >= 0; i--) {
		if (checkboxTreeViewer.getChecked(children[i]) != baseChildState || checkboxTreeViewer.getGrayed(children[i])) {
		   allSameState = false;
	       break;
		}
	}
	checkboxTreeViewer.setGrayed(parent, !allSameState);
	checkboxTreeViewer.setChecked(parent, !allSameState || baseChildState);
	updateParentState((IResource)parent, baseChildState);
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:22,代碼來源:ResourceSelectionTree.java

示例10: run

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
@Override
	public void run() {

		// uncheck all selected tours

		final CheckboxTreeViewer viewer = fCompareResultView.getViewer();
//		final StructuredSelection selection = (StructuredSelection) viewer.getSelection();
//		if (selection.size() > 0) {
//
//			for (final Object tour : selection.toArray()) {
//				viewer.setChecked(tour, false);
//			}
//		}

		viewer.setCheckedElements(new Object[0]);
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:17,代碼來源:ActionUncheckTours.java

示例11: run

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
@Override
public void run() {

	// check all selected compared tours which are not yet stored

	final CheckboxTreeViewer viewer = fCompareResultView.getViewer();
	final StructuredSelection selection = (StructuredSelection) viewer.getSelection();
	if (selection.size() > 0) {

		for (final Object tour : selection.toArray()) {

			if (tour instanceof TVICompareResultComparedTour) {
				final TVICompareResultComparedTour comparedTour = (TVICompareResultComparedTour) tour;
				if (comparedTour.isSaved() == false) {
					viewer.setChecked(tour, true);
				}
			}
		}
	}
}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:21,代碼來源:ActionCheckTours.java

示例12: createTreeViewer

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
/**
 *	Creates this group's tree viewer.
 * @param parent parent composite
 * @param width the width
 * @param height the height
 */
protected void createTreeViewer(Composite parent, int width, int height) {
	Tree tree= new Tree(parent, SWT.CHECK | SWT.BORDER);
	GridData data= new GridData(GridData.FILL_BOTH);
	data.widthHint= width;
	data.heightHint= height;
	tree.setLayoutData(data);

	fTreeViewer= new CheckboxTreeViewer(tree);
	fTreeViewer.setUseHashlookup(true);
	fTreeViewer.setContentProvider(fTreeContentProvider);
	fTreeViewer.setLabelProvider(fTreeLabelProvider);
	fTreeViewer.addTreeListener(this);
	fTreeViewer.addCheckStateListener(this);
	fTreeViewer.addSelectionChangedListener(this);
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:22,代碼來源:CheckboxTreeAndListGroup.java

示例13: createTreeViewer

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
@Override
protected CheckboxTreeViewer createTreeViewer(Composite composite) {
	initializeDialogUnits(composite);
	ViewerPane pane= new ViewerPane(composite, SWT.BORDER | SWT.FLAT);
	pane.setText(JavaUIMessages.OverrideMethodDialog_dialog_description);
	CheckboxTreeViewer treeViewer= super.createTreeViewer(pane);
	pane.setContent(treeViewer.getControl());
	GridLayout paneLayout= new GridLayout();
	paneLayout.marginHeight= 0;
	paneLayout.marginWidth= 0;
	paneLayout.numColumns= 1;
	pane.setLayout(paneLayout);
	GridData gd= new GridData(GridData.FILL_BOTH);
	gd.widthHint= convertWidthInCharsToPixels(55);
	gd.heightHint= convertHeightInCharsToPixels(15);
	pane.setLayoutData(gd);
	ToolBarManager manager= pane.getToolBarManager();
	manager.add(new OverrideFlatTreeAction()); // create after tree is created
	manager.update(true);
	treeViewer.getTree().setFocus();
	return treeViewer;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:23,代碼來源:OverrideMethodDialog.java

示例14: create

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
@Override
public void create() {
	super.create();

	// select the first checked element, or if none are checked, the first element
	CheckboxTreeViewer treeViewer= getTreeViewer();
	TreeItem[] items= treeViewer.getTree().getItems();
	if (items.length > 0) {
		Object revealedElement= items[0];

		for (int i= 0; i < items.length; i++) {
			if (items[i].getChecked()) {
				revealedElement= items[i].getData();
				break;
			}
		}
		treeViewer.setSelection(new StructuredSelection(revealedElement));
		treeViewer.reveal(revealedElement);
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:21,代碼來源:SourceActionDialog.java

示例15: createTreeViewer

import org.eclipse.jface.viewers.CheckboxTreeViewer; //導入依賴的package包/類
/**
 * Creates the tree viewer.
 *
 * @param parent the parent composite
 * @return the tree viewer
 */
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
	fViewer = new CheckboxTreeViewer(parent, SWT.BORDER);

	fViewer.setContentProvider(fContentProvider);
	fViewer.setLabelProvider(fLabelProvider);
	fViewer.addCheckStateListener(new ICheckStateListener() {
		public void checkStateChanged(CheckStateChangedEvent event) {
			updateOKStatus();
		}
	});

	fViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
	if (fFilters != null) {
		for (int i = 0; i != fFilters.size(); i++)
			fViewer.addFilter(fFilters.get(i));
	}

	fViewer.setInput(fInput);

	return fViewer;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:28,代碼來源:MultipleFolderSelectionDialog.java


注:本文中的org.eclipse.jface.viewers.CheckboxTreeViewer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。