PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/PrototypeVisualElement.java
author Jiri Rechtacek <jrechtacek@netbeans.org>
Sun, 18 Sep 2011 15:31:13 +0200
branchmultiview_prototype
changeset 19 cd34d58c6d85
permissions -rw-r--r--
registrer Prototype multiview
     1 /*
     2  * To change this template, choose Tools | Templates and open the template in
     3  * the editor.
     4  */
     5 package org.netbeans.modules.plsql.filetype;
     6 
     7 import javax.swing.Action;
     8 import javax.swing.JComponent;
     9 import javax.swing.JPanel;
    10 import javax.swing.JToolBar;
    11 import org.netbeans.core.spi.multiview.CloseOperationState;
    12 import org.netbeans.core.spi.multiview.MultiViewElement;
    13 import org.netbeans.core.spi.multiview.MultiViewElementCallback;
    14 import org.openide.awt.UndoRedo;
    15 import org.openide.util.Lookup;
    16 import org.openide.util.NbBundle.Messages;
    17 import org.openide.windows.TopComponent;
    18 
    19 @MultiViewElement.Registration(displayName = "#LBL_Prototype_VISUAL",
    20 iconBase = "SET/PATH/TO/ICON/HERE",
    21 mimeType = "text/x-plsql-prototype",
    22 persistenceType = TopComponent.PERSISTENCE_NEVER,
    23 preferredID = "PrototypeVisual",
    24 position = 2000)
    25 @Messages({
    26     "LBL_Prototype_VISUAL=Visual"
    27 })
    28 public final class PrototypeVisualElement extends JPanel implements MultiViewElement {
    29 
    30     private PrototypeDataObject obj;
    31     private JToolBar toolbar = new JToolBar();
    32     private transient MultiViewElementCallback callback;
    33 
    34     public PrototypeVisualElement(Lookup lkp) {
    35         obj = lkp.lookup(PrototypeDataObject.class);
    36         assert obj != null;
    37         initComponents();
    38     }
    39 
    40     @Override
    41     public String getName() {
    42         return "PrototypeVisualElement";
    43     }
    44 
    45     /** This method is called from within the constructor to
    46      * initialize the form.
    47      * WARNING: Do NOT modify this code. The content of this method is
    48      * always regenerated by the Form Editor.
    49      */
    50     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    51     private void initComponents() {
    52 
    53         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    54         this.setLayout(layout);
    55         layout.setHorizontalGroup(
    56             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    57             .addGap(0, 400, Short.MAX_VALUE)
    58         );
    59         layout.setVerticalGroup(
    60             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    61             .addGap(0, 300, Short.MAX_VALUE)
    62         );
    63     }// </editor-fold>//GEN-END:initComponents
    64 
    65     // Variables declaration - do not modify//GEN-BEGIN:variables
    66     // End of variables declaration//GEN-END:variables
    67     @Override
    68     public JComponent getVisualRepresentation() {
    69         return this;
    70     }
    71 
    72     @Override
    73     public JComponent getToolbarRepresentation() {
    74         return toolbar;
    75     }
    76 
    77     @Override
    78     public Action[] getActions() {
    79         return new Action[0];
    80     }
    81 
    82     @Override
    83     public Lookup getLookup() {
    84         return obj.getLookup();
    85     }
    86 
    87     @Override
    88     public void componentOpened() {
    89     }
    90 
    91     @Override
    92     public void componentClosed() {
    93     }
    94 
    95     @Override
    96     public void componentShowing() {
    97     }
    98 
    99     @Override
   100     public void componentHidden() {
   101     }
   102 
   103     @Override
   104     public void componentActivated() {
   105     }
   106 
   107     @Override
   108     public void componentDeactivated() {
   109     }
   110 
   111     @Override
   112     public UndoRedo getUndoRedo() {
   113         return UndoRedo.NONE;
   114     }
   115 
   116     @Override
   117     public void setMultiViewCallback(MultiViewElementCallback callback) {
   118         this.callback = callback;
   119     }
   120 
   121     @Override
   122     public CloseOperationState canCloseElement() {
   123         return CloseOperationState.STATE_OK;
   124     }
   125 }