Java 类org.eclipse.jface.viewers.TreeNode 实例源码

项目:ermasterr    文件:ViewLabelProvider.java   
@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();
}
项目:ermasterr    文件:AbstractSelectImportedObjectDialog.java   
/**
 * {@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();
}
项目:ermaster-k    文件:ViewLabelProvider.java   
@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();

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

    }

    return value.toString();
}
项目:ermaster-k    文件:AbstractSelectImportedObjectDialog.java   
/**
 * {@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();
}
项目:ermaster-k    文件:AbstractSelectImportedObjectDialog.java   
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;
}
项目:ermaster-k    文件:SelectImportedSchemaDialog.java   
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;
    }
项目:ermaster-k    文件:ExportToTestDataDialog.java   
protected List<TreeNode> createTreeNodeList() {
    List<TreeNode> treeNodeList = new ArrayList<TreeNode>();

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

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

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

        nodeList.add(objectNode);
    }

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

    return treeNodeList;
}
项目:erflute    文件:AbstractSelectImportedObjectDialog.java   
@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();
}
项目:erflute    文件:SelectImportedSchemaDialog.java   
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;
}
项目:ermaster-nhit    文件:ViewLabelProvider.java   
@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();

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

    }

    return value.toString();
}
项目:ermaster-nhit    文件:AbstractSelectImportedObjectDialog.java   
/**
 * {@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();
}
项目:ermaster-nhit    文件:AbstractSelectImportedObjectDialog.java   
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;
}
项目:ermaster-nhit    文件:SelectImportedSchemaDialog.java   
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;
    }
项目:ermaster-nhit    文件:ExportToTestDataDialog.java   
protected List<TreeNode> createTreeNodeList() {
    List<TreeNode> treeNodeList = new ArrayList<TreeNode>();

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

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

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

        nodeList.add(objectNode);
    }

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

    return treeNodeList;
}
项目:emfstore-rest    文件:LogMessageColumnLabelProvider.java   
/**
 * {@inheritDoc}
 */
@Override
public String getText(Object element) {
    if (element instanceof TreeNode && !(((TreeNode) element).getValue() instanceof HistoryInfo)) {
        String toolTipText = super.getToolTipText(element);
        return toolTipText;
    } else if (element instanceof HistoryInfo) {
        LogMessage logMessage = null;
        HistoryInfo historyInfo = (HistoryInfo) element;
        StringBuilder builder = new StringBuilder();
        if (historyInfo.getLogMessage() != null) {
            logMessage = historyInfo.getLogMessage();
        } else if (historyInfo.getChangePackage() != null && historyInfo.getChangePackage().getLogMessage() != null) {
            logMessage = historyInfo.getChangePackage().getLogMessage();
        }
        if (logMessage != null) {
            builder.append(logMessage.getMessage());
        }
        return builder.toString();
    }
    return null;
}
项目:idecore    文件:PackageTreeNode.java   
@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (!super.equals(obj))
        return false;
    if (getClass() != obj.getClass())
        return false;
    PackageTreeNode other = (PackageTreeNode) obj;
    if (value == null) {
        if (other.value != null)
            return false;
    } else if (!value.equals(other.getValue())) {
        return false;
    } else {
        final TreeNode parent = getParent();
        while (parent != null) {
            if (!parent.equals(other.getParent())) {
                return false;
            }
break;
        }
    }
    return true;
}
项目:textuml    文件:SourceContentOutlinePage.java   
@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();
}
项目:SVoNt    文件:ConceptTree.java   
private static TreeNode buildConceptTree(TreeNode parent,OWLClass cl,OWLReasoner r) throws OWLReasonerException {
    ConceptTreeNode ctn = new ConceptTreeNode(cl);


    TreeNode td = new TreeNode(ctn);
    td.setParent(parent);
    ArrayList<TreeNode> childs = new ArrayList<TreeNode>();

    //recursivly build up tree
    Set<Set<OWLClass>> subs = r.getSubClasses(cl);
    for (Set<OWLClass> eqSubs:subs) {
        for (OWLClass sub:eqSubs) {
            if (sub != ontologyStore.getOntologyManager().getOWLDataFactory().getOWLNothing())
                childs.add(buildConceptTree(td, sub,r));
        }
    }

    if( !childs.isEmpty())
        td.setChildren(childs.toArray(new TreeNode[0]));
    else td.setChildren(null);
    return td;
}
项目:ermasterr    文件:AbstractSelectImportedObjectDialog.java   
@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();
}
项目:ermasterr    文件:AbstractSelectImportedObjectDialog.java   
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;
}
项目:ermasterr    文件:SelectImportedObjectFromFileDialog.java   
@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;
}
项目:ermasterr    文件:SelectImportedSchemaDialog.java   
/**
 * {@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);
        }
    }
}
项目:ermasterr    文件:ExportToTestDataDialog.java   
private void setTestDataTable() {
    final List<TreeNode> treeNodeList = createTreeNodeList();

    final TreeNode[] treeNodes = treeNodeList.toArray(new TreeNode[treeNodeList.size()]);
    testDataTable.setInput(treeNodes);
    testDataTable.expandAll();
}
项目:xstreamer    文件:ArmyContentProvider.java   
@Override
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof IASpec) {
        IASpec iaspec = (IASpec) parentElement;
        return iaspec.getArmy().getDeployments().toArray();
    }

    if (parentElement instanceof TreeNode) {
        TreeNode treenode = (TreeNode) parentElement;
        return treenode.getChildren();
    }

    return EMPTY_ARRAY;
}
项目:xstreamer    文件:ArmyContentProvider.java   
@Override
public boolean hasChildren(Object element) {
    if (element instanceof IASpec) {
        return true;
    }

    if (element instanceof TreeNode) {
        return ((TreeNode) element).hasChildren();
    }

    return false;
}
项目:xstreamer    文件:CommandCardsTreeNode.java   
@Override
public TreeNode[] getChildren() {
    List<CommandCardTreeNode> treeNodes = new ArrayList<>();

    for (CommandCards commandCard : commandCards) {
        CommandCardTreeNode node = new CommandCardTreeNode(commandCard.getCommandCard());
        treeNodes.add(node);
    }

    return treeNodes.toArray(new TreeNode[treeNodes.size()]);
}
项目:xstreamer    文件:ArmyTreeNode.java   
@Override
public TreeNode[] getChildren() {
    List<DeploymentTreeNode> treeNodes = new ArrayList<>();

    for (Deployments deployments : deployments) {
        DeploymentTreeNode node = new DeploymentTreeNode(deployments.getDeployment());
        treeNodes.add(node);
    }

    return treeNodes.toArray(new TreeNode[treeNodes.size()]);
}
项目:xstreamer    文件:SquadContentProvider.java   
@Override
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof XwsSpec) {
        XwsSpec xwsspec = (XwsSpec) parentElement;
        return xwsspec.getPilots().toArray();
    }

    if (parentElement instanceof TreeNode) {
        TreeNode treenode = (TreeNode) parentElement;
        return treenode.getChildren();
    }

    return EMPTY_ARRAY;
}
项目:xstreamer    文件:SquadContentProvider.java   
@Override
public boolean hasChildren(Object element) {
    if (element instanceof XwsSpec) {
        return true;
    }

    if (element instanceof TreeNode) {
        return ((TreeNode) element).hasChildren();
    }

    return false;
}
项目:xstreamer    文件:PilotTreeNode.java   
@Override
public TreeNode[] getChildren() {
    List<UpgradeTreeNode> upgrades = new ArrayList<>();
    for (Entry<String, Object> entry : this.upgrades.getAdditionalProperties().entrySet()) {
        UpgradeTreeNode upgradesTreeNode = new UpgradeTreeNode(entry.getKey(), (List<String>) entry.getValue(), this.upgrades);
        upgrades.add(upgradesTreeNode);
    }

    return upgrades.toArray(new TreeNode[upgrades.size()]);
}
项目:xstreamer    文件:UpgradeTreeNode.java   
@Override
public TreeNode[] getChildren() {
    List<UpgradeTypeTreeNode> upgradeType = new ArrayList();


    for(String upgradeName : upgradeOptions) {
        UpgradeTypeTreeNode treeNode = new UpgradeTypeTreeNode(upgradeName, parentUpgrades.findUpgrade(upgradeName));
        upgradeType.add(treeNode);
    }
    return upgradeType.toArray(new TreeNode[upgradeType.size()]);
}
项目:xstreamer    文件:XWSquadTreeNode.java   
@Override
public TreeNode[] getChildren() {
    List<PilotTreeNode> treeNodes = new ArrayList<>();
    for (Pilot pilot : playerModel.getPilots()) {
        PilotTreeNode node = new PilotTreeNode(pilot);
        treeNodes.add(node);
    }
    return treeNodes.toArray(new TreeNode[treeNodes.size()]);
}
项目:ermaster-k    文件:AbstractSelectImportedObjectDialog.java   
@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();
}
项目:ermaster-k    文件:SelectImportedObjectFromFileDialog.java   
@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;
}
项目:ermaster-k    文件:SelectImportedSchemaDialog.java   
/**
 * {@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);
        }
    }
}
项目:ermaster-k    文件:ExportToTestDataDialog.java   
private void setTestDataTable() {
    List<TreeNode> treeNodeList = createTreeNodeList();

    TreeNode[] treeNodes = treeNodeList.toArray(new TreeNode[treeNodeList
            .size()]);
    this.testDataTable.setInput(treeNodes);
    this.testDataTable.expandAll();
}
项目:APICloud-Studio    文件:CreateParamDialog.java   
@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);
}
项目:APICloud-Studio    文件:CreateFeatureDialog.java   
@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);
}
项目:APICloud-Studio    文件:Config.java   
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;
  }
项目:APICloud-Studio    文件:Feature.java   
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;
}