1 /*
2 * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24 package com.sun.hotspot.igv.coordinator;
25
26 import com.sun.hotspot.igv.coordinator.actions.RemoveCookie;
27 import com.sun.hotspot.igv.data.*;
28 import java.awt.Image;
29 import java.util.List;
30 import org.openide.nodes.AbstractNode;
31 import org.openide.nodes.Children;
32 import org.openide.nodes.Node;
33 import org.openide.util.ImageUtilities;
34 import org.openide.util.lookup.AbstractLookup;
35 import org.openide.util.lookup.InstanceContent;
36
37 /**
38 *
39 * @author Thomas Wuerthinger
40 */
41 public class FolderNode extends AbstractNode {
42
43 private InstanceContent content;
44 private FolderChildren children;
45
46 private static class FolderChildren extends Children.Keys<FolderElement> implements ChangedListener {
47
48 private final Folder folder;
49
50 public FolderChildren(Folder folder) {
51 this.folder = folder;
52 folder.getChangedEvent().addListener(this);
58 return new Node[]{new GraphNode((InputGraph) e)};
59 } else if (e instanceof Folder) {
60 return new Node[]{new FolderNode((Folder) e)};
61 } else {
62 return null;
63 }
64 }
65
66 @Override
67 public void addNotify() {
68 this.setKeys(folder.getElements());
69 }
70
71 @Override
72 public void changed(Object source) {
73 addNotify();
74 }
75 }
76
77 @Override
78 public Image getIcon(int i) {
79 return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.png");
80 }
81
82 protected FolderNode(Folder folder) {
83 this(folder, new FolderChildren(folder), new InstanceContent());
84 }
85
86 private FolderNode(final Folder folder, FolderChildren children, InstanceContent content) {
87 super(children, new AbstractLookup(content));
88 this.content = content;
89 this.children = children;
90 if (folder instanceof FolderElement) {
91 final FolderElement folderElement = (FolderElement) folder;
92 this.setDisplayName(folderElement.getName());
93 content.add(new RemoveCookie() {
94 @Override
95 public void remove() {
96 folderElement.getParent().removeElement(folderElement);
97 }
|
1 /*
2 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24 package com.sun.hotspot.igv.coordinator;
25
26 import com.sun.hotspot.igv.coordinator.actions.RemoveCookie;
27 import com.sun.hotspot.igv.data.*;
28 import com.sun.hotspot.igv.util.PropertiesSheet;
29 import java.awt.Image;
30 import java.util.List;
31 import org.openide.nodes.AbstractNode;
32 import org.openide.nodes.Children;
33 import org.openide.nodes.Node;
34 import org.openide.nodes.Sheet;
35 import org.openide.util.ImageUtilities;
36 import org.openide.util.lookup.AbstractLookup;
37 import org.openide.util.lookup.InstanceContent;
38
39 /**
40 *
41 * @author Thomas Wuerthinger
42 */
43 public class FolderNode extends AbstractNode {
44
45 private InstanceContent content;
46 private FolderChildren children;
47
48 private static class FolderChildren extends Children.Keys<FolderElement> implements ChangedListener {
49
50 private final Folder folder;
51
52 public FolderChildren(Folder folder) {
53 this.folder = folder;
54 folder.getChangedEvent().addListener(this);
60 return new Node[]{new GraphNode((InputGraph) e)};
61 } else if (e instanceof Folder) {
62 return new Node[]{new FolderNode((Folder) e)};
63 } else {
64 return null;
65 }
66 }
67
68 @Override
69 public void addNotify() {
70 this.setKeys(folder.getElements());
71 }
72
73 @Override
74 public void changed(Object source) {
75 addNotify();
76 }
77 }
78
79 @Override
80 protected Sheet createSheet() {
81 Sheet s = super.createSheet();
82 if (children.folder instanceof Properties.Entity) {
83 Properties.Entity p = (Properties.Entity) children.folder;
84 PropertiesSheet.initializeSheet(p.getProperties(), s);
85 }
86 return s;
87 }
88
89 @Override
90 public Image getIcon(int i) {
91 return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.png");
92 }
93
94 protected FolderNode(Folder folder) {
95 this(folder, new FolderChildren(folder), new InstanceContent());
96 }
97
98 private FolderNode(final Folder folder, FolderChildren children, InstanceContent content) {
99 super(children, new AbstractLookup(content));
100 this.content = content;
101 this.children = children;
102 if (folder instanceof FolderElement) {
103 final FolderElement folderElement = (FolderElement) folder;
104 this.setDisplayName(folderElement.getName());
105 content.add(new RemoveCookie() {
106 @Override
107 public void remove() {
108 folderElement.getParent().removeElement(folderElement);
109 }
|