Example usage for org.eclipse.jface.viewers TreeNode getChildren

List of usage examples for org.eclipse.jface.viewers TreeNode getChildren

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers TreeNode getChildren.

Prototype

public TreeNode[] getChildren() 

Source Link

Document

Returns the child nodes.

Usage

From source file:com.bluexml.side.application.ui.action.tree.ConfigurationContentProvider.java

License:Open Source License

public Object[] getChildren(Object object) {
    if (object instanceof TreeNode) {
        TreeNode elt = (TreeNode) object;
        Object[] arr = elt.getChildren().toArray();
        ArrayList<Object> result = new ArrayList<Object>();
        // System.out.println("getChildren from :" + elt);
        for (Object o : arr) {
            if (o instanceof TreeNode) {
                TreeNode tn = (TreeNode) o;
                if (!tn.isToHidde()) {
                    result.add(tn);//from  www .ja  v  a2s.c om
                    // System.err.println("getChildrens ADD :" + tn);
                } else {
                    // System.err.println("getChildrens HIDDEN :" + tn);
                }
            } else {
                // System.out.println("NOT TREE NODE :" + o);
            }
        }
        return result.toArray();
    }
    // System.out.println("Very Bad !");
    return null;
}

From source file:com.bluexml.side.application.ui.action.tree.ConfigurationContentProvider.java

License:Open Source License

private boolean cleanupBranch(TreeNode tn) {
    boolean result = false;
    for (TreeNode child : tn.getChildren()) {
        if (child instanceof ImplNode) {
            if (!child.isToHidde()) {
                result = true;/*w w  w  . jav a 2  s . co  m*/
            }
        } else if (child.getChildren().size() > 0) {
            for (TreeNode c : tn.getChildren()) {
                result = result | cleanupBranch(c);
            }
        }
    }
    if (!result) {
        tn.setToHidde(true);
    }
    return result;
}

From source file:com.bluexml.side.application.ui.action.tree.ConfigurationContentProvider.java

License:Open Source License

/**
 * @param mm/*from  w w w .  j  av  a  2  s . com*/
 */
private void printTree_(TreeNode mm, int level) {
    String identation = "";
    for (int i = 0; i < level; i++) {
        identation += "\t";
    }
    System.out.println(identation + mm);
    Collection<TreeNode> chidren = mm.getChildren();
    for (TreeNode treeNode : chidren) {
        printTree_(treeNode, level + 1);
    }
}

From source file:com.htmlhifive.tools.wizard.library.LibraryList.java

License:Apache License

/**
 * ?.<br>// w  ww . ja va2 s.  c o m
 * 
 * @param jsProject JS
 * @param projectName ??
 * @param defaultJsLibPath JS
 * @param rootNode 
 * @return ?.
 */
public IContainer[] checkLibrary(IJavaScriptProject jsProject, String projectName, String defaultJsLibPath,
        RootNode rootNode) {

    // TODO:?
    //      IContainer defaultInstallContainer = null;
    //      if (StringUtils.isNotEmpty(defaultJsLibPath)) {
    //         // ????????????????.
    //         defaultInstallContainer =
    //               ResourcesPlugin.getWorkspace().getRoot().getProject(projectName)
    //               .getFolder(Path.fromOSString(defaultJsLibPath));
    //      }

    IContainer[] checkContainers = getCheckContainers(jsProject);

    rootNode.setDefaultInstallPath(defaultJsLibPath);
    rootNode.setDefaultProjectPath(jsProject != null ? jsProject.getProject()
            : ResourcesPlugin.getWorkspace().getRoot().getProject(projectName));

    if (rootNode.getChildren() == null) {
        return checkContainers;
    }
    for (TreeNode node : rootNode.getChildren()) {
        CategoryNode categoryNode = (CategoryNode) node;

        categoryNode.setParentPath(null);

        // LibraryNode?????
        for (TreeNode node2 : node.getChildren()) {
            LibraryNode libraryNode = (LibraryNode) node2;

            // ?.
            libraryNode.setRecommended(libraryRefMap.containsValue(libraryNode.getValue()));

            // ?.
            //            if (jsProject != null) {
            libraryNode.setExists(false);
            libraryNode.setState(LibraryState.DEFAULT);

            boolean libraryFullExists = false;
            boolean libraryExists = false;
            IContainer lastContainer = null;
            List<String> lastExistsFileList = null;
            List<String> lastAllFileList = null;
            //List<String> lastNoExistsFileList = null;

            if (checkContainers.length == 0) {
                // ???????(??????????).
                List<String> noExistsFileList = new ArrayList<String>();
                for (Site site : libraryNode.getValue().getSite()) {
                    checkSite(site, null, categoryNode.getInstallSubPath(), null, noExistsFileList);
                }

                libraryNode.setFileList(noExistsFileList.toArray(new String[0]));
                libraryNode.setExists(false); // false??????
                libraryNode.setIncomplete(false);

                continue;
            }

            // Container?????
            for (IContainer container : checkContainers) {
                IContainer folder = container;

                List<String> existsFileList = new ArrayList<String>();
                List<String> noExistsFileList = new ArrayList<String>();
                List<String> allFileList = new ArrayList<String>();

                if (folder.exists()) {//if (folder.getRawLocation() != null) {project?????.
                    // Site?????
                    boolean allExists = true;
                    for (Site site : libraryNode.getValue().getSite()) {
                        // ???????????
                        if (checkSite(site, folder, categoryNode.getInstallSubPath(), existsFileList,
                                noExistsFileList)) {
                            // ???.
                            libraryExists = true;
                            lastExistsFileList = existsFileList;
                            //lastNoExistsFileList = noExistsFileList;
                            lastContainer = container;
                        } else {
                            // ?????.
                            allExists = false;
                        }
                    }
                    allFileList.addAll(existsFileList);
                    allFileList.addAll(noExistsFileList);
                    lastAllFileList = allFileList;

                    // Site??????
                    if (allExists) {
                        // ??????.
                        libraryFullExists = true;
                        lastContainer = container;
                        break;
                    }
                }
            }
            // Container??????

            if (libraryFullExists) {
                // ?????.
                categoryNode.setParentPath(lastContainer);
                libraryNode.setFileList(lastExistsFileList.toArray(new String[0]));
                libraryNode.setExists(true);
                libraryNode.setIncomplete(false);
                libraryNode.setState(LibraryState.EXISTS);
            } else if (libraryExists) {
                // ????.
                categoryNode.setParentPath(lastContainer);
                libraryNode.setFileList(lastExistsFileList.toArray(new String[0]));
                libraryNode.setExists(false); // false??????
                libraryNode.setIncomplete(true);
                // ?????
                //for (String name : lastNoExistsFileList) {
                //   H5LogUtils.putLog(null, Messages.SE0081, name);
                //}
            } else {
                // ???????(??????????).
                libraryNode.setFileList(lastAllFileList.toArray(new String[0]));
                libraryNode.setExists(false); // false??????
                libraryNode.setIncomplete(false);
            }
            //            }
        }
        // LibraryNode??????
    }
    return checkContainers;
}

From source file:com.nokia.carbide.cdt.internal.api.builder.ui.ManageConfigurationsDialog.java

License:Open Source License

private void propagateSdkTree() {
    List<ICarbideBuildConfiguration> buildConfigList = cpi.getBuildConfigurations();
    TreeItem[] items = properSdkViewer.getTree().getItems();
    for (int i = 0; i < items.length; i++) {
        TreeNode sdkNode = (TreeNode) items[i].getData();
        if (sdkNode.getValue() instanceof ISymbianSDK && sdkNode.hasChildren()) {
            TreeNode[] configNode = sdkNode.getChildren();
            for (TreeNode currConfigNode : configNode) {
                if (currConfigNode.getValue() instanceof ISymbianBuildContext) {
                    // if the current config is already a config set it to checked.
                    ISymbianBuildContext buildContext = (ISymbianBuildContext) currConfigNode.getValue();
                    for (ICarbideBuildConfiguration currExistingConfig : buildConfigList) {
                        boolean checkIt = false;
                        checkIt = currExistingConfig.getBuildContext().equals(buildContext);
                        if (CarbideBuilderPlugin.getBuildManager().isCarbideSBSv2Project(cpi.getProject())
                                && !checkIt) {

                            if (buildContext instanceof ISBSv2BuildContext) {
                                ISBSv2BuildContext v2Context = (ISBSv2BuildContext) buildContext;
                                ISBSv2BuildContext currV2Context = (ISBSv2BuildContext) currExistingConfig
                                        .getBuildContext();
                                // extra check to see if we're using SBSv2 and config display name is older SBSv1 style
                                if (currV2Context.getConfigID().startsWith(ISBSv2BuildContext.BUILDER_ID)) {
                                    if (v2Context.getConfigID().equals(currV2Context.getConfigID())) {
                                        checkIt = true;
                                    }/* www . j  a  v  a2  s . c o m*/
                                }
                            }
                        }
                        if (checkIt) {
                            // must expand parent before checking, otherwise, we won't succeed
                            properSdkViewer.setExpandedState(sdkNode, true);
                            properSdkViewer.setChecked(currConfigNode, true);
                            break;
                        }
                    }
                }
            }
        }
    }
    properSdkViewer.refresh();
}

From source file:com.nokia.carbide.cdt.internal.api.builder.ui.ManageConfigurationsDialog.java

License:Open Source License

private void saveConfigurations() {

    // get the modifier
    ICarbideProjectModifier cpm = CarbideBuilderPlugin.getBuildManager().getProjectModifier(cpi.getProject());

    // First go through all the checked tree items and add any configurations that are checked that don't already exist
    Object[] checkedElements = properSdkViewer.getCheckedElements();
    //List<ICarbideBuildConfiguration> buildConfigList = new ArrayList<ICarbideBuildConfiguration>();
    List<ICarbideBuildConfiguration> buildConfigList = cpm.getBuildConfigurations();

    for (Object obj : checkedElements) {
        TreeNode node = (TreeNode) obj;
        boolean configAlreadyExists = false;
        if (node.getValue() instanceof ISymbianBuildContext) {
            ISymbianBuildContext context = (ISymbianBuildContext) node.getValue();
            // Now check to see if the config already exists, if not create a new one
            for (ICarbideBuildConfiguration currExistingConfig : buildConfigList) {
                if (currExistingConfig.getBuildContext().equals(context)) {
                    configAlreadyExists = true;
                    break;
                }//from w w w.  j  av  a  2 s  .c  o m
            }

            if (!configAlreadyExists) {
                cpm.createNewConfiguration(context, false);
            }
        }
    }

    // Now check for good SDK configurations we need to remove. We need to be very careful here because a user may have a configuration
    // in the .settings but it may not actually appear in the tree view because the SDK is currently invalid or the license expired
    // so we cannot delete these.
    buildConfigList = cpm.getBuildConfigurations(); // get the list again as we may have added to it
    Iterator<ICarbideBuildConfiguration> configListIter = buildConfigList.iterator();
    while (configListIter.hasNext()) {
        ICarbideBuildConfiguration currExistingConfig = configListIter.next();
        TreeItem[] items = properSdkViewer.getTree().getItems();
        for (TreeItem currTreeItem : items) {
            TreeNode sdkNode = (TreeNode) currTreeItem.getData();
            if (sdkNode.getValue() instanceof ISymbianSDK) {
                TreeNode[] configNode = sdkNode.getChildren();
                if (configNode != null) {
                    for (TreeNode currConfigNode : configNode) {
                        if (currConfigNode.getValue() instanceof ISymbianBuildContext) {
                            // if the current config is already a config set it to checked.
                            ISymbianBuildContext buildContext = (ISymbianBuildContext) currConfigNode
                                    .getValue();
                            if (currExistingConfig.getBuildContext().equals(buildContext)) {
                                // The configuration is in both the tree viewer and the .settings
                                // Now find out if it's checked. If it's not checked remove it
                                if (!properSdkViewer.getChecked(currConfigNode)) {
                                    ICarbideBuildConfiguration config = cpm
                                            .getNamedConfiguration(buildContext.getDisplayString());
                                    if (config == null) {
                                        config = cpm
                                                .getNamedConfiguration(currExistingConfig.getDisplayString());
                                    }
                                    if (config != null) {
                                        cpm.deleteConfiguration(config);
                                        break;
                                    }

                                }
                            }
                        }
                    }
                }
            }
        }
    }

    // now apply any changes
    cpm.saveChanges();
}

From source file:com.nokia.carbide.cpp.internal.project.ui.importWizards.ImporterBuildTargetsPage.java

License:Open Source License

@Override
public void setVisible(boolean visible) {
    super.setVisible(visible);

    // this gets called just before the page goes in or out of view.  if it's
    // going into view first the first time then check the default build configs.
    // only do this if we haven't already done it though - check to see if the
    // bld.inf file has changed.
    if (visible) {
        if (parsedBldInfFile == null || !parsedBldInfFile.equals(theWizard.getBldInfFile())) {
            // start with a clean slate
            viewer.setAllChecked(false);
            viewer.collapseAll();/*w  ww .  j  a  v  a  2 s  .c  om*/
            // loop through all SDK's and see if the epocroot is the
            // root of the bld.inf file path.  if so then auto select
            // that SDK and all of its build configurtions.
            parsedBldInfFile = theWizard.getBldInfFile();
            ISDKManager sdkMgr = SDKCorePlugin.getSDKManager();
            for (ISymbianSDK sdk : sdkMgr.getSDKList()) {
                if (parsedBldInfFile.toLowerCase().startsWith(sdk.getEPOCROOT().toLowerCase())) {
                    TreeItem[] items = viewer.getTree().getItems();
                    for (int i = 0; i < items.length; i++) {
                        TreeNode node = (TreeNode) items[i].getData();
                        if (node.getValue() instanceof ISymbianSDK && node.getValue() == sdk) {
                            IBSFCatalog bsfCatalog = null;
                            ISBSv1BuildInfo sbsv1BuildInfo = null;
                            if (SBSv2Utils.enableSBSv1Support()) {
                                sbsv1BuildInfo = (ISBSv1BuildInfo) sdk
                                        .getBuildInfo(ISymbianBuilderID.SBSV1_BUILDER);
                            }

                            ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo) sdk
                                    .getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER);
                            if (sbsv1BuildInfo != null) {
                                // SBSv1 only
                                bsfCatalog = sbsv1BuildInfo.getBSFCatalog();
                            }
                            if (HostOS.IS_WIN32
                                    && (((SDKManager) sdkMgr).getBSFScannerEnabled() || (bsfCatalog != null
                                            && bsfCatalog.getVirtualVariantPlatforms().length > 0))) {
                                // Check and see if any of the configs in the SDK
                                // match any configuration that has been selected before
                                // for this SDK.
                                String selectedConfigsStore[] = getPreviouslySelectedConfigs();
                                viewer.setExpandedState(node, true); // must expand parent before checking, otherwise, we won't succeed
                                viewer.setChecked(node, false);
                                for (TreeNode configNode : node.getChildren()) {
                                    if (configNode.getValue() instanceof ISymbianBuildContext) {
                                        for (String currConfigStr : selectedConfigsStore) {
                                            ISymbianBuildContext context = (ISymbianBuildContext) (configNode
                                                    .getValue());
                                            if (currConfigStr.equals(context.getDisplayString())) {
                                                viewer.setChecked(configNode, true);
                                                break;
                                            }
                                        }

                                    }
                                }

                            } else {
                                viewer.setChecked(node, true);
                            }
                            viewer.setExpandedState(node, true);
                            break;
                        }
                    }
                }
            }
            setPageComplete(validatePage());
        }
    }
}

From source file:com.nokia.carbide.remoteconnections.settings.ui.ConnectionSettingsPage.java

License:Open Source License

private TreeNode findTreeNodeForPair(TreeNode[] treeNodes, Pair<String, String> pair) {
    for (TreeNode treeNode : treeNodes) {
        Object value = treeNode.getValue();
        if (value instanceof IRemoteAgentInstaller) {
            TreeNode versionNode = treeNode.getParent();
            TreeNode familyNode = versionNode.getParent();
            if (ObjectUtils.equals(pair.first, familyNode.getValue())
                    && ObjectUtils.equals(pair.second, versionNode.getValue()))
                return treeNode;
        }/*from   w  w w  . ja v a 2s . c o  m*/
        TreeNode[] children = treeNode.getChildren();
        if (children != null) {
            TreeNode treeNodeFromChildren = findTreeNodeForPair(children, pair);
            if (treeNodeFromChildren != null)
                return treeNodeFromChildren;
        }
    }
    return null;
}

From source file:com.nokia.carbide.remoteconnections.settings.ui.ConnectionSettingsPage.java

License:Open Source License

private void createFamilySubNodes(TreeNode familyNode, IRemoteAgentInstallerProvider installerProvider) {
    String familyName = familyNode.getValue().toString();
    List<String> versions = installerProvider.getVersions(familyName);
    List<TreeNode> childList = new ArrayList<TreeNode>();
    TreeNode[] children = familyNode.getChildren();
    if (children != null)
        childList.addAll(Arrays.asList(children));
    for (String version : versions) {
        TreeNode versionNode = getVersionNode(familyNode, version);
        if (versionNode == null) {
            versionNode = new TreeNode(version);
            versionNode.setParent(familyNode);
            childList.add(versionNode);//from w w  w.  j  av  a2  s . co m
        }
        createInstallerNodes(versionNode, installerProvider);
    }
    familyNode.setChildren((TreeNode[]) childList.toArray(new TreeNode[childList.size()]));
}

From source file:com.nokia.carbide.remoteconnections.settings.ui.ConnectionSettingsPage.java

License:Open Source License

private TreeNode getVersionNode(TreeNode familyNode, String version) {
    TreeNode[] children = familyNode.getChildren();
    if (children != null) {
        for (TreeNode node : children) {
            if (node.getValue().equals(version))
                return node;
        }/*  w  w  w. j ava  2s  .c o m*/
    }
    return null;
}