private Component refreshViewRegion(TreeNode node) {
    Component guiComponent = node.getGuiComponent();
    if (node.isLeaf()) {
      if (guiComponent == null) {
        guiComponent = new JTabbedPane();
        node.setGuiComponent(guiComponent);
      }
      JTabbedPane tabs = (JTabbedPane) guiComponent;
      for (LeafNodeComponent compNode : node.getComponents()) {
        boolean exists = false;
        for (Component comp : tabs.getComponents()) {
          if (comp == compNode.getComponent()) {
            exists = true;
          }
        }
        if (!exists) {
          tabs.addTab(compNode.getLabel(), compNode.getComponent());
        }
      }
      for (Component comp : tabs.getComponents()) {
        boolean removed = true;
        for (LeafNodeComponent compNode : node.getComponents()) {
          if (comp == compNode.getComponent()) {
            removed = false;
          }
        }
        if (removed) {
          tabs.remove(comp);
        }
      }
      return guiComponent;
    } else {
      JSplitPane split = null;
      if (guiComponent == null) {
        split = new JSplitPane();
        node.setGuiComponent(split);
      } else {
        split = (JSplitPane) guiComponent;
      }

      split.setOrientation(
          node.isVertical() ? JSplitPane.VERTICAL_SPLIT : JSplitPane.HORIZONTAL_SPLIT);

      Component firstGuiComponent = refreshViewRegion(node.getFirst());
      if (firstGuiComponent != null /* && firstGuiComponent instanceof JTabbedPane*/) {
        split.setTopComponent(firstGuiComponent);
      }

      Component secondGuiComponent = refreshViewRegion(node.getSecond());
      if (secondGuiComponent != null /* && secondGuiComponent instanceof JTabbedPane*/) {
        split.setBottomComponent(secondGuiComponent);
      }

      return split;
    }
  }
  private void layoutRightPart(JSplitPane mainSplitPane) {
    JSplitPane rightSplitPanel = new JSplitPane();
    rightSplitPanel.setResizeWeight(0.4);
    rightSplitPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);

    layoutTopRightPart(rightSplitPanel);
    layoutBottomRightPart(rightSplitPanel);

    mainSplitPane.setRightComponent(rightSplitPanel);
  }
Example #3
0
  /** Initializes the frame components. */
  private void initialize() {
    GridBagConstraints c;

    // Set title, size and menus
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setTitle("Mibble MIB Browser");
    Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
    Rectangle bounds = new Rectangle();
    bounds.width = (int) (size.width * 0.75);
    bounds.height = (int) (size.height * 0.75);
    bounds.x = (size.width - bounds.width) / 2;
    bounds.y = (size.height - bounds.height) / 2;
    setBounds(bounds);
    setMenuBar(menuBar);
    initializeMenu();
    getContentPane().setLayout(new GridBagLayout());

    // Add horizontal split pane
    JSplitPane horizontalSplitPane = new JSplitPane();
    horizontalSplitPane.setDividerLocation((int) (bounds.width * 0.35));
    c = new GridBagConstraints();
    c.weightx = 1.0d;
    c.weighty = 1.0d;
    c.fill = GridBagConstraints.BOTH;
    getContentPane().add(horizontalSplitPane, c);

    // Add status label
    c = new GridBagConstraints();
    c.gridy = 1;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(2, 5, 2, 5);
    getContentPane().add(statusLabel, c);

    // Add MIB tree
    mibTree = MibTreeBuilder.getInstance().getTree();
    mibTree.addTreeSelectionListener(
        new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent e) {
            updateTreeSelection();
          }
        });
    horizontalSplitPane.setLeftComponent(new JScrollPane(mibTree));

    // Add description area & SNMP panel
    JSplitPane verticalSplitPane = new JSplitPane();
    verticalSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    verticalSplitPane.setDividerLocation((int) (bounds.height * 0.40));
    verticalSplitPane.setOneTouchExpandable(true);
    descriptionArea.setEditable(false);
    verticalSplitPane.setLeftComponent(new JScrollPane(descriptionArea));
    snmpPanel = new SnmpPanel(this);
    verticalSplitPane.setRightComponent(snmpPanel);
    horizontalSplitPane.setRightComponent(verticalSplitPane);
  }
 @Override
 public void actionPerformed(ActionEvent ae) {
   if (ae.getSource().equals(openItem)) {
     File f = null;
     if (null == (f = SpeedyGrader.getInstance().getFilesLoc())) {
       f = new File(System.getProperty("user.home"));
     }
     JFileChooser chooser = new JFileChooser(f);
     chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     int ret = chooser.showOpenDialog(this);
     if (ret == JFileChooser.APPROVE_OPTION) {
       newFolderSelected(chooser.getSelectedFile());
     }
   } else if (ae.getSource().equals(inputItem)) {
     new InputDialog();
   } else if (ae.getSource().equals(saveItem)) {
     for (EditorPanel ep : editorPanels) {
       ep.save();
     }
     SpeedyGrader.getInstance().startComplieAndRun();
   } else if (ae.getSource().equals(refreshItem)) {
     newFolderSelected(null);
   } else if (ae.getSource().equals(githubItem)) {
     String url = "https://github.com/MitchellSlavik/SpeedyGrader";
     Desktop d = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
     if (d != null && d.isSupported(Action.BROWSE)) {
       try {
         d.browse(URI.create(url));
       } catch (IOException e) {
         e.printStackTrace();
       }
     } else {
       JOptionPane.showMessageDialog(
           this,
           "We were unable to open a web browser. The url has been copied to your clipboard.",
           "Unable to preform operation",
           JOptionPane.ERROR_MESSAGE);
       StringSelection selection = new StringSelection(url);
       Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
       clipboard.setContents(selection, selection);
     }
   } else if (ae.getSource().equals(aboutItem)) {
     new AboutDialog();
   } else if (ae.getSource().equals(installItem)) {
     new InstallDialog();
   } else if (ae.getSource().equals(upgradeItem)) {
     new AutoUpdater();
   } else if (ae.getSource().equals(editorSplitToggle)) {
     splitEditorPane.setOrientation(
         editorSplitToggle.isSelected() ? JSplitPane.VERTICAL_SPLIT : JSplitPane.HORIZONTAL_SPLIT);
     this.validate();
     this.repaint();
   }
 }
 /**
  * This method initializes splitPane
  *
  * @return javax.swing.JSplitPane
  */
 private JSplitPane getSplitPane() {
   if (splitPane == null) {
     splitPane = new JSplitPane();
     splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
     splitPane.setPreferredSize(new Dimension(300, 118));
     splitPane.setDividerLocation(100);
     splitPane.setBottomComponent(getPanelResultados());
     splitPane.setTopComponent(getScrollPane());
     splitPane.setOneTouchExpandable(true);
   }
   return splitPane;
 }
Example #6
0
  /**
   * Reset import screen. This can be used while creating totally new instance of import screen or
   * just resetting the default.
   *
   * @param setVisibleAfterReset set import screen frame visible after it has been reseted
   */
  public void resetImportScreen(boolean setVisibleAfterReset) {

    application = Session.getSession().getApplication();

    // If frame exists, set visibility to false while resetting
    if (frame != null) {
      frame.setVisible(false);
    }

    // Create new instances of conversion model, column type manager and trimmers
    conversionModel = new ConversionModel(this);
    columnTypeManager = new ColumnTypeManager(0);
    dataTrimmer = new DataTrimmer();

    // Ignore first
    dataTrimmer.addIgnoreColumnNumber(0);

    flagTrimmer = new DataTrimmer();
    flagTrimmer.addIgnoreColumnNumber(0);

    // Table has to be first to get references right
    tableFrame = new TableInternalFrame(this);
    toolsFrame = new ToolsInternalFrame(this);

    conversionModel.addConversionChangeListener(tableFrame);
    columnTypeManager.addColumnTypeChangeListener(tableFrame);
    columnTypeManager.addColumnTypeChangeListener(toolsFrame);

    frame = new JFrame("Import tool");
    mainSplit = new JSplitPane();

    frame.setLayout(new BorderLayout());
    frame.setSize(IMPORT_SCREEN_SIZE);

    mainSplit.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    mainSplit.setDividerLocation(TOOLS_FRAME_WIDTH);
    mainSplit.setLeftComponent(toolsFrame);
    mainSplit.setRightComponent(tableFrame);
    mainSplit.getLeftComponent().setMinimumSize(new Dimension(150, 0));
    mainSplit.setResizeWeight(0);

    frame.add(mainSplit, BorderLayout.CENTER);

    // Reset buttons
    changeStepPanel = null;
    frame.add(getChangeStepButtonsPanel(), BorderLayout.SOUTH);

    if (setVisibleAfterReset) {
      frame.setVisible(true);
    }
  }
Example #7
0
  /**
   * Descripción de Método
   *
   * @throws Exception
   */
  private void jbInit() throws Exception {
    this.setLayout(mainLayout);
    this.add(splitPane, BorderLayout.CENTER);
    splitPane.setOpaque(false);
    graphPanel.setLayout(graphLayout);

    //

    splitPane.add(graphPanel, JSplitPane.LEFT);
    splitPane.add(cardPanel, JSplitPane.RIGHT);
    splitPane.setBorder(null);
    splitPane.setName("gc_splitPane");

    //

    cardPanel.setLayout(cardLayout);
    cardPanel.add(srPane, "srPane"); // Sequence Important!
    cardPanel.add(mrPane, "mrPane");
    cardPanel.setBorder(null);
    cardPanel.setName("gc_cardPanel");

    // single row (w/o xPane it would be centered)

    srPane.setBorder(null);
    srPane.setName("gc_srPane");
    srPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    srPane.add(vPane, JSplitPane.TOP);
    srPane.setTopComponent(vPane);
    vPane.getViewport().add(xPanel, null);
    xPanel.add(vPanel);
    vPane.setBorder(null);
    xPanel.setLayout(xLayout);
    xPanel.setName("gc_xPanel");
    xLayout.setAlignment(FlowLayout.LEFT);
    xLayout.setHgap(0);
    xLayout.setVgap(0);

    // multi-row

    mrPane.setBorder(null);
    mrPane.getViewport().add(vTable, null);
    mrPane.setName("gc_mrPane");

    //

    graphPanel.setBorder(null);
    graphPanel.setName("gc_graphPanel");
    srPane.setDividerLocation(200);
  } // jbInit
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

    javax.swing.JSplitPane jSplitPane1 = new javax.swing.JSplitPane();
    jSplitPane2 = new javax.swing.JSplitPane();
    javax.swing.JPanel jPanel2 = new javax.swing.JPanel();
    javax.swing.JPanel jPanel3 = new javax.swing.JPanel();
    btnReloadXml = new javax.swing.JButton();
    btnSaveXml = new javax.swing.JButton();
    btnClearXml = new javax.swing.JButton();
    xmlContainer = new javax.swing.JPanel();
    javax.swing.JScrollPane xmlScrollpane = new javax.swing.JScrollPane();
    txtXml = new org.fife.ui.rsyntaxtextarea.RSyntaxTextArea();
    jPanel4 = new javax.swing.JPanel();
    jPanel5 = new javax.swing.JPanel();
    btnPrevResult = new javax.swing.JButton();
    lblResultIndex = new javax.swing.JLabel();
    btnNextResult = new javax.swing.JButton();
    javax.swing.JScrollPane outputScrollpane = new javax.swing.JScrollPane();
    txtOutput = new javax.swing.JEditorPane();
    javax.swing.JScrollPane jScrollPane2 = new javax.swing.JScrollPane();
    txtConcatedResult = new javax.swing.JTextPane();
    javax.swing.JPanel bottomPanel = new javax.swing.JPanel();
    txtInput = new javax.swing.JTextField();
    javax.swing.JPanel jPanel1 = new javax.swing.JPanel();
    btnMatch = new javax.swing.JButton();

    setLayout(new java.awt.BorderLayout());

    jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane1.setResizeWeight(1.0);

    jSplitPane2.setResizeWeight(1.0);

    jPanel2.setLayout(new java.awt.BorderLayout());

    btnReloadXml.setText("Reload");
    btnReloadXml.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnReloadXmlActionPerformed(evt);
          }
        });
    jPanel3.add(btnReloadXml);

    btnSaveXml.setText("Save & Compile");
    btnSaveXml.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSaveXmlActionPerformed(evt);
          }
        });
    jPanel3.add(btnSaveXml);

    btnClearXml.setText("Clear");
    btnClearXml.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnClearXmlActionPerformed(evt);
          }
        });
    jPanel3.add(btnClearXml);

    jPanel2.add(jPanel3, java.awt.BorderLayout.PAGE_START);

    xmlContainer.setBackground(new java.awt.Color(255, 153, 153));
    xmlContainer.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 2, 2, 2));

    org.jdesktop.beansbinding.Binding binding =
        org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
            this,
            org.jdesktop.beansbinding.ELProperty.create("${xmlTextIsDirty}"),
            xmlContainer,
            org.jdesktop.beansbinding.BeanProperty.create("opaque"));
    bindingGroup.addBinding(binding);

    xmlContainer.addPropertyChangeListener(
        new java.beans.PropertyChangeListener() {
          public void propertyChange(java.beans.PropertyChangeEvent evt) {
            xmlContainerPropertyChange(evt);
          }
        });
    xmlContainer.setLayout(new java.awt.BorderLayout());

    txtXml.setColumns(20);
    txtXml.setRows(5);
    txtXml.setSyntaxEditingStyle("text/xml");

    binding =
        org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
            this,
            org.jdesktop.beansbinding.ELProperty.create("${xmlString}"),
            txtXml,
            org.jdesktop.beansbinding.BeanProperty.create("text"));
    bindingGroup.addBinding(binding);

    xmlScrollpane.setViewportView(txtXml);

    xmlContainer.add(xmlScrollpane, java.awt.BorderLayout.CENTER);

    jPanel2.add(xmlContainer, java.awt.BorderLayout.CENTER);

    jSplitPane2.setLeftComponent(jPanel2);

    jPanel4.setLayout(new java.awt.BorderLayout());

    jPanel5.setMinimumSize(new java.awt.Dimension(300, 36));
    jPanel5.setPreferredSize(new java.awt.Dimension(300, 36));

    btnPrevResult.setText("Prev");
    btnPrevResult.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPrevResultActionPerformed(evt);
          }
        });
    jPanel5.add(btnPrevResult);

    lblResultIndex.setText("<empty>");
    lblResultIndex.setMaximumSize(new java.awt.Dimension(50, 16));
    lblResultIndex.setMinimumSize(new java.awt.Dimension(50, 16));
    lblResultIndex.setPreferredSize(new java.awt.Dimension(50, 16));
    jPanel5.add(lblResultIndex);

    btnNextResult.setText("Next");
    btnNextResult.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnNextResultActionPerformed(evt);
          }
        });
    jPanel5.add(btnNextResult);

    jPanel4.add(jPanel5, java.awt.BorderLayout.PAGE_START);

    txtOutput.setEditable(false);
    outputScrollpane.setViewportView(txtOutput);

    jPanel4.add(outputScrollpane, java.awt.BorderLayout.CENTER);

    jScrollPane2.setPreferredSize(new java.awt.Dimension(9, 50));

    txtConcatedResult.setEditable(false);
    jScrollPane2.setViewportView(txtConcatedResult);

    jPanel4.add(jScrollPane2, java.awt.BorderLayout.SOUTH);

    jSplitPane2.setRightComponent(jPanel4);

    jSplitPane1.setLeftComponent(jSplitPane2);

    bottomPanel.setLayout(new java.awt.BorderLayout());

    txtInput.setText("*");
    bottomPanel.add(txtInput, java.awt.BorderLayout.CENTER);

    jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));

    btnMatch.setText("Match");
    btnMatch.setPreferredSize(new java.awt.Dimension(70, 30));
    btnMatch.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnMatchActionPerformed(evt);
          }
        });
    jPanel1.add(btnMatch);

    bottomPanel.add(jPanel1, java.awt.BorderLayout.EAST);

    jSplitPane1.setRightComponent(bottomPanel);

    add(jSplitPane1, java.awt.BorderLayout.CENTER);

    bindingGroup.bind();
  } // </editor-fold>//GEN-END:initComponents
Example #9
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frmWow = new JFrame();
    frmWow.setIconImage(
        Toolkit.getDefaultToolkit().getImage(Wow.class.getResource("/org/wowdoge/doge.png")));
    frmWow.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowOpened(WindowEvent arg0) {
            try {
              if (coreWallet.getWalletFilePath() == null) {
                DialogStart d = new DialogStart();
                d.setLocationRelativeTo(frmWow);
                if (d.showDialog()) {
                  String path = d.getWalletFilePath();
                  File f = new File(path);
                  coreWallet.run(f.getParentFile(), f.getName());
                  mnRecent.addFileToFileHistory(path);
                  mnRecent.storeToPreferences();
                } else {
                  System.exit(0);
                }
              } else coreWallet.run();
            } catch (Exception e) {
              JOptionPane.showMessageDialog(
                  null,
                  "Failed to open wallet.\nDetails:\n" + e.getMessage(),
                  "Error",
                  JOptionPane.ERROR_MESSAGE);
              try {
                coreWallet.stop();
              } finally {
                System.exit(1);
              }
              // Improve!
              // e.printStackTrace();
            }
          }

          @Override
          public void windowClosing(WindowEvent e) {
            try {
              coreWallet.stop();
            } catch (Exception e1) {
              JOptionPane.showMessageDialog(
                  null, e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    frmWow.setTitle("Wow - Doge Wallet");
    frmWow.setBounds(100, 100, 819, 503);
    frmWow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmWow.getContentPane().setLayout(new BorderLayout(0, 0));

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    frmWow.getContentPane().add(tabbedPane, BorderLayout.CENTER);

    JPanel panelWallet = new JPanel();
    tabbedPane.addTab("Wallet", null, panelWallet, null);
    panelWallet.setLayout(new BorderLayout(0, 0));

    JSplitPane splitPaneWallet = new JSplitPane();
    panelWallet.add(splitPaneWallet, BorderLayout.CENTER);

    JPanel panelAddresses = new JPanel();
    panelAddresses.setMinimumSize(new Dimension(200, 10));
    panelAddresses.setPreferredSize(new Dimension(280, 10));
    splitPaneWallet.setLeftComponent(panelAddresses);
    panelAddresses.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPaneAddresses = new JScrollPane();
    scrollPaneAddresses.setAutoscrolls(true);
    panelAddresses.add(scrollPaneAddresses, BorderLayout.CENTER);

    listAddresses = new JList();
    listAddresses.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent arg0) {
            refreshAddressAndQRCode();
          }
        });
    scrollPaneAddresses.setViewportView(listAddresses);

    JToolBar toolBarAddresses = new JToolBar();
    panelAddresses.add(toolBarAddresses, BorderLayout.NORTH);

    JButton btnNewAddress = new JButton("New Address");
    btnNewAddress.setToolTipText("Create new wallet address for receiving coins");
    btnNewAddress.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            coreWallet.createNewKeys(1);
            System.out.println(coreWallet.getKeys());
          }
        });
    btnNewAddress.setActionCommand("");
    toolBarAddresses.add(btnNewAddress);

    JButton btnNewAddresses = new JButton("Create Multiple");
    btnNewAddresses.setToolTipText("Create multiple wallet addresses for receiving coins");
    btnNewAddresses.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            DialogAddress dialog = new DialogAddress();
            dialog.setLocationRelativeTo(frmWow);
            if (dialog.showDialog()) {
              int number = dialog.getNumberOfAddressToCreate();
              coreWallet.createNewKeys(number);
              System.out.println(coreWallet.getKeys());
            }
          }
        });
    toolBarAddresses.add(btnNewAddresses);

    JSplitPane splitPaneAddressAndTransactoions = new JSplitPane();
    splitPaneAddressAndTransactoions.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPaneWallet.setRightComponent(splitPaneAddressAndTransactoions);

    JPanel panelAddress = new JPanel();
    panelAddress.setPreferredSize(new Dimension(10, 100));
    splitPaneAddressAndTransactoions.setLeftComponent(panelAddress);
    panelAddress.setLayout(new BorderLayout(0, 0));

    JPanel panelDogeQRMain = new JPanel();
    panelDogeQRMain.setPreferredSize(new Dimension(240, 120));
    panelAddress.add(panelDogeQRMain, BorderLayout.CENTER);
    panelDogeQRMain.setLayout(new BorderLayout(0, 0));

    JPanel panelDogeQR = new JPanel();
    panelDogeQRMain.add(panelDogeQR);

    btnDoge = new JButton("");
    btnDoge.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent e) {
            int min =
                btnDoge.getWidth() > btnDoge.getHeight() ? btnDoge.getHeight() : btnDoge.getWidth();
            min = (int) (min * 0.9);
            // System.out.println("RESIZED");
            btnDoge.setIcon(
                new ImageIcon(
                    new ImageIcon(Wow.class.getResource("/org/wowdoge/doge.png"))
                        .getImage()
                        .getScaledInstance(min, min, Image.SCALE_SMOOTH)));
          }
        });
    btnDoge.setToolTipText("Send payment");
    btnDoge.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            tabbedPane.setSelectedComponent(panelAddressBook);
          }
        });
    panelDogeQR.setLayout(new GridLayout(0, 2, 0, 0));
    panelDogeQR.add(btnDoge);
    btnDoge.setIcon(new ImageIcon(Wow.class.getResource("/org/wowdoge/doge.png")));
    btnDoge.setSize(new Dimension(500, 500));
    btnDoge.setAlignmentX(Component.CENTER_ALIGNMENT);
    btnDoge.setMaximumSize(new Dimension(500, 500));
    btnDoge.setMinimumSize(new Dimension(120, 120));
    btnDoge.setPreferredSize(new Dimension(200, 200));

    btnQRCode = new JButton("");
    btnQRCode.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent arg0) {
            String address = (String) listAddresses.getSelectedValue();
            // System.out.println("Addres:" + address);
            if (address != null) {
              txtAddress.setText(address);
              btnQRCode.setIcon(
                  new ImageIcon(new QRImage(address, btnQRCode.getWidth(), btnQRCode.getHeight())));
            }
          }
        });
    btnQRCode.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {}
        });
    btnQRCode.setToolTipText("Request payment");
    panelDogeQR.add(btnQRCode);
    btnQRCode.setSize(new Dimension(120, 120));
    btnQRCode.setAlignmentX(Component.CENTER_ALIGNMENT);
    btnQRCode.setMinimumSize(new Dimension(120, 120));
    btnQRCode.setMaximumSize(new Dimension(500, 500));
    btnQRCode.setPreferredSize(new Dimension(200, 200));

    JPanel panelAddressNameBalance = new JPanel();
    panelAddress.add(panelAddressNameBalance, BorderLayout.NORTH);
    panelAddressNameBalance.setLayout(new BoxLayout(panelAddressNameBalance, BoxLayout.Y_AXIS));

    JLabel lblReceivingAddress = new JLabel(" Receiving Address:");
    lblReceivingAddress.setPreferredSize(new Dimension(59, 30));
    lblReceivingAddress.setAlignmentX(Component.CENTER_ALIGNMENT);
    panelAddressNameBalance.add(lblReceivingAddress);

    JPanel panel_1 = new JPanel();
    panelAddressNameBalance.add(panel_1);
    panel_1.setLayout(new BoxLayout(panel_1, BoxLayout.X_AXIS));

    txtAddress = new JTextField();
    txtAddress.setPreferredSize(new Dimension(14, 30));
    panel_1.add(txtAddress);
    txtAddress.setFont(new Font("Lucida Grande", Font.PLAIN, 18));
    txtAddress.setHorizontalAlignment(SwingConstants.CENTER);
    txtAddress.setBackground(SystemColor.window);
    txtAddress.setEditable(false);
    txtAddress.setColumns(10);

    JPanel panel_2 = new JPanel();
    panel_2.setVisible(false);
    panelAddressNameBalance.add(panel_2);
    panel_2.setLayout(new BoxLayout(panel_2, BoxLayout.X_AXIS));

    JLabel lblDescription = new JLabel(" Name:");
    lblDescription.setPreferredSize(new Dimension(55, 16));
    panel_2.add(lblDescription);

    txtName = new JTextField();
    panel_2.add(txtName);
    txtName.setFont(new Font("Lucida Grande", Font.PLAIN, 16));
    txtName.setText("Donation");
    txtName.setHorizontalAlignment(SwingConstants.CENTER);
    txtName.setBackground(Color.WHITE);
    txtName.setColumns(10);

    JPanel panel_3 = new JPanel();
    panel_3.setVisible(false);
    panelAddressNameBalance.add(panel_3);
    panel_3.setLayout(new BoxLayout(panel_3, BoxLayout.X_AXIS));

    JLabel lblBalance = new JLabel(" Balance:");
    lblBalance.setPreferredSize(new Dimension(55, 16));
    panel_3.add(lblBalance);

    txtBalance = new JTextField();
    panel_3.add(txtBalance);
    txtBalance.setFont(new Font("Lucida Grande", Font.PLAIN, 15));
    txtBalance.setText("NA");
    txtBalance.setHorizontalAlignment(SwingConstants.CENTER);
    txtBalance.setBackground(SystemColor.window);
    txtBalance.setEditable(false);
    txtBalance.setColumns(10);

    JLabel lblDoge = new JLabel("DOGE");
    lblDoge.setPreferredSize(new Dimension(40, 16));
    panel_3.add(lblDoge);

    JPanel panelReceivedSent = new JPanel();
    panelReceivedSent.setVisible(false);
    panelAddress.add(panelReceivedSent, BorderLayout.SOUTH);
    panelReceivedSent.setLayout(new GridLayout(0, 1, 0, 0));

    JPanel panelReceived = new JPanel();
    panelReceivedSent.add(panelReceived);
    panelReceived.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JLabel labelReceived = new JLabel("Received:");
    labelReceived.setHorizontalAlignment(SwingConstants.CENTER);
    labelReceived.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    panelReceived.add(labelReceived);

    txtReceived = new JTextField();
    txtReceived.setText("NA");
    txtReceived.setHorizontalAlignment(SwingConstants.CENTER);
    txtReceived.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    txtReceived.setEditable(false);
    txtReceived.setColumns(10);
    txtReceived.setBackground(SystemColor.window);
    panelReceived.add(txtReceived);

    JLabel lblDogeReceived = new JLabel("DOGE");
    panelReceived.add(lblDogeReceived);

    JPanel panelSent = new JPanel();
    panelReceivedSent.add(panelSent);
    panelSent.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JLabel labelSent = new JLabel("Sent:");
    labelSent.setPreferredSize(new Dimension(59, 16));
    labelSent.setHorizontalAlignment(SwingConstants.CENTER);
    labelSent.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    panelSent.add(labelSent);

    txtSent = new JTextField();
    txtSent.setText("NA");
    txtSent.setHorizontalAlignment(SwingConstants.CENTER);
    txtSent.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    txtSent.setEditable(false);
    txtSent.setColumns(10);
    txtSent.setBackground(SystemColor.window);
    panelSent.add(txtSent);

    JLabel lblDogeSent = new JLabel("DOGE");
    panelSent.add(lblDogeSent);

    JTable tableAddressTransactions = new JTable();
    tableAddressTransactions.setVisible(false);
    splitPaneAddressAndTransactoions.setRightComponent(tableAddressTransactions);

    panelTransactions = new JPanel();
    tabbedPane.addTab("Transactions", null, panelTransactions, null);
    panelTransactions.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setAutoscrolls(true);
    panelTransactions.add(scrollPane, BorderLayout.CENTER);

    tableTransactions = new JTable();
    tableTransactions.setRowHeight(30);
    tableTransactions.setAutoscrolls(true);
    tableTransactions.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    tableTransactions.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    scrollPane.setViewportView(tableTransactions);

    panelAddressBook = new JPanel();
    tabbedPane.addTab("Address Book", null, panelAddressBook, null);
    panelAddressBook.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPaneAddressBook = new JScrollPane();
    panelAddressBook.add(scrollPaneAddressBook, BorderLayout.CENTER);

    tableAddressBook = new JTable();
    tableAddressBook.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            if (arg0.getClickCount() == 2) {
              JTable target = (JTable) arg0.getSource();
              int row = target.getSelectedRow();
              // int column = target.getSelectedColumn();
              if (row != -1) {
                Contact c = addressBookTableModel.getAddressBook().getContacts().get(row);
                send(c.getAddress(), c.getAmount());
              }
            }
          }
        });
    tableAddressBook.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tableAddressBook.setRowHeight(25);
    scrollPaneAddressBook.setViewportView(tableAddressBook);

    JToolBar toolBarAddressbook = new JToolBar();
    panelAddressBook.add(toolBarAddressbook, BorderLayout.NORTH);

    JButton btnNewRecipient = new JButton("New");
    btnNewRecipient.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            DialogContact d = new DialogContact();
            d.setLocationRelativeTo(frmWow);
            d.edit(false);
            d.setNetworkParameters(coreWallet.getNetworkParameters());
            if (d.showDialog()) {
              Contact c =
                  new Contact(d.getName(), d.getAddress(), d.getDescription(), d.getAmount());
              addressBookTableModel.getAddressBook().addContact(c);
              addressBookTableModel.getAddressBook().sort();

              try {
                addressBookTableModel.getAddressBook().save();
              } catch (IOException e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(
                    frmWow,
                    e1.getMessage(),
                    "Error During Address Book Save",
                    JOptionPane.ERROR_MESSAGE);
              } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(
                    frmWow,
                    e1.getMessage(),
                    "Error During Address Book Save",
                    JOptionPane.ERROR_MESSAGE);
              } catch (BackingStoreException e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(
                    frmWow,
                    e1.getMessage(),
                    "Error During Address Book Save",
                    JOptionPane.ERROR_MESSAGE);
              }
              addressBookTableModel.fireTableDataChanged();
            }
          }
        });
    btnNewRecipient.setToolTipText("New address template to send payments to");
    toolBarAddressbook.add(btnNewRecipient);

    JButton btnEdit = new JButton("Edit");
    btnEdit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            DialogContact d = new DialogContact();
            d.setLocationRelativeTo(frmWow);
            d.edit(true);
            int index = tableAddressBook.getSelectedRow();
            if (index != -1) {
              d.setNetworkParameters(coreWallet.getNetworkParameters());
              Contact c = addressBookTableModel.getAddressBook().getContacts().get(index);
              d.setName(c.getName());
              d.setAddress(c.getAddress());
              d.setDescription(c.getDescription());
              d.setAmount(c.getAmount());
              if (d.showDialog()) {
                c.setName(d.getName());
                c.setAddress(d.getAddress());
                c.setDescription(d.getDescription());
                c.setAmount(d.getAmount());
                addressBookTableModel.getAddressBook().sort();
                try {
                  addressBookTableModel.getAddressBook().save();
                } catch (IOException e1) {
                  e1.printStackTrace();
                  JOptionPane.showMessageDialog(
                      frmWow,
                      e1.getMessage(),
                      "Error During Address Book Save",
                      JOptionPane.ERROR_MESSAGE);
                } catch (ClassNotFoundException e1) {
                  e1.printStackTrace();
                  JOptionPane.showMessageDialog(
                      frmWow,
                      e1.getMessage(),
                      "Error During Address Book Save",
                      JOptionPane.ERROR_MESSAGE);
                } catch (BackingStoreException e1) {
                  e1.printStackTrace();
                  JOptionPane.showMessageDialog(
                      frmWow,
                      e1.getMessage(),
                      "Error During Address Book Save",
                      JOptionPane.ERROR_MESSAGE);
                }
                addressBookTableModel.fireTableDataChanged();
              }
            }
          }
        });
    btnEdit.setToolTipText("Edit address template");
    toolBarAddressbook.add(btnEdit);

    JButton btnDelete = new JButton("Delete");
    btnDelete.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            int index = tableAddressBook.getSelectedRow();
            if (index != -1) {
              Contact c = addressBookTableModel.getAddressBook().getContacts().get(index);
              if (JOptionPane.showConfirmDialog(
                      frmWow,
                      "Do you really want to delete Address Template?\nName: "
                          + c.getName()
                          + "\nAddress: "
                          + c.getAddress()
                          + "\nDescription: "
                          + c.getDescription()
                          + "\nAmount: "
                          + c.getAmount(),
                      "Confirm Deletion",
                      JOptionPane.YES_NO_OPTION,
                      JOptionPane.QUESTION_MESSAGE)
                  == JOptionPane.YES_OPTION) {
                addressBookTableModel.getAddressBook().getContacts().remove(c);
                try {
                  addressBookTableModel.getAddressBook().save();
                } catch (IOException e1) {
                  e1.printStackTrace();
                  JOptionPane.showMessageDialog(
                      frmWow,
                      e1.getMessage(),
                      "Error During Address Book Save",
                      JOptionPane.ERROR_MESSAGE);
                } catch (ClassNotFoundException e1) {
                  e1.printStackTrace();
                  JOptionPane.showMessageDialog(
                      frmWow,
                      e1.getMessage(),
                      "Error During Address Book Save",
                      JOptionPane.ERROR_MESSAGE);
                } catch (BackingStoreException e1) {
                  e1.printStackTrace();
                  JOptionPane.showMessageDialog(
                      frmWow,
                      e1.getMessage(),
                      "Error During Address Book Save",
                      JOptionPane.ERROR_MESSAGE);
                }
                addressBookTableModel.fireTableDataChanged();
              }
            }
          }
        });
    btnDelete.setToolTipText("Delete address template");
    toolBarAddressbook.add(btnDelete);

    JButton btnSend = new JButton("Send");
    btnSend.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            int row = tableAddressBook.getSelectedRow();
            if (row != -1) {
              Contact c = addressBookTableModel.getAddressBook().getContacts().get(row);
              send(c.getAddress(), c.getAmount());
            }
          }
        });
    btnSend.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    btnSend.setToolTipText("Send payment to address template");
    toolBarAddressbook.add(btnSend);

    Component horizontalGlue = Box.createHorizontalGlue();
    toolBarAddressbook.add(horizontalGlue);

    JButton btnSendToAddress = new JButton("Send to Address");
    btnSendToAddress.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            send(null, 0);
          }
        });
    btnSendToAddress.setToolTipText("Send payment to specified address");
    btnSendToAddress.setFont(new Font("Lucida Grande", Font.PLAIN, 14));
    toolBarAddressbook.add(btnSendToAddress);

    Component horizontalGlue_1 = Box.createHorizontalGlue();
    toolBarAddressbook.add(horizontalGlue_1);

    Component horizontalStrut = Box.createHorizontalStrut(20);
    horizontalStrut.setPreferredSize(new Dimension(110, 0));
    toolBarAddressbook.add(horizontalStrut);

    JToolBar toolBarTotal = new JToolBar();
    frmWow.getContentPane().add(toolBarTotal, BorderLayout.NORTH);

    tglbtnLock = new JToggleButton("Not Encrypted");
    tglbtnLock.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (coreWallet.isEncrypted()) {
              DialogPassword d = new DialogPassword();
              d.setLocationRelativeTo(frmWow);
              if (d.showDialog()) {
                try {
                  coreWallet.decrypt(new String(d.getPassword()));
                } catch (KeyCrypterException e) {
                  e.printStackTrace();
                  JOptionPane.showMessageDialog(
                      frmWow, "Wallet dencryption failed!", "Error", JOptionPane.ERROR_MESSAGE);
                }
              }
            } else {
              DialogEncrypt d = new DialogEncrypt();
              d.setLocationRelativeTo(frmWow);
              if (d.showDialog()) {
                // System.out.println("NAZDAR");
                // System.out.println(d.getPassword());
                try {
                  coreWallet.encrypt(new String(d.getPassword()));
                } catch (Exception e) { // KeyCrypterException
                  e.printStackTrace();
                  JOptionPane.showMessageDialog(
                      frmWow, "Wallet encryption failed!\n", "Error", JOptionPane.ERROR_MESSAGE);
                }
              }
            }
            updateEncryptionState();
          }
        });
    toolBarTotal.add(tglbtnLock);
    tglbtnLock.setToolTipText("Wallet not encrypted");

    JLabel lblTotal = new JLabel("Balance:");
    lblTotal.setFont(new Font("Lucida Grande", Font.PLAIN, 23));
    toolBarTotal.add(lblTotal);

    textTotalBalance = new JTextField();
    textTotalBalance.setPreferredSize(new Dimension(250, 28));
    textTotalBalance.setFont(new Font("Lucida Grande", Font.PLAIN, 23));
    textTotalBalance.setHorizontalAlignment(SwingConstants.CENTER);
    textTotalBalance.setBackground(SystemColor.window);
    textTotalBalance.setEditable(false);
    toolBarTotal.add(textTotalBalance);
    textTotalBalance.setColumns(10);

    JLabel lblTotalDoge = new JLabel("DOGE ");
    lblTotalDoge.setFont(new Font("Lucida Grande", Font.PLAIN, 23));
    toolBarTotal.add(lblTotalDoge);

    JToolBar toolBarStatus = new JToolBar();
    frmWow.getContentPane().add(toolBarStatus, BorderLayout.SOUTH);

    lblStatus = new JLabel(" Connecting...    ");
    toolBarStatus.add(lblStatus);

    progressBarStatus = new JProgressBar();
    progressBarStatus.setPreferredSize(new Dimension(250, 20));
    toolBarStatus.add(progressBarStatus);

    JLabel label = new JLabel("    ");
    toolBarStatus.add(label);
  }
Example #10
0
  @Override
  protected void initialiseOWLView() throws Exception {
    obdaController = (OBDAModelManager) getOWLEditorKit().get(OBDAModelImpl.class.getName());
    obdaController.addListener(this);

    prefixManager = obdaController.getActiveOBDAModel().getPrefixManager();

    queryEditorPanel =
        new QueryInterfacePanel(
            obdaController.getActiveOBDAModel(), obdaController.getQueryController());
    queryEditorPanel.setPreferredSize(new Dimension(400, 250));
    queryEditorPanel.setMinimumSize(new Dimension(400, 250));

    resultTablePanel = new ResultViewTablePanel(queryEditorPanel);
    resultTablePanel.setMinimumSize(new java.awt.Dimension(400, 250));
    resultTablePanel.setPreferredSize(new java.awt.Dimension(400, 250));

    JSplitPane splQueryInterface = new JSplitPane();
    splQueryInterface.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splQueryInterface.setResizeWeight(0.5);
    splQueryInterface.setDividerLocation(0.5);
    splQueryInterface.setOneTouchExpandable(true);
    splQueryInterface.setTopComponent(queryEditorPanel);
    splQueryInterface.setBottomComponent(resultTablePanel);

    JPanel pnlQueryInterfacePane = new JPanel();
    pnlQueryInterfacePane.setLayout(new BorderLayout());
    pnlQueryInterfacePane.add(splQueryInterface, BorderLayout.CENTER);
    setLayout(new BorderLayout());
    add(pnlQueryInterfacePane, BorderLayout.CENTER);

    // Setting up model listeners
    ontologyListener =
        new OWLOntologyChangeListener() {
          @Override
          public void ontologiesChanged(List<? extends OWLOntologyChange> changes)
              throws OWLException {
            Runnable runner =
                new Runnable() {
                  public void run() {
                    resultTablePanel.setTableModel(new DefaultTableModel());
                  }
                };
            SwingUtilities.invokeLater(runner);
          }
        };

    this.getOWLModelManager().addOntologyChangeListener(ontologyListener);
    setupListeners();

    // Setting up actions for all the buttons of this view.
    resultTablePanel.setCountAllTuplesActionForUCQ(
        new OBDADataQueryAction<Integer>("Counting tuples...", QueryInterfaceView.this) {
          @Override
          public OWLEditorKit getEditorKit() {
            return getOWLEditorKit();
          }

          @Override
          public int getNumberOfRows() {
            return -1;
          }

          @Override
          public void handleResult(Integer result) {
            updateTablePanelStatus(result);
          }

          @Override
          public Integer executeQuery(QuestOWLStatement st, String query) throws OWLException {
            return st.getTupleCount(query);
          }

          @Override
          public boolean isRunning() {
            return false;
          }
        });

    queryEditorPanel.setExecuteSelectAction(
        new OBDADataQueryAction<QuestOWLResultSet>(
            "Executing queries...", QueryInterfaceView.this) {

          @Override
          public OWLEditorKit getEditorKit() {
            return getOWLEditorKit();
          }

          @Override
          public void handleResult(QuestOWLResultSet result) throws OWLException {
            createTableModelFromResultSet(result);
            showTupleResultInTablePanel();
          }

          @Override
          public void run(String query) {
            removeResultTable();
            super.run(query);
          }

          @Override
          public int getNumberOfRows() {
            OWLResultSetTableModel tm = getTableModel();
            if (tm == null) return 0;
            return getTableModel().getRowCount();
          }

          public boolean isRunning() {
            OWLResultSetTableModel tm = getTableModel();
            if (tm == null) return false;
            return tm.isFetching();
          }

          @Override
          public QuestOWLResultSet executeQuery(QuestOWLStatement st, String queryString)
              throws OWLException {
            return st.executeTuple(queryString);
          }
        });

    queryEditorPanel.setExecuteGraphQueryAction(
        new OBDADataQueryAction<List<OWLAxiom>>("Executing queries...", QueryInterfaceView.this) {

          @Override
          public OWLEditorKit getEditorKit() {
            return getOWLEditorKit();
          }

          @Override
          public List<OWLAxiom> executeQuery(QuestOWLStatement st, String queryString)
              throws OWLException {
            return st.executeGraph(queryString);
          }

          @Override
          public void handleResult(List<OWLAxiom> result) {
            OWLAxiomToTurtleVisitor owlVisitor = new OWLAxiomToTurtleVisitor(prefixManager);
            populateResultUsingVisitor(result, owlVisitor);
            showGraphResultInTextPanel(owlVisitor);
          }

          @Override
          public int getNumberOfRows() {
            OWLResultSetTableModel tm = getTableModel();
            if (tm == null) return 0;
            return getTableModel().getRowCount();
          }

          public boolean isRunning() {
            OWLResultSetTableModel tm = getTableModel();
            if (tm == null) return false;
            return tm.isFetching();
          }
        });

    queryEditorPanel.setRetrieveUCQExpansionAction(
        new OBDADataQueryAction<String>("Rewriting query...", QueryInterfaceView.this) {

          @Override
          public String executeQuery(QuestOWLStatement st, String query) throws OWLException {
            return st.getRewriting(query);
          }

          @Override
          public OWLEditorKit getEditorKit() {
            return getOWLEditorKit();
          }

          @Override
          public void handleResult(String result) {
            showActionResultInTextPanel("UCQ Expansion Result", result);
          }

          @Override
          public int getNumberOfRows() {
            return -1;
          }

          @Override
          public boolean isRunning() {
            return false;
          }
        });

    queryEditorPanel.setRetrieveUCQUnfoldingAction(
        new OBDADataQueryAction<String>("Unfolding queries...", QueryInterfaceView.this) {
          @Override
          public String executeQuery(QuestOWLStatement st, String query) throws OWLException {
            return st.getUnfolding(query);
          }

          @Override
          public OWLEditorKit getEditorKit() {
            return getOWLEditorKit();
          }

          @Override
          public void handleResult(String result) {
            showActionResultInTextPanel("UCQ Unfolding Result", result);
          }

          @Override
          public int getNumberOfRows() {
            return -1;
          }

          @Override
          public boolean isRunning() {
            return false;
          }
        });

    resultTablePanel.setOBDASaveQueryToFileAction(
        new OBDASaveQueryResultToFileAction() {
          @Override
          public void run(String fileLocation) {
            OBDAProgessMonitor monitor = null;
            try {
              monitor = new OBDAProgessMonitor("Writing output files...");
              monitor.start();
              CountDownLatch latch = new CountDownLatch(1);
              List<String[]> data = tableModel.getTabularData();
              if (monitor.isCanceled()) return;
              File output = new File(fileLocation);
              BufferedWriter writer = new BufferedWriter(new FileWriter(output, false));
              SaveQueryToFileAction action = new SaveQueryToFileAction(latch, data, writer);
              monitor.addProgressListener(action);
              action.run();
              latch.await();
              monitor.stop();
            } catch (Exception e) {
              DialogUtils.showQuickErrorDialog(QueryInterfaceView.this, e);
            }
          }
        });
    log.debug("Query Manager view initialized");
  }
  private void jbInit() throws Exception {
    border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    border2 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    border3 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder1 = new TitledBorder(border3, "Subject");
    border4 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder2 = new TitledBorder(border4, "Message");
    border5 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder3 = new TitledBorder(border5, "Subject");
    border6 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder4 = new TitledBorder(border6, "Message");
    border7 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder5 = new TitledBorder(border7, "Messages");
    border8 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder6 = new TitledBorder(border8, "Online Users");
    border9 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder7 = new TitledBorder(border9, "Send Message");
    this.getContentPane().setLayout(borderLayout1);
    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
    jSplitPane1.setBorder(border1);
    jSplitPane1.setLastDividerLocation(250);
    jSplitPane1.setResizeWeight(1.0);
    jLabelServer.setRequestFocusEnabled(true);
    jLabelServer.setText("Server");
    jLabelUserId.setText("User Id");
    jTextFieldServer.setPreferredSize(new Dimension(75, 20));
    jTextFieldServer.setText("");
    jTextFieldUser.setPreferredSize(new Dimension(75, 20));
    jTextFieldUser.setText("");
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setJMenuBar(jMenuBarMain);
    this.setTitle("Message Client");
    jLabeltargetUser.setText("Target");
    jTextFieldTargetUser.setPreferredSize(new Dimension(75, 20));
    jTextFieldTargetUser.setText("");
    jPanelSendMessages.setBorder(border2);
    jPanelSendMessages.setMaximumSize(new Dimension(32767, 32767));
    jPanelSendMessages.setOpaque(false);
    jPanelSendMessages.setPreferredSize(new Dimension(96, 107));
    jPanelSendMessages.setRequestFocusEnabled(true);
    jPanelSendMessages.setToolTipText("");
    jPanelSendMessages.setLayout(verticalFlowLayout1);
    jTextFieldSendSubject.setBorder(titledBorder3);
    jTextFieldSendSubject.setText("");
    jTextFieldSendSubject.addKeyListener(new Client_jTextFieldSendSubject_keyAdapter(this));
    jSplitPane2.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    jScrollPane1.setBorder(titledBorder5);
    jScrollPane2.setBorder(titledBorder6);
    jToggleButtonRegister.setText("Register");
    jToggleButtonRegister.addActionListener(new Client_jToggleButtonRegister_actionAdapter(this));
    jButtonMultiConnect.setText("Multi-Connect");
    jButtonMultiConnect.addActionListener(new Client_jButtonMultiConnect_actionAdapter(this));
    jListOnlineUsers.addMouseListener(new Client_jListOnlineUsers_mouseAdapter(this));
    jToggleButtonConnect.setText("Connect");
    jToggleButtonConnect.addActionListener(new Client_jToggleButtonConnect_actionAdapter(this));
    jTextPaneDisplayMessages.setEditable(false);
    jTextPaneDisplayMessages.addMouseListener(
        new Client_jTextPaneDisplayMessages_mouseAdapter(this));
    jTextFieldSendMessages.setBorder(titledBorder7);
    jTextFieldSendMessages.setToolTipText("");
    jTextFieldSendMessages.addKeyListener(new Client_jTextFieldSendMessages_keyAdapter(this));
    jButtonMessageStresser.setText("Msg Stresser");
    jButtonMessageStresser.addActionListener(
        new Client_jToggleButtonMessageStresser_actionAdapter(this));
    jMenuItemClearMessages.setText("Clear Messages");
    jMenuItemClearMessages.addActionListener(new Client_jMenuItemClearMessages_actionAdapter(this));
    jMenuServer.setText("Server");
    jMenuItemServerConnect.setText("Connect");
    jMenuItemServerConnect.addActionListener(new Client_jMenuItemServerConnect_actionAdapter(this));
    jMenuItemServerDisconnect.setText("Disconnect");
    jMenuItemServerDisconnect.addActionListener(
        new Client_jMenuItemServerDisconnect_actionAdapter(this));
    jMenuOptions.setText("Options");
    jMenuTest.setText("Test");
    jMenuItemOptionsRegister.setText("Register");
    jMenuItemOptionsRegister.addActionListener(
        new Client_jMenuItemOptionsRegister_actionAdapter(this));
    jMenuItemOptionsDeregister.setText("Deregister");
    jMenuItemOptionsDeregister.addActionListener(
        new Client_jMenuItemOptionsDeregister_actionAdapter(this));
    jMenuItemOptionsEavesdrop.setText("Eavesdrop");
    jMenuItemOptionsEavesdrop.addActionListener(
        new Client_jMenuItemOptionsEavesdrop_actionAdapter(this));
    jMenuItemOptionsUneavesdrop.setText("Uneavesdrop");
    jMenuItemOptionsUneavesdrop.addActionListener(
        new Client_jMenuItemOptionsUneavesdrop_actionAdapter(this));
    jMenuItemTestMulticonnect.setText("Multiconnect");
    jMenuItemTestMulticonnect.addActionListener(
        new Client_jMenuItemTestMulticonnect_actionAdapter(this));
    jMenuItemTestMessageStresser.setText("Message Stresser");
    jMenuItemTestMessageStresser.addActionListener(
        new Client_jMenuItemTestMessageStresser_actionAdapter(this));
    jMenuItemTestMultidisconnect.setText("Multidisconnect");
    jMenuItemTestMultidisconnect.addActionListener(
        new Client_jMenuItemTestMultidisconnect_actionAdapter(this));
    jMenuItemOptionsGlobalEavesdrop.setText("Global Eavesdrop");
    jMenuItemOptionsGlobalEavesdrop.addActionListener(
        new Client_jMenuItemOptionsGlobalEavesdrop_actionAdapter(this));
    jMenuItemOptionsGlobalUneavesdrop.setEnabled(false);
    jMenuItemOptionsGlobalUneavesdrop.setText("Global Uneavesdrop");
    jMenuItemOptionsGlobalUneavesdrop.addActionListener(
        new Client_jMenuItemOptionsGlobalUneavesdrop_actionAdapter(this));
    jLabelPwd.setText("Pwd");
    jPasswordFieldPwd.setMinimumSize(new Dimension(11, 20));
    jPasswordFieldPwd.setPreferredSize(new Dimension(75, 20));
    jPasswordFieldPwd.setText("");
    jMenuItemScheduleCommand.setText("Schedule Command");
    jMenuItemScheduleCommand.addActionListener(
        new Client_jMenuItemScheduleCommand_actionAdapter(this));
    jMenuItemEditScheduledCommands.setText("Edit Scheduled Commands");
    jMenuItemEditScheduledCommands.addActionListener(
        new Client_jMenuItemEditScheduledCommands_actionAdapter(this));
    jPanelSendMessages.add(jTextFieldSendSubject, null);
    jPanelSendMessages.add(jTextFieldSendMessages, null);
    jSplitPane1.add(jSplitPane2, JSplitPane.TOP);
    jSplitPane2.add(jScrollPane1, JSplitPane.TOP);
    jScrollPane1.getViewport().add(jTextPaneDisplayMessages, null);
    jSplitPane2.add(jScrollPane2, JSplitPane.BOTTOM);
    jScrollPane2.getViewport().add(jListOnlineUsers, null);
    this.getContentPane().add(jSplitPane1, BorderLayout.CENTER);
    jSplitPane1.add(jPanelSendMessages, JSplitPane.BOTTOM);
    this.getContentPane().add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(jLabelServer, null);
    jPanel1.add(jTextFieldServer, null);
    jPanel1.add(jLabelUserId, null);
    jPanel1.add(jTextFieldUser, null);
    jPanel1.add(jLabelPwd, null);
    jPanel1.add(jPasswordFieldPwd, null);
    jPanel1.add(jLabeltargetUser, null);
    jPanel1.add(jTextFieldTargetUser, null);
    jPanel1.add(jToggleButtonConnect, null);
    jPanel1.add(jToggleButtonRegister, null);
    jPanel1.add(jButtonMultiConnect, null);
    jPanel1.add(jButtonMessageStresser, null);
    jPopupMenuMessageArea.add(jMenuItemClearMessages);
    jMenuBarMain.add(jMenuServer);
    jMenuBarMain.add(jMenuOptions);
    jMenuBarMain.add(jMenuTest);
    jMenuServer.add(jMenuItemServerConnect);
    jMenuServer.add(jMenuItemServerDisconnect);
    jMenuOptions.add(jMenuItemOptionsRegister);
    jMenuOptions.add(jMenuItemOptionsDeregister);
    jMenuOptions.add(jMenuItemOptionsEavesdrop);
    jMenuOptions.add(jMenuItemOptionsUneavesdrop);
    jMenuOptions.add(jMenuItemOptionsGlobalEavesdrop);
    jMenuOptions.add(jMenuItemOptionsGlobalUneavesdrop);
    jMenuTest.add(jMenuItemTestMulticonnect);
    jMenuTest.add(jMenuItemTestMultidisconnect);
    jMenuTest.add(jMenuItemTestMessageStresser);
    jMenuTest.add(jMenuItemScheduleCommand);
    jMenuTest.add(jMenuItemEditScheduledCommands);
    jSplitPane1.setDividerLocation(200);
    jSplitPane2.setDividerLocation(600);
    jListOnlineUsers.setCellRenderer(new OnlineListCellRenderer());
    jListOnlineUsers.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    jMenuItemTestMulticonnect.setEnabled(true);
    jMenuItemTestMultidisconnect.setEnabled(false);
    jMenuItemServerConnect.setEnabled(true);
    jMenuItemServerDisconnect.setEnabled(false);
    jMenuItemOptionsRegister.setEnabled(true);
    jMenuItemOptionsDeregister.setEnabled(false);
  }
Example #12
0
  /** Create the main JFrame */
  public Driver() {
    frame = (JFrame) this;

    setTitle("RIDVentory v2.1.2");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Creates connection to controller
    control = Controller.getInstance();

    setBounds(100, 100, 593, 370);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] {577, 0};
    gridBagLayout.rowHeights = new int[] {332, 0};
    gridBagLayout.columnWeights = new double[] {0.0, Double.MIN_VALUE};
    gridBagLayout.rowWeights = new double[] {0.0, Double.MIN_VALUE};
    getContentPane().setLayout(gridBagLayout);

    // Create Menu
    TopMenuBar topMenu = new TopMenuBar();
    this.setJMenuBar(topMenu.createMenuBar());

    // Popup Menus

    // Category Menu
    final JPopupMenu popupCat = new JPopupMenu();
    final JMenuItem addCat = new JMenuItem("Add Category");
    final JMenuItem editCat = new JMenuItem("Edit Category");
    final JMenuItem deleteCat = new JMenuItem("Delete Category");

    popupCat.add(addCat);
    popupCat.add(editCat);
    popupCat.add(deleteCat);

    // Brand Menu
    final JPopupMenu popupBrand = new JPopupMenu();
    final JMenuItem addBrand = new JMenuItem("Add Brand");
    final JMenuItem editBrand = new JMenuItem("Edit Brand");
    final JMenuItem deleteBrand = new JMenuItem("Delete Brand");

    popupBrand.add(addBrand);
    popupBrand.add(editBrand);
    popupBrand.add(deleteBrand);

    GridBagConstraints gbc_table = new GridBagConstraints();
    gbc_table.gridwidth = 3;
    gbc_table.fill = GridBagConstraints.BOTH;
    gbc_table.insets = new Insets(0, 0, 5, 0);
    gbc_table.gridx = 0;
    gbc_table.gridy = 0;
    gbc_table.weightx = 1;
    gbc_table.weighty = 1;

    GridBagConstraints gbc_buttonPanel = new GridBagConstraints();
    gbc_buttonPanel.insets = new Insets(0, 0, 5, 5);
    gbc_buttonPanel.fill = GridBagConstraints.BOTH;
    gbc_buttonPanel.gridx = 0;
    gbc_buttonPanel.gridy = 0;
    gbc_buttonPanel.weightx = 1;
    gbc_buttonPanel.weighty = 1;

    GridBagConstraints gbc_list = new GridBagConstraints();
    gbc_list.insets = new Insets(0, 0, 5, 0);
    gbc_list.anchor = GridBagConstraints.NORTHWEST;
    gbc_list.gridx = 1;
    gbc_list.gridy = 0;
    gbc_list.weightx = 1;
    gbc_list.weighty = 1;

    GridBagConstraints gbc_topMenu = new GridBagConstraints();
    gbc_topMenu.insets = new Insets(0, 0, 5, 0);
    gbc_topMenu.anchor = GridBagConstraints.NORTHWEST;
    gbc_topMenu.gridx = 1;
    gbc_topMenu.gridy = 0;
    gbc_topMenu.weightx = 1;
    gbc_topMenu.weighty = 1;

    JSplitPane splitPane = new JSplitPane();
    splitPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    GridBagConstraints gbc_splitPane = new GridBagConstraints();
    gbc_splitPane.weighty = 1.0;
    gbc_splitPane.weightx = 1.0;
    gbc_splitPane.fill = GridBagConstraints.BOTH;
    gbc_splitPane.gridx = 0;
    gbc_splitPane.gridy = 0;
    getContentPane().add(splitPane, gbc_splitPane);

    JPanel rightPanel = new JPanel();
    splitPane.setRightComponent(rightPanel);
    GridBagLayout gbl_rightPanel = new GridBagLayout();
    gbl_rightPanel.columnWidths = new int[] {499, 0};
    gbl_rightPanel.rowHeights = new int[] {281, 0};
    gbl_rightPanel.columnWeights = new double[] {0.0, Double.MIN_VALUE};
    gbl_rightPanel.rowWeights = new double[] {0.0, Double.MIN_VALUE};
    rightPanel.setLayout(gbl_rightPanel);

    table =
        new JTable() {
          /** */
          private static final long serialVersionUID = 1L;

          public boolean isCellEditable(int rowIndex, int vColIndex) {

            if (vColIndex > 0) // ID is not editable
            return true;
            else return false;
          }
        };

    table.setFillsViewportHeight(true);
    table.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setAlignmentY(Component.BOTTOM_ALIGNMENT);

    // Load table data
    tableData = control.loadTableData();

    final TableRowSorter<DefaultTableModel> sorter =
        new TableRowSorter<DefaultTableModel>((DefaultTableModel) tableData);
    table.setModel(tableData);
    table.setRowSorter(sorter);

    // Change it so load is only called once (Store results of load call and use it for list)

    catCellEditor = new JComboBox<String>(control.loadCategories());
    brandCellEditor = new JComboBox<String>(control.loadBrands());

    // Make model editor a dropdown (Make dynamic in the future)
    categoryColumn = table.getColumnModel().getColumn(3);
    brandColumn = table.getColumnModel().getColumn(4);

    categoryColumn.setCellEditor(new DefaultCellEditor(catCellEditor));
    brandColumn.setCellEditor(new DefaultCellEditor(brandCellEditor));

    // Right main pane
    JSplitPane splitPaneMain = new JSplitPane();
    splitPaneMain.setBorder(null);
    splitPaneMain.setDividerSize(-1);
    splitPaneMain.setResizeWeight(1.0);
    splitPaneMain.setPreferredSize(new Dimension(187, 25));
    splitPaneMain.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    splitPaneMain.setOrientation(JSplitPane.VERTICAL_SPLIT);

    GridBagConstraints gbc_splitPaneMain = new GridBagConstraints();
    gbc_splitPaneMain.weighty = 1.0;
    gbc_splitPaneMain.weightx = 1.0;
    gbc_splitPaneMain.fill = GridBagConstraints.BOTH;
    gbc_splitPaneMain.gridx = 0;
    gbc_splitPaneMain.gridy = 0;

    // Add split pane to main Right split pane
    rightPanel.add(splitPaneMain, gbc_splitPaneMain);

    // Right main pane, buttons row
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(0, 2, 0, 0));

    final JButton btnInsert = new JButton("Insert");
    final JButton btnDelete = new JButton("Delete");

    buttonPanel.add(btnInsert);
    buttonPanel.add(btnDelete);

    // Set components
    splitPaneMain.setTopComponent(new JScrollPane(table));
    splitPaneMain.setBottomComponent(buttonPanel);

    JPanel leftPanel = new JPanel();
    splitPane.setLeftComponent(leftPanel);
    GridBagLayout gbl_leftPanel = new GridBagLayout();
    gbl_leftPanel.columnWidths = new int[] {71, 0};
    gbl_leftPanel.rowHeights = new int[] {34, 0};
    gbl_leftPanel.columnWeights = new double[] {0.0, Double.MIN_VALUE};
    gbl_leftPanel.rowWeights = new double[] {0.0, Double.MIN_VALUE};
    leftPanel.setLayout(gbl_leftPanel);

    // Left Split panel
    JSplitPane splitPaneLists = new JSplitPane();
    splitPaneLists.setResizeWeight(0.5);
    splitPaneLists.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    GridBagConstraints gbc_splitPaneLists = new GridBagConstraints();
    gbc_splitPaneLists.anchor = GridBagConstraints.NORTHWEST;
    gbc_splitPaneLists.gridx = 0;
    gbc_splitPaneLists.gridy = 0;
    gbc_splitPaneLists.weightx = 1;
    gbc_splitPaneLists.weighty = 1;
    gbc_splitPaneLists.fill = GridBagConstraints.BOTH;

    leftPanel.add(splitPaneLists, gbc_splitPaneLists);

    // Right list
    final JList<String> brandList = new JList<String>();
    brandList.setLayoutOrientation(JList.VERTICAL_WRAP);
    brandList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    brandList.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    brandList.setAlignmentX(Component.RIGHT_ALIGNMENT);
    brandList.setAlignmentY(Component.TOP_ALIGNMENT);
    brandList.setModel(control.loadListBrands());
    brandList.setSelectedIndex(0);

    final ListSelectionModel brandListSelectionModel =
        (ListSelectionModel) brandList.getSelectionModel();
    splitPaneLists.setRightComponent(brandList);

    // Left List
    final JList<String> categoryList = new JList<String>();
    categoryList.setLayoutOrientation(JList.VERTICAL_WRAP);
    categoryList.setVisible(true);
    categoryList.setAlignmentY(Component.TOP_ALIGNMENT);
    categoryList.setAlignmentX(Component.LEFT_ALIGNMENT);
    categoryList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ListSelectionModel catListSelectionModel =
        categoryList.getSelectionModel(); // Created to add listener
    categoryList.setModel(control.loadListCategories());
    categoryList.setSelectedIndex(0);

    splitPaneLists.setLeftComponent(categoryList);

    table.addMouseListener(
        new MouseAdapter() {

          public void mouseReleased(MouseEvent e) {

            if (e.isPopupTrigger()) {

              Point p = e.getPoint();

              int rowNumber = table.rowAtPoint(p);

              if (Debug.LEVEL > 1) System.out.println("Row " + rowNumber + " selected");
            }
          }
        });

    btnDelete.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {

            int selectedRow = table.getSelectedRow();

            String name = (String) table.getModel().getValueAt(selectedRow, 1);

            if (selectedRow != -1) {
              int answer =
                  JOptionPane.showConfirmDialog(
                      frame,
                      "Are you sure you want to erase product " + name + "?\n",
                      "Are you sure?",
                      JOptionPane.YES_NO_OPTION);

              if (answer == JOptionPane.YES_OPTION) {

                if (Debug.LEVEL > 1) System.out.println("Row " + selectedRow + " Deleted");

                DefaultTableModel model = (DefaultTableModel) table.getModel();

                // Call Delete in controller

                int id = (int) model.getValueAt(selectedRow, 0);

                if (control.deleteItem(id) == -1) {
                  JOptionPane.showMessageDialog(
                      frame, "Error: Item could not be erased", "Error", JOptionPane.ERROR_MESSAGE);
                }

                if (Debug.LEVEL > 2) System.out.println("Product ID " + id);

                // Delete it from table model

                model.removeRow(selectedRow);
              }
            }
          }
        });

    btnInsert.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {

            InsertItem dialog = new InsertItem(table.getModel());

            dialog.setVisible(true);

            btnInsert.setEnabled(false); // Disable insert button so no multiple inserts
            btnDelete.setEnabled(false);

            // Put a listener on the window to determine when it closes
            dialog.addWindowListener(
                new WindowAdapter() {
                  @Override
                  public void windowClosed(WindowEvent e) {

                    // Notify table that data has changed to rerun filter
                    // fireTableCellUpdated
                    ((DefaultTableModel) tableData).fireTableDataChanged();

                    btnInsert.setEnabled(true); // Re-Enable insert button
                    btnDelete.setEnabled(true);

                    if (Debug.LEVEL > 3) System.out.println("Insert item window closed");
                  }
                });
          }
        });

    categoryList.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent e) {

            if (e.isPopupTrigger()) {

              Point p = e.getPoint();

              int itemChosen = categoryList.locationToIndex(p);

              // Make sure an item is chosen
              if (itemChosen > 0) // Greater than 0 to skip All
              {
                // Mark item as selected
                categoryList.setSelectedIndex(itemChosen);

                // Check if Delete Menu Item is on
                if (!popupDeleteOnCat) {
                  popupCat.add(editCat);
                  popupCat.add(deleteCat); // If not on, add it
                  popupDeleteOnCat = true;
                }

              } else {
                // Check if Delete is on
                if (popupDeleteOnCat) {
                  popupCat.remove(1); // Delete edit if turned on
                  popupCat.remove(1); // Delete delete if turned on
                  popupDeleteOnCat = false;
                }
              }

              popupCat.show(frame, e.getX(), e.getY());

              if (Debug.LEVEL > 0) System.out.println("Category List Item Chosen: " + itemChosen);
            }
          }
        });

    brandList.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent e) {

            if (e.isPopupTrigger()) {

              Point p = e.getPoint();

              int itemChosen = brandList.locationToIndex(p);

              // Make sure an item has been chosen
              if (itemChosen > 0) // Greater than 0 because 0 is All
              {
                // Mark item as selected
                brandList.setSelectedIndex(itemChosen);

                // Check if Delete Menu Item is not on the menu
                if (!popupDeleteOnBrand) {
                  popupBrand.add(editBrand);
                  popupBrand.add(deleteBrand); // If not on, add it
                  popupDeleteOnBrand = true;
                }

              } else {
                // Check if Delete is on the menu
                if (popupDeleteOnBrand) {
                  popupBrand.remove(1); // Delete edit
                  popupBrand.remove(1); // Delete delete if turned on
                  popupDeleteOnBrand = false;
                }
              }

              popupBrand.show(frame, e.getX(), e.getY());

              if (Debug.LEVEL > 0) System.out.println("Brand List Item Chosen: " + itemChosen);
            }
          }
        });

    // Selected index listeners
    catListSelectionModel.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {

            if (!e.getValueIsAdjusting()) // Proceed if values aren't being changed
            {
              int index = categoryList.getSelectedIndex();

              if (index >= 0) // Make sure you're actually working on an item
              {
                String category = (String) categoryList.getModel().getElementAt(index);

                index = brandList.getSelectedIndex();

                String brand = (String) brandList.getModel().getElementAt(index);

                // Call filter update
                sorter.setRowFilter(control.createFilter(category, brand));

                // debug
                if (Debug.LEVEL > 0) System.out.println("Category List Index Chosen: " + index);
              }
            }
          }
        });

    // Selected index listeners
    brandListSelectionModel.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {

            if (!e.getValueIsAdjusting()) // Proceed if values aren't being changed
            {
              int indexCat = categoryList.getSelectedIndex();
              int indexBrand = brandList.getSelectedIndex();

              if (indexCat >= 0 && indexBrand >= 0) // Make sure you're actually working on an item
              {
                String category = (String) categoryList.getModel().getElementAt(indexCat);

                String brand = (String) brandList.getModel().getElementAt(indexBrand);

                // Call filter update
                sorter.setRowFilter(control.createFilter(category, brand));
              }
            }
          }
        });

    addCat.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {

            String newCat =
                (String)
                    JOptionPane.showInputDialog(
                        frame,
                        "Enter the name of the new Category:",
                        "Add New Category",
                        JOptionPane.PLAIN_MESSAGE,
                        null,
                        null,
                        null);
            if (newCat == null) {

              return; // Don't do anything
            }

            if (newCat.isEmpty() || newCat == "") {
              JOptionPane.showMessageDialog(
                  frame,
                  "No input encountered",
                  "New category was not created",
                  JOptionPane.ERROR_MESSAGE);
              return; // Don't do anything
            }

            String result = control.addCategory(newCat);

            // Input checking needs to be added before beta 2
            if (result != null) {
              JOptionPane.showMessageDialog(
                  frame, result, "SQL Error Encountered", JOptionPane.ERROR_MESSAGE);

              return;
            }

            // Add category to list
            DefaultListModel<String> model = (DefaultListModel<String>) categoryList.getModel();

            model.addElement(newCat);
            catCellEditor.addItem(newCat);
          }
        });

    deleteCat.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {

            int catChosenIndex = categoryList.getSelectedIndex();
            String catName = (String) categoryList.getSelectedValue();

            // System.out.println(catChosen);

            int answer =
                JOptionPane.showConfirmDialog(
                    frame,
                    "Are you sure you want to delete category " + catName + "?\n",
                    "Are you sure?",
                    JOptionPane.YES_NO_OPTION);

            if (answer == JOptionPane.YES_OPTION) {
              if (control.deleteCategory(catName) != 0) {
                JOptionPane.showMessageDialog(
                    frame,
                    "Unable to erase category (category must not be used by any items)",
                    "SQL Error Encountered",
                    JOptionPane.ERROR_MESSAGE);

                return;
              }

              DefaultListModel<String> model = (DefaultListModel<String>) categoryList.getModel();

              categoryList.clearSelection();

              model.removeElementAt(catChosenIndex);
              catCellEditor.removeItem(catName);

              categoryList.setSelectedIndex(0);
            }
          }
        });

    addBrand.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {

            String newBrand =
                (String)
                    JOptionPane.showInputDialog(
                        frame,
                        "Enter the name of the new Brand:",
                        "Add New Category",
                        JOptionPane.PLAIN_MESSAGE,
                        null,
                        null,
                        null);
            if (newBrand == null) {

              return; // Don't do anything
            }

            if (newBrand.isEmpty() || newBrand == "") {
              JOptionPane.showMessageDialog(
                  frame,
                  "No input encountered",
                  "New category was not created",
                  JOptionPane.ERROR_MESSAGE);
              return; // Don't do anything
            }

            String result = control.addBrand(newBrand);

            // Input checking needs to be added before beta 2
            if (result != null) {
              JOptionPane.showMessageDialog(
                  frame, result, "SQL Error Encountered", JOptionPane.ERROR_MESSAGE);

              return;
            }

            // Add category to list
            DefaultListModel<String> model = (DefaultListModel<String>) brandList.getModel();

            model.addElement(newBrand);
            brandCellEditor.addItem(newBrand);
          }
        });

    deleteBrand.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {

            int brandChosenIndex = brandList.getSelectedIndex();
            String brandName = (String) brandList.getSelectedValue();

            System.out.println(brandChosenIndex);

            int answer =
                JOptionPane.showConfirmDialog(
                    frame,
                    "Are you sure you want to delete category " + brandName + "?\n",
                    "Are you sure?",
                    JOptionPane.YES_NO_OPTION);

            if (answer == JOptionPane.YES_OPTION) {
              if (control.deleteBrand(brandName) != 0) {
                JOptionPane.showMessageDialog(
                    frame,
                    "Unable to erase category (category must not be used by any items)",
                    "SQL Error Encountered",
                    JOptionPane.ERROR_MESSAGE);

                return;
              }

              DefaultListModel<String> model = (DefaultListModel<String>) brandList.getModel();

              // brandList.clearSelection();

              model.removeElementAt(brandChosenIndex);
              brandCellEditor.removeItem(brandName); // Use name to allow flexibility in future
              brandList.setSelectedIndex(0); // Reset to all
            }
          }
        });

    // Data change listener
    tableData.addTableModelListener(
        new TableModelListener() {

          public void tableChanged(TableModelEvent e) {

            try {
              int row = e.getFirstRow();
              int column = e.getColumn();
              String columnName = tableData.getColumnName(column);
              int itemID = (int) tableData.getValueAt(row, 0);
              Object data = tableData.getValueAt(row, column);

              if (Debug.LEVEL > 0) {
                System.out.println(
                    "Cell Edited at "
                        + row
                        + " "
                        + column
                        + ": "
                        + columnName
                        + " "
                        + data
                        + " ID: "
                        + itemID);
              }
              int rowsUpdated = control.updateItem(itemID, columnName, data);

              if (rowsUpdated == 0) {
                System.out.println("Failed to update, changes reverted");

                JOptionPane.showMessageDialog(
                    frame,
                    "Edit was invalid, please verify value is correct",
                    "SQL Error Encountered",
                    JOptionPane.ERROR_MESSAGE);

                // ((RidvTableModel)tableData).undoChange();
              }

            } catch (ArrayIndexOutOfBoundsException exception) {
              // Temp fix for data insertion bypass

            }
          }
        });
  }
Example #13
0
  /** Create the frame */
  public MainUI(BookingAgent agent) {
    super();
    setTitle("Centro " + BookingAgent.CENTRO.getNome() + " - " + BookingAgent.CENTRO.getTelefono());
    initializeLookAndFeels();
    getContentPane().setLayout(new BorderLayout());
    setBounds(100, 100, 550, 512);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JSplitPane splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(300);
    getContentPane().add(splitPane, BorderLayout.CENTER);

    final JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setSize(413, 299);
    panel.setMinimumSize(new Dimension(200, 200));
    splitPane.setLeftComponent(panel);

    final JPanel panel_1 = new JPanel();
    panel_1.setLayout(new BorderLayout());
    splitPane.setRightComponent(panel_1);

    final JPanel panel_2 = new JPanel();
    panel_1.add(panel_2, BorderLayout.NORTH);

    final JLabel lbl_prenotazioni = new JLabel();
    lbl_prenotazioni.setName("lbl_prenotazioni");
    lbl_prenotazioni.setText("Prenotazioni del");
    panel_2.add(lbl_prenotazioni);

    lbl_data = new JLabel();
    lbl_data.setName("lbl_data");
    panel_2.add(lbl_data);

    scrollPane = new JScrollPane();
    scrollPane.setName("sp_tabella");
    panel_1.add(scrollPane, BorderLayout.CENTER);

    /*table = new JTable(){
          public boolean isCellEditable(int rowIndex, int colIndex) {
              return false;   //Disallow the editing of any cell
            }
          };
    table.setMaximumSize(new Dimension(150, 150));
    table.setEditingRow(0);
    table.setEditingColumn(0);
    table.setName("tbl_prenotazioni");*/
    // inizializza la tabella
    initialize_table();
    scrollPane.setViewportView(table);

    calendar = new JCalendar();
    calendar.setMaximumSize(new Dimension(500, 400));
    calendar.setName("calendar");
    panel.add(calendar);
    calendar.setDecorationBackgroundVisible(true);
    calendar.setDecorationBordersVisible(false);
    calendar.setBorder(new MatteBorder(0, 0, 0, 0, Color.black));
    calendar.setWeekOfYearVisible(false);
    calendar.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            // System.out.println(evt.getPropertyName());
            setSelectedDate(calendar.getDate());
            getBooking();
          }
        });

    final JToolBar toolBar = new JToolBar();
    getContentPane().add(toolBar, BorderLayout.NORTH);
    //
  }
  public void initComponents() {

    allowedRoles = new String[] {"*"};
    idLabel = new JLabel("ID");
    vendorLabel = new JLabel("Vendor");
    currencyLabel = new JLabel("Currency");
    facilityLabel = new JLabel("Facility");

    modifyJButton = new TooltipJButton("modify");
    modifyJButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            modifyTableContent();
          }
        });
    modifyJButton.setBounds(420, 90, 75, 20);

    vendorLookup = new TooltipJButton("Lookup");
    vendorLookup.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            vendorSearch();
          }
        });
    facilityLookup = new TooltipJButton("Lookup");
    facilityLookup.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            facilitySearch();
          }
        });
    copyButton = new TooltipJButton("copy");
    copyButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            copy();
          }
        });
    importLabel = new JLabel("import");
    durationFromLabel = new JLabel("Valid From");
    durationToLabel = new JLabel("Valid To");
    idTextField = new ContextJTextField(this);
    vendor = new ContextJTextField(this, true);
    currency = new CurrencyBox(this, true);

    facility = new ContextJTextField(this, true);
    durationFromTextField = new DateJTextField(this, true);
    mandatoryFields.add(durationFromTextField);
    durationToTextField = new DateJTextField(this, true);
    mandatoryFields.add(durationToTextField);
    bargeTariffTable = new ComposedContextJTable();
    bargeTariffTable.setColorable(true);
    importCheckBox = new ImportExportPane(this);

    mandatoryFields.add(vendor);
    mandatoryFields.add(currency);
    mandatoryFields.add(facility);
    mandatoryFields.add(durationFromTextField);
    mandatoryFields.add(durationToTextField);

    scrollpane = new JScrollPane();
    scrollpane.setBounds(10, 120, 490, 200);

    bargeTariffTable.setBounds(0, 0, 400, 400);

    idLabel.setBounds(10, 10, 40, 20);
    idTextField.setBounds(100, 10, 100, 20);
    durationFromLabel.setBounds(10, 35, 80, 20);
    durationFromTextField.setBounds(100, 35, 100, 20);
    durationToLabel.setBounds(10, 60, 80, 20);
    durationToTextField.setBounds(100, 60, 100, 20);

    // importLabel.setBounds(10, 90, 40, 20);
    importCheckBox.setBounds(10, 90, 200, 25);

    vendorLabel.setBounds(220, 10, 80, 20);
    vendor.setBounds(300, 10, 100, 20);
    vendorLookup.setBounds(420, 10, 80, 20);

    currencyLabel.setBounds(220, 60, 80, 20);
    currency.setBounds(300, 60, 100, 20);

    facilityLabel.setBounds(220, 35, 80, 20);
    facility.setBounds(300, 35, 100, 20);
    facilityLookup.setBounds(420, 35, 80, 20);

    copyButton.setBounds(345, 90, 75, 20);
    panel.setLayout(null);
    panel.setSize(700, 215);
    panel.setMinimumSize(new Dimension(700, 130));
    panel.add(idLabel);
    panel.add(idTextField);
    panel.add(durationFromLabel);
    panel.add(durationFromTextField);
    panel.add(durationToLabel);
    panel.add(durationToTextField);
    panel.add(importLabel);
    panel.add(importCheckBox);
    panel.add(vendorLabel);
    panel.add(vendor);
    panel.add(vendorLookup);
    panel.add(currencyLabel);
    panel.add(currency);
    panel.add(facilityLabel);
    panel.add(facility);
    panel.add(facilityLookup);
    panel.add(copyButton);
    panel.add(modifyJButton);

    // tabbed pane
    tabPane = new JTabbedPane();
    tabPane.setBounds(10, 175, 870, 200);
    tabPane.add("Tarifflines", scrollpane);

    // VERSION_TOGGLE Tariff.2ExtraSurcharges Start ----------
    if (ResourceUtil.getBoolean("Tariff.2ExtraSurcharges")) {
      surchargesPanel = new SurchargesPanel((Tariff) getModel());
      tabPane.add("Surcharges", surchargesPanel);
    }
    // VERSION_TOGGLE Tariff.2ExtraSurcharges End ----------

    scrollpane.getViewport().add(bargeTariffTable);
    JSplitPane splitp = new JSplitPane();
    splitp.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitp.setLeftComponent(panel);
    splitp.setRightComponent(tabPane);
    splitp.setDividerSize(0);
    getContentPane().add(splitp);
    pack();
  }
  /**
   * Costruttore_ pg : riferimento all'oggetto di cui si vogliono modificare le caratteristiche_ g2d
   * : necessaria per l'implementazione_ lframe : riferimento al frame "proprietario" della finestra
   * di dialogo_ titolo : titolo della finestra di dialogo.
   */
  public FinestraElementoClasse(
      ElementoClasse ep,
      Graphics2D g2d,
      Frame lframe,
      String titolo,
      FileManager fileManager) // ezio 2006 - serve il fileManager
      {
    // Finestra di dialogo di tipo modale.
    super(lframe, titolo, true);

    this.fileManager = fileManager;
    // ctrlClient = Cliente;
    processo = ep;
    processografico = (ElementoBoxTesto) processo.getGrafico();
    grafica2D = g2d;

    // Costruzione del pannello relativo alle caratteristiche del rettangolo.
    dimensionirettangolopannello = new JPanel();
    dimensionirettangolopannello.setLayout(new GridLayout(2, 2));
    dimensionirettangolopannello.add(new JLabel("Width: "));
    controllolarghezza =
        new JComboBoxStep(
            ElementoBoxTesto.minlarghezza,
            ElementoBoxTesto.maxlarghezza,
            ElementoBoxTesto.steplarghezza,
            processografico.getWidth());
    dimensionirettangolopannello.add(controllolarghezza);
    dimensionirettangolopannello.add(new JLabel("Height: "));
    controlloaltezza =
        new JComboBoxStep(
            ElementoBoxTesto.minaltezza,
            ElementoBoxTesto.maxaltezza,
            ElementoBoxTesto.stepaltezza,
            processografico.getHeight());
    dimensionirettangolopannello.add(controlloaltezza);

    posizionerettangolopannello = new JPanel();
    posizionerettangolopannello.setLayout(new GridLayout(2, 2));
    posizionerettangolopannello.add(new JLabel("X: "));
    controllorettangoloX = new JTextField(processografico.getXAsString(), 4);
    posizionerettangolopannello.add(controllorettangoloX);
    posizionerettangolopannello.add(new JLabel("Y: "));
    controllorettangoloY = new JTextField(processografico.getYAsString(), 4);
    posizionerettangolopannello.add(controllorettangoloY);
    controllorettangoloY.setEnabled(false);

    dimANDposrettangolopannello = new JPanel();
    dimANDposrettangolopannello.setLayout(new BorderLayout());
    dimANDposrettangolopannello.add(dimensionirettangolopannello, BorderLayout.WEST);
    dimANDposrettangolopannello.add(posizionerettangolopannello, BorderLayout.EAST);
    dimANDposrettangolopannello.setBorder(BorderFactory.createTitledBorder("Shape"));

    sfondopannello = new JPanel();
    sfondopannello.setLayout(new GridLayout(2, 2));
    sfondopannello.add(new JLabel("Color: "));
    controllosfondocolore = new JComboBoxColor(processografico.getBackgroundColor());
    sfondopannello.add(controllosfondocolore);
    sfondopannello.setBorder(BorderFactory.createTitledBorder("BackGround"));

    lineapannello = new JPanel();
    lineapannello.setLayout(new GridLayout(2, 2));
    lineapannello.add(new JLabel("Color: "));
    controllolineacolore = new JComboBoxColor(processografico.getLineColor());
    lineapannello.add(controllolineacolore);
    lineapannello.add(new JLabel("Weight: "));
    controllolineaspessore =
        new JComboBoxStep(
            ElementoBox.minspessorelinea,
            ElementoBox.maxspessorelinea,
            ElementoBox.stepspessorelinea,
            processografico.getLineWeight());
    lineapannello.add(controllolineaspessore);
    lineapannello.setBorder(BorderFactory.createTitledBorder("Border"));

    sfoANDlinpannello = new JPanel();
    sfoANDlinpannello.setLayout(new BorderLayout());
    sfoANDlinpannello.add(sfondopannello, BorderLayout.WEST);
    sfoANDlinpannello.add(lineapannello, BorderLayout.EAST);

    graficoproprietapannello = new JPanel();
    graficoproprietapannello.setLayout(new BorderLayout());
    graficoproprietapannello.add(dimANDposrettangolopannello, BorderLayout.NORTH);
    graficoproprietapannello.add(sfoANDlinpannello, BorderLayout.SOUTH);

    // Costruzione del pannello relativo alle caratteristiche del testo.
    stringapannello = new JPanel();
    stringapannello.setLayout(new FlowLayout(FlowLayout.LEFT));
    stringapannello.add(new JLabel("Text: "));
    controllotesto = new JTextField(processo.getName(), 20);
    controllotesto.setEditable(false);
    stringapannello.add(controllotesto);
    stringapannello.setVisible(false);

    testopannello = new JPanel();
    testopannello.setLayout(new GridLayout(4, 1));
    testopannello.add(new JLabel("Font: "));
    controllotestofont = new JComboBoxFont(processografico.getTextFont());
    testopannello.add(controllotestofont);
    JLabel FontColor = new JLabel("Color: ");
    testopannello.add(FontColor);
    controllotestocolore = new JComboBoxColor(processografico.getTextColor());
    testopannello.add(controllotestocolore);
    testopannello.setBorder(BorderFactory.createTitledBorder("Text"));

    fontpannello = new JPanel();
    fontpannello.setLayout(new GridLayout(4, 1));
    fontpannello.add(new JLabel("Size: "));
    controllofontdimensione =
        new JComboBoxStep(
            ElementoBoxTesto.minfontdimensione,
            ElementoBoxTesto.maxfontdimensione,
            ElementoBoxTesto.stepfontdimensione,
            processografico.getFontSize());
    fontpannello.add(controllofontdimensione);
    fontpannello.add(new JLabel("Style: "));
    controllofontstile = new JComboBoxStyle(processografico.getFontStyle());
    fontpannello.add(controllofontstile);
    fontpannello.setBorder(BorderFactory.createTitledBorder("Font"));

    tesANDfonpannello = new JPanel();
    tesANDfonpannello.setLayout(new BorderLayout());
    tesANDfonpannello.add(testopannello, BorderLayout.WEST);
    tesANDfonpannello.add(fontpannello, BorderLayout.EAST);

    testoproprietapannello = new JPanel();
    testoproprietapannello.setLayout(new BorderLayout());
    testoproprietapannello.add(stringapannello, BorderLayout.NORTH);
    testoproprietapannello.add(tesANDfonpannello, BorderLayout.SOUTH);

    // Costruzione dei pannelli principali.
    nordpannello = new JTabbedPane();
    nordpannello.addTab(" Graphic ", graficoproprietapannello);
    nordpannello.addTab(" Text ", testoproprietapannello);

    okpulsante = new JButton("OK");
    okpulsante.addActionListener(new pulsantiListener());
    annullapulsante = new JButton("Cancel");
    annullapulsante.addActionListener(new pulsantiListener());
    sudpannello = new JPanel();
    sudpannello.setLayout(new FlowLayout());
    sudpannello.add(annullapulsante);
    sudpannello.add(okpulsante);
    getRootPane().setDefaultButton(okpulsante);

    principalepannello = new JSplitPane();
    principalepannello.setOrientation(JSplitPane.VERTICAL_SPLIT);
    principalepannello.setTopComponent(nordpannello);
    principalepannello.setBottomComponent(sudpannello);
    getContentPane().add(principalepannello);
    pack();

    Toolkit SystemKit = Toolkit.getDefaultToolkit();
    Dimension ScreenSize = SystemKit.getScreenSize();
    Dimension DialogSize = getSize();
    setLocation(
        (ScreenSize.width - DialogSize.width) / 2, (ScreenSize.height - DialogSize.height) / 2);
    setVisible(true);
  }
    public TestlocWorldFrame(String wdPath) {
      mapDirPath = wdPath;
      initFilelist();

      Model roundModel = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
      globeMapPanel = new MapPanel(roundModel, true);
      roundModel.getLayers().getLayerByName("Bing Imagery").setEnabled(true);
      LayerPanel layerPanel = new LayerPanel(globeMapPanel.wwd);
      globeDisplayAdapter =
          new DisplayAdapter(globeMapPanel.wwd, pointBuilderListener, MouseEvent.BUTTON1, 5, true);

      mapRenderLayer = new RenderableLayer();
      mapRenderLayer.setName("Surface Images");
      mapRenderLayer.setPickEnabled(false);
      LayerList layers = new LayerList();
      layers.add(mapRenderLayer);

      Model flatModel = new BasicModel(new EarthFlat(), layers);
      ((EarthFlat) flatModel.getGlobe()).setProjection(FlatGlobe.PROJECTION_LAT_LON);
      mapMapPanel = new MapPanel(flatModel, false);
      mapDisplayAdapter =
          new DisplayAdapter(
              mapMapPanel.wwd, markerBuilderListener, MouseEvent.BUTTON3, 50000, false);

      try {
        globeMapPanel.add(new GazetteerPanel(globeMapPanel.wwd, null), BorderLayout.NORTH);
      } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
        e.printStackTrace();
        System.exit(1);
      }

      mapSelectionList = new JList<String>(trackNames);
      mapSelectionList.addListSelectionListener(listListener);

      JLabel lblStepsize = new JLabel("Stepsize:");
      textFieldStepsize = new JTextField();
      textFieldStepsize.setText("5");

      btnStep = new JButton("Step");
      btnStep.addMouseListener(stepListener);

      btnStepToMarker = new JButton("to Marker");
      btnStepToMarker.addMouseListener(notImplementedListener);

      slider = new JSlider();
      slider.setValue(0);
      slider.addMouseListener(sliderListener);

      JLabel lblDstFallofExp = new JLabel("Distance Fallof:");
      textFieldDistFallofExp = new JTextField();
      textFieldDistFallofExp.setText(String.valueOf(7));

      JLabel lblTriDissimilarity = new JLabel("Tri Dissimilarity:");
      textFieldTriDissimilarity = new JTextField();
      textFieldTriDissimilarity.setText(String.valueOf(0.50));

      JLabel lblMinTriAngle = new JLabel("Min Tri Angle:");
      textFieldMinTriAngle = new JTextField();
      textFieldMinTriAngle.setText(String.valueOf(4.2));

      JLabel lblBadTriPen = new JLabel("Bad Tri Penalty:");
      textFieldBadTriPen = new JTextField();
      textFieldBadTriPen.setText(String.valueOf(0.10));

      btnDisplayTriangles = new JButton("Display Triangles");
      btnDisplayTriangles.addMouseListener(notImplementedListener);

      btnRefresh = new JButton("Refresh");
      btnRefresh.addMouseListener(parameterRefreshListener);

      tglbtnMouseMode = new JToggleButton("Mode: Move");
      tglbtnMouseMode.addMouseListener(toggleAction);

      JButton btnNewFile = new JButton("New File");
      btnNewFile.addMouseListener(newFileListener);

      JButton btnSaveFile = new JButton("Save File");
      btnSaveFile.addMouseListener(saveFileListener);

      // Window Builder generated stuff
      JPanel settings = new JPanel();
      GroupLayout groupLayout = new GroupLayout(settings);
      groupLayout.setHorizontalGroup(
          groupLayout
              .createParallelGroup(Alignment.TRAILING)
              .addGroup(
                  groupLayout
                      .createSequentialGroup()
                      .addContainerGap()
                      .addGroup(
                          groupLayout
                              .createParallelGroup(Alignment.LEADING)
                              .addGroup(
                                  groupLayout
                                      .createSequentialGroup()
                                      .addComponent(lblStepsize)
                                      .addGroup(
                                          groupLayout
                                              .createParallelGroup(Alignment.LEADING)
                                              .addGroup(
                                                  groupLayout
                                                      .createSequentialGroup()
                                                      .addGap(421)
                                                      .addComponent(lblTriDissimilarity)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(
                                                          textFieldTriDissimilarity,
                                                          GroupLayout.PREFERRED_SIZE,
                                                          36,
                                                          GroupLayout.PREFERRED_SIZE)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(lblBadTriPen)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(
                                                          textFieldBadTriPen,
                                                          GroupLayout.PREFERRED_SIZE,
                                                          34,
                                                          GroupLayout.PREFERRED_SIZE)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(btnRefresh)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(btnNewFile)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(btnSaveFile))
                                              .addGroup(
                                                  groupLayout
                                                      .createSequentialGroup()
                                                      .addGap(12)
                                                      .addComponent(
                                                          textFieldStepsize,
                                                          GroupLayout.PREFERRED_SIZE,
                                                          66,
                                                          GroupLayout.PREFERRED_SIZE)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(lblDstFallofExp)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(
                                                          textFieldDistFallofExp,
                                                          GroupLayout.PREFERRED_SIZE,
                                                          35,
                                                          GroupLayout.PREFERRED_SIZE)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(lblMinTriAngle)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(
                                                          textFieldMinTriAngle,
                                                          GroupLayout.PREFERRED_SIZE,
                                                          42,
                                                          GroupLayout.PREFERRED_SIZE))))
                              .addGroup(
                                  groupLayout
                                      .createSequentialGroup()
                                      .addComponent(
                                          btnStep,
                                          GroupLayout.PREFERRED_SIZE,
                                          67,
                                          GroupLayout.PREFERRED_SIZE)
                                      .addPreferredGap(ComponentPlacement.RELATED)
                                      .addComponent(btnStepToMarker)
                                      .addPreferredGap(ComponentPlacement.RELATED)
                                      .addComponent(
                                          tglbtnMouseMode,
                                          GroupLayout.PREFERRED_SIZE,
                                          128,
                                          GroupLayout.PREFERRED_SIZE)
                                      .addPreferredGap(ComponentPlacement.RELATED)
                                      .addComponent(
                                          btnDisplayTriangles,
                                          GroupLayout.PREFERRED_SIZE,
                                          161,
                                          GroupLayout.PREFERRED_SIZE)
                                      .addPreferredGap(ComponentPlacement.RELATED)
                                      .addComponent(
                                          slider, GroupLayout.DEFAULT_SIZE, 1062, Short.MAX_VALUE)))
                      .addContainerGap()));
      groupLayout.setVerticalGroup(
          groupLayout
              .createParallelGroup(Alignment.LEADING)
              .addGroup(
                  groupLayout
                      .createSequentialGroup()
                      .addContainerGap()
                      .addGroup(
                          groupLayout
                              .createParallelGroup(Alignment.BASELINE)
                              .addComponent(lblStepsize)
                              .addComponent(
                                  textFieldStepsize,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE)
                              .addComponent(lblDstFallofExp)
                              .addComponent(
                                  textFieldDistFallofExp,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE)
                              .addComponent(lblMinTriAngle)
                              .addComponent(
                                  textFieldMinTriAngle,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE)
                              .addComponent(lblTriDissimilarity)
                              .addComponent(
                                  textFieldTriDissimilarity,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE)
                              .addComponent(lblBadTriPen)
                              .addComponent(
                                  textFieldBadTriPen,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE)
                              .addComponent(btnRefresh)
                              .addComponent(btnNewFile)
                              .addComponent(btnSaveFile))
                      .addPreferredGap(ComponentPlacement.RELATED)
                      .addGroup(
                          groupLayout
                              .createParallelGroup(Alignment.TRAILING)
                              .addGroup(
                                  groupLayout
                                      .createParallelGroup(Alignment.BASELINE)
                                      .addComponent(btnStep)
                                      .addComponent(btnStepToMarker)
                                      .addComponent(tglbtnMouseMode)
                                      .addComponent(btnDisplayTriangles))
                              .addComponent(
                                  slider,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE))));
      settings.setLayout(groupLayout);

      JSplitPane globeSplit = new JSplitPane();
      globeSplit.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
      globeSplit.setLeftComponent(layerPanel);
      globeSplit.setRightComponent(globeMapPanel);
      globeSplit.setOneTouchExpandable(true);
      globeSplit.setContinuousLayout(true);
      globeSplit.setDividerLocation(0);

      JSplitPane imgSplit = new JSplitPane();
      imgSplit.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
      imgSplit.setLeftComponent(mapMapPanel);
      imgSplit.setRightComponent(mapSelectionList);
      imgSplit.setOneTouchExpandable(true);
      imgSplit.setContinuousLayout(true);

      JSplitPane layer2Split = new JSplitPane();
      layer2Split.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
      layer2Split.setLeftComponent(globeSplit);
      layer2Split.setRightComponent(imgSplit);
      layer2Split.setOneTouchExpandable(true);
      layer2Split.setContinuousLayout(true);
      layer2Split.setResizeWeight(0.5);

      this.add(settings, BorderLayout.NORTH);
      this.add(layer2Split, BorderLayout.CENTER);
      this.pack();

      this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);

      enableSettingsMode(false);
    }
Example #17
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  private void initComponents() {
    contentPane = new javax.swing.JSplitPane();
    leftPanel = new javax.swing.JSplitPane();
    projectListPanel = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jList1 = new javax.swing.JList();
    treePanel = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    jTree1 = new javax.swing.JTree();
    infoPanel = new javax.swing.JPanel();
    jMenuBar2 = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    newProjectMenu = new javax.swing.JMenuItem();
    openMenu = new javax.swing.JMenuItem();
    saveMenu = new javax.swing.JMenuItem();
    saveAsMenu = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    importPSIMenu = new javax.swing.JMenuItem();
    jSeparator2 = new javax.swing.JSeparator();
    jSeparator3 = new javax.swing.JSeparator();
    quitMenu = new javax.swing.JMenuItem();
    projectMenu = new javax.swing.JMenu();
    indicsMenu = new javax.swing.JMenu();
    variationMenu = new javax.swing.JMenuItem();
    ressourceMenu = new javax.swing.JMenuItem();
    alertMenu = new javax.swing.JMenuItem();
    consoMenu = new javax.swing.JMenuItem();
    compareMenu = new javax.swing.JMenuItem();
    settingMenu = new javax.swing.JMenu();
    warningSettingMenu = new javax.swing.JMenuItem();
    helpMenu = new javax.swing.JMenu();
    helpContMenu = new javax.swing.JMenuItem();

    addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(java.awt.event.WindowEvent evt) {
            exitForm(evt);
          }
        });

    leftPanel.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    projectListPanel.setLayout(new java.awt.BorderLayout());

    jLabel1.setText("Projets");
    projectListPanel.add(jLabel1, java.awt.BorderLayout.NORTH);

    jList1.setPreferredSize(new java.awt.Dimension(0, 100));
    jList1.addListSelectionListener(
        new javax.swing.event.ListSelectionListener() {
          public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jList1ValueChanged(evt);
          }
        });

    projectListPanel.add(jList1, java.awt.BorderLayout.CENTER);

    leftPanel.setTopComponent(projectListPanel);

    treePanel.setLayout(new java.awt.BorderLayout());

    jLabel2.setText("Structure de projet");
    treePanel.add(jLabel2, java.awt.BorderLayout.NORTH);

    jTree1.addTreeSelectionListener(
        new javax.swing.event.TreeSelectionListener() {
          public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
            jTree1ValueChanged(evt);
          }
        });

    treePanel.add(jTree1, java.awt.BorderLayout.CENTER);

    leftPanel.setBottomComponent(treePanel);

    contentPane.setLeftComponent(leftPanel);

    infoPanel.setLayout(new java.awt.BorderLayout());

    contentPane.setRightComponent(infoPanel);

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

    fileMenu.setText("Fichier");

    openMenu.setText("Ouvrir environnement...");
    openMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            openMenuActionPerformed(evt);
          }
        });

    fileMenu.add(openMenu);

    saveMenu.setText("Enregistrer");
    saveMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveMenuActionPerformed(evt);
          }
        });

    fileMenu.add(saveMenu);

    saveAsMenu.setText("Enregistrer sous...");
    saveAsMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveAsMenuActionPerformed(evt);
          }
        });

    fileMenu.add(saveAsMenu);

    fileMenu.add(jSeparator1);

    quitMenu.setText("Quitter");
    quitMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            quitMenuActionPerformed(evt);
          }
        });

    fileMenu.add(quitMenu);

    jMenuBar2.add(fileMenu);

    projectMenu.setText("Projet");
    projectMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            projectMenuActionPerformed(evt);
          }
        });

    newProjectMenu.setText("Ajout projet");
    newProjectMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            newProjectMenuActionPerformed(evt);
          }
        });

    projectMenu.add(newProjectMenu);

    importPSIMenu.setText("Import une étape...");
    importPSIMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            importPSIMenuActionPerformed(evt);
          }
        });

    projectMenu.add(importPSIMenu);

    projectMenu.add(jSeparator2);

    indicsMenu.setText("Indicateurs");

    variationMenu.setText("Variation sur le projet");
    variationMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            variationMenuActionPerformed(evt);
          }
        });

    alertMenu.setText("alertes");
    alertMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            alertMenuActionPerformed(evt);
          }
        });
    projectMenu.add(alertMenu);
    ressourceMenu.setText("Ressources");
    ressourceMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            ressourceMenuActionPerformed(evt);
          }
        });

    projectMenu.add(indicsMenu);

    indicsMenu.add(variationMenu);
    indicsMenu.add(ressourceMenu);

    consoMenu.setText("Consolidation...");
    consoMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            consoMenuActionPerformed(evt);
          }
        });
    projectMenu.add(consoMenu);

    projectMenu.add(jSeparator3);

    compareMenu.setText("Comparer les projets...");
    compareMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            compareMenuActionPerformed(evt);
          }
        });
    projectMenu.add(compareMenu);

    jMenuBar2.add(projectMenu);

    warningSettingMenu.setText("Réglages des seuils d'alertes");
    settingMenu.setText("Réglages");

    warningSettingMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            warningPropertiesMenuActionPerformed(evt);
          }
        });

    settingMenu.add(warningSettingMenu);
    jMenuBar2.add(settingMenu);

    helpMenu.setText("Aide");
    helpContMenu.setText("Sommaire");
    helpContMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            helpContMenuActionPerformed(evt);
          }
        });

    helpMenu.add(helpContMenu);

    jMenuBar2.add(helpMenu);

    setJMenuBar(jMenuBar2);

    pack();
  }
  /**
   * Instantiates a new movie information panel.
   *
   * @param movieSelectionModel the movie selection model
   */
  public MovieInformationPanel(MovieSelectionModel movieSelectionModel) {
    this.movieSelectionModel = movieSelectionModel;

    setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("450px:grow"),
            },
            new RowSpec[] {
              RowSpec.decode("fill:default:grow"),
            }));

    splitPaneVertical = new JSplitPane();
    splitPaneVertical.setBorder(null);
    splitPaneVertical.setResizeWeight(0.9);
    splitPaneVertical.setContinuousLayout(true);
    splitPaneVertical.setOneTouchExpandable(true);
    splitPaneVertical.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(splitPaneVertical, "1, 1, fill, fill");

    panelTop = new JPanel();
    panelTop.setBorder(null);
    splitPaneVertical.setTopComponent(panelTop);
    panelTop.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              FormFactory.RELATED_GAP_COLSPEC,
              ColumnSpec.decode("200px:grow"),
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
            },
            new RowSpec[] {
              RowSpec.decode("fill:default"), RowSpec.decode("top:pref:grow"),
            }));

    JPanel panelMovieHeader = new JPanel();
    panelTop.add(panelMovieHeader, "2, 1, 3, 1, fill, top");
    panelMovieHeader.setBorder(null);
    panelMovieHeader.setLayout(new BorderLayout(0, 0));

    JPanel panelMovieTitle = new JPanel();
    panelMovieHeader.add(panelMovieTitle, BorderLayout.NORTH);
    panelMovieTitle.setLayout(new BorderLayout(0, 0));
    lblMovieName = new JLabel("");
    TmmFontHelper.changeFont(lblMovieName, 1.33, Font.BOLD);
    panelMovieTitle.add(lblMovieName);

    JPanel panelRatingTagline = new JPanel();
    panelMovieHeader.add(panelRatingTagline, BorderLayout.CENTER);
    panelRatingTagline.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.UNRELATED_GAP_COLSPEC,
              ColumnSpec.decode("25px:grow"),
            },
            new RowSpec[] {
              FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("24px"), FormFactory.DEFAULT_ROWSPEC,
            }));

    lblRating = new JLabel("");
    panelRatingTagline.add(lblRating, "2, 2, left, center");

    lblVoteCount = new JLabel("");
    panelRatingTagline.add(lblVoteCount, "3, 2, left, center");

    panelRatingStars = new StarRater(10, 1);
    panelRatingTagline.add(panelRatingStars, "1, 2, left, top");
    panelRatingStars.setEnabled(false);

    lblTop250 = new JLabel("");
    panelRatingTagline.add(lblTop250, "5, 2, left, default");

    lblTagline = new JLabel();
    panelRatingTagline.add(lblTagline, "1, 3, 5, 1, default, center");

    panelMovieLogos = new JPanel();
    panelMovieHeader.add(panelMovieLogos, BorderLayout.EAST);

    lblCertificationImage = new JLabel();
    panelMovieLogos.add(lblCertificationImage);

    JLayeredPane layeredPaneImages = new JLayeredPane();
    panelTop.add(layeredPaneImages, "1, 2, 4, 1, fill, fill");
    layeredPaneImages.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("max(10px;default)"),
              ColumnSpec.decode("left:120px:grow"),
              ColumnSpec.decode("default:grow(10)"),
            },
            new RowSpec[] {
              RowSpec.decode("max(10px;default)"),
              RowSpec.decode("top:180px:grow"),
              RowSpec.decode("fill:80px:grow(3)"),
            }));

    lblMovieBackground = new ImageLabel(false, true);
    lblMovieBackground.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); // $NON-NLS-1$
    lblMovieBackground.enableLightbox();
    layeredPaneImages.add(lblMovieBackground, "1, 1, 3, 3, fill, fill");

    lblMoviePoster = new ImageLabel();
    lblMoviePoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); // $NON-NLS-1$
    lblMoviePoster.enableLightbox();
    layeredPaneImages.setLayer(lblMoviePoster, 1);
    layeredPaneImages.add(lblMoviePoster, "2, 2, fill, fill");

    lblWatchedImage = new JLabel();
    lblWatchedImage.setOpaque(false);
    layeredPaneImages.setLayer(lblWatchedImage, 2);
    layeredPaneImages.add(lblWatchedImage, "2, 2, left, top");

    JPanel panelGenres = new MovieGenresPanel(movieSelectionModel);
    layeredPaneImages.setLayer(panelGenres, 2);
    layeredPaneImages.add(panelGenres, "2, 2, 2, 2, right, bottom");

    JPanel panelLogos = new JPanel();
    panelLogos.setOpaque(false);
    layeredPaneImages.setLayer(panelLogos, 2);
    layeredPaneImages.add(panelLogos, "2, 2, 2, 2, right, top");
    panelLogos.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    lblMediaLogoResolution = new JLabel("");
    panelLogos.add(lblMediaLogoResolution);

    lblMediaLogoVideoCodec = new JLabel("");
    panelLogos.add(lblMediaLogoVideoCodec);

    lblMediaLogoAudio = new JLabel("");
    panelLogos.add(lblMediaLogoAudio);

    JPanel panelBottom = new JPanel();
    panelBottom.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("300px:grow"),
            },
            new RowSpec[] {
              FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("fill:min:grow"),
            }));

    tabbedPaneMovieDetails = new JTabbedPane(JTabbedPane.TOP);
    panelBottom.add(tabbedPaneMovieDetails, "1, 2, fill, fill");
    splitPaneVertical.setBottomComponent(panelBottom);

    panelDetails = new MovieDetailsPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.details"), null, panelDetails, null); // $NON-NLS-1$

    panelOverview = new JPanel();
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.plot"), null, panelOverview, null); // $NON-NLS-1$
    panelOverview.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("200px:grow"),
            },
            new RowSpec[] {
              FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("fill:default:grow"),
            }));
    // panelMovieDetails.add(tabbedPaneMovieDetails, "2, 3, fill, fill");

    JScrollPane scrollPaneOverview = new JScrollPane();
    scrollPaneOverview.setBorder(null);
    panelOverview.add(scrollPaneOverview, "1, 2, fill, fill");

    tpOverview = new JTextPane();
    tpOverview.setOpaque(false);
    tpOverview.setEditable(false);
    scrollPaneOverview.setViewportView(tpOverview);

    panelMovieCrew = new MovieCrewPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.crew"), null, panelMovieCrew, null); // $NON-NLS-1$

    MovieActorPanel panelMovieActors = new MovieActorPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.cast"), null, panelMovieActors, null); // $NON-NLS-1$

    panelMediaInformation = new MovieMediaInformationPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.mediainformation"),
        null,
        panelMediaInformation,
        null); //$NON-NLS-1$

    panelMediaFiles = new MovieMediaFilesPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.mediafiles"), null, panelMediaFiles, null); // $NON-NLS-1$

    final List<MediaFile> mediaFiles = new ArrayList<MediaFile>();
    final ImagePanel panelArtwork = new ImagePanel(mediaFiles);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.artwork"), null, panelArtwork, null); // $NON-NLS-1$

    panelMovieTrailer = new MovieTrailerPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.trailer"), null, panelMovieTrailer, null); // $NON-NLS-1$

    // beansbinding init
    initDataBindings();

    // manual coded binding
    PropertyChangeListener propertyChangeListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            String property = propertyChangeEvent.getPropertyName();
            Object source = propertyChangeEvent.getSource();
            // react on selection of a movie and change of a movie
            if (source instanceof MovieSelectionModel
                || (source instanceof Movie && MEDIA_FILES.equals(property))) {
              Movie movie = null;
              if (source instanceof MovieSelectionModel) {
                movie = ((MovieSelectionModel) source).getSelectedMovie();
              }
              if (source instanceof Movie) {
                movie = (Movie) source;
              }

              if (movie != null) {
                if (movie.getTop250() > 0) {
                  lblTop250.setText("Top 250: #" + movie.getTop250());
                } else {
                  lblTop250.setText("");
                }
                lblMovieBackground.setImagePath(movie.getArtworkFilename(MediaFileType.FANART));
                lblMoviePoster.setImagePath(movie.getArtworkFilename(MediaFileType.POSTER));

                synchronized (mediaFiles) {
                  mediaFiles.clear();
                  for (MediaFile mediafile : movie.getMediaFiles()) {
                    if (mediafile.isGraphic()) {
                      mediaFiles.add(mediafile);
                    }
                  }
                  panelArtwork.rebuildPanel();
                }
              }
            }
            if ((source.getClass() == Movie.class && FANART.equals(property))) {
              Movie movie = (Movie) source;
              lblMovieBackground.clearImage();
              lblMovieBackground.setImagePath(movie.getArtworkFilename(MediaFileType.FANART));
            }
            if ((source.getClass() == Movie.class && POSTER.equals(property))) {
              Movie movie = (Movie) source;
              lblMoviePoster.clearImage();
              lblMoviePoster.setImagePath(movie.getArtworkFilename(MediaFileType.POSTER));
            }
            if ((source.getClass() == Movie.class && TOP250.equals(property))) {
              Movie movie = (Movie) source;
              if (movie.getTop250() > 0) {
                lblTop250.setText(
                    BUNDLE.getString("metatag.top250") + ": #" + movie.getTop250()); // $NON-NLS-1$
              } else {
                lblTop250.setText("");
              }
            }
          }
        };

    movieSelectionModel.addPropertyChangeListener(propertyChangeListener);
  }
Example #19
0
  /** Creates a test panel with split pane. */
  public SplitPanel() {
    this.setLayout(new BorderLayout());
    splitPane =
        new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new NumberedPanel(1), new NumberedPanel(2));
    splitPane.setDividerLocation(100);
    this.add(splitPane, BorderLayout.CENTER);

    FormLayout lm = new FormLayout("fill:pref:grow", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel());

    final JCheckBox isOneTouch = new JCheckBox("is one-touch");
    isOneTouch.setSelected(true);
    splitPane.setOneTouchExpandable(true);
    isOneTouch.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            splitPane.setOneTouchExpandable(isOneTouch.isSelected());
          }
        });

    final JCheckBox isFlat = new JCheckBox("is flat");
    isFlat.setSelected(true);
    isFlat.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            splitPane.putClientProperty(
                SubstanceLookAndFeel.FLAT_PROPERTY,
                (isFlat.isSelected() ? Boolean.TRUE : Boolean.FALSE));
            splitPane.repaint();
          }
        });

    final JCheckBox isVertical = new JCheckBox("is vertical");
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    isVertical.setSelected(true);
    isVertical.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            splitPane.setOrientation(
                isVertical.isSelected() ? JSplitPane.VERTICAL_SPLIT : JSplitPane.HORIZONTAL_SPLIT);
          }
        });

    final JCheckBox isEnabled = new JCheckBox("is enabled");
    isEnabled.setSelected(true);
    isEnabled.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            splitPane.setEnabled(isEnabled.isSelected());
          }
        });

    builder.append(isEnabled);
    builder.append(isOneTouch);
    builder.append(isFlat);
    builder.append(isVertical);

    this.controlPanel = builder.getPanel();

    this.setPreferredSize(new Dimension(400, 400));
    this.setSize(this.getPreferredSize());
    this.setMinimumSize(this.getPreferredSize());
  }
  private void jbInit() throws Exception {
    itemsGrid.setMaxNumberOfRowsOnInsert(50);
    impAllItemsButton.setToolTipText(
        ClientSettings.getInstance().getResources().getResource("import all items"));
    impAllItemsButton.addActionListener(
        new SupplierDetailFrame_impAllItemsButton_actionAdapter(this));

    detailPanel.setLayout(gridBagLayout4);
    itemsGrid.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    supplierPanel.setVOClassName("org.jallinone.purchases.suppliers.java.DetailSupplierVO");
    supplierPanel.addLinkedPanel(organizationPanel);
    titledBorder1 = new TitledBorder("");
    titledBorder2 = new TitledBorder("");
    subjectPanel.setLayout(gridBagLayout1);
    supplierPanel.setBorder(titledBorder1);
    supplierPanel.setLayout(gridBagLayout2);
    titledBorder1.setTitle(ClientSettings.getInstance().getResources().getResource("supplier"));
    titledBorder1.setTitleColor(Color.blue);
    labelSupplierCode.setText("supplierCodePUR01");
    labelPay.setText("payment terms");
    labelBank.setText("bank");
    controlSupplierCode.setAttributeName("supplierCodePUR01");
    controlSupplierCode.setCanCopy(false);
    controlSupplierCode.setLinkLabel(labelSupplierCode);
    controlSupplierCode.setMaxCharacters(20);
    //    controlSupplierCode.setRequired(true);
    controlSupplierCode.setTrimText(true);
    controlSupplierCode.setUpperCase(true);
    controlSupplierCode.setEnabledOnEdit(false);
    controlPayment.setAttributeName("paymentCodeReg10PUR01");
    controlPayment.setCanCopy(true);
    controlPayment.setLinkLabel(labelPay);
    controlPayment.setMaxCharacters(20);
    controlPayment.setRequired(true);
    controlPayDescr.setAttributeName("paymentDescriptionSYS10");
    controlPayDescr.setCanCopy(true);
    controlPayDescr.setEnabledOnInsert(false);
    controlPayDescr.setEnabledOnEdit(false);
    controlBank.setAttributeName("bankCodeReg12PUR01");
    controlBank.setCanCopy(true);
    controlBank.setLinkLabel(labelBank);
    controlBank.setMaxCharacters(20);
    controlBankDescr.setAttributeName("descriptionREG12");
    controlBankDescr.setCanCopy(true);
    controlBankDescr.setEnabledOnInsert(false);
    controlBankDescr.setEnabledOnEdit(false);
    refPanel.setLayout(borderLayout1);
    hierarPanel.setLayout(borderLayout4);
    treeGridItemsPanel.setLayout(borderLayout3);
    itemsSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    itemsSplitPane.setDividerSize(5);
    itemsPanel.setLayout(borderLayout5);
    itemButtonsPanel.setLayout(flowLayout2);
    flowLayout2.setAlignment(FlowLayout.LEFT);
    itemsGrid.setAutoLoadData(false);
    itemsGrid.setDeleteButton(deleteButton1);
    itemsGrid.setEditButton(editButton1);
    itemsGrid.setExportButton(exportButton1);
    itemsGrid.setFunctionId("PUR01");
    itemsGrid.setMaxSortedColumns(3);
    itemsGrid.setInsertButton(insertButton1);
    itemsGrid.setNavBar(navigatorBar1);
    itemsGrid.setReloadButton(reloadButton1);
    itemsGrid.setSaveButton(saveButton1);
    itemsGrid.setValueObjectClassName("org.jallinone.purchases.items.java.SupplierItemVO");
    insertButton1.setText("insertButton1");
    editButton1.setText("editButton1");
    saveButton1.setText("saveButton1");
    reloadButton1.setText("reloadButton1");
    deleteButton1.setText("deleteButton1");
    itemHierarsPanel.setLayout(gridBagLayout3);
    labelHierar.setText("item hierarchies");
    colItemCode.setColumnFilterable(true);
    colItemCode.setColumnName("itemCodeItm01PUR02");
    colItemCode.setColumnSortable(true);
    colItemCode.setEditableOnInsert(true);
    colItemCode.setHeaderColumnName("itemCodeITM01");
    colItemCode.setPreferredWidth(90);
    colItemCode.setSortVersus(org.openswing.swing.util.java.Consts.ASC_SORTED);
    colItemCode.setMaxCharacters(20);
    colItemDescr.setColumnFilterable(true);
    colItemDescr.setColumnName("descriptionSYS10");
    colItemDescr.setColumnSortable(true);
    colItemDescr.setHeaderColumnName("itemDescriptionSYS10");
    colItemDescr.setPreferredWidth(200);
    colSupplierItemCode.setMaxCharacters(20);
    colSupplierItemCode.setTrimText(true);
    colSupplierItemCode.setUpperCase(true);
    colSupplierItemCode.setColumnFilterable(true);
    colSupplierItemCode.setColumnName("supplierItemCodePUR02");
    colSupplierItemCode.setColumnSortable(true);
    colSupplierItemCode.setEditableOnEdit(true);
    colSupplierItemCode.setEditableOnInsert(true);
    colSupplierItemCode.setHeaderColumnName("supplierItemCodePUR02");
    colSupplierItemCode.setPreferredWidth(120);
    colUmCode.setColumnDuplicable(true);
    colUmCode.setColumnFilterable(true);
    colUmCode.setColumnName("umCodeReg02PUR02");
    colUmCode.setEditableOnEdit(true);
    colUmCode.setEditableOnInsert(true);
    colUmCode.setHeaderColumnName("umCodeReg02PUR02");
    colUmCode.setMaxCharacters(20);
    colMinQty.setDecimals(2);
    colMinQty.setGrouping(false);
    colMinQty.setColumnDuplicable(true);
    colMinQty.setColumnFilterable(true);
    colMinQty.setColumnSortable(true);
    colMinQty.setEditableOnEdit(true);
    colMinQty.setEditableOnInsert(true);
    colMinQty.setPreferredWidth(80);
    colMinQty.setColumnName("minPurchaseQtyPUR02");
    colMultipleQty.setGrouping(false);
    colMultipleQty.setColumnDuplicable(true);
    colMultipleQty.setColumnFilterable(true);
    colMultipleQty.setColumnSortable(true);
    colMultipleQty.setEditableOnEdit(true);
    colMultipleQty.setEditableOnInsert(true);
    colMultipleQty.setPreferredWidth(80);
    colMultipleQty.setColumnName("multipleQtyPUR02");
    subjectPanel.add(
        organizationPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    this.setTitle(ClientSettings.getInstance().getResources().getResource("supplier detail"));
    buttonsPanel.setLayout(flowLayout1);
    flowLayout1.setAlignment(FlowLayout.LEFT);
    insertButton.setText("insertButton1");
    editButton.setText("editButton1");
    saveButton.setEnabled(false);
    saveButton.setText("saveButton1");
    reloadButton.setText("reloadButton1");
    deleteButton.setText("deleteButton1");

    labelCompanyCode.setText("companyCodeSys01REG04");
    controlCompanyCode.setAttributeName("companyCodeSys01REG04");
    controlCompanyCode.setLinkLabel(labelCompanyCode);
    controlCompanyCode.setRequired(true);
    controlCompanyCode.setEnabledOnEdit(false);

    this.getContentPane().add(buttonsPanel, BorderLayout.NORTH);
    buttonsPanel.add(insertButton, null);
    buttonsPanel.add(editButton, null);
    buttonsPanel.add(saveButton, null);
    buttonsPanel.add(reloadButton, null);
    buttonsPanel.add(deleteButton, null);
    buttonsPanel.add(navigatorBar, null);
    //    tabbedPane.add(subjectPanel,   "generic data");
    this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
    supplierPanel.add(
        labelCompanyCode,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        controlCompanyCode,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));

    //    tabbedPane.add(supplierPanel,    "supplierPanel");
    supplierPanel.add(
        labelSupplierCode,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        controlSupplierCode,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        labelPay,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        controlPayment,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            40,
            0));
    supplierPanel.add(
        controlPayDescr,
        new GridBagConstraints(
            2,
            2,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        labelPricelist,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        labelBank,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 5),
            0,
            0));
    supplierPanel.add(
        controlBank,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            40,
            0));
    supplierPanel.add(
        controlBankDescr,
        new GridBagConstraints(
            2,
            4,
            2,
            3,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));

    supplierPanel.add(
        labelDebit,
        new GridBagConstraints(
            0,
            5,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        labelPurchase,
        new GridBagConstraints(
            0,
            6,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 15, 5),
            0,
            0));
    supplierPanel.add(
        controlDebitsCode,
        new GridBagConstraints(
            1,
            5,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            40,
            0));
    supplierPanel.add(
        controlDebitsDescr,
        new GridBagConstraints(
            2,
            5,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    supplierPanel.add(
        controlCostsCode,
        new GridBagConstraints(
            1,
            6,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            40,
            0));
    supplierPanel.add(
        controlCostsDescr,
        new GridBagConstraints(
            2,
            6,
            2,
            3,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));

    labelDebit.setText("debits account");
    labelPurchase.setText("purchase costs account");
    controlDebitsCode.setAttributeName("debitAccountCodeAcc02PUR01");
    controlDebitsDescr.setAttributeName("debitAccountDescrPUR01");
    controlCostsCode.setAttributeName("costsAccountCodeAcc02PUR01");
    controlCostsDescr.setAttributeName("costsAccountDescrPUR01");

    detailPanel.add(
        subjectPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));
    detailPanel.add(
        supplierPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    tabbedPane.add(detailPanel, "supplier data");

    tabbedPane.add(refPanel, "references");
    refPanel.add(referencesPanel, BorderLayout.CENTER);
    tabbedPane.add(hierarPanel, "hierarchies");
    hierarPanel.add(hierarchiesPanel, BorderLayout.CENTER);
    tabbedPane.add(treeGridItemsPanel, "supplierItems");
    treeGridItemsPanel.add(itemsSplitPane, BorderLayout.CENTER);
    itemsSplitPane.add(treePanel, JSplitPane.LEFT);
    itemsSplitPane.add(itemsPanel, JSplitPane.RIGHT);
    itemsPanel.add(itemButtonsPanel, BorderLayout.NORTH);
    itemsPanel.add(itemsGrid, BorderLayout.CENTER);
    itemsGrid.getColumnContainer().add(colItemCode, null);
    itemButtonsPanel.add(insertButton1, null);
    itemButtonsPanel.add(editButton1, null);
    itemButtonsPanel.add(saveButton1, null);
    itemButtonsPanel.add(reloadButton1, null);
    itemButtonsPanel.add(deleteButton1, null);
    itemButtonsPanel.add(exportButton1, null);
    itemButtonsPanel.add(navigatorBar1, null);
    itemButtonsPanel.add(impAllItemsButton, null);

    controlDebitsCode.setLinkLabel(labelDebit);
    controlDebitsCode.setMaxCharacters(20);
    controlDebitsCode.setRequired(true);
    controlDebitsDescr.setEnabledOnInsert(false);
    controlDebitsDescr.setEnabledOnEdit(false);
    controlCostsCode.setLinkLabel(labelPurchase);
    controlCostsCode.setMaxCharacters(20);
    controlCostsCode.setRequired(true);
    controlCostsDescr.setEnabledOnInsert(false);
    controlCostsDescr.setEnabledOnEdit(false);

    treeGridItemsPanel.add(itemHierarsPanel, BorderLayout.NORTH);
    itemHierarsPanel.add(
        labelHierar,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 0),
            0,
            0));
    itemHierarsPanel.add(
        controlHierarchy,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            100,
            0));
    tabbedPane.add(supplierPricelistPanel, "supplierPricelistPanel");
    itemsGrid.getColumnContainer().add(colItemDescr, null);
    itemsGrid.getColumnContainer().add(colSupplierItemCode, null);
    itemsGrid.getColumnContainer().add(colUmCode, null);
    itemsGrid.getColumnContainer().add(colMinQty, null);
    itemsGrid.getColumnContainer().add(colMultipleQty, null);

    tabbedPane.setTitleAt(
        0, ClientSettings.getInstance().getResources().getResource("supplier data"));
    tabbedPane.setTitleAt(1, ClientSettings.getInstance().getResources().getResource("references"));
    tabbedPane.setTitleAt(
        2, ClientSettings.getInstance().getResources().getResource("hierarchies"));
    tabbedPane.setTitleAt(
        3, ClientSettings.getInstance().getResources().getResource("supplierItems"));
    tabbedPane.setTitleAt(
        4, ClientSettings.getInstance().getResources().getResource("supplierPricelists"));
    itemsSplitPane.setDividerLocation(200);
  }
  public BorrowerSearchPanel(BorrowerView borrowerView, Controller mySession) {
    super(new BorderLayout());
    parent = borrowerView;
    this.mySession = mySession;

    listModel = new DefaultListModel();

    // Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);
    JScrollPane listScrollPane = new JScrollPane(list);
    /*
    employeeName = new JTextField(10);
    employeeName.addActionListener(hireListener);
    employeeName.getDocument().addDocumentListener(hireListener);
    String name = listModel.getElementAt(
                          list.getSelectedIndex()).toString();*/

    // Create a panel that uses BoxLayout.
    JPanel buttonPane = new JPanel();
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(listScrollPane, BorderLayout.CENTER);

    JPanel panel = new JPanel();
    listScrollPane.setColumnHeaderView(panel);

    JLabel lblSearchForBooks = new JLabel("Search For Books");
    panel.add(lblSearchForBooks);
    add(buttonPane, BorderLayout.PAGE_END);
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setContinuousLayout(true);
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    buttonPane.add(splitPane);

    JPanel panel_1 = new JPanel();
    splitPane.setLeftComponent(panel_1);

    cmboKeyWords = new JComboBox();
    cmboKeyWords.setModel(new DefaultComboBoxModel(new String[] {"Title", "Author", "Subject"}));
    cmboKeyWords.setSize(100, 75);
    panel_1.add(cmboKeyWords);

    searchArgument = new JTextField();
    panel_1.add(searchArgument);
    searchArgument.setColumns(10);

    JPanel panel_2 = new JPanel();
    splitPane.setRightComponent(panel_2);

    btnSearch = new JButton("Search");
    btnSearch.addActionListener(new SearchListener());
    panel_2.add(btnSearch);

    btbPlaceOnHold = new JButton("Place Hold Request");
    btbPlaceOnHold.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            System.out.println("yep");
            PlaceHoldRequestDialog test =
                new PlaceHoldRequestDialog(
                    getInstance(), getLoggedInUserBID(), getInstance().mySession);
            test.setVisible(true);
          }
        });
    panel_2.add(btbPlaceOnHold);
  }
Example #22
0
  /** Initialize the contents of the frame. */
  public void drawBoard() {
    // Set up the frame
    frmFloodFantasyLeague = new JFrame();
    frmFloodFantasyLeague.setBackground(new Color(0, 0, 205));
    frmFloodFantasyLeague.setTitle("FLOOD Fantasy League: " + theLeague.getName());
    frmFloodFantasyLeague.setBounds(100, 100, 450, 300);
    frmFloodFantasyLeague.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmFloodFantasyLeague.setSize(new Dimension(700, 400));
    frmFloodFantasyLeague.setVisible(true);

    // Initialize and add the tabbed pane
    final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    frmFloodFantasyLeague.getContentPane().add(tabbedPane, BorderLayout.CENTER);

    // Initialize the home tab
    JSplitPane homeSplitPane = new JSplitPane();
    homeSplitPane.setResizeWeight(0.99);
    homeSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);

    // Initialize the home tab toolbar
    JToolBar homeToolBar = new JToolBar();
    homeToolBar.setFloatable(false);
    homeSplitPane.setRightComponent(homeToolBar);

    // Add the upload stats button to the toolbar
    JButton uploadStatsButton = new JButton("Upload Stat File");
    uploadStatsButton.setMaximumSize(new Dimension(32767, 32767));
    homeToolBar.add(uploadStatsButton);

    // Add the create dump button to the toolbar
    JButton createDumpButton = new JButton("Create Dump File");
    createDumpButton.setMaximumSize(new Dimension(32767, 32767));
    homeToolBar.add(createDumpButton);

    // Add the import dump button to the toolbar
    JButton importDumpButton = new JButton("Import Dump File");
    importDumpButton.setMaximumSize(new Dimension(32767, 32767));
    homeToolBar.add(importDumpButton);

    // Initialize the home tab scrollpane
    JScrollPane homePane = new JScrollPane();
    homeSplitPane.setLeftComponent(homePane);

    // Add the home tab to the tabbed pane
    tabbedPane.addTab("Home", null, homeSplitPane, null);

    // Initialize, format and add the home table
    homeModel = new DefaultTableModel(homeHeader, 0); // Add the header but no rows
    homeTable = new MyTableModel(homeModel);
    homeTable.setEnabled(false); // Make the rows unselectable
    homeTable.setAutoCreateRowSorter(true); // Allow sorting
    homePane.setViewportView(homeTable); // Put the table into the scroll pane

    populateHome(); // Populate the home table

    JSplitPane draftSplitPane = new JSplitPane(); // Add the draft split pane
    draftSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); // Split vertically
    tabbedPane.addTab("Draft", null, draftSplitPane, null); // Add the split pane to the tabbed pane

    // Initialize and add the draft scroll pane
    JScrollPane draftScrollPane = new JScrollPane();
    draftSplitPane.setRightComponent(draftScrollPane);

    // Initialize, format and add the draft table
    draftModel = new DefaultTableModel(playerInfoHeader, 0); // Add the header but no rows
    draftTable = new MyTableModel(draftModel);
    draftTable.setRowSelectionAllowed(true); // Allow row selection
    draftTable.setSelectionMode(
        ListSelectionModel.SINGLE_SELECTION); // Allow only one row selection at a time
    draftTable.setAutoCreateRowSorter(true); // Allow sorting
    draftScrollPane.setViewportView(draftTable); // Put the table into the scroll pane

    // Initialize, format and add the draft tool bar
    JToolBar draftToolBar = new JToolBar();
    draftToolBar.setFloatable(false);
    draftSplitPane.setLeftComponent(draftToolBar);

    // Initialize, format and add the draft label
    draftLabel = new JLabel();
    draftLabel.setMinimumSize(new Dimension(600, 15));
    draftLabel.setMaximumSize(new Dimension(32767, 15));
    draftToolBar.add(draftLabel);

    // Initialize,format and add the draft button
    JButton btnDraft = new JButton("Draft");
    btnDraft.setPreferredSize(new Dimension(100, 25));
    btnDraft.setMaximumSize(new Dimension(100, 25));
    btnDraft.setMinimumSize(new Dimension(100, 25));
    draftToolBar.add(btnDraft);

    // Initialize, format and add the trade split pane
    JSplitPane tradeSplitPane = new JSplitPane();
    tradeSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); // Split vertically
    tabbedPane.addTab("Trade", null, tradeSplitPane, null);

    // Initialize, format and add the trade tool bar
    JToolBar tradeToolBar = new JToolBar();
    tradeToolBar.setFloatable(false);
    tradeSplitPane.setLeftComponent(tradeToolBar);

    // Initialize, format and add the first trade combo box
    final JComboBox tradeComboBox_1 = new JComboBox();
    tradeToolBar.add(tradeComboBox_1);

    // Initialize, format and add the second trade combo bos
    final JComboBox tradeComboBox_2 = new JComboBox();
    tradeToolBar.add(tradeComboBox_2);

    // Initialize and add the trade button
    JButton btnTrade = new JButton("Trade");
    tradeToolBar.add(btnTrade);

    // Initialize, format and add the second trade split pane
    JSplitPane tradeSplitPane_2 = new JSplitPane();
    tradeSplitPane_2.setResizeWeight(0.5);
    tradeSplitPane.setRightComponent(tradeSplitPane_2);

    // Initialize and add the left trade scroll pane
    JScrollPane tradeScrollPane_1 = new JScrollPane();
    tradeSplitPane_2.setLeftComponent(tradeScrollPane_1);

    // Initialize, format and add the left trade table
    tradeModel_1 = new DefaultTableModel(playerInfoHeader, 0); // Add the header but no rows
    tradeTable_1 = new MyTableModel(tradeModel_1);
    tradeTable_1.setRowSelectionAllowed(true); // Set selection of entire rows
    tradeTable_1.setSelectionMode(
        ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // Allow multiple row selection
    tradeTable_1.setAutoCreateRowSorter(true); // Allow sorting
    tradeScrollPane_1.setViewportView(tradeTable_1); // Add table to scroll pane

    // Initialize and add the right trade scroll pane
    JScrollPane tradeScrollPane_2 = new JScrollPane();
    tradeSplitPane_2.setRightComponent(tradeScrollPane_2);

    // Initialize, format and add the right trade table
    tradeModel_2 = new DefaultTableModel(playerInfoHeader, 0); // Add the header but no rows
    tradeTable_2 = new MyTableModel(tradeModel_2);
    tradeTable_2.setRowSelectionAllowed(true); // Set selection of entire rows
    tradeTable_2.setSelectionMode(
        ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // Allow multiple row selection
    tradeTable_2.setAutoCreateRowSorter(true); // Allow sorting
    tradeScrollPane_2.setViewportView(tradeTable_2); // Add table to scroll pane

    // Initialize, format and add the drop split pane
    JSplitPane dropSplitPane = new JSplitPane();
    dropSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); // Split vertically
    tabbedPane.addTab("Drop", null, dropSplitPane, null);

    // Initialize, format and add the drop toolbar
    JToolBar dropToolBar = new JToolBar();
    dropToolBar.setFloatable(false);
    dropSplitPane.setLeftComponent(dropToolBar);

    // Initialize and add the drop combo box
    final JComboBox dropComboBox = new JComboBox();
    dropToolBar.add(dropComboBox);

    // Initialize and add the drop button
    JButton btnDrop = new JButton("Drop");
    dropToolBar.add(btnDrop);

    // Initialize and add the drop scroll pane
    JScrollPane dropScrollPane = new JScrollPane();
    dropSplitPane.setRightComponent(dropScrollPane);

    // Initialize, format and add the drop table
    dropModel = new DefaultTableModel(playerInfoHeader, 0); // Add the header but no rows
    dropTable = new MyTableModel(dropModel);
    dropTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Alow single selection
    dropTable.setAutoCreateRowSorter(true); // Allow sorting
    dropScrollPane.setViewportView(dropTable); // Add the table to the scroll pane

    // Initialize the home tab scrollpane
    JScrollPane actionPane = new JScrollPane();

    // Add the home tab to the tabbed pane
    tabbedPane.addTab("Actions", null, actionPane, null);

    // Initialize, format and add the home table
    actionModel = new DefaultTableModel(ruleHeader, 0); // Add the header but no rows
    actionTable = new MyTableModel(actionModel);
    actionTable.setEnabled(false); // Make the rows unselectable
    actionTable.setAutoCreateRowSorter(true); // Allow sorting
    actionPane.setViewportView(actionTable); // Put the table into the scroll pane

    populateActions(); // Populate the home table

    // Initialize the file chooser
    final JFileChooser chooser = new JFileChooser();

    // Populate both trade and the drop combo boxes
    User[] rankedTeams = theLeague.getRankedUsers();
    for (int i = 0; i < rankedTeams.length; i++) {
      tradeComboBox_1.insertItemAt(rankedTeams[i].getName(), i);
      tradeComboBox_2.insertItemAt(rankedTeams[i].getName(), i);
      dropComboBox.insertItemAt(rankedTeams[i].getName(), i);
    }

    // ************************************************************************
    // ****************************Action Listeners****************************
    // ************************************************************************

    // Action listener for changing tabs
    tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            int selection = tabbedPane.getSelectedIndex(); // Get selected tab
            switch (selection) {
              case 0: // Populate home table
                populateHome();
                break;
              case 1: // Populate draft table
                populateDraft();
                break;
              case 4:
                populateActions();
                break;
            }
          }
        });

    // Stats upload action listener
    uploadStatsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            int result = chooser.showOpenDialog(null); // Determine what the user pressed
            switch (result) {
              case JFileChooser.APPROVE_OPTION: // Opened file
                File file = chooser.getSelectedFile(); // Get the chosen file
                IOManager.uploadStats(
                    theLeague, file.getAbsolutePath()); // Pass the file path to the parser method
                populateHome();
                break;
              case JFileChooser.CANCEL_OPTION: // Canceled
                break;
              case JFileChooser.ERROR_OPTION: // Generated an error
                GUI.error("Upload Error!", "Sorry, there was an error opening the stat file.");
                break;
            }
          }
        });

    // Dump generator action listener
    createDumpButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            chooser.setSelectedFile(new File("flooddmp.txt"));
            int result = chooser.showSaveDialog(null);
            switch (result) {
              case JFileChooser.APPROVE_OPTION: // Opened file
                File file = chooser.getSelectedFile(); // Get the chosen file
                if (file.exists()) {
                  int overwrite =
                      JOptionPane.showConfirmDialog(
                          frmFloodFantasyLeague, "Do you want to overwrite " + file.getName());
                  if (overwrite == JOptionPane.YES_OPTION) {
                    IOManager.writeState(
                        theLeague,
                        file.getAbsolutePath(),
                        currentTurn); // Pass the file path to the parser method
                    tabbedPane.setSelectedIndex(0);
                  }
                } else {
                  IOManager.writeState(
                      theLeague,
                      file.getAbsolutePath(),
                      currentTurn); // Pass the file path to the parser method
                  tabbedPane.setSelectedIndex(0);
                }
                break;
              case JFileChooser.CANCEL_OPTION: // Canceled
                break;
              case JFileChooser.ERROR_OPTION: // Generated an error
                GUI.error("Upload Error!", "Sorry, error creating the dump file.");
                break;
            }
          }
        });

    // Dump importer action listener
    importDumpButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            int result = chooser.showOpenDialog(null); // Determine what the user pressed
            switch (result) {
              case JFileChooser.APPROVE_OPTION: // Opened file
                File file = chooser.getSelectedFile(); // Get the chosen file
                int temp =
                    IOManager.importState(
                        theLeague,
                        file.getAbsolutePath()); // Pass the file path to the parser method
                if (temp != -1) {
                  currentTurn = temp;
                  populateDraft();
                }
                populateHome();
                break;
              case JFileChooser.CANCEL_OPTION: // Canceled
                break;
              case JFileChooser.ERROR_OPTION: // Generated an error
                GUI.error("Upload Error!", "Sorry, there was an error opening the stat file.");
                break;
            }
          }
        });

    // Determine which user is picking first
    pick = FloodProgram.draftFunction(currentTurn); // Gets the number representing the user's turn
    draftLabel.setText(
        theLeague.getUser(pick).getName() + "'s turn!"); // Puts the user's name in the label

    // Draft action listener
    btnDraft.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            for (int i = 0; i < draftModel.getRowCount(); i++) { // Iterate through table entries
              if (draftTable.isCellSelected(i, 0)) { // If it's selected
                int overwrite =
                    JOptionPane.showConfirmDialog(
                        frmFloodFantasyLeague,
                        "Are you sure you want to draft: "
                            + League.athletes.get(draftModel.getValueAt(i, 0)).getName());
                if (overwrite == JOptionPane.YES_OPTION) {
                  if (!FloodProgram.draftPlayer(
                      theLeague.getUser(pick),
                      League.athletes.get(
                          draftModel.getValueAt(i, 0)))) { // If the draft isn't successful
                    GUI.error("Invalid draft!", "Sorry, your draft violates rules of the league.");
                    return;
                  }
                  currentTurn++; // Increment the turn
                  draftModel.removeRow(i); // Remove that row from the draft table
                  populateDraft();
                  // Make all the combo boxes not select anything
                  tradeComboBox_1.setSelectedIndex(-1);
                  tradeComboBox_2.setSelectedIndex(-1);
                  dropComboBox.setSelectedIndex(-1);
                  // Remove the current tables in all the other tabs so that they are up to date
                  while (tradeModel_1.getRowCount() > 0) {
                    tradeModel_1.removeRow(0);
                  }
                  while (tradeModel_2.getRowCount() > 0) {
                    tradeModel_2.removeRow(0);
                  }
                  while (dropModel.getRowCount() > 0) {
                    dropModel.removeRow(0);
                  }
                  return;
                }
                return;
              }
            }
            // If no selection is found
            GUI.error("Add error!", "Sorry, no player was selected!");
          }
        });

    // Action listener for left trade combo box
    tradeComboBox_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (tradeComboBox_1.getSelectedIndex() != -1) { // If a user is selected
              Player[] teamPlayers =
                  League.teams
                      .get(tradeComboBox_1.getSelectedItem())
                      .getPlayers(); // Get the players the user has
              while (tradeModel_1.getRowCount() > 0) { // Clear the current table
                tradeModel_1.removeRow(0);
              }
              for (int i = 0; i < teamPlayers.length; i++) { // Populate the table with the new data
                String[] temp = {
                  teamPlayers[i].getName(),
                  teamPlayers[i].getPosition(),
                  Float.toString(teamPlayers[i].getPoints())
                }; // Initialize the row
                tradeModel_1.addRow(temp);
              }
            }
          }
        });

    // Action listener for the right trade combo box
    tradeComboBox_2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (tradeComboBox_2.getSelectedIndex() != -1) { // If a user is selected
              Player[] teamPlayers =
                  League.teams
                      .get(tradeComboBox_2.getSelectedItem())
                      .getPlayers(); // Get the players the user has
              while (tradeModel_2.getRowCount() > 0) { // Clear the current table
                tradeModel_2.removeRow(0);
              }
              for (int i = 0; i < teamPlayers.length; i++) { // Populate the table with the new data
                String[] temp = {
                  teamPlayers[i].getName(),
                  teamPlayers[i].getPosition(),
                  Float.toString(teamPlayers[i].getPoints())
                }; // Initialize the row
                tradeModel_2.addRow(temp);
              }
            }
          }
        });

    // Action listener for the trade button
    btnTrade.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (tradeComboBox_1.getSelectedIndex() == -1
                || tradeComboBox_2.getSelectedIndex()
                    == -1) { // If either combo box doesn't have a user selected
              GUI.error("Trade error!", "Must select two teams to trade between.");
              return;
            } else if (tradeComboBox_1.getSelectedIndex()
                == tradeComboBox_2
                    .getSelectedIndex()) { // If the same user is selected in each combo box
              GUI.error("Trade error!", "Must select two different teams to trade between.");
              return;
            }
            int rows1[] = tradeTable_1.getSelectedRows(); // Get selected rows in the left table
            int rows2[] = tradeTable_2.getSelectedRows(); // Get selected rows in the right table
            if (rows1.length == 0 && rows2.length == 0) { // If no players are selected
              GUI.error("Trade error!", "Must select at least one player to trade.");
              return;
            }
            int overwrite =
                JOptionPane.showConfirmDialog(
                    frmFloodFantasyLeague, "Are you sure you want to trade?");
            if (overwrite == JOptionPane.YES_OPTION) {
              Player[] p1 =
                  new Player[rows1.length]; // Initialize player array for the left table selection
              Player[] p2 =
                  new Player[rows2.length]; // Initialize player array for the right table selection
              // Populate the player arrays
              for (int i = 0; i < p1.length; i++) {
                p1[i] = League.athletes.get(tradeModel_1.getValueAt(rows1[i], 0));
              }
              for (int i = 0; i < p2.length; i++) {
                p2[i] = League.athletes.get(tradeModel_2.getValueAt(rows2[i], 0));
              }
              boolean success =
                  FloodProgram.trade(
                      League.teams.get(
                          tradeComboBox_1 // Determine if it's a successful trade
                              .getSelectedItem()),
                      p1,
                      League.teams.get(tradeComboBox_2.getSelectedItem()),
                      p2);
              if (!success) { // If unsuccessful
                GUI.error("Invalid trade!", "Sorry, your trade violates rules of the league.");
                return;
              }
              // Repopulate the tables
              Player[] teamPlayers =
                  League.teams.get(tradeComboBox_1.getSelectedItem()).getPlayers();
              while (tradeModel_1.getRowCount() > 0) { // Clear the left trade table
                tradeModel_1.removeRow(0);
              }
              for (int i = 0; i < teamPlayers.length; i++) { // Repopulate the left trade table
                String[] temp = {
                  teamPlayers[i].getName(),
                  teamPlayers[i].getPosition(),
                  Float.toString(teamPlayers[i].getPoints())
                };
                tradeModel_1.addRow(temp); // Add the row
              }
              teamPlayers = League.teams.get(tradeComboBox_2.getSelectedItem()).getPlayers();
              while (tradeModel_2.getRowCount() > 0) { // Clear the left trade table
                tradeModel_2.removeRow(0);
              }
              for (int i = 0; i < teamPlayers.length; i++) { // Repopulate the left trade table
                String[] temp = {
                  teamPlayers[i].getName(),
                  teamPlayers[i].getPosition(),
                  Float.toString(teamPlayers[i].getPoints())
                };
                tradeModel_2.addRow(temp); // Add the row
              }
            }
          }
        });

    // Action listener for drop combo box
    dropComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (dropComboBox.getSelectedIndex() != -1) { // If a user is selected
              Player[] teamPlayers =
                  League.teams
                      .get(dropComboBox.getSelectedItem())
                      .getPlayers(); // Get the user's players
              while (dropModel.getRowCount() > 0) { // Clear the table
                dropModel.removeRow(0);
              }
              for (int i = 0; i < teamPlayers.length; i++) { // Repopulate the table
                String[] temp = {
                  teamPlayers[i].getName(),
                  teamPlayers[i].getPosition(),
                  Float.toString(teamPlayers[i].getPoints())
                };
                dropModel.addRow(temp); // Add the row
              }
            }
          }
        });

    // Action listener for drop button
    btnDrop.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            int index = dropTable.getSelectedRow();
            if (index == -1) { // If no player is selected to drop
              GUI.error("Drop error!", "Must select a team to drop a player from.");
              return;
            }
            int overwrite =
                JOptionPane.showConfirmDialog(
                    frmFloodFantasyLeague,
                    "Are you sure you want to drop: "
                        + League.athletes.get(dropModel.getValueAt(index, 0)).getName());
            if (overwrite == JOptionPane.YES_OPTION) {
              Player drop = League.athletes.get(dropModel.getValueAt(index, 0)); // Get player
              boolean success =
                  FloodProgram.dropPlayer(
                      League.teams.get(dropComboBox.getSelectedItem()),
                      drop); // Determine if drop is successful
              if (!success) {
                GUI.error("Invalid drop!", "Sorry, your drop violates rules of the league.");
                return;
              }
              dropModel.removeRow(index); // Delete that row
              // Make all the combo boxes not select anything
              tradeComboBox_1.setSelectedIndex(-1);
              tradeComboBox_2.setSelectedIndex(-1);
              while (tradeModel_1.getRowCount() > 0) {
                tradeModel_1.removeRow(0);
              }
              while (tradeModel_2.getRowCount() > 0) {
                tradeModel_2.removeRow(0);
              }
            }
          }
        });

    tabbedPane.setSelectedIndex(0);
  }
Example #23
0
  void jbInit() throws Exception {
    titledBorder1 =
        new TitledBorder(
            BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Assembler messages");
    this.getContentPane().setLayout(borderLayout1);

    this.setIconifiable(true);
    this.setMaximizable(true);
    this.setResizable(true);

    this.setTitle("EDIT");

    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(470);
    sourceArea.setFont(new java.awt.Font("Monospaced", 0, 12));
    controlPanel.setLayout(gridBagLayout1);
    controlPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    positionPanel.setLayout(gridBagLayout2);
    fileLabel.setText("Source file:");
    fileText.setEditable(false);
    browseButton.setSelected(false);
    browseButton.setText("Browse ...");
    assembleButton.setEnabled(false);
    assembleButton.setText("Assemble file");
    saveButton.setEnabled(false);
    saveButton.setText("Save file");
    lineLabel.setText("Line:");
    lineText.setMinimumSize(new Dimension(50, 20));
    lineText.setPreferredSize(new Dimension(50, 20));
    lineText.setEditable(false);
    columnLabel.setText("Column:");
    columnText.setMinimumSize(new Dimension(41, 20));
    columnText.setPreferredSize(new Dimension(41, 20));
    columnText.setEditable(false);
    columnText.setText("");
    messageScrollPane.setBorder(titledBorder1);
    messageScrollPane.setMinimumSize(new Dimension(33, 61));
    messageScrollPane.setPreferredSize(new Dimension(60, 90));
    optionsButton.setEnabled(false);
    optionsButton.setText("Assembler options ...");
    messageScrollPane.getViewport().add(messageList, null);
    messageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.getContentPane().add(splitPane, BorderLayout.CENTER);
    splitPane.add(textScrollPane, JSplitPane.TOP);
    splitPane.add(controlPanel, JSplitPane.BOTTOM);
    textScrollPane.getViewport().add(sourceArea, null);

    controlPanel.add(
        fileLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        fileText,
        new GridBagConstraints(
            1,
            0,
            3,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        browseButton,
        new GridBagConstraints(
            4,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        optionsButton,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        assembleButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        saveButton,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        positionPanel,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        lineLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    positionPanel.add(
        lineText,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        columnLabel,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    positionPanel.add(
        columnText,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        messageScrollPane,
        new GridBagConstraints(
            0,
            2,
            5,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));
  }
  public ObjectInspector(Db4oViewer viewer, Object object) {
    this.viewer = viewer;
    this.object = object;

    this.setPreferredSize(new Dimension(600, 800));
    BorderLayout thisLayout = new BorderLayout();
    getContentPane().setLayout(thisLayout);
    this.setLocation(400, 150);

    {
      jSplitPane1 = new JSplitPane();
      getContentPane().add(jSplitPane1, BorderLayout.NORTH);
      jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
      {
        jPanel1 = new JPanel();
        jSplitPane1.add(jPanel1, JSplitPane.BOTTOM);
        BorderLayout jPanel1Layout = new BorderLayout();
        jPanel1.setLayout(jPanel1Layout);
        jPanel1.setPreferredSize(new java.awt.Dimension(590, 191));
        {
          jPanel2 = new JPanel();
          FlowLayout jPanel2Layout = new FlowLayout();
          jPanel1.add(jPanel2, BorderLayout.SOUTH);
          jPanel2.setPreferredSize(new java.awt.Dimension(592, 33));
          jPanel2.setLayout(jPanel2Layout);
          {
            saveButton = new JButton();
            jPanel2.add(saveButton);
            saveButton.setText("Save");
            saveButton.setActionCommand("save");
            saveButton.addActionListener(this);
          }
          {
            deleteButton = new JButton();
            jPanel2.add(deleteButton);
            deleteButton.setText("Delete");
            deleteButton.setActionCommand("delete");
            deleteButton.addActionListener(this);
          }
          {
            refreshButton = new JButton();
            jPanel2.add(refreshButton);
            refreshButton.setText("Refresh");
            refreshButton.setActionCommand("refresh");
            refreshButton.addActionListener(this);
          }
        }
        {
          jPanel3 = new JPanel();
          jPanel1.add(jPanel3, BorderLayout.NORTH);
          FlowLayout jPanel3Layout = new FlowLayout();
          jPanel3.setLayout(jPanel3Layout);
          jPanel3.setPreferredSize(new java.awt.Dimension(592, 114));
          {
            fieldEdit = new JTextArea();
            jPanel3.add(fieldEdit);
            fieldEdit.setPreferredSize(new java.awt.Dimension(324, 92));
            fieldEdit.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
          }
          {
            editApply = new JButton();
            jPanel3.add(editApply);
            editApply.setText("Apply");
            editApply.setActionCommand("apply");
            editApply.addActionListener(this);
          }
        }
      }
      {
        jScrollPane1 = new JScrollPane();
        jSplitPane1.add(jScrollPane1, JSplitPane.TOP);
        {
          jTree1 = new AutoScrollingJTree(new DefaultMutableTreeNode());
          jScrollPane1.setViewportView(jTree1);
          jTree1.setDragEnabled(true);

          TreeDragSource ds = new TreeDragSource(jTree1, DnDConstants.ACTION_COPY_OR_MOVE);
          TreeDropTarget dt = new TreeDropTarget(jTree1);
        }
      }
    }

    if (object != null) {
      this.setTitle(object.toString());
    }

    System.out.println(object);

    buildTree();
    jTree1.addMouseListener(this);

    this.pack();
    this.setVisible(true);
  }
Example #25
0
  private void jbInit() throws Exception {
    borderForProjectView = BorderFactory.createLineBorder(Color.black, 2);
    titleBoderForProjectView = new TitledBorder(borderForProjectView, "Project view");
    borderForEntitiesView = BorderFactory.createLineBorder(Color.black, 2);
    titledBorderForEntitiesView = new TitledBorder(borderForEntitiesView, "Entities view");
    titledBorderForMessagesPane =
        new TitledBorder(
            BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)), "Messages");
    this.getContentPane().setLayout(borderLayout2);
    file.setText("File");
    save.setEnabled(false);
    save.setText("Save");
    save.setName("Savefilemenu");
    save.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            save_actionPerformed(e);
          }
        });
    load.setText("Load");
    load.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            load_actionPerformed(e);
          }
        });
    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    this.setJMenuBar(mainMenuBar);
    this.setTitle("INGENIAS Development Kit");
    this.setSize(625, 470);
    this.addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosed(WindowEvent e) {
            this_windowClosed(e);
          }

          public void windowClosing(WindowEvent e) {
            this_windowClosing(e);
          }
        });
    splitPaneSeparatingProjectsAndEntitiesView.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPaneSeparatingProjectsAndEntitiesView.setBottomComponent(scrollPaneForEntitiesView);
    splitPaneSeparatingProjectsAndEntitiesView.setTopComponent(scrollPaneForProyectView);
    jPanel1.setLayout(gridLayout1);
    arbolObjetos.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            arbolObjetos_mouseClicked(e);
          }
        });
    scrollPaneForProyectView.setAutoscrolls(true);
    scrollPaneForProyectView.setBorder(titleBoderForProjectView);
    scrollPaneForEntitiesView.setBorder(titledBorderForEntitiesView);
    edit.setText("Edit");
    copyImage.setText("Copy diagram as a file");
    copyImage.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            capture_actionPerformed(e);
          }
        });
    saveas.setText("Save as");
    saveas.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveas_actionPerformed(e);
          }
        });
    help.setText("Help");
    manual.setText("Tool manual");
    manual.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            manual_actionPerformed(e);
          }
        });
    about.setText("About");
    about.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            about_actionPerformed(e);
          }
        });
    project.setText("Project");
    copy.setText("Copy");
    copy.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            copy_actionPerformed(e);
          }
        });
    paste.setText("Paste");
    paste.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            paste_actionPerformed(e);
          }
        });
    exit.setText("Exit");
    exit.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            exit_actionPerformed(e);
          }
        });
    splitPanelDiagramMessagesPaneSeparator.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPanelDiagramMessagesPaneSeparator.setLastDividerLocation(150);
    pprin.setLayout(new BorderLayout());
    pprin.setName("DiagramPane");
    pprin.setPreferredSize(new Dimension(400, 300));
    pprin.add(BorderLayout.SOUTH, pbar);
    pbar.setVisible(false);
    jSplitPane1.setOrientation(JSplitPane.HORIZONTAL_SPLIT);

    scrollLogs.setBorder(titledBorderForMessagesPane);
    scrollLogs.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            jScrollPane3_keyPressed(e);
          }
        });
    this.clearMessages.setText("Clear");
    clearMessages.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            clearMessages_actionPerformed(e, (JTextPane) messagesMenu.getInvoker());
          }
        });
    forcegc.setText("Force GC");
    forcegc.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            forcegc_actionPerformed(e);
          }
        });

    menuTools.setText("Tools");
    menuCodeGenerator.setText("Code Generator");
    profiles.setText("Profiles");

    menuModules.setText("Modules");
    this.properties.setText("Properties");
    properties.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            properties_actionPerformed(e);
          }
        });
    moutput.setEditable(false);
    moutput.setSelectionStart(0);
    moutput.setText("");
    moduleOutput.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            moduleOutput_mouseClicked(e);
          }
        });
    moduleOutput.setFont(new java.awt.Font("Monospaced", 0, 11));
    logs.setContentType("text/html");
    logs.setEditable(false);
    logs.setText("");
    logs.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            logs_mouseClicked(e);
          }
        });
    logs.addComponentListener(
        new java.awt.event.ComponentAdapter() {
          public void componentResized(ComponentEvent e) {
            logs_componentResized(e);
          }
        });
    newProject.setText("New");
    newProject.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            newProject_actionPerformed(e);
          }
        });
    undo.setText("Undo");
    undo.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            undo_actionPerformed(e);
          }
        });
    redo.setText("Redo");
    redo.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            redo_actionPerformed(e);
          }
        });
    delete.setText("Delete");
    delete.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            delete_actionPerformed(e);
          }
        });
    selectall.setText("Select all");
    selectall.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            selectall_actionPerformed(e);
          }
        });
    cpClipboard.setText("Copy diagram to clipboard");
    cpClipboard.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cpClipboard_actionPerformed(e);
          }
        });
    preferences.setText("Preferences");

    enableUMLView.setToolTipText("UML view" + "instead of its type");
    enableUMLView.setText("Enable UML view from now on");
    enableUMLView.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            enableUMLView_actionPerformed(e);
          }
        });
    enableINGENIASView.setToolTipText("INGENIAS view");
    enableINGENIASView.setText("Enable INGENIAS view from now on");
    enableINGENIASView.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            enableINGENIASView_actionPerformed(e);
          }
        });

    switchINGENIASView.setToolTipText("Switch to INGENIAS view");
    switchINGENIASView.setText("Switch to INGENIAS view");
    switchINGENIASView.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            switchINGENIASView_actionPerformed(e);
          }
        });

    switchUMLView.setToolTipText("Switch to UML view");
    switchUMLView.setText("Switch to UML view");
    switchUMLView.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            switchUMLView_actionPerformed(e);
          }
        });

    resizeAll.setToolTipText("Resize all");
    resizeAll.setText("Resize all entities within current diagram");
    resizeAll.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            resizeAll_actionPerformed(e);
          }
        });

    resizeAllDiagrams.setToolTipText("Resize all diagrams");
    resizeAllDiagrams.setText("Resize all entities within all defined diagram");
    resizeAllDiagrams.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            resizeAllDiagrams_actionPerformed(e);
          }
        });

    JMenuItem workspaceEntry = new JMenuItem("Switch workspace");
    workspaceEntry.setToolTipText("Change current workspace");
    workspaceEntry.setText("Switch workspace");
    workspaceEntry.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            changeWorkspace(e);
          }
        });
    preferences.add(workspaceEntry);
    preferences.add(resizeAll);
    preferences.add(resizeAllDiagrams);
    {
      elimOverlap = new JMenuItem();
      preferences.add(elimOverlap);
      elimOverlap.setText("Eliminate overlap");
      elimOverlap.setAccelerator(KeyStroke.getKeyStroke("F3"));
      elimOverlap.addMenuKeyListener(
          new MenuKeyListener() {
            public void menuKeyPressed(MenuKeyEvent evt) {
              System.out.println("elimOverlap.menuKeyPressed, event=" + evt);
              // TODO add your code for elimOverlap.menuKeyPressed
            }

            public void menuKeyReleased(MenuKeyEvent evt) {
              System.out.println("elimOverlap.menuKeyReleased, event=" + evt);
              // TODO add your code for elimOverlap.menuKeyReleased
            }

            public void menuKeyTyped(MenuKeyEvent evt) {
              elimOverlapMenuKeyTyped(evt);
            }
          });
      elimOverlap.addKeyListener(
          new KeyAdapter() {
            public void keyPressed(KeyEvent evt) {
              elimOverlapKeyPressed(evt);
            }
          });
      elimOverlap.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              elimOverlapActionPerformed(evt);
            }
          });
    }
    {
      modelingLanguageNotationSwitchMenu = new JMenu();
      preferences.add(modelingLanguageNotationSwitchMenu);
      modelingLanguageNotationSwitchMenu.setText("Modelling language");
      modelingLanguageNotationSwitchMenu.add(enableINGENIASView);

      viewSelection.add(enableINGENIASView);
      modelingLanguageNotationSwitchMenu.add(enableUMLView);
      viewSelection.add(enableUMLView);

      enableINGENIASView.setSelected(true);
      modelingLanguageNotationSwitchMenu.add(switchUMLView);
      modelingLanguageNotationSwitchMenu.add(switchINGENIASView);
    }
    {
      propertiesModeMenu = new JMenu();
      preferences.add(propertiesModeMenu);
      propertiesModeMenu.setText("Edit Properties Mode");
      {
        editPopUpProperties = new JCheckBoxMenuItem();
        propertiesModeMenu.add(editPopUpProperties);
        editPopUpProperties.setText("Edit Properties in a PopUp Window");
        editPopUpProperties.setSelected(true);
        editPopUpProperties.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                editPopUpProperties_selected();
              }
            });
        propertiesEditModeSelection.add(editPopUpProperties);
      }
      {
        editOnMessages = new JCheckBoxMenuItem();
        propertiesModeMenu.add(editOnMessages);
        editOnMessages.setText("Edit Properties in Messages Panel");
        propertiesEditModeSelection.add(editOnMessages);
        editOnMessages.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                editOnMessages_selected();
              }
            });
      }
    }

    mainMenuBar.add(file);
    mainMenuBar.add(edit);
    mainMenuBar.add(project);
    mainMenuBar.add(menuModules);
    mainMenuBar.add(profiles);
    mainMenuBar.add(preferences);
    mainMenuBar.add(help);
    file.add(newProject);
    file.add(load);
    {
      importFile = new JMenuItem();
      file.add(importFile);
      importFile.setText("Import file");
      importFile.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              importFileActionPerformed(evt);
            }
          });
    }
    file.add(save);
    file.add(saveas);
    file.addSeparator();
    file.add(exit);
    file.addSeparator();
    rightPanel.setLayout(new BorderLayout());
    rightPanel.add(buttonModelPanel, BorderLayout.WEST);
    this.getContentPane().add(jSplitPane1, BorderLayout.CENTER);
    rightPanel.add(splitPanelDiagramMessagesPaneSeparator, BorderLayout.CENTER);
    jSplitPane1.add(splitPaneSeparatingProjectsAndEntitiesView, JSplitPane.LEFT);
    splitPaneSeparatingProjectsAndEntitiesView.add(scrollPaneForProyectView, JSplitPane.TOP);
    {
      jPanel2 = new JPanel();
      BorderLayout jPanel2Layout = new BorderLayout();
      jPanel2.setLayout(jPanel2Layout);
      splitPaneSeparatingProjectsAndEntitiesView.add(jPanel2, JSplitPane.BOTTOM);
      jPanel2.add(jPanel1, BorderLayout.SOUTH);
      jPanel2.add(scrollPaneForEntitiesView, BorderLayout.CENTER);
    }
    jSplitPane1.add(rightPanel, JSplitPane.RIGHT);
    splitPanelDiagramMessagesPaneSeparator.add(pprin, JSplitPane.TOP);
    splitPanelDiagramMessagesPaneSeparator.add(messagespane, JSplitPane.BOTTOM);
    JScrollPane scrollSearchDiagram = new JScrollPane();
    scrollSearchDiagram.getViewport().add(searchDiagramPanel, null);
    searchDiagramPanel.setContentType("text/html");
    searchDiagramPanel.setEditable(false);

    messagespane.addConventionalTab(scrollLogs, "Logs");
    scrollLogs.getViewport().add(logs, null);
    scrolloutput.getViewport().add(this.moduleOutput, null);
    messagespane.addConventionalTab(scrolloutput, "Module Output");
    messagespane.addConventionalTab(scrollSearchDiagram, "Search");
    scrolloutput.getViewport().add(moduleOutput, null);
    {
      searchPanel = new JPanel();
      FlowLayout searchPanelLayout = new FlowLayout();
      searchPanelLayout.setVgap(1);
      searchPanel.setLayout(searchPanelLayout);
      jPanel1.add(searchPanel, BorderLayout.SOUTH);
      searchPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
      {
        searchField = new JTextField();
        searchPanel.add(searchField);
        searchField.setColumns(15);

        searchField.addKeyListener(
            new KeyAdapter() {
              public void keyTyped(KeyEvent evt) {
                searchFieldKeyTyped(evt);
              }
            });
      }
      {
        Search = new JButton();
        scrollPaneForProyectView.setViewportView(arbolProyectos);
        scrollPaneForEntitiesView.setViewportView(arbolObjetos);
        searchPanel.add(Search);

        Search.setIcon(new ImageIcon(ImageLoader.getImage(("images/lense.png"))));
        //	Search.setPreferredSize(new java.awt.Dimension(20, 20));
        Search.setIconTextGap(0);
        Search.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                SearchActionPerformed(evt);
              }
            });
      }
    }
    edit.add(undo);
    edit.add(redo);
    edit.addSeparator();
    edit.add(copy);
    edit.add(paste);
    edit.add(delete);
    edit.add(selectall);
    edit.addSeparator();
    edit.add(copyImage);
    edit.add(cpClipboard);
    help.add(manual);
    help.add(about);
    help.add(forcegc);

    menuModules.add(menuTools);
    menuModules.add(menuCodeGenerator);
    messagesMenu.add(this.clearMessages);
    project.add(this.properties);

    project.addSeparator();
    jSplitPane1.setDividerLocation(250);
    splitPaneSeparatingProjectsAndEntitiesView.setDividerLocation(250);
    arbolProyectos.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            arbolProyectos_mouseClicked(e);
          }
        });
    splitPanelDiagramMessagesPaneSeparator.setDividerLocation(400);
  }
Example #26
0
  private void initComponents() {
    splitPaneMain = new javax.swing.JSplitPane();
    //
    // splitPanel = new javax.swing.JSplitPane();
    splitPanelLeft = new javax.swing.JSplitPane();
    graphOptionsPanel = new javax.swing.JPanel();
    graphPanel = new javax.swing.JPanel();
    rightPanel = new javax.swing.JPanel();
    generalPanel = new javax.swing.JPanel();
    nameTextField = new javax.swing.JTextField();
    labelForName = new javax.swing.JLabel();
    blocksPanel = new javax.swing.JPanel();
    addBlockButton = new javax.swing.JButton();
    removeBlockButton = new javax.swing.JButton();
    adjustBlockButton = new javax.swing.JButton();
    portsPanel = new javax.swing.JPanel();
    addPortButton = new javax.swing.JButton();
    removePortButton = new javax.swing.JButton();
    adjustPortButton = new javax.swing.JButton();
    blockRelationsPanel = new javax.swing.JPanel();
    addRelationButton = new javax.swing.JButton();
    removeRelationButton = new javax.swing.JButton();

    splitPanelLeft.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

    graphOptionsPanel.setLayout(
        new javax.swing.BoxLayout(graphOptionsPanel, javax.swing.BoxLayout.PAGE_AXIS));

    topOptionsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Mouse Mode"));
    graphOptionsPanel.add(topOptionsPanel);

    bottomOptionsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Layout"));
    graphOptionsPanel.add(bottomOptionsPanel);

    gm = new DefaultModalGraphMouse();
    JComboBox modeBox = gm.getModeComboBox();
    topOptionsPanel.add(modeBox);

    PortConnections pconnsInst = PortConnections.getInstance();
    vv = new VisualizationViewer(new CircleLayout(pconnsInst));
    // create the transformers
    // edge label
    final Transformer edgeLabel =
        new Transformer() {
          public String transform(Object obj) {
            if (obj instanceof InteractionArc) {
              InteractionArc arc = (InteractionArc) obj;
              return arc.getArcStateShort();
            }
            return "unknown";
          }
        };
    this.edgeLabel = edgeLabel;
    vv.getRenderContext().setEdgeLabelTransformer(edgeLabel);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    // options
    java.util.List<String> options = new ArrayList<String>();
    options.add("FRLayout");
    options.add("KKLayout");
    options.add("CircleLayout");
    options.add("SpringLayout");
    options.add("SpringLayout2");
    options.add("ISOMLayout");
    layoutBox = new JComboBox(options.toArray());
    layoutBox.setSelectedItem(options.get(0));
    layoutBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            InteractionGraphs igraphs = InteractionGraphs.getInstance();
            InteractionGraph graph = igraphs.getGraph(emidSelected);
            String selected = (String) ((JComboBox) e.getSource()).getSelectedItem();
            if (selected.equals("FRLayout")) {
              vv = new VisualizationViewer(new FRLayout(graph));
            } else if (selected.equals("KKLayout")) {
              vv = new VisualizationViewer(new KKLayout(graph));
            } else if (selected.equals("CircleLayout")) {
              vv = new VisualizationViewer(new CircleLayout(graph));
            } else if (selected.equals("SpringLayout")) {
              vv = new VisualizationViewer(new SpringLayout(graph));
            } else if (selected.equals("SpringLayout2")) {
              vv = new VisualizationViewer(new SpringLayout2(graph));
            } else if (selected.equals("ISOMLayout")) {
              vv = new VisualizationViewer(new ISOMLayout(graph));
            }
            vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
            vv.getRenderContext().setEdgeLabelTransformer(edgeLabel);
            vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
            setVisualizationViewer(vv);
          }
        });
    layoutBox.setSelectedItem("CircleLayout");

    bottomOptionsPanel.add(layoutBox);

    splitPanelLeft.setTopComponent(graphOptionsPanel);

    javax.swing.GroupLayout graphPanelLayout = new javax.swing.GroupLayout(graphPanel);
    graphPanel.setLayout(graphPanelLayout);
    graphPanelLayout.setHorizontalGroup(
        graphPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 181, Short.MAX_VALUE));
    graphPanelLayout.setVerticalGroup(
        graphPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 432, Short.MAX_VALUE));

    // splitPanelLeft.setRightComponent(graphPanel);

    splitPaneMain.setLeftComponent(splitPanelLeft);

    rightPanel.setLayout(new javax.swing.BoxLayout(rightPanel, javax.swing.BoxLayout.PAGE_AXIS));

    generalPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("General"));

    labelForName.setText("name");

    nameTextField.setText("new");

    javax.swing.GroupLayout generalPanelLayout = new javax.swing.GroupLayout(generalPanel);
    generalPanel.setLayout(generalPanelLayout);
    generalPanelLayout.setHorizontalGroup(
        generalPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                generalPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(labelForName)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(
                        nameTextField,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        265,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(140, Short.MAX_VALUE)));
    generalPanelLayout.setVerticalGroup(
        generalPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                generalPanelLayout
                    .createSequentialGroup()
                    .addGroup(
                        generalPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelForName)
                            .addComponent(
                                nameTextField,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(96, Short.MAX_VALUE)));

    rightPanel.add(generalPanel);

    blocksPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Blocks"));

    javax.swing.GroupLayout blocksPanelLayout = new javax.swing.GroupLayout(blocksPanel);
    blocksPanel.setLayout(blocksPanelLayout);
    blocksPanelLayout.setHorizontalGroup(
        blocksPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                blocksPanelLayout
                    .createSequentialGroup()
                    .addGap(179, 179, 179)
                    .addGroup(
                        blocksPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(
                                adjustBlockButton,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                removeBlockButton,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                addBlockButton,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                114,
                                Short.MAX_VALUE))
                    .addContainerGap(158, Short.MAX_VALUE)));
    blocksPanelLayout.setVerticalGroup(
        blocksPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                blocksPanelLayout
                    .createSequentialGroup()
                    .addComponent(addBlockButton)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(removeBlockButton)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(adjustBlockButton)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    rightPanel.add(blocksPanel);

    portsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Ports"));

    javax.swing.GroupLayout portsPanelLayout = new javax.swing.GroupLayout(portsPanel);
    portsPanel.setLayout(portsPanelLayout);
    portsPanelLayout.setHorizontalGroup(
        portsPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                portsPanelLayout
                    .createSequentialGroup()
                    .addGap(177, 177, 177)
                    .addGroup(
                        portsPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(
                                adjustPortButton,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                removePortButton,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                addPortButton,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                115,
                                Short.MAX_VALUE))
                    .addContainerGap(159, Short.MAX_VALUE)));
    portsPanelLayout.setVerticalGroup(
        portsPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                portsPanelLayout
                    .createSequentialGroup()
                    .addComponent(addPortButton)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(removePortButton)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(adjustPortButton)
                    .addContainerGap(32, Short.MAX_VALUE)));

    rightPanel.add(portsPanel);

    blockRelationsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Block Relations"));

    javax.swing.GroupLayout blockRelationsPanelLayout =
        new javax.swing.GroupLayout(blockRelationsPanel);
    blockRelationsPanel.setLayout(blockRelationsPanelLayout);
    blockRelationsPanelLayout.setHorizontalGroup(
        blockRelationsPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                blockRelationsPanelLayout
                    .createSequentialGroup()
                    .addGap(177, 177, 177)
                    .addGroup(
                        blockRelationsPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(
                                removeRelationButton,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                addRelationButton,
                                javax.swing.GroupLayout.Alignment.LEADING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                114,
                                Short.MAX_VALUE))
                    .addContainerGap(159, Short.MAX_VALUE)));
    blockRelationsPanelLayout.setVerticalGroup(
        blockRelationsPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                blockRelationsPanelLayout
                    .createSequentialGroup()
                    .addComponent(addRelationButton)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(removeRelationButton)
                    .addContainerGap(61, Short.MAX_VALUE)));

    rightPanel.add(blockRelationsPanel);

    splitPaneMain.setRightComponent(rightPanel);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                splitPaneMain, javax.swing.GroupLayout.DEFAULT_SIZE, 653, Short.MAX_VALUE));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                splitPaneMain,
                javax.swing.GroupLayout.Alignment.TRAILING,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                541,
                Short.MAX_VALUE));
  }