public RolloverTitlePane(CollapsiblePane pane) {
    _layout = new CardLayout();

    setLayout(_layout);
    _messageLabel = new JLabel("");
    _messageLabel.setForeground(null);
    _messageLabel.setHorizontalAlignment(SwingConstants.TRAILING);
    add(_messageLabel, "Message");
    _buttonPanel = new NullPanel();
    _buttonPanel.setLayout(new JideBoxLayout(_buttonPanel, JideBoxLayout.X_AXIS));
    _buttonPanel.add(Box.createGlue(), JideBoxLayout.VARY);
    add(_buttonPanel, "Buttons");
    pane.addPropertyChangeListener(
        "rollover",
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            if (Boolean.TRUE.equals(evt.getNewValue())) {
              showButtons();
            } else {
              showMessage();
            }
          }
        });
    JideSwingUtilities.setOpaqueRecursively(this, false);
  }
  public static void main(String[] args) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      LookAndFeelFactory.installJideExtension();
    } catch (ClassNotFoundException e) {
    } catch (InstantiationException e) {
    } catch (IllegalAccessException e) {
    } catch (UnsupportedLookAndFeelException e) {
    }

    _frame = new JideButtonDemo("Demo of JideButton");
    _frame.setIconImage(JideIconsFactory.getImageIcon(JideIconsFactory.JIDE32).getImage());
    _frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel(new GridLayout(6, 1));
    _buttons = new JideButton[6];
    _buttons[0] =
        createHyperlinkButton(
            "Rename this file",
            ButtonsIconsFactory.getImageIcon(ButtonsIconsFactory.Buttons.RENAME));
    _buttons[1] =
        createHyperlinkButton(
            "Move this file", ButtonsIconsFactory.getImageIcon(ButtonsIconsFactory.Buttons.MOVE));
    _buttons[2] =
        createHyperlinkButton(
            "Copy this file", ButtonsIconsFactory.getImageIcon(ButtonsIconsFactory.Buttons.COPY));
    _buttons[3] =
        createHyperlinkButton(
            "Publish this file",
            ButtonsIconsFactory.getImageIcon(ButtonsIconsFactory.Buttons.PUBLISH));
    _buttons[4] =
        createHyperlinkButton(
            "Email this file", ButtonsIconsFactory.getImageIcon(ButtonsIconsFactory.Buttons.EMAIL));
    _buttons[5] =
        createHyperlinkButton(
            "Delete this file",
            ButtonsIconsFactory.getImageIcon(ButtonsIconsFactory.Buttons.DELET));
    for (int i = 0; i < _buttons.length; i++) {
      JideButton button = _buttons[i];
      panel.add(button);
    }

    panel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
    _frame.getContentPane().setLayout(new BorderLayout());
    _frame.getContentPane().add(createOptionsPanel(), BorderLayout.AFTER_LINE_ENDS);
    JPanel topPanel = JideSwingUtilities.createTopPanel(panel);
    topPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    _frame.getContentPane().add(topPanel, BorderLayout.CENTER);

    _frame.setBounds(10, 10, 300, 500);

    _frame.setVisible(true);
  }
示例#3
0
  private boolean doLocalTransfer(Transferable t, int action) {
    if (HermesBrowser.getBrowser().isRestrictedWithWarning()) {
      return false;
    }

    try {

      if (t.isDataFlavorSupported(JMSMessagesTransferable.FLAVOR)) {
        return doMessagesTransfer(
            (MessageGroup) t.getTransferData(JMSMessagesTransferable.FLAVOR), action);
      }

      if (t.isDataFlavorSupported(JMSAdministeredObjectTransferable.FLAVOR)) {
        return doContextContentTransfer(
            (HermesConfigGroup) t.getTransferData(JMSAdministeredObjectTransferable.FLAVOR));
      }

      if (t.isDataFlavorSupported(MessagesTransferable.BYTE_FLAVOR)) {

        return doBytesMessageTransfer(
            (Collection<byte[]>) t.getTransferData(MessagesTransferable.BYTE_FLAVOR));
      }
      if (t.isDataFlavorSupported(HermesAdministeredObjectTransferable.FLAVOR)) {
        if (getSelectionPath().getLastPathComponent() instanceof NamingConfigTreeNode) {
          final NamingConfigTreeNode namingConfigTreeNode =
              (NamingConfigTreeNode) getSelectionPath().getLastPathComponent();
          final Collection objects =
              (Collection) t.getTransferData(HermesAdministeredObjectTransferable.FLAVOR);
          final JNDIContextFactory contextFactory =
              new JNDIContextFactory(namingConfigTreeNode.getConfig());
          final BindToolDialog bindTool =
              new BindToolDialog(HermesBrowser.getBrowser(), contextFactory, "", objects);

          bindTool.pack();
          JideSwingUtilities.centerWindow(bindTool);
          bindTool.show();

          return true;
        }
      }
    } catch (Exception ex) {
      log.error(ex.getMessage(), ex);
      JOptionPane.showMessageDialog(
          this, "During transfer: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }

    return false;
  }
示例#4
0
 protected void paintBackground(Graphics g, Gripper b) {
   Rectangle rect = new Rectangle(0, 0, b.getWidth(), b.getHeight());
   if (b.isRollover()) {
     getPainter().paintButtonBackground(b, g, rect, 0, ThemePainter.STATE_ROLLOVER);
   } else {
     if (b.isOpaque()) {
       getPainter()
           .paintButtonBackground(
               b,
               g,
               rect,
               0,
               b.isSelected() ? ThemePainter.STATE_SELECTED : ThemePainter.STATE_DEFAULT,
               false);
       if ("true".equals(SecurityUtils.getProperty("shadingtheme", "false"))) {
         JideSwingUtilities.fillGradient(g, rect, SwingConstants.HORIZONTAL);
       }
     }
   }
 }
  protected void customizeDemoPanel(
      final JTable table, final TableModel tableModel, final JPanel demoPanel) {
    final QuickTableFilterField field =
        new QuickTableFilterField(tableModel) {
          @Override
          public Filter getFilter() {
            String s = getSearchingText();
            if (s != null && s.length() > 0) {
              if (isWildcardEnabled()) {
                s = s.replace("*", "%");
                s = s.replace(".", "_");
              }
              StringBuffer pattern = new StringBuffer();
              if (isFromStart()) {
                pattern.append(s).append("%");
              } else {
                pattern.append("%").append(s).append("%");
              }
              LikeFilter likeFilter = new LikeFilter(pattern.toString());
              likeFilter.setCaseSensitive(isCaseSensitive());
              return likeFilter;
            } else {
              return null;
            }
          }

          @Override
          protected IFilterableTableModel createFilterableTableModel(TableModel tableModel) {
            if (tableModel instanceof IFilterableTableModel) {
              return (IFilterableTableModel) tableModel;
            } else {
              return super.createFilterableTableModel(tableModel);
            }
          }
        };

    final FilterableTableModel filterableTableModel =
        new FilterableTableModel(field.getDisplayTableModel());
    int floatColumnIndex = -1;
    for (int i = 0; i < filterableTableModel.getColumnCount(); i++) {
      if (filterableTableModel.getColumnClass(i) == Float.class) {
        floatColumnIndex = i;
        break;
      }
    }
    final int filterColumnIndex = floatColumnIndex == -1 ? 3 : floatColumnIndex;
    JCheckBox addFilterCheckBox1 = new JCheckBox("Using local filtering");
    final JLabel filterMessage1 = new JLabel();
    addFilterCheckBox1.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              //                        filterableTableModel.addFilter(1, new LikeFilter("%Meat%"));
              //                        filterableTableModel.addFilter(filterColumnIndex, new
              // GreaterThanFilter(1000f));
              //                        filterableTableModel.addFilter(filterColumnIndex, new
              // BetweenFilter(20f, 60f));
              filterableTableModel.addFilter(
                  filterColumnIndex, new InFilter(new Object[] {45f, 46f, 77f}));
            } else {
              filterableTableModel.clearFilters();
            }
            long start = System.nanoTime();
            filterableTableModel.setFiltersApplied(true);
            long end = System.nanoTime();
            filterMessage1.setText("Taking " + (end - start) / 1000000 + " ms");
          }
        });
    JCheckBox addFilterCheckBox2 = new JCheckBox("Using the database filtering feature");
    final JLabel filterMessage2 = new JLabel();
    addFilterCheckBox2.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (tableModel instanceof IFilterableTableModel) {
              if (e.getStateChange() == ItemEvent.SELECTED) {
                //                        tableModel.addFilter(1, new LikeFilter("Meat"));
                //                        tableModel.addFilter(filterColumnIndex, new
                // GreaterThanFilter(1000f));
                //                        tableModel.addFilter(filterColumnIndex, new
                // BetweenFilter(20f, 60f));
                ((IFilterableTableModel) tableModel)
                    .addFilter(filterColumnIndex, new InFilter(new Object[] {45f, 46f, 77f}));
              } else {
                ((IFilterableTableModel) tableModel).clearFilters();
              }
              long start = System.nanoTime();
              ((IFilterableTableModel) tableModel).setFiltersApplied(true);
              long end = System.nanoTime();
              filterMessage2.setText("Taking " + (end - start) / 1000000 + " ms");
            }
          }
        });

    JPanel checkBoxPanel = new JPanel(new GridLayout(2, 2, 0, 0));
    checkBoxPanel.add(addFilterCheckBox1);
    checkBoxPanel.add(addFilterCheckBox2);
    checkBoxPanel.add(filterMessage1);
    checkBoxPanel.add(filterMessage2);

    demoPanel.add(checkBoxPanel, BorderLayout.BEFORE_FIRST_LINE);

    table.setModel(filterableTableModel);
    demoPanel.add(
        JideSwingUtilities.createLabeledComponent(
            new JLabel("QuickTableFilterField (use SQL LIKE):"),
            field,
            BorderLayout.BEFORE_LINE_BEGINS),
        BorderLayout.AFTER_LAST_LINE);
    demoPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Demo for DatabaseTableModel"),
            BorderFactory.createEmptyBorder(5, 10, 5, 10)));
  }
  @Override
  public Component getOptionsPanel() {
    JPanel panel = new JPanel(new GridLayout(0, 1, 4, 4));
    final JCheckBox hideOriginalTableHeader = new JCheckBox("Hide the original table header");
    hideOriginalTableHeader.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            JTableHeader header = _table.getTableHeader();
            if (header instanceof NestedTableHeader) {
              ((NestedTableHeader) header)
                  .setOriginalTableHeaderVisible(!hideOriginalTableHeader.isSelected());
            }
          }
        });
    panel.add(hideOriginalTableHeader);

    final JCheckBox autoStartCellEditing = new JCheckBox("Auto-start editing when TAB or ENTER");
    autoStartCellEditing.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            _table.setAutoStartCellEditing(autoStartCellEditing.isSelected());
          }
        });
    autoStartCellEditing.setSelected(_table.isAutoStartCellEditing());
    panel.add(autoStartCellEditing);

    final JCheckBox autoSelectTextWhenStartsEditing =
        new JCheckBox("Auto-select the cell text when editing");
    autoSelectTextWhenStartsEditing.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            _table.setAutoSelectTextWhenStartsEditing(autoSelectTextWhenStartsEditing.isSelected());
          }
        });
    autoSelectTextWhenStartsEditing.setSelected(_table.isAutoSelectTextWhenStartsEditing());
    panel.add(autoSelectTextWhenStartsEditing);

    final JCheckBox enable = new JCheckBox("Enable Table");
    enable.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            _table.setEnabled(enable.isSelected());
          }
        });
    enable.setSelected(_table.isEnabled());
    panel.add(enable);

    JCheckBox columnAutoResizable = new JCheckBox("Column Auto Resizable");
    columnAutoResizable.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            boolean selected = e.getStateChange() == ItemEvent.SELECTED;
            _table.setColumnAutoResizable(selected);
            _table.setAutoResizeMode(
                selected ? JTable.AUTO_RESIZE_OFF : JTable.AUTO_RESIZE_ALL_COLUMNS);
          }
        });
    columnAutoResizable.setSelected(_table.isColumnAutoResizable());
    panel.add(columnAutoResizable);

    JComboBox autoCompletionModeComboBox =
        new JComboBox(
            new Object[] {
              "Disabled", "Cells in the same column", "Cells in the same row", "All cells"
            });
    autoCompletionModeComboBox.setSelectedIndex(_table.getEditorAutoCompletionMode());
    autoCompletionModeComboBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              _table.setEditorAutoCompletionMode(((JComboBox) e.getSource()).getSelectedIndex());
            }
          }
        });
    panel.add(
        JideSwingUtilities.createLabeledComponent(
            new JLabel("AutoCompletion Mode: "),
            autoCompletionModeComboBox,
            BorderLayout.BEFORE_LINE_BEGINS));

    return panel;
  }