public boolean supportsSpaces() { return spaceChangeHandler.getCurrentSpacesDescriptor() != null && spaceChangeHandler.getCurrentSpacesDescriptor().supportsSpaces(); }
public void setInput() { if (spaceChangeHandler != null && orgsSpacesViewer != null && !orgsSpacesViewer.getTree().isDisposed()) { List<CloudOrganization> orgInput = spaceChangeHandler.getCurrentSpacesDescriptor() != null ? spaceChangeHandler.getCurrentSpacesDescriptor().getOrgsAndSpaces().getOrgs() : null; if (orgInput != null && orgInput.size() > 0) { CloudOrganization[] organizationInput = orgInput.toArray(new CloudOrganization[orgInput.size()]); orgsSpacesViewer.setInput(organizationInput); // Expand all first, so that child elements can be selected orgsSpacesViewer.setExpandedElements(organizationInput); CloudSpace selectedSpace = spaceChangeHandler.getCurrentSpacesDescriptor() != null ? spaceChangeHandler .getCurrentSpacesDescriptor() .getOrgsAndSpaces() .getDefaultCloudSpace() : null; if (selectedSpace != null) { // First set the default cloud space as the selected space setSpaceSelection(selectedSpace); // Now set the cloud space in the tree Tree tree = orgsSpacesViewer.getTree(); TreeItem[] orgItems = tree.getItems(); if (orgItems != null) { TreeItem orgItem = null; // Find the tree item corresponding to the cloud space's // org for (TreeItem item : orgItems) { Object treeObj = item.getData(); if (treeObj instanceof CloudOrganization && ((CloudOrganization) treeObj) .getName() .equals(selectedSpace.getOrganization().getName())) { orgItem = item; break; } } if (orgItem != null) { TreeItem[] children = orgItem.getItems(); if (children != null) { for (TreeItem childItem : children) { Object treeObj = childItem.getData(); if (treeObj instanceof CloudSpace && ((CloudSpace) treeObj).getName().equals(selectedSpace.getName())) { tree.select(childItem); break; } } } } } } } } }