Java Code Examples for org.eclipse.jface.viewers.TreeNode#setParent()

The following examples show how to use org.eclipse.jface.viewers.TreeNode#setParent() . 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 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 2
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 3
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 4
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 5
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 6
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 7
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 8
Source File: AbstractSelectImportedObjectDialog.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
protected List<TreeNode> createTreeNodeList() {
    final List<TreeNode> treeNodeList = new ArrayList<TreeNode>();

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

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

    for (final Map.Entry<String, List<DBObject>> entry : dbObjectSet.getSchemaDbObjectListMap().entrySet()) {
        String schemaName = entry.getKey();
        if ("".equals(schemaName)) {
            schemaName = ResourceString.getResourceString("label.none");
        }
        final TreeNode schemaNode = new TreeNode(new StringObjectModel(schemaName));
        schemaNode.setParent(topNode);
        schemaNodeList.add(schemaNode);

        final List<DBObject> dbObjectList = entry.getValue();

        final TreeNode[] objectTypeNodes = new TreeNode[DBObject.ALL_TYPES.length];

        for (int i = 0; i < DBObject.ALL_TYPES.length; i++) {
            objectTypeNodes[i] = new TreeNode(new StringObjectModel(ResourceString.getResourceString("label.object.type." + DBObject.ALL_TYPES[i])));

            final List<TreeNode> objectNodeList = new ArrayList<TreeNode>();

            for (final DBObject dbObject : dbObjectList) {
                if (DBObject.ALL_TYPES[i].equals(dbObject.getType())) {
                    final TreeNode objectNode = new TreeNode(dbObject);
                    objectNode.setParent(objectTypeNodes[i]);

                    objectNodeList.add(objectNode);
                }
            }

            objectTypeNodes[i].setChildren(objectNodeList.toArray(new TreeNode[objectNodeList.size()]));
        }

        schemaNode.setChildren(objectTypeNodes);
    }

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

    topNode = createTopNode(DBObject.TYPE_TABLESPACE, dbObjectSet.getTablespaceList());
    treeNodeList.add(topNode);

    return treeNodeList;
}
 
Example 9
Source File: SelectImportedSchemaDialog.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
protected List<TreeNode> createTreeNodeList() {

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

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

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

        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 10
Source File: ExportToTestDataDialog.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
protected List<TreeNode> createTreeNodeList() {
    final List<TreeNode> treeNodeList = new ArrayList<TreeNode>();

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

    final List<TreeNode> nodeList = new ArrayList<TreeNode>();

    for (final TestData testData : testDataList) {
        final TreeNode objectNode = new TreeNode(testData);
        objectNode.setParent(topNode);

        nodeList.add(objectNode);
    }

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

    return treeNodeList;
}
 
Example 11
Source File: AbstractSelectImportedObjectDialog.java    From erflute with Apache License 2.0 4 votes vote down vote up
protected List<TreeNode> createTreeNodeList() {
    final List<TreeNode> treeNodeList = new ArrayList<>();

    TreeNode topNode = new TreeNode(new StringObjectModel(DisplayMessages.getMessage("label.schema")));
    treeNodeList.add(topNode);

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

    for (final Map.Entry<String, List<DBObject>> entry : dbObjectSet.getSchemaDbObjectListMap().entrySet()) {
        String schemaName = entry.getKey();
        if ("".equals(schemaName)) {
            schemaName = DisplayMessages.getMessage("label.none");
        }
        final TreeNode schemaNode = new TreeNode(new StringObjectModel(schemaName));
        schemaNode.setParent(topNode);
        schemaNodeList.add(schemaNode);

        final List<DBObject> dbObjectList = entry.getValue();

        final TreeNode[] objectTypeNodes = new TreeNode[DBObject.ALL_TYPES.length];

        for (int i = 0; i < DBObject.ALL_TYPES.length; i++) {
            objectTypeNodes[i] =
                    new TreeNode(new StringObjectModel(DisplayMessages.getMessage("label.object.type." + DBObject.ALL_TYPES[i])));

            final List<TreeNode> objectNodeList = new ArrayList<>();

            for (final DBObject dbObject : dbObjectList) {
                if (DBObject.ALL_TYPES[i].equals(dbObject.getType())) {
                    final TreeNode objectNode = new TreeNode(dbObject);
                    objectNode.setParent(objectTypeNodes[i]);

                    objectNodeList.add(objectNode);
                }
            }

            objectTypeNodes[i].setChildren(objectNodeList.toArray(new TreeNode[objectNodeList.size()]));
        }

        schemaNode.setChildren(objectTypeNodes);
    }

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

    topNode = createTopNode(DBObject.TYPE_TABLESPACE, dbObjectSet.getTablespaceList());
    treeNodeList.add(topNode);

    return treeNodeList;
}
 
Example 12
Source File: AbstractSelectImportedObjectDialog.java    From ermaster-b with Apache License 2.0 4 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 (Map.Entry<String, List<DBObject>> entry : dbObjectSet
			.getSchemaDbObjectListMap().entrySet()) {
		String schemaName = entry.getKey();
		if ("".equals(schemaName)) {
			schemaName = ResourceString.getResourceString("label.none");
		}
		TreeNode schemaNode = new TreeNode(
				new StringObjectModel(schemaName));
		schemaNode.setParent(topNode);
		schemaNodeList.add(schemaNode);

		List<DBObject> dbObjectList = entry.getValue();

		TreeNode[] objectTypeNodes = new TreeNode[DBObject.ALL_TYPES.length];

		for (int i = 0; i < DBObject.ALL_TYPES.length; i++) {
			objectTypeNodes[i] = new TreeNode(new StringObjectModel(
					ResourceString.getResourceString("label.object.type."
							+ DBObject.ALL_TYPES[i])));

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

			for (DBObject dbObject : dbObjectList) {
				if (DBObject.ALL_TYPES[i].equals(dbObject.getType())) {
					TreeNode objectNode = new TreeNode(dbObject);
					objectNode.setParent(objectTypeNodes[i]);

					objectNodeList.add(objectNode);
				}
			}

			objectTypeNodes[i].setChildren(objectNodeList
					.toArray(new TreeNode[objectNodeList.size()]));
		}

		schemaNode.setChildren(objectTypeNodes);
	}

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

	topNode = createTopNode(DBObject.TYPE_TABLESPACE, this.dbObjectSet
			.getTablespaceList());
	treeNodeList.add(topNode);

	return treeNodeList;
}