public void run(TaskMonitor monitor, PlugInContext context) throws Exception {
   // -- get the LM because when the Histogram will be shown, the app. focus
   //   will change and context.addLayer will not work (null pointer exc.)
   // [mmichaud 2012-04-09] to completely resolve this problem, I added the
   // new JInternalFrame is added after the addLayer method has been called
   this.currentLM = context.getLayerManager();
   monitor.allowCancellationRequests();
   if (this.selAttribute == null) {
     context.getWorkbenchFrame().warnUser(I18N.get(sNoAttributeChoosen));
     return;
   }
   javax.swing.JInternalFrame internalFrame = context.getWorkbenchFrame().getActiveInternalFrame();
   FeatureDataset result = classifyAndCreatePlot(monitor, context);
   context.getWorkbenchFrame().activateFrame(internalFrame);
   if (result == null) {
     context.getWorkbenchFrame().warnUser(I18N.get(sNotEnoughValuesWarning));
   } else if (result.size() > 0) {
     String name = this.selAttribute + "_" + this.selClassifier;
     this.currentLM.addLayer(StandardCategoryNames.WORKING, name, result);
     JInternalFrame frame = new JInternalFrame(this.sHistogram);
     frame.setLayout(new BorderLayout());
     frame.add(plot, BorderLayout.CENTER);
     frame.setClosable(true);
     frame.setResizable(true);
     frame.setMaximizable(true);
     frame.setSize(450, 450);
     context.getWorkbenchFrame().addInternalFrame(frame);
     plot = null;
   } else {
     context.getWorkbenchFrame().warnUser(sWarning);
   }
 }
 /**
  * Creates a new {@code JInternalFrame} with a size of 200 x 100. The title of the created
  * internal frame includes the value of a counter that is automatically increased every time a new
  * internal frame is created. This method is {@code not} executed in the event dispatch thread
  * (EDT.)
  *
  * @return the created frame.
  */
 @RunsInCurrentThread
 protected static JInternalFrame createInternalFrame() {
   // TODO: should be create and add
   JInternalFrame internalFrame =
       new JInternalFrame(concat("Internal Frame ", ++internalFrameCounter));
   internalFrame.setIconifiable(true);
   internalFrame.setMaximizable(true);
   internalFrame.setResizable(true);
   internalFrame.setSize(new Dimension(200, 100));
   internalFrame.setVisible(true);
   return internalFrame;
 }
示例#3
0
 protected void showDeployAgentDialog() {
   // TODO Auto-generated method stub
   JInternalFrame fr = new JInternalFrame("Deploy Agent");
   fr.getContentPane().add(new NewAgentPanel());
   fr.pack();
   fr.setClosable(true);
   fr.setIconifiable(true);
   fr.setResizable(true);
   fr.setMaximizable(true);
   fr.setVisible(true);
   jDesktopPane1.add(fr);
 }
 /*
  * Class under test for void void setPalette(boolean)
  */
 public void testSetPalette() {
   TestMetalInternalFrameTitlePane pane = new TestMetalInternalFrameTitlePane(frame);
   frame.setClosable(true);
   frame.setIconifiable(true);
   frame.setMaximizable(true);
   // test set to true
   pane.setPalette(true);
   assertTrue("isPalette is true", pane.isPalette);
   assertTrue("changed close icon", pane.getCloseButton().getIcon() == pane.paletteCloseIcon);
   assertTrue("1 child", pane.getComponentCount() == 1);
   // is layoutContainer called?
   // test set to false
   pane.setPalette(false);
   assertFalse("isPalette is false", pane.isPalette);
   assertTrue("changed close icon", pane.getCloseButton().getIcon() == pane.getCloseIcon());
   assertTrue("3 children", pane.getComponentCount() == 3);
 }
示例#5
0
 private void showDomainDialog(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_showDomainDialog
   // TODO add your handling code here:
   JInternalFrame fr = new JInternalFrame("Add new Domain");
   fr.getContentPane().add(new NewDomainPanel());
   fr.pack();
   fr.setClosable(true);
   fr.setIconifiable(true);
   fr.setResizable(true);
   fr.setMaximizable(true);
   fr.setVisible(true);
   jDesktopPane1.add(fr);
   GridBagConstraints gc = new GridBagConstraints();
   gc.gridx = 0;
   gc.gridy = GridBagConstraints.RELATIVE;
   gc.insets = new Insets(6, 12, 0, 12);
   gc.fill = GridBagConstraints.HORIZONTAL;
   domainsPanel.add(new JButton("Dynamic"), gc);
 } // GEN-LAST:event_showDomainDialog
 /*
  * Test MetalInternalFrameTitlePane.MetalTitlePaneLayout class
  */
 public void testMetalTitlePaneLayout() {
   TestMetalInternalFrameTitlePane pane = new TestMetalInternalFrameTitlePane(frame);
   pane.setSize(200, 31);
   LayoutManager layout = pane.getLayout();
   final Rectangle iconButtonBounds = new Rectangle(134, 7, 16, 16);
   final Rectangle maximizeButtonBounds = new Rectangle(156, 7, 16, 16);
   final Rectangle closeButtonBounds = new Rectangle(178, 7, 16, 16);
   // test layoutContainer(): non-iconifiable, non-maximizable, non-closable
   layout.layoutContainer(null);
   //        assertEquals("iconButton", zeroBounds,
   //                     pane.getComponent(0).getBounds());
   //        assertTrue("maximizeButton", pane.getComponent(1).getBounds().
   //                equals(zeroBounds));
   //        assertTrue("closeButton", pane.getComponent(2).getBounds().
   //                equals(zeroBounds));
   // test layoutContainer(): iconifiable, maximizable, closable
   frame.setIconifiable(true);
   frame.setMaximizable(true);
   frame.setClosable(true);
   layout.layoutContainer(pane);
   if (isHarmony()) {
     assertEquals("iconButton", iconButtonBounds, pane.getComponent(0).getBounds());
     assertEquals("maximizeButton", maximizeButtonBounds, pane.getComponent(1).getBounds());
     assertEquals("closeButton", closeButtonBounds, pane.getComponent(2).getBounds());
   }
   // test layoutContainer(): isPalette == true
   pane.setPalette(true);
   layout.layoutContainer(null);
   // these bounds can be changed in the future
   if (isHarmony()) {
     assertEquals(
         "palette: closeButton", new Rectangle(189, 11, 8, 8), pane.getComponent(0).getBounds());
   }
   // minimumLayoutSize(), preferredLayoutSize() implementations
   assertTrue("", layout.minimumLayoutSize(pane) != null);
   assertTrue("", layout.preferredLayoutSize(pane) != null);
 }
示例#7
0
  public static void init(
      JInternalFrame comp, Thing thing, Container parent, ActionContext actionContext) {
    JComponentCreator.init(comp, thing, parent, actionContext);

    String title = JavaCreator.createText(thing, "title", actionContext);
    if (title != null) {
      comp.setTitle(title);
    }

    Boolean closable = JavaCreator.createBoolean(thing, "closable");
    if (closable != null) {
      comp.setClosable(closable);
    }

    Boolean closed = JavaCreator.createBoolean(thing, "closed");
    if (closed != null) {
      try {
        comp.setClosed(closed);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }

    Cursor cursor = AwtCreator.createCursor(thing, "cursor", actionContext);
    if (cursor != null) {
      comp.setCursor(cursor);
    }

    Integer defaultCloseOperation = null;
    String d = thing.getString("defaultCloseOperation");
    if ("DO_NOTHING_ON_CLOSE".equals(d)) {
      defaultCloseOperation = JInternalFrame.DO_NOTHING_ON_CLOSE;
    } else if ("HIDE_ON_CLOSE".equals(d)) {
      defaultCloseOperation = JInternalFrame.HIDE_ON_CLOSE;
    } else if ("DISPOSE_ON_CLOSE".equals(d)) {
      defaultCloseOperation = JInternalFrame.DISPOSE_ON_CLOSE;
    }
    if (defaultCloseOperation != null) {
      comp.setDefaultCloseOperation(defaultCloseOperation);
    }

    Boolean focusCycleRoot = JavaCreator.createBoolean(thing, "focusCycleRoot");
    if (focusCycleRoot != null) {
      comp.setFocusCycleRoot(focusCycleRoot);
    }

    Icon frameIcon = SwingCreator.createIcon(thing, "frameIcon", actionContext);
    if (frameIcon != null) {
      comp.setFrameIcon(frameIcon);
    }

    Boolean setIcon = JavaCreator.createBoolean(thing, "setIcon");
    if (setIcon != null) {
      try {
        comp.setIcon(setIcon);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }

    Boolean iconifiable = JavaCreator.createBoolean(thing, "iconifiable");
    if (iconifiable != null) {
      comp.setIconifiable(iconifiable);
    }

    Integer layer = JavaCreator.createInteger(thing, "layer");
    if (layer != null) {
      comp.setLayer(layer);
    }

    Boolean maximizable = JavaCreator.createBoolean(thing, "maximizable");
    if (maximizable != null) {
      comp.setMaximizable(maximizable);
    }

    Boolean maximum = JavaCreator.createBoolean(thing, "maximum");
    if (maximum != null) {
      try {
        comp.setMaximum(maximum);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }

    Boolean resizable = JavaCreator.createBoolean(thing, "resizable");
    if (resizable != null) {
      comp.setResizable(resizable);
    }

    Boolean selected = JavaCreator.createBoolean(thing, "selected");
    if (selected != null) {
      try {
        comp.setSelected(selected);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }
  }
示例#8
0
  /** The graphic handling and deployment. */
  private void initComponents() {
    jDesktopPane1 = new javax.swing.JDesktopPane();
    jInternalFrame1 = new javax.swing.JInternalFrame();
    tf = new javax.swing.JTextField();
    b1 = new javax.swing.JButton();
    jInternalFrame3 = new javax.swing.JInternalFrame();
    ta = new javax.swing.JTextArea();
    jsp_ta = new javax.swing.JScrollPane(ta);
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem3 = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    jMenuItem4 = new javax.swing.JMenuItem();

    jInternalFrame1
        .getContentPane()
        .setLayout(
            new javax.swing.BoxLayout(
                jInternalFrame1.getContentPane(), javax.swing.BoxLayout.X_AXIS));

    jInternalFrame1.setIconifiable(true);
    jInternalFrame1.setMaximizable(true);
    jInternalFrame1.setResizable(true);
    jInternalFrame1.setTitle("Message editor");
    jInternalFrame1.setToolTipText(
        "Move and resize all of these to make the chat room appearance match your preferences.");
    jInternalFrame1.setVisible(true);
    tf.setFont(new java.awt.Font("Lucida Sans", 0, 12));
    jInternalFrame1.getContentPane().add(tf);

    b1.setText("Send Message");
    jInternalFrame1.getContentPane().add(b1);

    jInternalFrame1.setBounds(10, 10, 440, 60);
    jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);

    jInternalFrame3.setIconifiable(true);
    jInternalFrame3.setMaximizable(true);
    jInternalFrame3.setResizable(true);
    jInternalFrame3.setTitle("Messages");
    jInternalFrame3.setToolTipText(
        "Move and resize all of these to make the chat room appearance match your preferences.");
    jInternalFrame3.setVisible(true);
    ta.setBackground(new Color(255, 255, 255));
    ta.setEditable(false);
    ta.setFont(new java.awt.Font("Lucida Sans", 0, 12));
    // jsp_ta.setAutoscrolls(true);
    jsp_ta.setDoubleBuffered(true);

    jInternalFrame3.getContentPane().add(jsp_ta, java.awt.BorderLayout.CENTER);

    jInternalFrame3.setBounds(10, 80, 420, 240);

    jDesktopPane1.add(jInternalFrame3, javax.swing.JLayeredPane.DEFAULT_LAYER);

    getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER);

    jMenu1.setText("Private room options");
    jMenu1.setMnemonic(KeyEvent.VK_O);
    jMenu1.setToolTipText("Choose some options.");
    jMenuItem3.setText("Save conversation");
    jMenuItem3.setMnemonic(KeyEvent.VK_S);
    jMenuItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    jMenu1.add(jMenuItem3);
    jMenu1.add(jSeparator1);
    jMenuItem4.setText("Exit");
    jMenuItem4.setMnemonic(KeyEvent.VK_E);
    jMenuItem4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));
    jMenu1.add(jMenuItem4);
    jMenuBar1.add(jMenu1);
    setJMenuBar(jMenuBar1);

    this.pack();

    b1.addActionListener(this);
    tf.addActionListener(this);
    jMenuItem3.addActionListener(this);
    jMenuItem4.addActionListener(this);

    posx = (int) Math.random() * 640;
    posy = (int) Math.random() * 480;

    this.pack();
    this.setSize(dimx, dimy);
    this.setLocation(posx, posy);
    this.show();
  }