org.eclipse.jface.viewers.TreeNode Java Examples

The following examples show how to use org.eclipse.jface.viewers.TreeNode. 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: SelectImportedSchemaDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
protected List<TreeNode> createTreeNodeList() {

		List<TreeNode> treeNodeList = new ArrayList<TreeNode>();

		TreeNode topNode = new TreeNode(new StringObjectModel(ResourceString
				.getResourceString("label.schema")));
		treeNodeList.add(topNode);

		List<TreeNode> schemaNodeList = new ArrayList<TreeNode>();

		for (String schemaName : schemaList) {
			TreeNode schemaNode = new TreeNode(schemaName);
			schemaNode.setParent(topNode);
			schemaNodeList.add(schemaNode);
		}

		topNode.setChildren(schemaNodeList.toArray(new TreeNode[schemaNodeList
				.size()]));

		return treeNodeList;
	}
 
Example #2
Source File: AbstractSelectImportedObjectDialog.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
protected void performOK() throws InputException {
    final Object[] selectedNodes = viewer.getCheckedElements();

    this.resultSelectedDbObjects = new ArrayList<>();

    for (int i = 0; i < selectedNodes.length; i++) {
        final Object value = ((TreeNode) selectedNodes[i]).getValue();

        if (value instanceof DBObject) {
            resultSelectedDbObjects.add((DBObject) value);
        }
    }

    this.resultMergeWord = mergeWordButton.getSelection();
    this.resultMergeGroup = mergeGroupButton.getSelection();
}
 
Example #3
Source File: SelectImportedSchemaDialog.java    From erflute with Apache License 2.0 6 votes vote down vote up
protected List<TreeNode> createTreeNodeList() {
    final List<TreeNode> treeNodeList = new ArrayList<>();
    final TreeNode topNode = new TreeNode(new StringObjectModel(DisplayMessages.getMessage("label.schema")));
    treeNodeList.add(topNode);

    final List<TreeNode> schemaNodeList = new ArrayList<>();
    for (final String schemaName : schemaList) {
        final TreeNode schemaNode = new TreeNode(schemaName);
        schemaNode.setParent(topNode);
        schemaNodeList.add(schemaNode);
    }

    topNode.setChildren(schemaNodeList.toArray(new TreeNode[schemaNodeList.size()]));

    return treeNodeList;
}
 
Example #4
Source File: SourceContentOutlinePage.java    From textuml with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
    super.createControl(parent);
    viewer = getTreeViewer();
    contentProvider = new TreeNodeContentProvider();
    viewer.setContentProvider(contentProvider);
    labelProvider = new TextUMLLabelProvider();
    viewer.setLabelProvider(labelProvider);
    // disabled: used to make elements to show sorted by type
    // viewer.setComparator(new UIModelObjectViewerComparator());
    viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);

    // tracks selections in the outline and reflects them in the editor
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            TreeSelection selection = (TreeSelection) event.getSelection();
            if (!selection.isEmpty()) {
                TreeNode treeNode = (TreeNode) selection.getFirstElement();
                UIModelObject model = (UIModelObject) treeNode.getValue();
                selectInEditor(model.getToken());
            }
        }
    });

    refresh();
}
 
Example #5
Source File: AbstractSelectImportedObjectDialog.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void perfomeOK() throws InputException {
    final Object[] selectedNodes = viewer.getCheckedElements();

    resultSelectedDbObjects = new ArrayList<DBObject>();

    for (int i = 0; i < selectedNodes.length; i++) {
        final Object value = ((TreeNode) selectedNodes[i]).getValue();

        if (value instanceof DBObject) {
            resultSelectedDbObjects.add((DBObject) value);
        }
    }

    resultMergeWord = mergeWordButton.getSelection();
}
 
Example #6
Source File: ViewLabelProvider.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
@Override
public String getText(final Object element) {
    final TreeNode treeNode = (TreeNode) element;

    final Object value = treeNode.getValue();
    if (value instanceof DBObject) {
        final DBObject dbObject = (DBObject) value;
        return dbObject.getName();

    } else if (value instanceof StringObjectModel) {
        final StringObjectModel object = (StringObjectModel) value;
        return object.getName();

    } else if (value instanceof TestData) {
        final TestData testData = (TestData) value;
        return testData.getName();

    }

    return value.toString();
}
 
Example #7
Source File: ViewLabelProvider.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
@Override
public String getText(Object element) {
	TreeNode treeNode = (TreeNode) element;

	Object value = treeNode.getValue();
	if (value instanceof DBObject) {
		DBObject dbObject = (DBObject) value;
		return dbObject.getName();

	} else if (value instanceof StringObjectModel) {
		StringObjectModel object = (StringObjectModel) value;
		return object.getName();
	}

	return value.toString();
}
 
Example #8
Source File: AbstractSelectImportedObjectDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void perfomeOK() throws InputException {
	Object[] selectedNodes = this.viewer.getCheckedElements();

	this.resultSelectedDbObjects = new ArrayList<DBObject>();

	for (int i = 0; i < selectedNodes.length; i++) {
		Object value = ((TreeNode) selectedNodes[i]).getValue();

		if (value instanceof DBObject) {
			resultSelectedDbObjects.add((DBObject) value);
		}
	}

	this.resultMergeWord = this.mergeWordButton.getSelection();
	this.resultMergeGroup = this.mergeGroupButton.getSelection();
}
 
Example #9
Source File: AbstractSelectImportedObjectDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
protected TreeNode createTopNode(String objectType,
		List<DBObject> dbObjectList) {
	TreeNode treeNode = new TreeNode(new StringObjectModel(ResourceString
			.getResourceString("label.object.type." + objectType)));
	List<TreeNode> objectNodeList = new ArrayList<TreeNode>();

	for (DBObject dbObject : dbObjectList) {
		TreeNode objectNode = new TreeNode(dbObject);
		objectNode.setParent(treeNode);

		objectNodeList.add(objectNode);
	}

	treeNode.setChildren(objectNodeList.toArray(new TreeNode[objectNodeList
			.size()]));

	return treeNode;
}
 
Example #10
Source File: AbstractSelectImportedObjectDialog.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@Override
protected void setData() {
	List<TreeNode> treeNodeList = createTreeNodeList();

	TreeNode[] treeNodes = treeNodeList.toArray(new TreeNode[treeNodeList
			.size()]);
	this.viewer.setInput(treeNodes);
	this.viewer.setCheckedElements(treeNodes);
	this.viewer.expandAll();
}
 
Example #11
Source File: SelectImportedObjectFromFileDialog.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@Override
protected List<TreeNode> createTreeNodeList() {
	List<TreeNode> treeNodeList = super.createTreeNodeList();

	TreeNode topNode = createTopNode(DBObject.TYPE_NOTE, this.dbObjectSet
			.getNoteList());
	treeNodeList.add(topNode);
	topNode = createTopNode(DBObject.TYPE_GROUP, this.dbObjectSet
			.getGroupList());
	treeNodeList.add(topNode);

	return treeNodeList;
}
 
Example #12
Source File: SelectImportedSchemaDialog.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void perfomeOK() throws InputException {
	Object[] selectedNodes = this.viewer.getCheckedElements();

	this.resultSelectedSchemas.clear();

	for (int i = 0; i < selectedNodes.length; i++) {
		Object value = ((TreeNode) selectedNodes[i]).getValue();
		if (value instanceof String) {
			resultSelectedSchemas.add((String) value);
		}
	}
}
 
Example #13
Source File: SelectImportedSchemaDialog.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected void performOK() throws InputException {
    final Object[] selectedNodes = viewer.getCheckedElements();

    resultSelectedSchemas.clear();

    for (int i = 0; i < selectedNodes.length; i++) {
        final Object value = ((TreeNode) selectedNodes[i]).getValue();
        if (value instanceof String) {
            resultSelectedSchemas.add((String) value);
        }
    }
}
 
Example #14
Source File: SelectImportedObjectFromFileDialog.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected List<TreeNode> createTreeNodeList() {
    final List<TreeNode> treeNodeList = super.createTreeNodeList();

    TreeNode topNode = createTopNode(DBObject.TYPE_NOTE, dbObjectSet.getNoteList());
    treeNodeList.add(topNode);
    topNode = createTopNode(DBObject.TYPE_GROUP, dbObjectSet.getGroupList());
    treeNodeList.add(topNode);

    return treeNodeList;
}
 
Example #15
Source File: AbstractSelectImportedObjectDialog.java    From erflute with Apache License 2.0 5 votes vote down vote up
protected TreeNode createTopNode(String objectType, List<DBObject> dbObjectList) {
    final TreeNode treeNode = new TreeNode(new StringObjectModel(DisplayMessages.getMessage("label.object.type." + objectType)));
    final List<TreeNode> objectNodeList = new ArrayList<>();

    for (final DBObject dbObject : dbObjectList) {
        final TreeNode objectNode = new TreeNode(dbObject);
        objectNode.setParent(treeNode);

        objectNodeList.add(objectNode);
    }

    treeNode.setChildren(objectNodeList.toArray(new TreeNode[objectNodeList.size()]));

    return treeNode;
}
 
Example #16
Source File: AbstractSelectImportedObjectDialog.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected void setupData() {
    final List<TreeNode> treeNodeList = createTreeNodeList();

    final TreeNode[] treeNodes = treeNodeList.toArray(new TreeNode[treeNodeList.size()]);
    viewer.setInput(treeNodes);
    viewer.setCheckedElements(treeNodes);
    viewer.expandAll();
}
 
Example #17
Source File: Config.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public TreeNode[] createTreeNode() {
TreeNode components[] = new TreeNode[getFeatures().size()];
for (int i = 0; i < getFeatures().size(); i++) {
	TreeNode component = new TreeNode(getFeatures().get(i));
	component.setChildren(getFeatures().get(i).createTreeNode(component));
	components[i] = component;
}
return components;
  }
 
Example #18
Source File: ViewLabelProvider.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
public String getText(Object element) {
    final TreeNode treeNode = (TreeNode) element;

    final Object value = treeNode.getValue();
    if (value instanceof DBObject) {
        final DBObject dbObject = (DBObject) value;
        return dbObject.getName();
    } else if (value instanceof StringObjectModel) {
        final StringObjectModel object = (StringObjectModel) value;
        return object.getName();
    }

    return value.toString();
}
 
Example #19
Source File: Feature.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public TreeNode[] createTreeNode(TreeNode parent) {
	int size = getParams().size();
	TreeNode params[] = new TreeNode[size];
	for (int i = 0; i < size; i++) {
		TreeNode param = new TreeNode(getParams().get(i));
		param.setParent(parent);
		params[i] = param;
	}
	return params;
}
 
Example #20
Source File: CreateFeatureDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void buttonPressed(int buttonId) {
	setErrorMessage(null);
	if (buttonId == IDialogConstants.OK_ID) {
		if ("".equals(this.featureNameText.getText())) { //$NON-NLS-1$
			setErrorMessage(Messages.CreateFeatureDialog_FEATURE_NMAE_NOT_NULL); 
			return;
		}
		for(Feature feature : config.getFeatures()) {
			if(feature.getName().equals(this.featureNameText.getText())) {
				setErrorMessage(Messages.CreateFeatureDialog_FEATURE_NAME_DUP); 
				return;
			}
		}
		feature = new Feature();
		feature.setName(this.featureNameText.getText());
		config.addFeature(feature);
		TreeNode node = new TreeNode(feature);
		treeViewer.setInput(config.createTreeNode());
		treeViewer.collapseAll();
		StructuredSelection selection = new StructuredSelection(node);
		treeViewer.setSelection(selection, true);
		treeViewer.refresh();
		editor.setDirty(true);
		editor.change();
	} 
	super.buttonPressed(buttonId);
}
 
Example #21
Source File: ExportToTestDataDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private void setTestDataTable() {
    final List<TreeNode> treeNodeList = createTreeNodeList();

    final TreeNode[] treeNodes = treeNodeList.toArray(new TreeNode[treeNodeList.size()]);
    testDataTable.setInput(treeNodes);
    testDataTable.expandAll();
}
 
Example #22
Source File: PShelfViewerSnippet1.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void createModel() {
	myModel = new MyTreeNode("All");
	TreeNode list = new MyTreeNode("List");
	TreeNode tree = new MyTreeNode("Tree");
	myModel.setChildren(new TreeNode[] { list, tree });

	list.setChildren(new TreeNode[] {
		new MyTreeNode("List item 1"),	new MyTreeNode("List item 2")
	});

	MyTreeNode treeNode1 = new MyTreeNode("Tree item 1");
	tree.setChildren(new TreeNode[] { treeNode1, new MyTreeNode("Tree item 2") });
	treeNode1.setChildren(new TreeNode[] { new MyTreeNode("Sub item 1.1") });
}
 
Example #23
Source File: SelectImportedSchemaDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void perfomeOK() throws InputException {
    final Object[] selectedNodes = viewer.getCheckedElements();

    resultSelectedSchemas.clear();

    for (int i = 0; i < selectedNodes.length; i++) {
        final Object value = ((TreeNode) selectedNodes[i]).getValue();
        if (value instanceof String) {
            resultSelectedSchemas.add((String) value);
        }
    }
}
 
Example #24
Source File: SelectImportedObjectFromFileDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
@Override
protected List<TreeNode> createTreeNodeList() {
    final List<TreeNode> treeNodeList = super.createTreeNodeList();

    TreeNode topNode = createTopNode(DBObject.TYPE_NOTE, dbObjectSet.getNoteList());
    treeNodeList.add(topNode);
    topNode = createTopNode(DBObject.TYPE_GROUP, dbObjectSet.getGroupList());
    treeNodeList.add(topNode);

    return treeNodeList;
}
 
Example #25
Source File: AbstractSelectImportedObjectDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
protected TreeNode createTopNode(final String objectType, final List<DBObject> dbObjectList) {
    final TreeNode treeNode = new TreeNode(new StringObjectModel(ResourceString.getResourceString("label.object.type." + objectType)));
    final List<TreeNode> objectNodeList = new ArrayList<TreeNode>();

    for (final DBObject dbObject : dbObjectList) {
        final TreeNode objectNode = new TreeNode(dbObject);
        objectNode.setParent(treeNode);

        objectNodeList.add(objectNode);
    }

    treeNode.setChildren(objectNodeList.toArray(new TreeNode[objectNodeList.size()]));

    return treeNode;
}
 
Example #26
Source File: OutlinePage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.8
 */
protected void showBusyStatus() {
	TreeViewer treeViewer = getTreeViewer();
	treeViewer.setLabelProvider(busyLabelProvider);
	treeViewer.setContentProvider(new TreeNodeContentProvider());
	treeViewer.setInput(new TreeNode[] { new TreeNode("Loading...") });
}
 
Example #27
Source File: CreateParamDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void buttonPressed(int buttonId) {
	setErrorMessage(null);
	if (buttonId == IDialogConstants.OK_ID) {
		if ("".equals(this.paramNameText.getText())) { //$NON-NLS-1$
			setErrorMessage("param\u540D\u4E0D\u80FD\u4E3A\u7A7A"); //$NON-NLS-1$
			return;
		}
		if ("".equals(this.paramValueText.getText())) { //$NON-NLS-1$
			setErrorMessage("param\u503C\u4E0D\u80FD\u4E3A\u7A7A"); //$NON-NLS-1$
			return;
		}
		StructuredSelection ss = (StructuredSelection)list.getSelection();
		Feature feature = (Feature)ss.getFirstElement();
		
		for(Param param : feature.getParams()) {
			if(param.getName().equals(this.paramNameText.getText())) {
				setErrorMessage(Messages.PARAMNAMEREPEAT); //$NON-NLS-1$
				return;
			}
		}
		Param p = new Param();
		p.setName(this.paramNameText.getText());
		p.setValue(this.paramValueText.getText());
		
		feature.addParams(p);
		TreeNode node = new TreeNode(p);
		node.setParent(new TreeNode(feature));
		treeViewer.setInput(config.createTreeNode());
		treeViewer.collapseAll();
		StructuredSelection selection = new StructuredSelection(node);
		treeViewer.setSelection(selection, true);
		treeViewer.refresh();
		editor.setDirty(true);
		editor.change();
	} 
	super.buttonPressed(buttonId);
}
 
Example #28
Source File: OutlinePage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String doGetText(Object element) {
	if (element instanceof TreeNode) {
		TreeNode node = (TreeNode) element;
		return String.valueOf(node.getValue());
	}
	return super.getText(element);
}
 
Example #29
Source File: AbstractSelectImportedObjectDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
@Override
protected void setData() {
    final List<TreeNode> treeNodeList = createTreeNodeList();

    final TreeNode[] treeNodes = treeNodeList.toArray(new TreeNode[treeNodeList.size()]);
    viewer.setInput(treeNodes);
    viewer.setCheckedElements(treeNodes);
    viewer.expandAll();
}
 
Example #30
Source File: TextUMLLabelProvider.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
public Image getImage(Object element) {
    UIModelObject model = (UIModelObject) ((TreeNode) element).getValue();
    return model.getImage();
}