View Javadoc
1   package info.mikethomas.fahview.v6project.files.queue;
2   
3   /*
4    * #%L
5    * This file is part of FAHView-v6project.
6    * %%
7    * Copyright (C) 2011 - 2017 Mike Thomas <mikepthomas@outlook.com>
8    * %%
9    * FAHView is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   * %
14   * FAHView is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * %
19   * You should have received a copy of the GNU General Public License
20   * along with FAHView.  If not, see <http://www.gnu.org/licenses/>.
21   * #L%
22   */
23  
24  import javax.swing.Action;
25  import javax.swing.JComponent;
26  import javax.swing.JPanel;
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   * <p>QueueFileVisualElement class.</p>
38   *
39   * @author <a href="mailto:mikepthomas@outlook.com">Michael Thomas</a>
40   * @version $Id: $Id
41   */
42  @MultiViewElement.Registration(
43          displayName = "#LBL_QueueFile_VISUAL",
44          iconBase = "info/mikethomas/fahview/v6project/files/queue/QueueFile.png",
45          mimeType = "application/x-fahqueue",
46          persistenceType = TopComponent.PERSISTENCE_NEVER,
47          preferredID = "QueueFileVisual",
48          position = 2000)
49  @Messages("LBL_QueueFile_VISUAL=Visual")
50  public final class QueueFileVisualElement extends JPanel implements MultiViewElement {
51  
52      private QueueFileDataObject obj;
53      private JToolBar toolbar = new JToolBar();
54      private transient MultiViewElementCallback callback;
55  
56      /**
57       * <p>Constructor for QueueFileVisualElement.</p>
58       *
59       * @param lkp a {@link org.openide.util.Lookup} object.
60       */
61      public QueueFileVisualElement(Lookup lkp) {
62          obj = lkp.lookup(QueueFileDataObject.class);
63          assert obj != null;
64          initComponents();
65      }
66  
67      /** {@inheritDoc} */
68      @Override
69      public String getName() {
70          return "QueueFileVisualElement";
71      }
72  
73      /**
74       * This method is called from within the constructor to initialize the form.
75       * WARNING: Do NOT modify this code. The content of this method is always
76       * regenerated by the Form Editor.
77       */
78      // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
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      }// </editor-fold>//GEN-END:initComponents
92  
93      // Variables declaration - do not modify//GEN-BEGIN:variables
94      // End of variables declaration//GEN-END:variables
95      /** {@inheritDoc} */
96      @Override
97      public JComponent getVisualRepresentation() {
98          return this;
99      }
100 
101     /** {@inheritDoc} */
102     @Override
103     public JComponent getToolbarRepresentation() {
104         return toolbar;
105     }
106 
107     /** {@inheritDoc} */
108     @Override
109     public Action[] getActions() {
110         return new Action[0];
111     }
112 
113     /** {@inheritDoc} */
114     @Override
115     public Lookup getLookup() {
116         return obj.getLookup();
117     }
118 
119     /** {@inheritDoc} */
120     @Override
121     public void componentOpened() {
122     }
123 
124     /** {@inheritDoc} */
125     @Override
126     public void componentClosed() {
127     }
128 
129     /** {@inheritDoc} */
130     @Override
131     public void componentShowing() {
132     }
133 
134     /** {@inheritDoc} */
135     @Override
136     public void componentHidden() {
137     }
138 
139     /** {@inheritDoc} */
140     @Override
141     public void componentActivated() {
142     }
143 
144     /** {@inheritDoc} */
145     @Override
146     public void componentDeactivated() {
147     }
148 
149     /** {@inheritDoc} */
150     @Override
151     public UndoRedo getUndoRedo() {
152         return UndoRedo.NONE;
153     }
154 
155     /** {@inheritDoc} */
156     @Override
157     public void setMultiViewCallback(MultiViewElementCallback callback) {
158         this.callback = callback;
159     }
160 
161     /** {@inheritDoc} */
162     @Override
163     public CloseOperationState canCloseElement() {
164         return CloseOperationState.STATE_OK;
165     }
166 }