Esempio n. 1
0
 @Override
 protected void setValue(final Object value) {
   try {
     // System.out.println("setValue Called");
     // System.out.println(value);
     iconContainer.setVisible(true);
     if (value == null) {
       setText("");
       // return this;
     } else if (value instanceof Integer) {
       iconContainer.setIcon(valid);
       iconContainer.putClientProperty("state", "VALID");
       setText(((Integer) value).toString());
       // return this;
     } else {
       Toolkit.getDefaultToolkit().beep();
       iconContainer.setIcon(error);
       iconContainer.putClientProperty("state", "ERROR");
       setText("Ungültige Eingabe");
       // return this;
     }
   } catch (Exception e) {
     log.error("Error in setValue()", e);
   }
 }
  // TODO SIGNATURE CHANGED
  @Override
  public void validationStateChanged(final Object validatedObject) {
    if (vali != null) {
      final int status = vali.getStatus();
      iconContainer.setToolTipText(vali.getValidationMessage());
      iconContainer.setVisible(true);
      switch (status) {
        case Validatable.ERROR:
          {
            iconContainer.setIcon(error);
            iconContainer.putClientProperty("state", "ERROR");
            break;
          }
        case Validatable.WARNING:
          {
            iconContainer.setIcon(warning);
            iconContainer.putClientProperty("state", "WARNING");
            break;
          }
        case Validatable.VALID:
          {
            iconContainer.setIcon(valid);
            iconContainer.putClientProperty("state", "VALID");
            final Integer counter = (Integer) (iconContainer.getClientProperty("validCounter"));
            if (counter != null) {
              iconContainer.putClientProperty("validCounter", new Integer(counter.intValue() + 1));
            } else {
              iconContainer.putClientProperty("validCounter", new Integer(1));
            }
            final java.awt.event.ActionListener timerAction =
                new java.awt.event.ActionListener() {

                  @Override
                  public void actionPerformed(final java.awt.event.ActionEvent event) {
                    if (iconContainer.getClientProperty("state").equals("VALID")) {
                      final Integer counter =
                          (Integer) (iconContainer.getClientProperty("validCounter"));
                      iconContainer.putClientProperty(
                          "validCounter", new Integer(counter.intValue() - 1));
                      if (counter.equals(new Integer(1))) {
                        iconContainer.setVisible(false);
                      }
                    } else {
                      iconContainer.putClientProperty("validCounter", new Integer(0));
                    }
                  }
                };

            final javax.swing.Timer timer = new javax.swing.Timer(4000, timerAction);
            timer.setRepeats(false);
            timer.start();
          }
      }
    }
  }
  public ButtonTabComponent(final JTabbedPane pane) {
    // unset default FlowLayout' gaps
    super(new BorderLayout());
    if (pane == null) throw new NullPointerException("TabbedPane is null");
    this.pane = pane;
    setOpaque(false);

    // make JLabel read titles from JTabbedPane
    final JLabel label =
        new JLabel() {
          /** */
          private static final long serialVersionUID = 1L;

          @Override
          public String getText() {
            final int i = pane.indexOfTabComponent(ButtonTabComponent.this);
            if (i != -1) {
              final String title = pane.getTitleAt(i);
              return title;
            }
            return null;
          }
        };
    label.putClientProperty("html.disable", true);

    add(label, BorderLayout.CENTER);
    // add more space between the label and the button
    label.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));

    // tab button
    final JButton button = new TabButton();
    add(button, BorderLayout.WEST);
  }
  public void show() {
    FloorcJson floorcJson = null;
    try {
      floorcJson = Settings.get();
    } catch (Throwable ignored) {
    }

    HashMap<String, String> auth =
        floorcJson != null ? floorcJson.auth.get(Constants.defaultHost) : null;
    String username = "******";
    if (auth != null) {
      username = auth.get("username");
    }
    usernameInput.setText(username);
    frame = new JFrame();
    frame.getContentPane().add(contentContainer);
    frame.setMinimumSize(new Dimension(650, 500));
    frame.setResizable(false);
    frame.setLocationRelativeTo(null);
    frame.pack();
    contentContainer.setBorder(new EmptyBorder(5, 5, 5, 5));
    frame.setVisible(true);
    String contents =
        "<html><body><p>When you submit an "
            + "issue we will be notified right away. If we have contact information for you<br/> we will respond. You can also "
            + "contact us via [email protected], on IRC in #floobits<br/> "
            + "on Freenode, or via @floobits Twitter. If you run into "
            + "a bug it may help us if you send us your <br/>log. You can find it by going to Help -&gt; Find "
            + "log....     </p></body></html>";

    instructionsLabel.setText(contents);
    instructionsLabel.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
  }
 /** Demo. */
 public static void main(String[] args) {
   try {
     JFrame frame = new JFrame("Panner");
     JPanel p = (JPanel) frame.getContentPane();
     URL url = PannerHandler.class.getResource("desert.jpg");
     String key =
         System.getProperty("os.name").toLowerCase().indexOf("mac") != -1 ? "\u2318" : "control";
     JLabel label =
         new JLabel("Press " + key + "+shift to display panner, click/drag to navigate");
     label.setBorder(new EmptyBorder(4, 4, 4, 4));
     p.add(label, BorderLayout.NORTH);
     JLabel image = new JLabel(new ImageIcon(url));
     image.setFocusable(true);
     PannerHandler handler = new PannerHandler(image, 95, new Point(0, 0));
     image.putClientProperty("panner", handler);
     p.add(new JScrollPane(image));
     frame.pack();
     Dimension size = image.getPreferredSize();
     size.width /= 2;
     size.height /= 2;
     Dimension ssize = frame.getToolkit().getScreenSize();
     frame.setLocation((ssize.width - size.width) / 2, (ssize.height - size.height) / 2);
     frame.setSize(size);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     frame.setVisible(true);
     image.requestFocus();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
    @NotNull
    @Override
    public Component getTableCellRendererComponent(
        @NotNull JTable table,
        Object value,
        boolean isSelected,
        boolean hasFocus,
        int row,
        int column) {
      boolean isEnabled = true;
      final DefaultMutableTreeNode node =
          (DefaultMutableTreeNode)
              ((TreeTable) table).getTree().getPathForRow(row).getLastPathComponent();
      Option key = null;
      if (node instanceof MyTreeNode) {
        isEnabled = ((MyTreeNode) node).isEnabled();
        key = ((MyTreeNode) node).getKey();
      }
      if (!table.isEnabled()) {
        isEnabled = false;
      }

      Color background = table.getBackground();
      if (value instanceof Boolean) {
        myCheckBox.setSelected(((Boolean) value).booleanValue());
        myCheckBox.setBackground(background);
        myCheckBox.setEnabled(isEnabled);
        return myCheckBox;
      } else if (value instanceof String) {
        /*
        myComboBox.removeAllItems();
        myComboBox.addItem(value);
        */
        myComboBox.setText((String) value);
        myComboBox.setBackground(background);
        myComboBox.setEnabled(isEnabled);
        return myComboBox;
      } else if (value instanceof Integer) {
        if (key instanceof IntOption && ((IntOption) key).isDefaultValue(value)) {
          myIntLabel.setText(((IntOption) key).getDefaultValueText());
        } else {
          myIntLabel.setText(value.toString());
        }
        return myIntLabel;
      }

      myCheckBox.putClientProperty("JComponent.sizeVariant", "small");
      myComboBox.putClientProperty("JComponent.sizeVariant", "small");

      myEmptyLabel.setBackground(background);
      return myEmptyLabel;
    }
Esempio n. 7
0
  /**
   * Build the UI of the given process according to the given data.
   *
   * @param processExecutionData Process data.
   * @return The UI for the configuration of the process.
   */
  public JComponent buildUIExec(ProcessExecutionData processExecutionData) {
    JPanel panel = new JPanel(new MigLayout("fill"));

    JPanel executorPanel = new JPanel(new MigLayout());
    executorPanel.setBorder(BorderFactory.createTitledBorder("Executor :"));
    executorPanel.add(new JLabel("localhost"));

    JPanel statusPanel = new JPanel(new MigLayout());
    statusPanel.setBorder(BorderFactory.createTitledBorder("Status :"));
    stateLabel = new JLabel(processExecutionData.getState().getValue());
    statusPanel.add(stateLabel);

    JPanel resultPanel = new JPanel(new MigLayout());
    resultPanel.setBorder(BorderFactory.createTitledBorder("Result :"));
    for (Output o : processExecutionData.getProcess().getOutput()) {
      JLabel title = new JLabel(o.getTitle() + " : ");
      JLabel result = new JLabel();
      result.putClientProperty("URI", o.getIdentifier());
      outputJLabelList.add(result);
      resultPanel.add(title);
      resultPanel.add(result, "wrap");
    }

    JPanel logPanel = new JPanel(new BorderLayout());
    logPanel.setBorder(BorderFactory.createTitledBorder("Log :"));
    logPane = new JTextPane();
    logPane.setCaretPosition(0);
    JScrollPane scrollPane = new JScrollPane(logPane);
    logPanel.add(scrollPane, BorderLayout.CENTER);

    panel.add(executorPanel, "growx, wrap");
    panel.add(statusPanel, "growx, wrap");
    panel.add(resultPanel, "growx, wrap");
    panel.add(logPanel, "growx, growy, wrap");

    return panel;
  }