1 package info.mikethomas.fahview.viewer.files.xyz;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import info.mikethomas.fahview.viewer.JmolPanel;
25 import javax.swing.Action;
26 import javax.swing.JComponent;
27 import javax.swing.JToolBar;
28 import org.netbeans.core.spi.multiview.CloseOperationState;
29 import org.netbeans.core.spi.multiview.MultiViewElement;
30 import org.netbeans.core.spi.multiview.MultiViewElementCallback;
31 import org.openide.awt.UndoRedo;
32 import org.openide.util.Lookup;
33 import org.openide.util.NbBundle.Messages;
34 import org.openide.windows.TopComponent;
35
36
37
38
39
40
41
42 @MultiViewElement.Registration(
43 displayName = "#LBL_XyzFile_VISUAL",
44 iconBase = "info/mikethomas/fahview/viewer/files/xyz/XyzFile.png",
45 mimeType = "model/x-xyz",
46 persistenceType = TopComponent.PERSISTENCE_NEVER,
47 preferredID = "XyzFileVisual",
48 position = 2000)
49 @Messages("LBL_XyzFile_VISUAL=Visual")
50 public final class XyzFileVisualElement extends JmolPanel implements MultiViewElement {
51
52 private XyzFileDataObject obj;
53 private JToolBar toolbar = new JToolBar();
54 private transient MultiViewElementCallback callback;
55
56
57
58
59
60
61 public XyzFileVisualElement(Lookup lkp) {
62 obj = lkp.lookup(XyzFileDataObject.class);
63 assert obj != null;
64 initComponents();
65 }
66
67
68 @Override
69 public String getName() {
70 return "XyzFileVisualElement";
71 }
72
73
74
75
76
77
78
79 private void initComponents() {
80
81 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
82 this.setLayout(layout);
83 layout.setHorizontalGroup(
84 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
85 .addGap(0, 400, Short.MAX_VALUE)
86 );
87 layout.setVerticalGroup(
88 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
89 .addGap(0, 300, Short.MAX_VALUE)
90 );
91 }
92
93
94
95
96 @Override
97 public JComponent getVisualRepresentation() {
98 return this;
99 }
100
101
102 @Override
103 public JComponent getToolbarRepresentation() {
104 return toolbar;
105 }
106
107
108 @Override
109 public Action[] getActions() {
110 return new Action[0];
111 }
112
113
114 @Override
115 public Lookup getLookup() {
116 return obj.getLookup();
117 }
118
119
120 @Override
121 public void componentOpened() {
122
123 getViewer().openFile(obj.getPrimaryFile().getPath());
124
125
126 }
127
128
129 @Override
130 public void componentClosed() {
131 }
132
133
134 @Override
135 public void componentShowing() {
136 }
137
138
139 @Override
140 public void componentHidden() {
141 }
142
143
144 @Override
145 public void componentActivated() {
146 }
147
148
149 @Override
150 public void componentDeactivated() {
151 }
152
153
154 @Override
155 public UndoRedo getUndoRedo() {
156 return UndoRedo.NONE;
157 }
158
159
160 @Override
161 public void setMultiViewCallback(MultiViewElementCallback callback) {
162 this.callback = callback;
163 }
164
165
166 @Override
167 public CloseOperationState canCloseElement() {
168 return CloseOperationState.STATE_OK;
169 }
170 }