use of javax.swing.tree.TreeNode in project intellij-plugins by JetBrains.
the class FoundUsersModelTest method testUserInProject.
public void testUserInProject() throws Exception {
MockUser bob = new MockUser("BobName", null);
bob.setProjects(new String[] { "bobProject" });
FoundUsersModel model = createModel(Arrays.asList(new User[] { bob }));
assertEquals("One project expected", 1, getRoot(model).getChildCount());
TreeNode projectNode = getRoot(model).getChildAt(0);
assertEquals("Invalid project node", "bobProject", projectNode.toString());
assertEquals("One user in group expected", 1, projectNode.getChildCount());
assertEquals("Invalid user node", bob.getName(), projectNode.getChildAt(0).toString());
}
use of javax.swing.tree.TreeNode in project intellij-plugins by JetBrains.
the class SelectionProcessor method removeSelectionOfGroupUsers.
private void removeSelectionOfGroupUsers(TreePath path) {
TreeNode treeNode = ((TreeNode) path.getLastPathComponent());
Enumeration children = treeNode.children();
while (children.hasMoreElements()) {
TreeNode node = (TreeNode) children.nextElement();
myUserTree.removeSelectionPath(TreeUtils.getPathFromRoot(node));
}
}
use of javax.swing.tree.TreeNode in project intellij-plugins by JetBrains.
the class FlexBuildConfigurationsExtension method getFlexModuleForNode.
@Nullable
private static Module getFlexModuleForNode(@Nullable MasterDetailsComponent.MyNode node) {
while (node != null) {
final NamedConfigurable configurable = node.getConfigurable();
final Object editableObject = configurable == null ? null : configurable.getEditableObject();
if (editableObject instanceof Module && ModuleType.get((Module) editableObject) instanceof FlexModuleType) {
return (Module) editableObject;
}
final TreeNode parent = node.getParent();
node = parent instanceof MasterDetailsComponent.MyNode ? (MasterDetailsComponent.MyNode) parent : null;
}
return null;
}
use of javax.swing.tree.TreeNode in project processdash by dtuma.
the class CheckboxTree method toggleCheck.
protected void toggleCheck(TreePath selPath) {
TreeNode node = (TreeNode) selPath.getLastPathComponent();
// toggle current checked status.
boolean isChecked = uncheckedNodes.contains(node);
setCheckedStatusRecursive(node, isChecked);
if (!isChecked) {
while (true) {
node = node.getParent();
if (node == null)
break;
setCheckedStatus(node, false);
}
}
fireListSelectionEvent(false);
}
use of javax.swing.tree.TreeNode in project processdash by dtuma.
the class HierarchyEditor method copyTemplate.
public TreeNode copyTemplate(DefaultMutableTreeNode destParent, String templateName) {
//recursive copy of node, children and properties
PropertyKey parent = treeModel.getPropKey(useProps, destParent.getPath());
PropertyKey templateKey = templates.getRootChildByName(templateName);
int newIndex = useProps.getNumChildren(parent);
// See if should be adding at other index...
// if parent specifies allowed children
Prop val = useProps.pget(parent);
String status, allowedChild;
if ((val != null) && ((status = val.getStatus()) != null)) {
int idx1 = status.indexOf(ALLOWED_CHILD);
int idx2 = status.indexOf(REQUIRED_PARENT);
if (idx1 >= 0) {
if (idx2 < 0)
idx2 = status.length();
StringTokenizer st = new StringTokenizer(status.substring(idx1 + 1, idx2), String.valueOf(ALLOWED_CHILD));
while (st.hasMoreTokens()) {
allowedChild = st.nextToken();
// if parent specifies THIS child
if (allowedChild.startsWith(templateName)) {
idx1 = allowedChild.indexOf("(");
idx2 = allowedChild.indexOf(")");
// if parent specifies index
if (idx1 >= 0 && idx2 >= 0) {
// change index
idx1 = Integer.valueOf(allowedChild.substring(idx1 + 1, idx2)).intValue();
newIndex = ((idx1 < 0) ? (newIndex + idx1) : idx1);
}
// exit while loop
break;
}
}
}
}
// now add it
useProps.addChildKey(parent, useProps.pget(parent).uniqueChildName(templateName), newIndex);
useProps.copyFrom(templates, templateKey, useProps.getChildKey(parent, newIndex));
// clear and reload the tree (NEEDS WORK)
treeModel.useTreeModelListener(false);
treeModel.reload(useProps);
expandRoot();
treeModel.useTreeModelListener(true);
treeModel.nodeStructureChanged(destParent);
return (TreeNode) treeModel.getChild(destParent, newIndex);
}
Aggregations