Ejemplo n.º 1
0
  public JToolBar getToolBar() {
    JToolBar toolBar = new JToolBar();
    toolBar.setOpaque(false);
    toolBar.setBorder(null);
    toolBar.setFloatable(false);
    toolBar.setBorderPainted(false);

    Insets insets = new Insets(6, 0, 0, 0);
    JButton button = null;
    button = toolBar.add(new NovoAction(this));
    button.setMargin(insets);
    button = toolBar.add(new CancelarAction(this));
    button.setMargin(insets);
    button = toolBar.add(new SalvarAction(this));
    button.setMargin(insets);
    button = toolBar.add(new ExcluirAction(this));
    button.setMargin(insets);
    button = toolBar.add(new PesquisarAction(this));
    button.setMargin(insets);
    button = toolBar.add(new LimparAction(this));
    button.setMargin(insets);
    button = toolBar.add(new ImprimirAction(this));
    button.setMargin(insets);
    toolBar.addSeparator(new Dimension(20, 10));
    return toolBar;
  }
Ejemplo n.º 2
0
  public static void init(
      JToolBar comp, Thing thing, Container parent, ActionContext actionContext) {
    JComponentCreator.init(comp, thing, parent, actionContext);

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

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

    Insets margin = AwtCreator.createInsets(thing, "margin", actionContext);
    if (margin != null) {
      comp.setMargin(margin);
    }

    Integer orientation = null;
    String v = thing.getString("orientation");
    if ("HORIZONTAL".equals(v)) {
      orientation = JToolBar.HORIZONTAL;
    } else if ("VERTICAL".equals(v)) {
      orientation = JToolBar.VERTICAL;
    }
    if (orientation != null) {
      comp.setOrientation(orientation);
    }

    Boolean rollover = JavaCreator.createBoolean(thing, "rollover");
    if (rollover != null) {
      comp.setRollover(rollover);
    }
  }
 protected JToolBar createToolbar() {
   JToolBar toolbar = new JToolBar();
   toolbar.setFloatable(false);
   toolbar.setBorderPainted(false);
   toolbar.add(createButton("images/cross_add.gif", null, ADD));
   toolbar.add(createButton("images/cross_delete.gif", null, REMOVE));
   toolbar.add(createButton("images/arrow_up.gif", null, UP));
   toolbar.add(createButton("images/arrow_down.gif", null, DOWN));
   setButtonEnabled(ADD, true);
   return toolbar;
 }
Ejemplo n.º 4
0
 /**
  * Static component init.
  *
  * <pre>
  *  - panel
  *      - northPanel
  *          - parameterPanel
  *          - toolBar
  *      - gridController
  *      - confirmPanel
  *  - statusBar
  *  </pre>
  *
  * @throws Exception
  */
 void jbInit() throws Exception {
   // [ 1707303 ] Account Combination Form(VAccountDialog) translation issue
   titledBorder =
       new TitledBorder(
           BorderFactory.createEtchedBorder(Color.white, new Color(134, 134, 134)),
           Msg.getMsg(Env.getCtx(), "Parameter"));
   //
   panelLayout.setHgap(5);
   panelLayout.setVgap(5);
   northLayout.setHgap(5);
   northLayout.setVgap(5);
   //
   parameterPanel.setLayout(parameterLayout);
   parameterPanel.setBorder(titledBorder);
   northPanel.setLayout(northLayout);
   toolBar.setOrientation(JToolBar.VERTICAL);
   toolBar.setBorder(null);
   toolBar.setRequestFocusEnabled(false);
   toolBar.setBorderPainted(false);
   toolBar.setMargin(new Insets(5, 5, 5, 5));
   bSave.setIcon(new ImageIcon(ResourceFinder.getResource("images/Save24.gif")));
   bSave.setMargin(new Insets(2, 2, 2, 2));
   bSave.setToolTipText(Msg.getMsg(Env.getCtx(), "AccountNewUpdate"));
   bSave.addActionListener(this);
   bRefresh.setIcon(new ImageIcon(ResourceFinder.getResource("images/Refresh24.gif")));
   bRefresh.setMargin(new Insets(2, 2, 2, 2));
   bRefresh.setToolTipText(Msg.getMsg(Env.getCtx(), "Refresh"));
   bRefresh.addActionListener(this);
   bIgnore.setIcon(new ImageIcon(ResourceFinder.getResource("images/Ignore24.gif")));
   bIgnore.setMargin(new Insets(2, 2, 2, 2));
   bIgnore.setToolTipText(Msg.getMsg(Env.getCtx(), "Ignore"));
   bIgnore.addActionListener(this);
   //
   toolBar.addSeparator();
   toolBar.add(bRefresh, null);
   toolBar.add(bIgnore, null);
   toolBar.add(bSave, null);
   //
   getContentPane().add(panel);
   panel.setLayout(panelLayout);
   panel.add(confirmPanel, BorderLayout.SOUTH);
   panel.add(northPanel, BorderLayout.NORTH);
   northPanel.add(parameterPanel, BorderLayout.CENTER);
   northPanel.add(toolBar, BorderLayout.EAST);
   //
   this.getContentPane().add(statusBar, BorderLayout.SOUTH);
   confirmPanel.addActionListener(this);
 } //	jbInit
Ejemplo n.º 5
0
  public JToolBar buildToolBar(MutableGuiContext ctxt) throws MenuFactory.BuildException {
    JToolBar bar = new JToolBar();
    bar.setFloatable(getFloatable());
    bar.setBorderPainted(getBorderPainted());

    for (MenuBuilder item : getComponents()) {
      item.setForMenu(false);

      Component cmp = item.build(ctxt);

      if (cmp instanceof JMenuItem && ((JMenuItem) cmp).getIcon() != null) {

        Action currentAction = ((JMenuItem) cmp).getAction();
        if (!item.isHiddenWhenNotAllowed() || currentAction.isEnabled()) {
          bar.add(currentAction).setName(currentAction.getValue(Action.NAME).toString());
          ;
        }

      } else {
        if (cmp instanceof AbstractButton) {
          Action actionObject = ((AbstractButton) cmp).getAction();
          if (actionObject != null) {
            String actionName = (String) actionObject.getValue(Action.NAME);
            cmp.setName(actionName);
          }
        }
        if (getIconOnly() && cmp instanceof JButton && ((JButton) cmp).getIcon() != null) {
          ((JButton) cmp).setText("");
        }
        if (!item.isHiddenWhenNotAllowed() || cmp.isEnabled()) {
          bar.add(cmp);
        }
      }
    }
    rolloverEffect.doEffect(bar);
    return removeUnnecessarySeparators(bar);
  }
Ejemplo n.º 6
0
  @SuppressWarnings("serial")
  public static JToolBar newToolbar(boolean anchorRight) {
    JToolBar toolbar;

    if (anchorRight) {
      toolbar =
          new JToolBar() {
            @Override
            protected void addImpl(Component c, Object constraints, int index) {
              int reverseIndex;
              if (index == -1) {
                reverseIndex = 0;
              } else {
                int oldIndex = getComponentIndex(c);
                if (oldIndex >= 0 && index > oldIndex) {
                  index--;
                }

                reverseIndex = getComponentCount() - index;
              }

              super.addImpl(c, constraints, reverseIndex);
            }
          };
      toolbar.setComponentOrientation(RIGHT_TO_LEFT);
    } else {
      toolbar = new JToolBar();
    }

    toolbar.setBorder(null);
    toolbar.setBorderPainted(false);
    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    toolbar.setOpaque(false);
    return toolbar;
  }
Ejemplo n.º 7
0
    /**
     * Constructs a new {@code ImageryProvidersPanel}.
     *
     * @param gui The parent preference tab pane
     * @param layerInfoArg The list of imagery entries to display
     */
    public ImageryProvidersPanel(final PreferenceTabbedPane gui, ImageryLayerInfo layerInfoArg) {
      super(new GridBagLayout());
      this.gui = gui;
      this.layerInfo = layerInfoArg;
      this.activeModel = new ImageryLayerTableModel();

      activeTable =
          new JTable(activeModel) {
            @Override
            public String getToolTipText(MouseEvent e) {
              java.awt.Point p = e.getPoint();
              return activeModel.getValueAt(rowAtPoint(p), columnAtPoint(p)).toString();
            }
          };
      activeTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

      defaultModel = new ImageryDefaultLayerTableModel();
      defaultTable = new JTable(defaultModel);

      defaultModel.addTableModelListener(e -> activeTable.repaint());
      activeModel.addTableModelListener(e -> defaultTable.repaint());

      TableColumnModel mod = defaultTable.getColumnModel();
      mod.getColumn(2).setPreferredWidth(800);
      mod.getColumn(2).setCellRenderer(new ImageryURLTableCellRenderer(layerInfo.getLayers()));
      mod.getColumn(1).setPreferredWidth(400);
      mod.getColumn(1).setCellRenderer(new ImageryNameTableCellRenderer());
      mod.getColumn(0).setPreferredWidth(50);

      mod = activeTable.getColumnModel();
      mod.getColumn(1).setPreferredWidth(800);
      mod.getColumn(1)
          .setCellRenderer(new ImageryURLTableCellRenderer(layerInfo.getDefaultLayers()));
      mod.getColumn(0).setPreferredWidth(200);

      RemoveEntryAction remove = new RemoveEntryAction();
      activeTable.getSelectionModel().addListSelectionListener(remove);

      add(new JLabel(tr("Available default entries:")), GBC.eol().insets(5, 5, 0, 0));
      // Add default item list
      JScrollPane scrolldef = new JScrollPane(defaultTable);
      scrolldef.setPreferredSize(new Dimension(200, 200));
      add(
          scrolldef,
          GBC.std()
              .insets(0, 5, 0, 0)
              .fill(GridBagConstraints.BOTH)
              .weight(1.0, 0.6)
              .insets(5, 0, 0, 0));

      // Add default item map
      defaultMap = new JMapViewer();
      defaultMap.setTileSource(new OsmTileSource.Mapnik()); // for attribution
      defaultMap.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              if (e.getButton() == MouseEvent.BUTTON1) {
                defaultMap.getAttribution().handleAttribution(e.getPoint(), true);
              }
            }
          });
      defaultMap.setZoomContolsVisible(false);
      defaultMap.setMinimumSize(new Dimension(100, 200));
      add(
          defaultMap,
          GBC.std()
              .insets(5, 5, 0, 0)
              .fill(GridBagConstraints.BOTH)
              .weight(0.33, 0.6)
              .insets(5, 0, 0, 0));

      defaultTableListener = new DefListSelectionListener();
      defaultTable.getSelectionModel().addListSelectionListener(defaultTableListener);

      defaultToolbar = new JToolBar(JToolBar.VERTICAL);
      defaultToolbar.setFloatable(false);
      defaultToolbar.setBorderPainted(false);
      defaultToolbar.setOpaque(false);
      defaultToolbar.add(new ReloadAction());
      add(defaultToolbar, GBC.eol().anchor(GBC.SOUTH).insets(0, 0, 5, 0));

      ActivateAction activate = new ActivateAction();
      defaultTable.getSelectionModel().addListSelectionListener(activate);
      JButton btnActivate = new JButton(activate);

      middleToolbar = new JToolBar(JToolBar.HORIZONTAL);
      middleToolbar.setFloatable(false);
      middleToolbar.setBorderPainted(false);
      middleToolbar.setOpaque(false);
      middleToolbar.add(btnActivate);
      add(middleToolbar, GBC.eol().anchor(GBC.CENTER).insets(5, 15, 5, 0));

      add(Box.createHorizontalGlue(), GBC.eol().fill(GridBagConstraints.HORIZONTAL));

      add(new JLabel(tr("Selected entries:")), GBC.eol().insets(5, 0, 0, 0));
      JScrollPane scroll = new JScrollPane(activeTable);
      add(
          scroll,
          GBC.std()
              .fill(GridBagConstraints.BOTH)
              .span(GridBagConstraints.RELATIVE)
              .weight(1.0, 0.4)
              .insets(5, 0, 0, 5));
      scroll.setPreferredSize(new Dimension(200, 200));

      activeToolbar = new JToolBar(JToolBar.VERTICAL);
      activeToolbar.setFloatable(false);
      activeToolbar.setBorderPainted(false);
      activeToolbar.setOpaque(false);
      activeToolbar.add(new NewEntryAction(ImageryInfo.ImageryType.WMS));
      activeToolbar.add(new NewEntryAction(ImageryInfo.ImageryType.TMS));
      activeToolbar.add(new NewEntryAction(ImageryInfo.ImageryType.WMTS));
      // activeToolbar.add(edit); TODO
      activeToolbar.add(remove);
      add(activeToolbar, GBC.eol().anchor(GBC.NORTH).insets(0, 0, 5, 5));
    }
  private void initUI() {
    setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar();
    toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders
    toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    toolBar.setBorderPainted(false);

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("add");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.add");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            add();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("add_par");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.add.from.report");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            addFromReport();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("parameter_clone");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.add.clone");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            cloneParameter();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("edit");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.edit");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            modify();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("delete");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.delete");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            delete();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("parameter_up");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.up");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            up();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("parameter_down");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.down");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            down();
          }
        });

    //        SwingUtil.registerButtonsForFocus(buttonsPanel);

    add(toolBar, BorderLayout.NORTH);

    createTable();
    table
        .getColumnModel()
        .getColumn(1)
        .setCellRenderer(
            new DefaultTableCellRenderer() {

              @Override
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
                String tmp = (String) value;
                tmp = tmp.substring(tmp.lastIndexOf('.') + 1);
                /*
                if ("Object".equals(tmp)) {
                	tmp = "Any";
                }
                */
                setText(tmp);

                return this;
              }
            });
    table.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent event) {
            if (event.getClickCount() == 2) {
              modify();
            }
          }
        });
    table.addKeyListener(
        new KeyAdapter() {

          @Override
          public void keyPressed(KeyEvent event) {
            int keyCode = event.getKeyCode();
            if (keyCode == KeyEvent.VK_ENTER) {
              modify();
              // don't let anyone else handle the event
              event.consume();
            } else if (keyCode == KeyEvent.VK_INSERT) {
              add();
              // don't let anyone else handle the event
              event.consume();
            } else if (keyCode == KeyEvent.VK_DELETE) {
              delete();
              // don't let anyone else handle the event
              event.consume();
            }
          }
        });
    add(new JScrollPane(table), BorderLayout.CENTER);
    table.setPreferredScrollableViewportSize(new Dimension(250, 200));
  }
Ejemplo n.º 9
0
  /**
   * Constructor
   *
   * @param compactLayout if false, there will be message type selectors in the panel
   */
  public ChatServicePanel(boolean compactLayout) {
    super(new BorderLayout());

    // Prepare the title header
    titleHeader.setBackground(getBackground().darker());
    titleHeader.setOpaque(true);
    titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    titleHeader.setHorizontalAlignment(SwingConstants.CENTER);
    add(titleHeader, BorderLayout.NORTH);

    // Add messages panel
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    messagesPanel.setOpaque(false);
    messagesPanel.setLayout(new GridBagLayout());
    messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(scrollPane, BorderLayout.CENTER);

    JPanel sendPanel = new JPanel(new GridBagLayout());
    add(sendPanel, BorderLayout.SOUTH);
    Insets insets = new Insets(2, 2, 2, 2);

    // Add text area
    if (compactLayout) {
      messageText = new JTextField();
      ((JTextField) messageText).addActionListener(this);
      sendPanel.add(
          messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));

    } else {
      messageText = new JTextArea();
      JScrollPane scrollPane2 = new JScrollPane(messageText);
      scrollPane2.setPreferredSize(new Dimension(100, 50));
      scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
      scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
      sendPanel.add(
          scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    }

    // Add buttons
    ButtonGroup group = new ButtonGroup();
    messageTypeBtn = createMessageTypeButton("Send messages", ICON_MESSAGE, true, group);
    warningTypeBtn = createMessageTypeButton("Send warnings", ICON_WARNING, false, group);
    alertTypeBtn = createMessageTypeButton("Send alerts", ICON_ALERT, false, group);

    if (!compactLayout) {
      JToolBar msgTypePanel = new JToolBar();
      msgTypePanel.setBorderPainted(false);
      msgTypePanel.setOpaque(true);
      msgTypePanel.setFloatable(false);
      sendPanel.add(
          msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
      msgTypePanel.add(messageTypeBtn);
      msgTypePanel.add(warningTypeBtn);
      msgTypePanel.add(alertTypeBtn);
    }

    if (compactLayout) {
      sendBtn = new JButton("Send");
      sendPanel.add(
          sendBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    } else {
      sendBtn = new JButton("Send", ICON_MESSAGE);
      sendBtn.setPreferredSize(new Dimension(100, sendBtn.getPreferredSize().height));
      sendPanel.add(
          sendBtn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    }
    sendBtn.setEnabled(false);
    messageText.setEditable(false);
    sendBtn.addActionListener(this);
  }