Exemplo n.º 1
0
  private void newComps() {
    ta = new JTextArea();
    // ta.setLineWrap(true);
    ta.setWrapStyleWord(true);
    ta.setFocusable(false);
    ta.setEditable(false);
    ta.setFont(new Font("Courier New", Font.BOLD, 20));
    ta.setBackground(Color.black);
    ta.setForeground(Color.GREEN);

    sc = new JScrollPane();
    sc.setViewportView(ta);

    btnExport = new JButton("Export");
    btnExport.setOpaque(false);
    btnExport.setFont(ta.getFont());
    btnExport.setFocusable(false);

    ckWrap = new JCheckBox("Wrap text");
    ckWrap.setOpaque(false);
    ckWrap.setForeground(Color.white);
    ckWrap.setFont(ta.getFont());
    ckWrap.setFocusable(false);

    chooser = new JFileChooser();
  }
Exemplo n.º 2
0
  public BarUI(BarCntl theBarCntl) {
    this.theBarCntl = theBarCntl;
    this.newBar = new Bar();
    this.setSize(400, 300);
    this.setLocationRelativeTo(null);
    this.setResizable(false);
    this.setLayout(new BorderLayout());
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    topPanel = new JPanel();
    centerPanel = new JPanel();

    back = new JButton("< Back");
    back.setBounds(50, 50, 100, 50);
    back.addActionListener(this);
    topPanel.add(back);

    getBar = new JButton("Get Bar");
    getBar.setBounds(50, 50, 100, 50);
    getBar.addActionListener(this);
    topPanel.add(getBar);

    displayBar = new JTextArea("Press 'Get Bar'");
    displayBar.setMargin(new Insets(20, 20, 20, 50));
    displayBar.setFont(displayBar.getFont().deriveFont(18.0f));
    displayBar.setEditable(false);
    centerPanel.add(displayBar);

    this.add(topPanel, BorderLayout.NORTH);
    this.add(centerPanel, BorderLayout.CENTER);
  }
Exemplo n.º 3
0
  /**
   * Create a new JumpSourcePanel.
   *
   * @param tab parent JumpTab
   */
  public JumpSourcePanel(final JumpTab tab) {
    this.tab = tab;
    this.editorPane = new JTextArea();
    this.highlighter = new DefaultHighlighter();
    highlighter.setDrawsLayeredHighlights(false);

    setLayout(new BorderLayout());
    setBorder(new TitledBorder("Source"));
    editorPane.setFont(JumpGui.FONT_MONOSPACED);
    editorPane.setHighlighter(highlighter);
    final StringBuilder sb = new StringBuilder();
    for (int i = 1; i < MAXIMUM_LINE_NUMBER; ++i) {
      sb.append(String.format("%3d %n", i));
    }

    final JTextArea lineNumbers = new JTextArea(sb.toString());
    lineNumbers.setFont(editorPane.getFont());
    lineNumbers.setBackground(getBackground());
    lineNumbers.setEditable(false);
    lineNumbers.setFocusable(false);

    final JScrollPane scrollPane =
        new JScrollPane(
            editorPane,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setRowHeaderView(lineNumbers);
    add(scrollPane);
    SwingUtilities.invokeLater(this);
  }
Exemplo n.º 4
0
  /**
   * Get the {@link JComponent} that displays the given message.
   *
   * @param msg Message to display.
   * @param breakLines Whether or not {@literal "long"} lines should be broken up.
   * @return {@code JComponent} that displays {@code msg}.
   */
  private static JComponent getMessageComponent(String msg, boolean breakLines) {
    if (msg.startsWith("<html>")) {
      Component[] comps = GuiUtils.getHtmlComponent(msg, null, 500, 400);
      return (JScrollPane) comps[1];
    }

    int msgLength = msg.length();
    if (msgLength < 50) {
      return new JLabel(msg);
    }

    StringBuilder sb = new StringBuilder(msgLength * 2);
    if (breakLines) {
      for (String line : StringUtil.split(msg, "\n")) {
        line = StringUtil.breakText(line, "\n", 50);
        sb.append(line).append('\n');
      }
    } else {
      sb.append(msg).append('\n');
    }

    JTextArea textArea = new JTextArea(sb.toString());
    textArea.setFont(textArea.getFont().deriveFont(Font.BOLD));
    textArea.setBackground(new JPanel().getBackground());
    textArea.setEditable(false);
    JScrollPane textSp = GuiUtils.makeScrollPane(textArea, 400, 200);
    textSp.setPreferredSize(new Dimension(400, 200));
    return textSp;
  }
Exemplo n.º 5
0
  @Override
  public void setFont(Font font) {
    if (font == null) font = txtSample.getFont();

    fontList.setSelectedValue(font.getName(), true);
    fontList.ensureIndexIsVisible(fontList.getSelectedIndex());
    sizeList.setSelectedValue("" + font.getSize(), true);
    sizeList.ensureIndexIsVisible(sizeList.getSelectedIndex());

    cbBold.setSelected(font.isBold());
    cbItalic.setSelected(font.isItalic());
  }
Exemplo n.º 6
0
  public tempDisplay() {
    // Window for viewing
    JFrame frame = new JFrame("Client Window");
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(this);
    Dimension d = new Dimension(500, 500);
    frame.setSize(d);
    frame.setPreferredSize(d);
    frame.setMinimumSize(d);
    frame.setLayout(new BorderLayout());
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    // The panel for all the messages
    read = new JTextArea();
    read.setEditable(false);
    read.setLineWrap(true);
    read.setWrapStyleWord(true);
    Font font = read.getFont();
    read.setFont(new Font(font.getName(), font.getStyle(), font.getSize() + 2));
    JScrollPane scroll = new JScrollPane(read);
    scroll.setSize(read.getSize());
    panel.add(scroll, BorderLayout.CENTER);
    // The area you write in
    write = new JTextField();
    write.setEnabled(true);
    panel.add(write, BorderLayout.SOUTH);
    // What you do when you press enter!
    write.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent arg0) {}

          @Override
          public void keyReleased(KeyEvent arg0) {}

          @Override
          public void keyTyped(KeyEvent arg0) {
            if (arg0.getKeyChar() == KeyEvent.VK_ENTER) {
              String text = write.getText();
              client.send(text);
              write.setText("");
            }
          }
        });
    // Add the panel and look at it
    frame.add(panel);
    // client = new chatClient( this, "localhost", "Clifford" );
    if (client.connect()) {
      client.start();
      frame.setVisible(true);
    }
  }
Exemplo n.º 7
0
 private void setMessage(JPanel messageContentPanel, String message, boolean isError) {
   JTextArea textArea = new JTextArea(message);
   Font editorFont =
       textArea.getFont().deriveFont(UIManager.getFont("TextField.font").getSize2D());
   textArea.setFont(new Font("Monospaced", editorFont.getStyle(), editorFont.getSize()));
   textArea.setEditable(false);
   if (isError) {
     textArea.setForeground(Color.RED);
   }
   messageContentPanel.add(new JScrollPane(textArea), BorderLayout.CENTER);
   messageContentPanel.revalidate();
   messageContentPanel.repaint();
 }
Exemplo n.º 8
0
  public static Dimension getPreferredSize(JTextArea textArea, int preferredWidth) {
    Font font = textArea.getFont();
    String text = textArea.getText();

    Hashtable<Attribute, Object> attributes = new Hashtable<Attribute, Object>();
    attributes.put(TextAttribute.FONT, font);

    /**
     * It is crucial this be accurate! I used to have it always true/true, and XP sometimes failed
     * because of it.
     */
    Graphics2D g = ((Graphics2D) textArea.getGraphics());
    FontRenderContext frc = null;
    if (g != null) frc = g.getFontRenderContext();

    if (frc == null) {
      // on Mac "true, false" seemed to be the right combo.
      // try testing with QOptionPaneDemo in French and see the
      // external changes dialog
      frc = new FontRenderContext(null, true, false);
    }

    String[] paragraphs = Text.getParagraphs(text);
    int rows = 0;
    for (int a = 0; a < paragraphs.length; a++) {
      int textLength = paragraphs[a].length();
      if (Text.isWhiteSpace(paragraphs[a])) {
        rows++;
      } else {
        AttributedString attrString = new AttributedString(paragraphs[a], attributes);

        LineBreakMeasurer lbm = new LineBreakMeasurer(attrString.getIterator(), frc);

        int pos = 0;
        while (pos < textLength) {
          pos = lbm.nextOffset(preferredWidth);
          lbm.setPosition(pos);
          rows++;
        }
      }
    }
    int extra = 0;
    if (JVM.isWindowsXP) { // allow for descents
      extra = (int) (font.getLineMetrics("g", frc).getDescent() + 1);
    }

    FontMetrics metrics = textArea.getFontMetrics(font);
    int rowHeight = metrics.getHeight();

    return new Dimension(preferredWidth, rows * rowHeight + extra);
  }
  /** Constructs the <tt>AuthenticationWindow</tt>. */
  private void init() {
    this.idValue =
        new JTextField(
            chatRoom.getParentProvider().getProtocolProvider().getAccountID().getUserID());

    this.infoTextArea.setOpaque(false);
    this.infoTextArea.setLineWrap(true);
    this.infoTextArea.setWrapStyleWord(true);
    this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
    this.infoTextArea.setEditable(false);
    this.infoTextArea.setText(
        GuiActivator.getResources()
            .getI18NString(
                "service.gui.CHAT_ROOM_REQUIRES_PASSWORD",
                new String[] {chatRoom.getChatRoomName()}));

    this.idLabel.setFont(idLabel.getFont().deriveFont(Font.BOLD));
    this.passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD));

    this.labelsPanel.add(idLabel);
    this.labelsPanel.add(passwdLabel);

    this.textFieldsPanel.add(idValue);
    this.textFieldsPanel.add(passwdField);

    this.buttonsPanel.add(loginButton);
    this.buttonsPanel.add(cancelButton);

    this.mainPanel.add(infoTextArea, BorderLayout.NORTH);
    this.mainPanel.add(labelsPanel, BorderLayout.WEST);
    this.mainPanel.add(textFieldsPanel, BorderLayout.CENTER);
    this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH);

    this.backgroundPanel.add(mainPanel, BorderLayout.CENTER);

    this.loginButton.setName("ok");
    this.cancelButton.setName("cancel");

    this.loginButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK"));
    this.cancelButton.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    this.loginButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.getRootPane().setDefaultButton(loginButton);

    this.setTransparent(true);
  }
Exemplo n.º 10
0
  private Font getCurrentFont() {
    try {
      String fontFamily = (String) fontList.getSelectedValue();
      int fontSize = Integer.parseInt((String) sizeList.getSelectedValue());

      int fontType = Font.PLAIN;

      if (cbBold.isSelected()) fontType += Font.BOLD;
      if (cbItalic.isSelected()) fontType += Font.ITALIC;
      return new Font(fontFamily, fontType, fontSize);
    } catch (Exception ex) {
      // if error return current sample font.
      return txtSample.getFont();
    }
  }
  public int createField(JPanel panel, int x, int y, int width) {
    JTextArea l = new JTextArea(this.getLabel());
    l.setEditable(false);
    l.setLineWrap(true);
    l.setBackground(this.getOwner().getBackground());
    l.setWrapStyleWord(true);
    l.setSize(
        new Dimension(
            this.getOwner().getWidth(), this.height * (l.getFontMetrics(l.getFont())).getHeight()));
    this.setLabelControl(null);
    l.setLocation(new Point(0, y));
    panel.add(l);

    return y + 100;
  }
Exemplo n.º 12
0
  // counts lines
  public static int countLines(JTextArea textArea) {
    AttributedString text = new AttributedString(textArea.getText());
    FontRenderContext frc = textArea.getFontMetrics(textArea.getFont()).getFontRenderContext();

    int lines = 0;
    if (!textArea.getText().equals("")) {
      AttributedCharacterIterator charIt = text.getIterator();
      LineBreakMeasurer lineMeasurer = new LineBreakMeasurer(charIt, frc);
      float formatWidth = (float) textArea.getSize().width;
      lineMeasurer.setPosition(charIt.getBeginIndex());
      while (lineMeasurer.getPosition() < charIt.getEndIndex()) {
        lineMeasurer.nextLayout(formatWidth);
        lines++;
      }
      for (int i = 0; i < textArea.getText().length(); i++) {
        if (textArea.getText().charAt(i) == '\r' || textArea.getText().charAt(i) == '\n') lines++;
      }
    } else {
      lines = 1;
    }
    return lines;
  }
Exemplo n.º 13
0
 public Font getTextFont() {
   return txaRaw.getFont();
 }
Exemplo n.º 14
0
  protected final void showMsg(final String msg, final boolean quit) {
    final JPanel p = new JPanel();
    p.setLayout(new GridBagLayout());
    final GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(10, 10, 10, 10);
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.BOTH;
    final JImage im = new JImage(new ImageIcon(this.getClass().getResource("error.png")));
    final JLabel l = new JLabel("Une erreur est survenue");
    l.setFont(l.getFont().deriveFont(Font.BOLD));
    final JLabel lError = new JLabel(msg);

    final JTextArea textArea = new JTextArea();
    textArea.setFont(textArea.getFont().deriveFont(11f));

    c.gridheight = 3;
    p.add(im, c);
    c.insets = new Insets(2, 4, 2, 4);
    c.gridheight = 1;
    c.gridx++;
    c.weightx = 1;
    c.gridwidth = 2;
    p.add(l, c);
    c.gridy++;
    p.add(lError, c);

    c.gridy++;
    p.add(
        new JLabel(
            "Il s'agit probablement d'une mauvaise configuration ou installation du logiciel."),
        c);

    c.gridx = 0;
    c.gridwidth = 3;
    c.gridy++;
    c.weighty = 0;
    c.gridwidth = 1;
    c.gridx = 1;
    c.gridy++;

    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    final Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
    final boolean browseSupported = desktop != null && desktop.isSupported(Action.BROWSE);
    if (ForumURL != null) {
      final javax.swing.Action communityAction;
      if (browseSupported) {
        communityAction =
            new AbstractAction("Consulter le forum") {
              @Override
              public void actionPerformed(ActionEvent e) {
                try {
                  desktop.browse(new URI(ForumURL));
                } catch (Exception e1) {
                  e1.printStackTrace();
                }
              }
            };
      } else {
        communityAction =
            new AbstractAction("Copier l'adresse du forum") {
              @Override
              public void actionPerformed(ActionEvent e) {
                copyToClipboard(ForumURL);
              }
            };
      }
      p.add(new JButton(communityAction), c);
    }
    c.weightx = 0;
    c.gridx++;

    final javax.swing.Action supportAction;
    if (browseSupported)
      supportAction =
          new AbstractAction("Contacter l'assistance") {
            @Override
            public void actionPerformed(ActionEvent e) {
              try {
                desktop.browse(URI.create(ILM_CONTACT));
              } catch (Exception e1) {
                e1.printStackTrace();
              }
            }
          };
    else
      supportAction =
          new AbstractAction("Copier l'adresse de l'assistance") {
            @Override
            public void actionPerformed(ActionEvent e) {
              copyToClipboard(ILM_CONTACT);
            }
          };

    p.add(new JButton(supportAction), c);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(0, 0, 0, 0);
    p.add(new JSeparator(), c);

    c.gridx = 0;
    c.gridwidth = 3;
    c.gridy++;
    c.insets = new Insets(2, 4, 2, 4);
    p.add(new JLabel("Détails de l'erreur:"), c);
    c.insets = new Insets(0, 0, 0, 0);
    c.gridy++;
    String message = this.getCause() == null ? null : this.getCause().getMessage();
    if (message == null) {
      message = msg;
    } else {
      message = msg + "\n\n" + message;
    }
    message += "\n";
    message += getTrace();
    textArea.setText(message);
    textArea.setEditable(false);
    // Scroll
    JScrollPane scroll = new JScrollPane(textArea);
    scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scroll.getViewport().setMinimumSize(new Dimension(200, 300));
    c.weighty = 1;
    c.gridwidth = 3;
    c.gridx = 0;
    c.gridy++;
    p.add(scroll, c);

    c.gridy++;
    c.fill = GridBagConstraints.NONE;
    c.weighty = 0;
    c.insets = new Insets(2, 4, 2, 4);
    final JButton buttonClose = new JButton("Fermer");
    p.add(buttonClose, c);

    final Window window = this.comp == null ? null : SwingUtilities.getWindowAncestor(this.comp);
    final JDialog f;
    if (window instanceof Frame) {
      f = new JDialog((Frame) window, "Erreur", true);
    } else {
      f = new JDialog((Dialog) window, "Erreur", true);
    }
    f.setContentPane(p);
    f.pack();
    f.setSize(580, 680);
    f.setMinimumSize(new Dimension(380, 380));
    f.setLocationRelativeTo(this.comp);
    final ActionListener al =
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (quit) {
              System.exit(1);
            } else {
              f.dispose();
            }
          }
        };
    buttonClose.addActionListener(al);
    // cannot set EXIT_ON_CLOSE on JDialog
    f.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            al.actionPerformed(null);
          }
        });
    f.setVisible(true);
  }
Exemplo n.º 15
0
  /** Constructs the <tt>LoginWindow</tt>. */
  private void init() {
    String title;

    if (windowTitle != null) title = windowTitle;
    else
      title =
          DesktopUtilActivator.getResources()
              .getI18NString("service.gui.AUTHENTICATION_WINDOW_TITLE", new String[] {server});

    String text;
    if (windowText != null) text = windowText;
    else
      text =
          DesktopUtilActivator.getResources()
              .getI18NString("service.gui.AUTHENTICATION_REQUESTED_SERVER", new String[] {server});

    String uinText;
    if (usernameLabelText != null) uinText = usernameLabelText;
    else uinText = DesktopUtilActivator.getResources().getI18NString("service.gui.IDENTIFIER");

    String passText;
    if (passwordLabelText != null) passText = passwordLabelText;
    else passText = DesktopUtilActivator.getResources().getI18NString("service.gui.PASSWORD");

    setTitle(title);

    infoTextArea.setEditable(false);
    infoTextArea.setOpaque(false);
    infoTextArea.setLineWrap(true);
    infoTextArea.setWrapStyleWord(true);
    infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
    infoTextArea.setText(text);
    infoTextArea.setAlignmentX(0.5f);

    JLabel uinLabel = new JLabel(uinText);
    uinLabel.setFont(uinLabel.getFont().deriveFont(Font.BOLD));

    JLabel passwdLabel = new JLabel(passText);
    passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD));

    TransparentPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8));

    labelsPanel.add(uinLabel);
    labelsPanel.add(passwdLabel);

    TransparentPanel textFieldsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8));

    textFieldsPanel.add(uinValue);
    textFieldsPanel.add(passwdField);

    JPanel southFieldsPanel = new TransparentPanel(new GridLayout(1, 2));

    this.rememberPassCheckBox.setOpaque(false);
    this.rememberPassCheckBox.setBorder(null);

    southFieldsPanel.add(rememberPassCheckBox);
    if (signupLink != null && signupLink.length() > 0)
      southFieldsPanel.add(
          createWebSignupLabel(
              DesktopUtilActivator.getResources().getI18NString("plugin.simpleaccregwizz.SIGNUP"),
              signupLink));
    else southFieldsPanel.add(new JLabel());

    boolean allowRememberPassword = true;

    String allowRemPassStr =
        DesktopUtilActivator.getResources().getSettingsString(PNAME_ALLOW_SAVE_PASSWORD);
    if (allowRemPassStr != null) {
      allowRememberPassword = Boolean.parseBoolean(allowRemPassStr);
    }
    allowRememberPassword =
        DesktopUtilActivator.getConfigurationService()
            .getBoolean(PNAME_ALLOW_SAVE_PASSWORD, allowRememberPassword);

    setAllowSavePassword(allowRememberPassword);

    JPanel buttonPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));

    buttonPanel.add(loginButton);
    buttonPanel.add(cancelButton);

    JPanel southEastPanel = new TransparentPanel(new BorderLayout());
    southEastPanel.add(buttonPanel, BorderLayout.EAST);

    TransparentPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));

    mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 20, 20));

    JPanel mainFieldsPanel = new TransparentPanel(new BorderLayout(0, 10));
    mainFieldsPanel.add(labelsPanel, BorderLayout.WEST);
    mainFieldsPanel.add(textFieldsPanel, BorderLayout.CENTER);
    mainFieldsPanel.add(southFieldsPanel, BorderLayout.SOUTH);

    mainPanel.add(infoTextArea, BorderLayout.NORTH);
    mainPanel.add(mainFieldsPanel, BorderLayout.CENTER);
    mainPanel.add(southEastPanel, BorderLayout.SOUTH);

    this.getContentPane().add(mainPanel, BorderLayout.EAST);

    this.loginButton.setName("ok");
    this.cancelButton.setName("cancel");
    if (loginButton.getPreferredSize().width > cancelButton.getPreferredSize().width)
      cancelButton.setPreferredSize(loginButton.getPreferredSize());
    else loginButton.setPreferredSize(cancelButton.getPreferredSize());

    this.loginButton.setMnemonic(
        DesktopUtilActivator.getResources().getI18nMnemonic("service.gui.OK"));
    this.cancelButton.setMnemonic(
        DesktopUtilActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    this.loginButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.getRootPane().setDefaultButton(loginButton);
  }
Exemplo n.º 16
0
  /**
   * Constructor for main GUI
   *
   * @param configManager The configuration
   * @param title The titlebar title
   */
  public SQLRunnerGUI(ConfigurationManager configManager, String title) {

    this.configManager = configManager;

    mainWindow = new JFrame(title);

    // XXX DO NOT USE mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // Because the GUI is intended to be embedded in other applications!!
    // They will call SQLRunner.setOkToExit(true) if they want.
    mainWindow.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            mainWindow.dispose();
            SQLRunner.exit(0);
          }
        });

    final Container controlsArea = new JPanel();
    BoxLayout layout = new BoxLayout(controlsArea, BoxLayout.LINE_AXIS);
    controlsArea.setLayout(layout);
    mainWindow.add(controlsArea, BorderLayout.NORTH);

    configurations = configManager.getConfigurations();
    connectionsList =
        new JComboBox(configurations.toArray(new Configuration[configurations.size()]));
    // when you change to a different database you don't want to remember the "force passwd prompt"
    // setting
    connectionsList.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            passwdPromptCheckBox.setSelected(false);
          }
        });
    controlsArea.add(new JLabel("Connection"));
    controlsArea.add(connectionsList);
    passwdPromptCheckBox = new JCheckBox("Ask for passwd");
    controlsArea.add(passwdPromptCheckBox);

    JButton tb = new JButton("Test");
    controlsArea.add(tb);
    tb.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            // XXX
          }
        });

    final JComboBox inTemplateChoice = new JComboBox();
    // XXX Of course these should be editable...
    inTemplateChoice.addItem("Input Template:");
    for (SQLTemplate t : SQLTemplate.getList()) {
      inTemplateChoice.addItem(t);
    }
    controlsArea.add(inTemplateChoice);

    modeList = new JComboBox();
    for (OutputMode mode : OutputMode.values()) {
      modeList.addItem(mode);
    }

    // If the mode is set to JTable, switch the
    // tab to 1, else reset it to 0 (which is shared
    // by Text, SQL, etc...
    // XXX  should be a third tab for HTML
    modeList.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            mode = (OutputMode) modeList.getSelectedItem();
            switch (mode) {
              case j:
                outputPanel.setSelectedIndex(1);
                break;
              default:
                outputPanel.setSelectedIndex(0);
            }
          }
        });
    controlsArea.add(new JLabel("Output Format:"));
    controlsArea.add(modeList);

    runButton = new JButton(runAction);
    controlsArea.add(runButton);

    JButton clearOutput = new JButton("Clear Output");
    clearOutput.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            textTextArea.setText("");
            resultsStatusBar.reset();
          }
        });
    controlsArea.add(clearOutput);

    // END OF TOP ROW

    // Used by Run...
    busyDialog = new JDialog(mainWindow, "Running...");
    JProgressBar busyIndicator = new JProgressBar();
    busyIndicator.setIndeterminate(true);
    busyDialog.add(busyIndicator, BorderLayout.CENTER);
    JPanel bottomPanel = new JPanel();
    bottomPanel.add(new JButton(cancelAction));
    busyDialog.add(bottomPanel, BorderLayout.SOUTH);
    busyDialog.pack();
    busyDialog.setLocationRelativeTo(mainWindow);

    inputTextArea = new JTextArea(6, DISPLAY_COLUMNS);
    // Switch to monospaced font
    Font msFont = new Font("SansSerif", Font.PLAIN, inputTextArea.getFont().getSize());
    inputTextArea.setFont(msFont);
    JScrollPane inputAreaScrollPane = new JScrollPane(inputTextArea);
    inputAreaScrollPane.setBorder(BorderFactory.createTitledBorder("SQL Command"));

    outputPanel = new JTabbedPane();

    textTextArea = new JTextArea(20, DISPLAY_COLUMNS);
    textTextArea.setFont(msFont);
    JScrollPane outputAreaScrollPane = new JScrollPane(textTextArea);
    String resultTypeName;
    resultTypeName = OutputMode.t.toString();
    outputAreaScrollPane.setBorder(BorderFactory.createTitledBorder(resultTypeName));
    outputPanel.addTab(resultTypeName, outputAreaScrollPane);

    jtable = new JTable();
    resultTypeName = OutputMode.j.toString();
    outputPanel.addTab(resultTypeName, new JScrollPane(jtable));

    inTemplateChoice.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (inTemplateChoice.getSelectedIndex() == 0) {
              return;
            }
            final SQLTemplate selectedItem = (SQLTemplate) inTemplateChoice.getSelectedItem();
            inputTextArea.setText(selectedItem.getTemplate());
          }
        });

    mainWindow.add(
        new JSplitPane(JSplitPane.VERTICAL_SPLIT, inputAreaScrollPane, outputPanel),
        BorderLayout.CENTER);

    out = new PrintWriter(new TextAreaWriter(textTextArea));

    resultsStatusBar = new SuccessFailureBarSwing(mainWindow.getBackground(), 400, 20);
    resultsStatusBar.reset();
    mainWindow.add((JComponent) resultsStatusBar, BorderLayout.SOUTH);

    mainWindow.pack();
    UtilGUI.monitorWindowPosition(mainWindow, prefsNode);
    mainWindow.setVisible(true);
    inputTextArea.requestFocusInWindow();
  }
Exemplo n.º 17
0
 /**
  * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
  * call it in your code!
  *
  * @noinspection ALL
  */
 private void $$$setupUI$$$() {
   rootPanel = new JPanel();
   rootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
   final JToolBar toolBar1 = new JToolBar();
   rootPanel.add(
       toolBar1,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           new Dimension(-1, 20),
           null,
           0,
           false));
   openSrcButton = new JButton();
   openSrcButton.setText("Open Src");
   openSrcButton.setToolTipText("Open source file");
   toolBar1.add(openSrcButton);
   openBinButton = new JButton();
   openBinButton.setEnabled(true);
   openBinButton.setText("Open Bin");
   openBinButton.setToolTipText("Open and disassemble binaries");
   toolBar1.add(openBinButton);
   saveSrcButton = new JButton();
   saveSrcButton.setEnabled(true);
   saveSrcButton.setText("Save Src");
   saveSrcButton.setToolTipText("Save sources");
   toolBar1.add(saveSrcButton);
   saveBinButton = new JButton();
   saveBinButton.setEnabled(true);
   saveBinButton.setText("Save Bin");
   saveBinButton.setToolTipText("Save assembled binary");
   toolBar1.add(saveBinButton);
   final JToolBar.Separator toolBar$Separator1 = new JToolBar.Separator();
   toolBar1.add(toolBar$Separator1);
   asmButton = new JButton();
   asmButton.setText("Asm");
   asmButton.setToolTipText("Assemble sources");
   toolBar1.add(asmButton);
   final JToolBar.Separator toolBar$Separator2 = new JToolBar.Separator();
   toolBar1.add(toolBar$Separator2);
   hardResetButton = new JButton();
   hardResetButton.setEnabled(true);
   hardResetButton.setText("Hard Reset");
   hardResetButton.setToolTipText("Hard Reset - zeroize memory and reupload binary");
   toolBar1.add(hardResetButton);
   resetButton = new JButton();
   resetButton.setEnabled(true);
   resetButton.setText("Reset");
   resetButton.setToolTipText("Reset CPU (registers to zero)");
   toolBar1.add(resetButton);
   execButton = new JButton();
   execButton.setEnabled(true);
   execButton.setText("Exec");
   execButton.setToolTipText("Run forever");
   toolBar1.add(execButton);
   pauseButton = new JButton();
   pauseButton.setEnabled(false);
   pauseButton.setText("Pause");
   pauseButton.setToolTipText("Pause execution");
   toolBar1.add(pauseButton);
   runButton = new JButton();
   runButton.setEnabled(true);
   runButton.setText("Run");
   runButton.setToolTipText("Run until breakpoint/reserved");
   toolBar1.add(runButton);
   stepButton = new JButton();
   stepButton.setEnabled(true);
   stepButton.setText("Step");
   stepButton.setToolTipText("Execute one instruction");
   toolBar1.add(stepButton);
   final JToolBar.Separator toolBar$Separator3 = new JToolBar.Separator();
   toolBar1.add(toolBar$Separator3);
   breakpointButton = new JButton();
   breakpointButton.setEnabled(true);
   breakpointButton.setText("Breakpoint");
   breakpointButton.setToolTipText("Toggle breakpoint on instruction address");
   toolBar1.add(breakpointButton);
   final JPanel panel1 = new JPanel();
   panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
   rootPanel.add(
       panel1,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   final JLabel label1 = new JLabel();
   label1.setText("Source");
   panel1.add(
       label1,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label2 = new JLabel();
   label2.setText("Memory");
   panel1.add(
       label2,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label3 = new JLabel();
   label3.setText("Registers");
   panel1.add(
       label3,
       new GridConstraints(
           0,
           2,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   memoryScrollPane = new JScrollPane();
   panel1.add(
       memoryScrollPane,
       new GridConstraints(
           1,
           1,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(600, -1),
           null,
           0,
           false));
   memoryTable = new JTable();
   memoryScrollPane.setViewportView(memoryTable);
   final JScrollPane scrollPane1 = new JScrollPane();
   panel1.add(
       scrollPane1,
       new GridConstraints(
           1,
           2,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(100, -1),
           null,
           0,
           false));
   registersTable = new JTable();
   scrollPane1.setViewportView(registersTable);
   sourceScrollPane = new JScrollPane();
   panel1.add(
       sourceScrollPane,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(500, 400),
           null,
           0,
           false));
   sourceTextarea = new JTextArea();
   sourceTextarea.setFont(new Font("Courier New", sourceTextarea.getFont().getStyle(), 12));
   sourceTextarea.setText(
       "; Input your program here\n            set a, 1\n            add a, 1\n            ife a, 2\n                set a, 3\n:mainloop\n            ife [message + I], 0\n                set pc, end\n            set a, [message + I]\n            add a, 0xA100\n            set [0x8000 + I], a\n            add i, 1\n            set pc, mainloop\n:message    dat \"Hello, world!\", 0\n:end        set pc, end");
   sourceScrollPane.setViewportView(sourceTextarea);
   final JPanel panel2 = new JPanel();
   panel2.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
   panel2.setVisible(false);
   rootPanel.add(
       panel2,
       new GridConstraints(
           2,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   consoleTextarea = new JTextArea();
   consoleTextarea.setEditable(true);
   panel2.add(
       consoleTextarea,
       new GridConstraints(
           1,
           0,
           1,
           3,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(150, 200),
           null,
           0,
           false));
   final JLabel label4 = new JLabel();
   label4.setText("Console");
   panel2.add(
       label4,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   clearButton = new JButton();
   clearButton.setText("Clear");
   panel2.add(
       clearButton,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final Spacer spacer1 = new Spacer();
   panel2.add(
       spacer1,
       new GridConstraints(
           0,
           2,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           1,
           null,
           null,
           null,
           0,
           false));
 }
Exemplo n.º 18
0
  private void updateWindow(GraphElementAbstract element) {
    p.removeAll();
    // this.element = element;
    // this.ab = (GraphElementAbstract) graphInstance
    // .getPathwayElement(element);
    original = element;
    PropertyWindowListener pwl = new PropertyWindowListener(element);

    JTextField label = new JTextField(20);
    JTextField name = new JTextField(20);

    if (ref != null) {
      this.ab = ref;
      label.setText(ref.getLabel());
      name.setText(ref.getName());
    } else {
      this.ab = original;
      label.setText(ab.getLabel());
      name.setText(ab.getName());
    }

    reference = new JCheckBox();
    knockedOut = new JCheckBox();
    colorButton = new JButton("Colour");
    hideNeighbours = new JButton("Hide all Neighbours");
    showNeighbours = new JButton("Show all Neighbours");
    parametersButton = new JButton("Parameters");
    showLabels = new JButton("Show Labels");

    colorButton.setBackground(ab.getColor());
    colorButton.setToolTipText("Colour");
    colorButton.setActionCommand("colour");
    colorButton.addActionListener(this);

    // System.out.println("label: "+ab.getLabel());
    // System.out.println("name: "+ab.getName());
    label.setName("label");
    name.setName("name");

    label.addFocusListener(pwl);
    name.addFocusListener(pwl);

    reference.setSelected(ab.isReference());
    reference.setToolTipText("Set this element to a reference");
    reference.setActionCommand("reference");
    reference.addActionListener(this);

    MigLayout headerlayout = new MigLayout("fillx", "[right]rel[grow,fill]", "");
    JPanel headerPanel = new JPanel(headerlayout);
    // headerPanel.setBackground(new Color(192, 215, 227));
    headerPanel.add(new JLabel(ab.getBiologicalElement()), "");
    headerPanel.add(new JSeparator(), "gap 10");

    MigLayout layout = new MigLayout("fillx", "[grow,fill]", "");
    p.setLayout(layout);
    p.add(new JLabel("Element"), "gap 5 ");
    p.add(new JLabel(ab.getBiologicalElement()), "wrap,span 3");
    p.add(new JLabel("Label"), "gap 5 ");
    p.add(label, "wrap,span 3");
    p.add(new JLabel("Name"), "gap 5 ");
    p.add(name, "wrap ,span 3");

    // JCheckBox transitionfire = new JCheckBox("Should transition fire:",
    // true);
    // JTextField transitionStatement = new JTextField("true");

    if (ab.isVertex()) {
      BiologicalNodeAbstract bna = (BiologicalNodeAbstract) original;
      String lbl = "";
      if (bna.hasRef()) {
        lbl = bna.getID() + "_" + bna.getRef().getLabel();
      }
      p.add(new JLabel("Reference:"), "gap 5 ");
      p.add(new JLabel(lbl), "wrap ,span 3");

      if (bna.hasRef()) {
        this.deleteRef = new JButton("Delete Reference");
        deleteRef.setToolTipText("Delete Reference");
        deleteRef.setActionCommand("deleteRef");
        deleteRef.addActionListener(this);
        p.add(deleteRef);
        this.pickOrigin = new JButton("Highlight Origin");
        pickOrigin.setToolTipText("Highlight Origin");
        pickOrigin.setActionCommand("pickOrigin");
        pickOrigin.addActionListener(this);
        p.add(pickOrigin);

      } else {
        this.chooseRef = new JButton("Choose Reference");
        chooseRef.setToolTipText("Choose Reference");
        chooseRef.setActionCommand("chooseRef");
        chooseRef.addActionListener(this);
        p.add(chooseRef);
        if (bna.getRefs().size() > 0) {
          this.pickRefs = new JButton("Highlight References");
          pickRefs.setToolTipText("Highlight References");
          pickRefs.setActionCommand("pickRefs");
          pickRefs.addActionListener(this);
          p.add(pickRefs);
        }
      }

      showLabels.setToolTipText("Show all Labels");
      showLabels.setActionCommand("showLabels");
      showLabels.addActionListener(this);
      p.add(showLabels, "wrap");

      JComboBox<String> compartment = new JComboBox<String>();
      addCompartmentItems(compartment);
      AutoCompleteDecorator.decorate(compartment);

      compartment.setSelectedItem(bna.getCompartment());
      compartment.addItemListener(this);

      p.add(new JLabel("Compartment"), "gap 5 ");
      p.add(compartment, "wrap ,span 3");

      // ADDing Attributes (for all nodes)

      // Show Database IDs
      JTextArea dbids = new JTextArea();
      String dbidstring = new String();
      dbids.setEditable(false);
      dbids.setFont(dbids.getFont().deriveFont(Font.BOLD));
      dbids.setBackground(Color.WHITE);

      p.add(new JLabel("IDs known:"), "gap 5");
      p.add(dbids, "wrap, span 3");

      // Show Experiment names and values
      JTextArea experiments = new JTextArea();
      String experimentstring = new String();
      experiments.setEditable(false);
      experiments.setBackground(Color.WHITE);

      p.add(new JLabel("Dataset:"), "gap 5");
      p.add(experiments, "wrap, span 3");

      // Show GO annotations
      JTextArea goannoations = new JTextArea();
      String annotationstring = new String();
      goannoations.setEditable(false);
      goannoations.setForeground(Color.BLUE);
      goannoations.setBackground(Color.WHITE);

      p.add(new JLabel("Gene Ontology:"), "gap 5");
      p.add(goannoations, "wrap, span 3");

      // Show graph properties (local property)
      JTextArea graphproperties = new JTextArea();
      String propertiesstring = new String();
      graphproperties.setEditable(false);
      graphproperties.setForeground(new Color(255, 55, 55));
      graphproperties.setBackground(Color.WHITE);

      p.add(new JLabel("Graph properties:"), "gap 5");
      p.add(graphproperties, "wrap, span 3");

      // JTextField aaSequence = new JTextField(20);
      // aaSequence.setText(protein.getAaSequence());
      // aaSequence.setName("protein");
      // aaSequence.addFocusListener(pwl);
      // p.add(new JLabel("AA-Sequence"), "gap 5 ");
      // p.add(aaSequence, "wrap, span 3");

      String atname, atsvalue;
      double atdvalue;

      ArrayList<String> experimententries = new ArrayList<>(),
          databaseidentries = new ArrayList<>(),
          annotationentries = new ArrayList<>(),
          graphpropertiesentries = new ArrayList<>();

      for (NodeAttribute att : bna.getNodeAttributes()) {
        atname = att.getName();
        atsvalue = att.getStringvalue();
        atdvalue = att.getDoublevalue();

        switch (att.getType()) {
          case NodeAttributeTypes.EXPERIMENT:
            experimententries.add(atname + ":\t" + atdvalue + "\n");
            break;

          case NodeAttributeTypes.DATABASE_ID:
            databaseidentries.add(atname + ":\t" + atsvalue + "\n");
            break;

          case NodeAttributeTypes.ANNOTATION:
            annotationentries.add(atname + ":\t" + atsvalue + "\n");
            break;

          case NodeAttributeTypes.GRAPH_PROPERTY:
            graphpropertiesentries.add(atname + ":\t" + atdvalue + "\n");
            break;

          default:
            break;
        }
      }

      // Sort for more convenient display
      Collections.sort(experimententries);
      for (String exp : experimententries) experimentstring += exp;

      Collections.sort(databaseidentries);
      for (String dbid : databaseidentries) dbidstring += dbid;

      Collections.sort(annotationentries);
      for (String ann : annotationentries) annotationstring += ann;

      Collections.sort(graphpropertiesentries);
      for (String gprop : graphpropertiesentries) propertiesstring += gprop;

      experiments.setText(experimentstring);
      dbids.setText(dbidstring);
      goannoations.setText(annotationstring);
      graphproperties.setText(propertiesstring);

      if (ab instanceof PathwayMap) {
        p.add(new JLabel("Linked to Pathway"), "gap 5 ");
        boolean b = ((PathwayMap) ab).getPathwayLink() == null;
        JCheckBox linked = new JCheckBox("", !b);
        linked.setToolTipText(
            "Shows whether there is a connected Pathway in Memory to this Map (uncheck the Box to delete that Pathway)");
        linked.setActionCommand("pathwayLink");
        linked.addActionListener(this);
        linked.setEnabled(!b);
        p.add(linked, "wrap ,span 3");
      } else if (ab instanceof Protein) {
        Protein protein = (Protein) ab;
        JTextField aaSequence = new JTextField(20);
        aaSequence.setText(protein.getAaSequence());
        aaSequence.setName("protein");
        aaSequence.addFocusListener(pwl);
        p.add(new JLabel("AA-Sequence"), "gap 5 ");
        p.add(aaSequence, "wrap, span 3");
      } else if (ab instanceof DNA) {
        DNA dna = (DNA) ab;
        JTextField ntSequence = new JTextField(20);
        ntSequence.setText(dna.getNtSequence());
        ntSequence.setName("dna");
        ntSequence.addFocusListener(pwl);
        p.add(new JLabel("NT-Sequence"), "gap 5 ");
        p.add(ntSequence, "wrap, span 3");
      } else if (ab instanceof Gene) {
        Gene dna = (Gene) ab;
        JTextField ntSequence = new JTextField(20);
        ntSequence.setText(dna.getNtSequence());
        ntSequence.setName("gene");
        ntSequence.addFocusListener(pwl);
        p.add(new JLabel("NT-Sequence"), "gap 5 ");
        p.add(ntSequence, "wrap, span 3");
      } else if (ab instanceof RNA) {
        RNA rna = (RNA) ab;
        JTextField ntSequence = new JTextField(20);
        ntSequence.setText(rna.getNtSequence());
        ntSequence.setName("rna");
        ntSequence.addFocusListener(pwl);
        p.add(new JLabel("NT-Sequence"), "gap 5 ");
        p.add(ntSequence, "wrap, span 3");
      } else if (ab instanceof Place) {
        p.add(new JLabel("ID"), "gap 5 ");
        JTextField id = new JTextField(20);
        id.setText("P" + Integer.toString(ab.getID()));
        id.setEditable(false);
        p.add(id, "wrap ,span 3");
        Place place = (Place) ab;

        JLabel lswitchPlace = new JLabel("Place Type");
        JComboBox<String> placeList =
            new JComboBox<String>(new String[] {"discrete", "continuous"});
        if (place.isDiscrete()) placeList.setSelectedItem("discrete");
        else placeList.setSelectedItem("continuous");
        placeList.setName("placeList");
        placeList.addFocusListener(pwl);
        p.add(lswitchPlace, "gap 5 ");
        p.add(placeList, "wrap");

        MyJFormattedTextField token;
        MyJFormattedTextField tokenStart;

        JLabel lblTokenStart = new JLabel("Token Start");
        if (place.isDiscrete()) {
          token = new MyJFormattedTextField(MyNumberFormat.getIntegerFormat());
          tokenStart = new MyJFormattedTextField(MyNumberFormat.getIntegerFormat());
          tokenMin = new MyJFormattedTextField(MyNumberFormat.getIntegerFormat());
          tokenMax = new MyJFormattedTextField(MyNumberFormat.getIntegerFormat());
          token.setText((int) place.getToken() + "");
          tokenStart.setText((int) place.getTokenStart() + "");
          tokenMin.setText((int) place.getTokenMin() + "");
          tokenMax.setText((int) place.getTokenMax() + "");
        } else {
          token = new MyJFormattedTextField(MyNumberFormat.getDecimalFormat());
          tokenStart = new MyJFormattedTextField(MyNumberFormat.getDecimalFormat());
          tokenMin = new MyJFormattedTextField(MyNumberFormat.getDecimalFormat());
          tokenMax = new MyJFormattedTextField(MyNumberFormat.getDecimalFormat());
          token.setText(place.getToken() + "");
          tokenStart.setText(place.getTokenStart() + "");
          tokenMin.setText(place.getTokenMin() + "");
          tokenMax.setText(place.getTokenMax() + "");
        }
        JLabel lblToken = new JLabel("Token");

        token.setName("token");
        // token.addFocusListener(pwl);
        token.setEditable(false);
        token.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);

        tokenStart.setName("tokenStart");
        tokenStart.setFocusLostBehavior(JFormattedTextField.COMMIT);
        tokenStart.addFocusListener(pwl);

        tokenMin.setName("tokenMin");
        tokenMin.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);
        tokenMin.addFocusListener(pwl);
        JLabel lblTokenMin = new JLabel("min Tokens");

        tokenMax.setName("tokenMax");
        tokenMax.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);
        tokenMax.addFocusListener(pwl);
        JLabel lblTokenMax = new JLabel("max Tokens");
        p.add(lblToken, "gap 5 ");
        p.add(token, "wrap");

        p.add(lblTokenStart, "gap 5 ");
        p.add(tokenStart, "");

        constCheck = new JCheckBox("constant");
        constCheck.setActionCommand("constCheck");
        constCheck.addActionListener(this);
        constCheck.setSelected(place.isConstant());
        p.add(constCheck, "wrap");

        if (constCheck.isSelected()) {
          tokenMin.setEnabled(false);
          tokenMax.setEnabled(false);
        }
        p.add(lblTokenMin, "gap 5 ");
        p.add(tokenMin, "wrap");
        p.add(lblTokenMax, "gap 5");
        p.add(tokenMax, "wrap");
      } else if (ab instanceof Transition) {
        JLabel lswitchTrans = new JLabel("Transition Type");
        JComboBox<String> transList =
            new JComboBox<String>(
                new String[] {
                  DiscreteTransition.class.getName(),
                  ContinuousTransition.class.getName(),
                  StochasticTransition.class.getName()
                });
        transList.setSelectedItem(ab.getClass().getCanonicalName());
        transList.setName("transList");
        transList.addFocusListener(pwl);
        p.add(lswitchTrans, "gap 5");
        p.add(transList, "wrap");

        JTextField firingCondition = new JTextField(4);
        JLabel lblFiringCondition = new JLabel("Firing Condition");
        firingCondition.setText(((Transition) ab).getFiringCondition());
        firingCondition.setName("firingCondition");
        firingCondition.addFocusListener(pwl);

        p.add(lblFiringCondition, "gap 5");
        p.add(firingCondition, "wrap");

        if (ab instanceof DiscreteTransition) {
          DiscreteTransition trans = (DiscreteTransition) ab;
          JTextField delay = new JTextField(4);
          JLabel lbldelay = new JLabel("Delay");
          delay.setText(trans.getDelay() + "");
          delay.setName("delay");
          delay.addFocusListener(pwl);

          p.add(lbldelay, "gap 5");
          p.add(delay, "wrap");
        } else if (ab instanceof StochasticTransition) {
          StochasticTransition trans = (StochasticTransition) ab;
          String[] disStrings = {"norm", "exp"};
          // Create the combo box, select item at index 4.
          // Indices start at 0, so 4 specifies the pig.
          JComboBox<String> distributionList = new JComboBox<String>(disStrings);
          distributionList.setSelectedItem(trans.getDistribution());
          distributionList.setName("disList");
          distributionList.addFocusListener(pwl);
          p.add(new JLabel("Distribution"), "gap 5");
          p.add(distributionList, "wrap");
        } else if (ab instanceof ContinuousTransition) {
          ContinuousTransition trans = (ContinuousTransition) ab;
          JTextField maxSpeed = new JTextField(4);
          JLabel lblMaxSpeed = new JLabel("Maximum Speed");
          maxSpeed.setText(trans.getMaximumSpeed());
          maxSpeed.setName("maximumSpeed");
          maxSpeed.addFocusListener(pwl);

          p.add(lblMaxSpeed, "gap 5");
          p.add(maxSpeed, "wrap");

          if (trans.isKnockedOut()) {
            maxSpeed.setEnabled(false);
          }
        }
      }

    } else if (ab.isEdge()) {
      // System.out.println("edge");
      if (ab instanceof PNEdge) {

        PNEdge e = (PNEdge) ab;
        JTextField prob = new JTextField(4);
        prob.setText(e.getActivationProbability() + "");
        prob.setName("activationProb");
        prob.addFocusListener(pwl);
        JLabel lblProb = new JLabel("activation Probability");
        JTextField function = new JTextField(5);
        function.setText(e.getFunction());
        function.setName("function");
        function.addFocusListener(pwl);
        JLabel lblpassingTokens = new JLabel("Edge Function");
        JTextField lowBoundary = new JTextField(5);
        lowBoundary.setText(e.getLowerBoundary() + "");
        lowBoundary.setName("lowBoundary");
        lowBoundary.addFocusListener(pwl);
        JLabel lblLow = new JLabel("lower Boundary");
        JTextField upBoundary = new JTextField(5);
        upBoundary.setText(e.getUpperBoundary() + "");
        upBoundary.setName("upBoundary");
        upBoundary.addFocusListener(pwl);
        JLabel lblUp = new JLabel("upper Boundary");

        // String[] types = { "discrete", "continuous", "inhibition" };
        // Create the combo box, select item at index 4.
        // Indices start at 0, so 4 specifies the pig.
        // JLabel typeList = new JComboBox(types);

        p.add(new JLabel("Edge Type"), "gap 5 ");
        p.add(new JLabel(e.getType()), "wrap");

        JButton dirChanger = new JButton("Change Direction");
        dirChanger.setActionCommand("dirChanger");
        dirChanger.addActionListener(this);
        p.add(dirChanger, "wrap");

        p.add(lblProb, "gap 5");
        p.add(prob, "wrap");
        p.add(lblpassingTokens, "gap 5");
        p.add(function, "wrap");
        p.add(lblLow, "gap 5");
        p.add(lowBoundary, "wrap");
        p.add(lblUp, "gap 5");
        p.add(upBoundary, "wrap");
      }
    }

    p.add(new JLabel("Reference"), "gap 5 ");
    p.add(reference, "wrap, span 3");
    if (ab instanceof Transition) {
      knockedOut.setSelected(((Transition) ab).isKnockedOut());
      knockedOut.setToolTipText("Knock out");
      knockedOut.setActionCommand("knockedOut");
      knockedOut.addActionListener(this);
      p.add(new JLabel("Knocked out"), "gap 5 ");
      p.add(knockedOut, "wrap ,span 3");
    }

    if (ab.isVertex()) {
      hideNeighbours.setToolTipText("Sets all Neighbors of the selected Node to Reference");
      hideNeighbours.setActionCommand("hideNeighbours");
      hideNeighbours.addActionListener(this);
      hideNeighbours.setMaximumSize(new Dimension(120, 30));
      showNeighbours.setToolTipText("Delete Reference flag of all Neighbours of the current Node");
      showNeighbours.setActionCommand("showNeighbours");
      showNeighbours.addActionListener(this);
      showNeighbours.setMaximumSize(new Dimension(120, 30));
      p.add(showNeighbours);
      p.add(hideNeighbours);
    }
    parametersButton.setToolTipText("Show all Parameters");
    parametersButton.setActionCommand("showParameters");
    parametersButton.addActionListener(this);
    p.add(parametersButton);

    p.add(colorButton, "gap 5");
  }
Exemplo n.º 19
0
  public RegisterPane(final Controller controller) {

    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();

    JPanel panel1 = new JPanel();
    panel1.setLayout(new GridBagLayout());
    panel1.setOpaque(false);

    titleLabel = new JLabel("Create a new account");
    titleLabel.setForeground(Color.WHITE);
    titleLabel.setFont(new Font("Helvatica", Font.BOLD, 14));
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 3;
    panel1.add(titleLabel, constraints);

    usernameLabel = new JLabel("Username:"******"Email:");
    emailLabel.setForeground(Color.WHITE);
    constraints.gridx = 0;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.insets.top = 0;
    constraints.anchor = GridBagConstraints.EAST;
    panel1.add(emailLabel, constraints);

    emailField = new JTextField(16);
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.gridwidth = 3;
    constraints.insets.top = 0;
    constraints.anchor = GridBagConstraints.EAST;
    panel1.add(emailField, constraints);

    passwordLabel = new JLabel("Password:"******"Register");
    constraints.gridx = 3;
    constraints.gridy = 4;
    constraints.gridwidth = 1;
    constraints.insets.top = 20;
    constraints.ipady = 5;
    constraints.anchor = GridBagConstraints.EAST;
    panel1.add(registerButton, constraints);

    registerButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (registerButton.isEnabled()) {
              statusLabel.setText("");
              controller.register(
                  usernameField.getText(),
                  emailField.getText(),
                  new String(passwordField.getPassword()));
              registerButton.setEnabled(false);
            }
          }
        });

    backButton = new JLabel("<HTML><FONT color=\"#00ffff\"><U>Back</U></FONT></HTML>");
    backButton.setOpaque(false);
    backButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    constraints.gridx = 3;
    constraints.gridy = 5;
    constraints.gridwidth = 1;
    constraints.insets.top = 20;
    constraints.insets.right = 0;
    constraints.ipady = 5;
    constraints.anchor = GridBagConstraints.EAST;
    panel1.add(backButton, constraints);

    backButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (backButton.isEnabled()) {
              controller.goBack(RegisterPane.class);
            }
          }
        });

    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.insets.top = 0;
    constraints.insets.right = 0;
    constraints.ipady = 0;
    constraints.anchor = GridBagConstraints.CENTER;
    add(panel1, constraints);

    JPanel panel2 = new JPanel();
    panel2.setLayout(new BorderLayout());
    panel2.setOpaque(false);

    statusLabel = new JTextArea();
    statusLabel.putClientProperty("html.disable", Boolean.TRUE);
    statusLabel.setFont(statusLabel.getFont().deriveFont(Font.BOLD));
    statusLabel.setBackground(new Color(0, 0, 0, 0));
    statusLabel.setForeground(Color.PINK);
    statusLabel.setOpaque(false);
    statusLabel.setBorder(null);
    statusLabel.setEditable(false);
    // statusLabel.setHorizontalAlignment(SwingConstants.CENTER);

    panel2.add(statusLabel, BorderLayout.CENTER);

    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 1;
    constraints.insets.top = 20;
    constraints.insets.right = 0;
    constraints.ipady = 5;
    constraints.anchor = GridBagConstraints.WEST;
    add(panel2, constraints);
  }
Exemplo n.º 20
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.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    buttonGroup1 = new javax.swing.ButtonGroup();
    buttonGroup2 = new javax.swing.ButtonGroup();
    buttonGroup3 = new javax.swing.ButtonGroup();
    xmlPanel = new javax.swing.JPanel();
    javax.swing.JPanel xmlFilePanel = new javax.swing.JPanel();
    javax.swing.JPanel trainXmlFilePanel = new javax.swing.JPanel();
    trainXmlFileTextField = new javax.swing.JTextField();
    javax.swing.JButton trainXmlFileButton = new javax.swing.JButton();
    javax.swing.JPanel targetPanel = new javax.swing.JPanel();
    javax.swing.JPanel targetFilePanel = new javax.swing.JPanel();
    targetFileTextField = new javax.swing.JTextField();
    javax.swing.JButton targetFileButton = new javax.swing.JButton();
    javax.swing.JPanel ptmPanel = new javax.swing.JPanel();
    ptmComboBox = new javax.swing.JComboBox();
    javax.swing.JPanel aatypePanel1 = new javax.swing.JPanel();
    javax.swing.JPanel aatypeComboPanel = new javax.swing.JPanel();
    javax.swing.JScrollPane noteTypeScrollPane = new javax.swing.JScrollPane();
    javax.swing.JTextArea noteTypeTextArea = new javax.swing.JTextArea();
    typePanel = new javax.swing.JPanel();
    crossValidationRadioButton = new javax.swing.JRadioButton();
    looRadioButton = new javax.swing.JRadioButton();
    selfTrainingRadioButton = new javax.swing.JRadioButton();
    kfoldPanel = new javax.swing.JPanel();
    javax.swing.JLabel kfoldLabel = new javax.swing.JLabel();
    kfoldTextField = new javax.swing.JTextField();
    javax.swing.JLabel repeatLabel = new javax.swing.JLabel();
    repeatTextField = new javax.swing.JTextField();
    javax.swing.JLabel repeatTimesLabel = new javax.swing.JLabel();
    negSizePanel = new javax.swing.JPanel();
    sameSizeNegRadioButton = new javax.swing.JRadioButton();
    samePercentageRadioButton = new javax.swing.JRadioButton();
    negDataPanel = new javax.swing.JPanel();
    javax.swing.JPanel negFromOtherFilePanel = new javax.swing.JPanel();
    negFromTrainFileRadioButton = new javax.swing.JRadioButton();
    negFromValidFileRadioButton = new javax.swing.JRadioButton();
    negFileTextField = new javax.swing.JTextField();
    negFileButton = new javax.swing.JButton();
    javax.swing.JPanel negValidSizePanel = new javax.swing.JPanel();
    negValidSizeTextField = new javax.swing.JTextField();
    javax.swing.JLabel numValidSizeNoteLabel = new javax.swing.JLabel();
    javax.swing.JPanel optionPanel = new javax.swing.JPanel();
    javax.swing.JButton optionBtn = new javax.swing.JButton();
    javax.swing.JPanel OKPanel = new javax.swing.JPanel();
    OKBtn = new javax.swing.JButton();
    javax.swing.JButton cancelBtn = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("PHOSIDE train");
    getContentPane().setLayout(new java.awt.GridBagLayout());

    xmlPanel.setLayout(new java.awt.GridBagLayout());

    xmlFilePanel.setBorder(
        javax.swing.BorderFactory.createTitledBorder("Training file in XML format"));
    xmlFilePanel.setMinimumSize(new java.awt.Dimension(400, 63));
    xmlFilePanel.setPreferredSize(new java.awt.Dimension(500, 63));
    xmlFilePanel.setLayout(new java.awt.GridBagLayout());

    trainXmlFilePanel.setLayout(new java.awt.GridBagLayout());

    trainXmlFileTextField.setToolTipText("Please select a FASTA training file");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    trainXmlFilePanel.add(trainXmlFileTextField, gridBagConstraints);

    trainXmlFileButton.setText("Open");
    trainXmlFileButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            trainXmlFileButtonActionPerformed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    trainXmlFilePanel.add(trainXmlFileButton, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
    gridBagConstraints.weightx = 1.0;
    xmlFilePanel.add(trainXmlFilePanel, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    xmlPanel.add(xmlFilePanel, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    getContentPane().add(xmlPanel, gridBagConstraints);

    targetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Save to "));
    targetPanel.setMinimumSize(new java.awt.Dimension(400, 63));
    targetPanel.setPreferredSize(new java.awt.Dimension(500, 63));
    targetPanel.setLayout(new java.awt.GridBagLayout());

    targetFilePanel.setLayout(new java.awt.GridBagLayout());

    targetFileTextField.setToolTipText("Please select a FASTA training file");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    targetFilePanel.add(targetFileTextField, gridBagConstraints);

    targetFileButton.setText("Open");
    targetFileButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            targetFileButtonActionPerformed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    targetFilePanel.add(targetFileButton, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
    gridBagConstraints.weightx = 1.0;
    targetPanel.add(targetFilePanel, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(targetPanel, gridBagConstraints);

    // ptmPanel.setVisible(false); // TODO: remove this line for other ptm
    ptmPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("PTM type"));
    ptmPanel.setLayout(new java.awt.GridBagLayout());

    ptmComboBox.setModel(new javax.swing.DefaultComboBoxModel(PTM.values()));
    ptmComboBox.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            ptmComboBoxActionPerformed(evt);
          }
        });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    ptmPanel.add(ptmComboBox, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(ptmPanel, gridBagConstraints);

    aatypePanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Residue types"));
    aatypePanel1.setLayout(new java.awt.GridBagLayout());

    aatypeComboPanel.setLayout(
        new javax.swing.BoxLayout(aatypeComboPanel, javax.swing.BoxLayout.LINE_AXIS));

    typesCombo = new CheckComboBox(((PTM) ptmComboBox.getSelectedItem()).getAminoAcids());
    aatypeComboPanel.add(typesCombo);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    aatypePanel1.add(aatypeComboPanel, gridBagConstraints);

    noteTypeScrollPane.setBorder(null);
    noteTypeScrollPane.setVerticalScrollBarPolicy(
        javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

    noteTypeTextArea.setColumns(20);
    noteTypeTextArea.setEditable(false);
    noteTypeTextArea.setFont(
        noteTypeTextArea.getFont().deriveFont(noteTypeTextArea.getFont().getSize() - 2f));
    noteTypeTextArea.setLineWrap(true);
    noteTypeTextArea.setRows(5);
    noteTypeTextArea.setText(
        "Hint: selected amino acids will be trained together. For example, for phosphorylation, it is advisable to train serine and threonine together, but it may not be a good practice to train serine, threonine, and tyrosine together.");
    noteTypeTextArea.setWrapStyleWord(true);
    noteTypeTextArea.setOpaque(false);
    noteTypeScrollPane.setViewportView(noteTypeTextArea);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    aatypePanel1.add(noteTypeScrollPane, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(aatypePanel1, gridBagConstraints);

    // typePanel.setVisible(false);
    typePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

    buttonGroup1.add(crossValidationRadioButton);
    crossValidationRadioButton.setSelected(true);
    crossValidationRadioButton.setText("K Cross Validation");
    crossValidationRadioButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            crossValidationRadioButtonActionPerformed(evt);
          }
        });
    typePanel.add(crossValidationRadioButton);

    buttonGroup1.add(looRadioButton);
    looRadioButton.setText("Leave-one-out Validation");
    looRadioButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            looRadioButtonActionPerformed(evt);
          }
        });
    typePanel.add(looRadioButton);

    buttonGroup1.add(selfTrainingRadioButton);
    selfTrainingRadioButton.setText("Self Training");
    selfTrainingRadioButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            selfTrainingRadioButtonActionPerformed(evt);
          }
        });
    typePanel.add(selfTrainingRadioButton);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    getContentPane().add(typePanel, gridBagConstraints);

    kfoldPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Kfold cross validation"));
    kfoldPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

    kfoldLabel.setText("K: ");
    kfoldPanel.add(kfoldLabel);

    kfoldTextField.setText("10");
    kfoldTextField.setMinimumSize(new java.awt.Dimension(50, 19));
    kfoldTextField.setPreferredSize(new java.awt.Dimension(50, 19));
    kfoldPanel.add(kfoldTextField);

    repeatLabel.setText("Repeat for ");
    kfoldPanel.add(repeatLabel);

    repeatTextField.setText("1");
    repeatTextField.setPreferredSize(new java.awt.Dimension(40, 19));
    kfoldPanel.add(repeatTextField);

    repeatTimesLabel.setText("times");
    kfoldPanel.add(repeatTimesLabel);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(kfoldPanel, gridBagConstraints);

    negSizePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Negative test data size"));
    negSizePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

    buttonGroup2.add(sameSizeNegRadioButton);
    sameSizeNegRadioButton.setSelected(true);
    sameSizeNegRadioButton.setText("Same size as positive test data");
    negSizePanel.add(sameSizeNegRadioButton);

    buttonGroup2.add(samePercentageRadioButton);
    samePercentageRadioButton.setText("Same percentage as positive test data");
    negSizePanel.add(samePercentageRadioButton);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(negSizePanel, gridBagConstraints);

    negDataPanel.setVisible(false);
    negDataPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Negative data"));
    negDataPanel.setLayout(new java.awt.GridBagLayout());

    negFromOtherFilePanel.setBorder(
        javax.swing.BorderFactory.createTitledBorder("Select negative validation data from"));
    negFromOtherFilePanel.setLayout(new java.awt.GridBagLayout());

    buttonGroup3.add(negFromTrainFileRadioButton);
    negFromTrainFileRadioButton.setSelected(true);
    negFromTrainFileRadioButton.setText("Training file");
    negFromTrainFileRadioButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            negFromTrainFileRadioButtonActionPerformed(evt);
          }
        });
    negFromOtherFilePanel.add(negFromTrainFileRadioButton, new java.awt.GridBagConstraints());

    buttonGroup3.add(negFromValidFileRadioButton);
    negFromValidFileRadioButton.setText("A validation file");
    negFromValidFileRadioButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            negFromValidFileRadioButtonActionPerformed(evt);
          }
        });
    negFromOtherFilePanel.add(negFromValidFileRadioButton, new java.awt.GridBagConstraints());

    negFileTextField.setVisible(false);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    negFromOtherFilePanel.add(negFileTextField, gridBagConstraints);

    negFileButton.setVisible(false);
    negFileButton.setText("Open");
    negFileButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            negFileButtonActionPerformed(evt);
          }
        });
    negFromOtherFilePanel.add(negFileButton, new java.awt.GridBagConstraints());

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    negDataPanel.add(negFromOtherFilePanel, gridBagConstraints);

    negValidSizePanel.setBorder(
        javax.swing.BorderFactory.createTitledBorder("No. of negarive validation sites"));
    negValidSizePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

    negValidSizeTextField.setText("1000");
    negValidSizeTextField.setPreferredSize(new java.awt.Dimension(60, 19));
    negValidSizePanel.add(negValidSizeTextField);

    numValidSizeNoteLabel.setText("Put -1 to use all");
    negValidSizePanel.add(numValidSizeNoteLabel);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    negDataPanel.add(negValidSizePanel, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(negDataPanel, gridBagConstraints);

    optionBtn.setText("Advanced options");
    optionBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            optionBtnActionPerformed(evt);
          }
        });
    optionPanel.add(optionBtn);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 10;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(optionPanel, gridBagConstraints);

    OKBtn.setText("   OK   ");
    OKBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            OKBtnActionPerformed(evt);
          }
        });
    OKPanel.add(OKBtn);

    cancelBtn.setText("Cancel");
    cancelBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelBtnActionPerformed(evt);
          }
        });
    OKPanel.add(cancelBtn);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 10;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(OKPanel, gridBagConstraints);

    pack();
  } // </editor-fold>//GEN-END:initComponents
Exemplo n.º 21
0
  public ErrorMessageDialog(
      Frame owner, String title, String friendlyMessage, String moreInfo, Throwable t) {
    super(owner, (title == null || title.length() == 0 ? "Error" : title), true);
    getContentPane().setLayout(new BorderLayout());

    if ((moreInfo == null || moreInfo.length() == 0) && t != null) {
      moreInfo = t.getMessage();
    }

    if (friendlyMessage == null || friendlyMessage.length() == 0) {
      friendlyMessage = moreInfo;
      moreInfo = null;
    }

    friendLabel = new JLabel(friendlyMessage == null ? "Unknown error" : friendlyMessage);
    friendPanel = new JPanel(new BorderLayout());
    friendPanel.add(friendLabel, BorderLayout.CENTER);
    getContentPane().add(friendPanel, BorderLayout.NORTH);

    okButton = new JButton("OK");
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            THIS.setVisible(false);
          }
        });
    JPanel okPanel = new JPanel(new FlowLayout());
    okPanel.add(okButton);
    getContentPane().add(okPanel, BorderLayout.SOUTH);

    if (moreInfo != null) {
      moreButton = new JButton("More info");
      moreButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              showMore = !showMore;
              moreButton.setText(showMore ? "Less info" : "More info");
              arrange();
            }
          });
      friendPanel.add(moreButton, BorderLayout.EAST);

      // Make html out of long texts to enable line breaking
      if (moreInfo.length() > 80 && !moreInfo.startsWith("<html>")) {
        StringBuffer sb = new StringBuffer(moreInfo.length() + 40);
        sb.append("<html><p>");
        for (int i = 0; i < moreInfo.length(); i++) {
          char c = moreInfo.charAt(i);
          if (c == '&') {
            sb.append("&amp;");
          } else if (c == '<') {
            sb.append("&lt;");
          } else if (c == '>') {
            sb.append("&gt;");
          } else if (c == '\n') {
            sb.append("<br/>");
          } else {
            sb.append(c);
          }
        }
        sb.append("</p></html>");
        moreInfo = sb.toString();
      }
      moreLabel = new JLabel(moreInfo);
      morePanel = new JPanel(new BorderLayout());
      morePanel.add(moreLabel, BorderLayout.CENTER);

      extraPanel = new JPanel(new BorderLayout());
      extraPanel.add(morePanel, BorderLayout.NORTH);
    }

    if (t != null) {
      advancedButton = new JButton("Advanced");
      advancedButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              showAdvanced = !showAdvanced;
              if (morePanel == null) showMore = showAdvanced;
              advancedButton.setText(showAdvanced ? "Simple" : "Advanced");
              arrange();
            }
          });

      if (morePanel == null) {
        friendPanel.add(advancedButton, BorderLayout.EAST);
      } else {
        final Box box = Box.createVerticalBox();
        box.add(advancedButton);
        box.add(Box.createVerticalGlue());
        morePanel.add(box, BorderLayout.EAST);
      }

      final StringBuffer buf = new StringBuffer(200);
      Throwable cause = t;
      while (null != cause) {
        if (buf.length() > 0) {
          buf.append("\nCaused by ");
        }
        buf.append(cause.toString());

        final StackTraceElement[] elements = cause.getStackTrace();
        for (int i = 0; i < elements.length; i++) {
          buf.append("\n  at ").append(elements[i].toString());
        }
        cause = cause.getCause();
      }
      JTextArea advancedTextArea = new JTextArea(buf.toString());
      final Font oldFont = advancedTextArea.getFont();
      final Font newFont = new Font(oldFont.getName(), oldFont.getStyle(), 10);
      advancedTextArea.setFont(newFont);
      advancedLabel = new JScrollPane(advancedTextArea);
    }

    arrange();
    setLocationRelativeTo(getOwner());
    String friendliness =
        Util.getProperty("org.knopflerfish.desktop.errordialogfriendliness", null);
    if (friendliness != null) {
      if ("more".equals(friendliness)) {
        moreButton.doClick();
      } else if ("advanced".equals(friendliness)) {
        moreButton.doClick();
        advancedButton.doClick();
      }
    }
  }
Exemplo n.º 22
0
  /** create the form */
  private void createForm() {

    // create the panel
    setName(getMyType() + " editor");

    // create the information message
    String msg =
        "1. Use the buttons to the right to add/remove and re-order the points in the "
            + getMyType()
            + ".\r\n";
    msg +=
        " 2. Use the Drag button to switch on and off dragging of " + getMyType() + " points.\r\n";
    msg += " 3. Select a point from the list below to edit it in Point Editor (below).\r\n";
    msg += " 4. Use Reset to return to the original " + getMyType() + ".\r\n";
    msg += " 5. Finally use Apply then Close to update the shape.\r\n";

    // create the information panel
    final JTextArea info = new JTextArea();
    info.setBackground(this.getBackground());
    info.setLineWrap(true);
    info.setWrapStyleWord(true);
    info.setText(msg);
    // make the text a little smaller
    final Font infoFont = info.getFont();
    info.setFont(infoFont.deriveFont((float) 10.0));

    // create the top panel (with the new, up, down button)
    final JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new BorderLayout());
    final JPanel btnBar = new JPanel();
    btnBar.setLayout(new GridLayout(2, 0));
    infoPanel.add("East", btnBar);
    infoPanel.add("Center", info);

    // and the new, up, down buttons
    final JButton upBtn = createButton("Move current point up", "images/Up.gif", "Up");
    upBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doUpDown(true);
          }
        });

    final JButton downBtn = createButton("Move current point down", "images/Down.gif", "Down");
    downBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doUpDown(false);
          }
        });

    final JButton newBtn = createButton("Add new point", "images/NewPin.gif", "New");
    newBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            addNew();
          }
        });

    final JButton deleteBtn =
        createButton("Delete current point", "images/DeletePin.gif", "Delete");
    deleteBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            deleteCurrent();
          }
        });

    btnBar.add(upBtn);
    btnBar.add(downBtn);
    btnBar.add(newBtn);
    btnBar.add(deleteBtn);

    // create the list
    _myList = new JList();
    _myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _myList.setBorder(new javax.swing.border.EtchedBorder());
    _myList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(final ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
              if (!_myList.isSelectionEmpty()) {
                final WorldLocation loc = (WorldLocation) _myList.getSelectedValue();
                if (loc != null) editThis(_myList.getSelectedValue());
              }
            }
          }
        });

    // show the list
    final JPanel listHolder = new JPanel();
    listHolder.setLayout(new BorderLayout());
    _dragger = new DragButton(getChart(), _theParent);
    listHolder.add("North", _dragger);
    listHolder.add("Center", _myList);

    // create the sub-form
    _subPanel = new JPanel();
    _subPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Point Editor"));
    _subPanel.setName("Point editor");
    _subPanel.setLayout(new BorderLayout());
    _subPanel.add("Center", _editor.getCustomEditor());
    final JButton subApply = new JButton("Apply");
    subApply.setToolTipText("Apply the changes to our " + getMyType());
    subApply.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            final WorldLocation curLoc = (WorldLocation) _myList.getSelectedValue();
            if (curLoc != null) {
              curLoc.copy((WorldLocation) _editor.getValue());
              _myList.repaint();

              // also update the point in the path
              final int index = _myList.getSelectedIndex();
              getPath().getLocationAt(index).copy(curLoc);

              // update the plot
              getChart().getLayers().fireReformatted(null);
            }
          }
        });

    // create the bottom toolbar
    final JButton closeBtn = new JButton("Close");
    closeBtn.setToolTipText("Close this panel");
    closeBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doClose();
          }
        });

    // now the reset button
    final JButton resetBtn = new JButton("Reset");
    resetBtn.setToolTipText("Reset the data");
    resetBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doReset();
          }
        });

    final JPanel buttonHolder = new JPanel();
    buttonHolder.setLayout(new GridLayout(1, 0));
    buttonHolder.add(closeBtn);
    buttonHolder.add(subApply);
    buttonHolder.add(resetBtn);

    final JPanel bottomHolder = new JPanel();
    bottomHolder.setLayout(new BorderLayout());
    bottomHolder.add("Center", _subPanel);
    bottomHolder.add("South", buttonHolder);

    // put them into the form
    setLayout(new BorderLayout());
    add("North", infoPanel);
    add("Center", listHolder);
    add("South", bottomHolder);
  }
Exemplo n.º 23
0
 private static int getTextAreaBaseline(JTextArea text, int height) {
   Insets insets = text.getInsets();
   FontMetrics fm = text.getFontMetrics(text.getFont());
   return insets.top + fm.getAscent();
 }
Exemplo n.º 24
-1
  /**
   * Shows a dialog request to enter text in a multiline text field <br>
   * Though not all text might be visible, everything entered is delivered with the returned text
   * <br>
   * The main purpose for this feature is to allow pasting text from somewhere preserving line
   * breaks <br>
   *
   * @param msg the message to display.
   * @param title the title for the dialog (default: Sikuli input request)
   * @param lines the maximum number of lines visible in the text field (default 9)
   * @param width the maximum number of characters visible in one line (default 20)
   * @return The user's input including the line breaks.
   */
  public static String inputText(String msg, String title, int lines, int width) {
    width = Math.max(20, width);
    lines = Math.max(9, lines);
    if ("".equals(title)) {
      title = "Sikuli input request";
    }
    JTextArea ta = new JTextArea("");
    int w = width * ta.getFontMetrics(ta.getFont()).charWidth('m');
    int h = (int) (lines * ta.getFontMetrics(ta.getFont()).getHeight());
    ta.setPreferredSize(new Dimension(w, h));
    ta.setMaximumSize(new Dimension(w, 2 * h));

    JScrollPane sp = new JScrollPane(ta);
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);

    JTextArea tm = new JTextArea(msg);
    tm.setColumns(width);
    tm.setLineWrap(true);
    tm.setWrapStyleWord(true);
    tm.setEditable(false);
    tm.setBackground(new JLabel().getBackground());

    JPanel pnl = new JPanel();
    pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS));
    pnl.add(sp);
    pnl.add(Box.createVerticalStrut(10));
    pnl.add(tm);
    pnl.add(Box.createVerticalStrut(10));

    if (0 == JOptionPane.showConfirmDialog(null, pnl, title, JOptionPane.OK_CANCEL_OPTION)) {
      return ta.getText();
    } else {
      return "";
    }
  }