Example usage for com.jgoodies.looks Options HEADER_STYLE_KEY

List of usage examples for com.jgoodies.looks Options HEADER_STYLE_KEY

Introduction

In this page you can find the example usage for com.jgoodies.looks Options HEADER_STYLE_KEY.

Prototype

String HEADER_STYLE_KEY

To view the source code for com.jgoodies.looks Options HEADER_STYLE_KEY.

Click Source Link

Document

A client property key for JMenuBar and JToolBar style hints.

Usage

From source file:ro.nextreports.designer.querybuilder.SQLViewPanel.java

License:Apache License

private void initUI() {
    sqlEditor = new Editor() {
        public void afterCaretMove() {
            removeHighlightErrorLine();/*from   w w w.  j  a  va  2  s. com*/
        }
    };
    this.queryArea = sqlEditor.getEditorPanel().getEditorPane();
    queryArea.setText(DEFAULT_QUERY);

    errorPainter = new javax.swing.text.Highlighter.HighlightPainter() {
        @Override
        public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) {
            try {
                Rectangle r = c.modelToView(c.getCaretPosition());
                g.setColor(Color.RED.brighter().brighter());
                g.fillRect(0, r.y, c.getWidth(), r.height);
            } catch (BadLocationException e) {
                // ignore
            }
        }
    };

    ActionMap actionMap = sqlEditor.getEditorPanel().getEditorPane().getActionMap();

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

    // add cut action
    Action cutAction = actionMap.get(BaseEditorKit.cutAction);
    cutAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("cut"));
    cutAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.cut"));
    toolBar.add(cutAction);

    // add copy action
    Action copyAction = actionMap.get(BaseEditorKit.copyAction);
    copyAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("copy"));
    copyAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.copy"));
    toolBar.add(copyAction);

    // add paste action
    Action pasteAction = actionMap.get(BaseEditorKit.pasteAction);
    pasteAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("paste"));
    pasteAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.paste"));
    toolBar.add(pasteAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar);

    // add undo action
    Action undoAction = actionMap.get(BaseEditorKit.undoAction);
    undoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("undo"));
    undoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("undo"));
    toolBar.add(undoAction);

    // add redo action
    Action redoAction = actionMap.get(BaseEditorKit.redoAction);
    redoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("redo"));
    redoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("redo"));
    toolBar.add(redoAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar);

    // add find action
    Action findReplaceAction = actionMap.get(BaseEditorKit.findReplaceAction);
    findReplaceAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("find"));
    findReplaceAction.putValue(Action.SHORT_DESCRIPTION,
            I18NSupport.getString("sqleditor.findReplaceActionName"));
    toolBar.add(findReplaceAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar);

    // add run action
    runAction = new SQLRunAction();
    runAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run"));
    runAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4")));
    runAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " ("
            + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")");
    // runAction is globally registered in QueryBuilderPanel !
    toolBar.add(runAction);

    //        ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(buttonsPanel);

    // create the table
    resultTable = new JXTable();
    resultTable.setDefaultRenderer(Integer.class, new ToStringRenderer()); // to remove thousand separators
    resultTable.setDefaultRenderer(Long.class, new ToStringRenderer());
    resultTable.setDefaultRenderer(Date.class, new DateRenderer());
    resultTable.setDefaultRenderer(Double.class, new DoubleRenderer());
    resultTable.addMouseListener(new CopyTableMouseAdapter(resultTable));
    TableUtil.setRowHeader(resultTable);
    resultTable.setColumnControlVisible(true);
    //        resultTable.getTableHeader().setReorderingAllowed(false);
    resultTable.setHorizontalScrollEnabled(true);

    // highlight table
    Highlighter alternateHighlighter = HighlighterFactory.createAlternateStriping(Color.WHITE,
            ColorUtil.PANEL_BACKROUND_COLOR);
    Highlighter nullHighlighter = new TextHighlighter(ResultSetTableModel.NULL_VALUE, Color.YELLOW.brighter());
    Highlighter blobHighlighter = new TextHighlighter(ResultSetTableModel.BLOB_VALUE, Color.GRAY.brighter());
    Highlighter clobHighlighter = new TextHighlighter(ResultSetTableModel.CLOB_VALUE, Color.GRAY.brighter());
    resultTable.setHighlighters(alternateHighlighter, nullHighlighter, blobHighlighter, clobHighlighter);
    resultTable.setBackground(ColorUtil.PANEL_BACKROUND_COLOR);
    resultTable.setGridColor(Color.LIGHT_GRAY);

    resultTable.setRolloverEnabled(true);
    resultTable.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED));

    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setResizeWeight(0.66);
    split.setOneTouchExpandable(true);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridBagLayout());
    topPanel.add(toolBar, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    topPanel.add(sqlEditor, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridBagLayout());
    JScrollPane scrPanel = new JScrollPane(resultTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    statusPanel = new SQLStatusPanel();
    bottomPanel.add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    bottomPanel.add(statusPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

    split.setTopComponent(topPanel);
    split.setBottomComponent(bottomPanel);
    split.setDividerLocation(400);

    setLayout(new BorderLayout());
    this.add(split, BorderLayout.CENTER);
}

From source file:ro.nextreports.designer.ReportLayoutPanel.java

License:Apache License

private JToolBar createToolBar() {
    JToolBar toolBar = new JToolBar();
    toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders
    toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    toolBar.setBorderPainted(false);//from ww w.j  a  va 2  s.com

    Action widthAction = new AbstractAction() {
        public void actionPerformed(ActionEvent event) {

            if (!widthButton.isSelected()) {
                int option = JOptionPane.showConfirmDialog(Globals.getMainFrame(),
                        I18NSupport.getString("width.action.loose"), "", JOptionPane.YES_NO_OPTION);
                if (option != JOptionPane.YES_OPTION) {
                    widthButton.setSelected(true);
                    return;
                }
            }

            LayoutHelper.getReportLayout().setUseSize(widthButton.isSelected());
            // repaint headers to show/hide ruler
            reportGridPanel.repaintHeaders();
            ReportLayoutUtil.updateColumnWidth(Globals.getReportGrid());

            if (!widthButton.isSelected()) {
                Globals.getReportDesignerPanel().refresh();
            }

        }
    };
    widthAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("width"));
    widthAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("width.action"));
    widthButton = new JToggleButton(widthAction);
    toolBar.add(widthButton);

    SwingUtil.addCustomSeparator(toolBar);

    toolBar.add(new FormatPickerAction());
    toolBar.add(new FormatPainterAction());
    toolBar.add(new ApplyTemplateAction(true));
    toolBar.add(new ExtractTemplateAction());

    SwingUtil.addCustomSeparator(toolBar);

    toolBar.add(Globals.getReportUndoManager().getUndoAction());
    toolBar.add(Globals.getReportUndoManager().getRedoAction());

    SwingUtil.addCustomSeparator(toolBar);

    JPanel previewPanel = new JPanel();
    previewPanel.setLayout(new BoxLayout(previewPanel, BoxLayout.X_AXIS));
    previewPanel.setOpaque(false);
    maxRecordsCheckBox = new JCheckBox(I18NSupport.getString("max.records"));
    maxRecordsCheckBox.setOpaque(false);
    maxRecordsCheckBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                maxRecordsTextField.setEditable(true);
            } else {
                maxRecordsTextField.setEditable(false);
            }
        }

    });
    previewPanel.add(maxRecordsCheckBox);
    previewPanel.add(Box.createHorizontalStrut(5));
    maxRecordsTextField = new IntegerTextField();
    maxRecordsTextField.setText("10");
    maxRecordsTextField.setEditable(false);
    maxRecordsTextField.setPreferredSize(dim);
    maxRecordsTextField.setMinimumSize(dim);
    maxRecordsTextField.setMaximumSize(dim);
    previewPanel.add(maxRecordsTextField);

    dataSourcesComboBox = new JComboBox();
    dataSourcesComboBox.setPreferredSize(comboDim);
    dataSourcesComboBox.setMinimumSize(comboDim);
    dataSourcesComboBox.setMaximumSize(comboDim);
    dataSourcesComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //must reset parameters values because for a different data source
            // we may have different values.
            RuntimeParametersPanel.resetParametersValues();
        }
    });

    previewPanel.add(Box.createHorizontalStrut(5));

    previewPanel.add(dataSourcesComboBox);
    previewPanel.add(Box.createHorizontalStrut(5));

    toolBar.add(previewPanel);

    DropDownButton dropDownButton = new DropDownButton();
    dropDownButton.getPopupMenu().add(new ExportToExcelAction(null));
    dropDownButton.getPopupMenu().add(new ExportToPdfAction(null));
    dropDownButton.getPopupMenu().add(new ExportToDocxAction(null));
    dropDownButton.getPopupMenu().add(new ExportToRtfAction(null));
    dropDownButton.getPopupMenu().add(new ExportToCsvAction(null));
    dropDownButton.getPopupMenu().add(new ExportToTsvAction(null));
    dropDownButton.getPopupMenu().add(new ExportToXmlAction(null));
    dropDownButton.getPopupMenu().add(new ExportToTxtAction(null));
    dropDownButton.setAction(new ExportToHtmlAction(null));
    dropDownButton.addToToolBar(toolBar);

    JSpinner zoomSpinner = new JSpinner(spinnerModel);
    zoomSpinner.setPreferredSize(spinnerDim);
    zoomSpinner.setMinimumSize(spinnerDim);
    zoomSpinner.setMaximumSize(spinnerDim);
    zoomSpinner.addChangeListener(this);

    JPanel zPanel = new JPanel();
    zPanel.setLayout(new BoxLayout(zPanel, BoxLayout.X_AXIS));
    zPanel.setOpaque(false);
    zPanel.add(Box.createHorizontalGlue());
    zPanel.add(new JLabel(I18NSupport.getString("zoom")));
    zPanel.add(Box.createHorizontalStrut(2));
    zPanel.add(zoomSpinner);
    zPanel.add(Box.createHorizontalStrut(2));
    zPanel.add(new JLabel("%"));
    zPanel.add(Box.createHorizontalStrut(5));
    toolBar.add(zPanel);

    return toolBar;
}

From source file:ro.nextreports.designer.StructurePanel.java

License:Apache License

private void initComponents() {
    setLayout(new BorderLayout());

    rootNode = new StructureTreeNode();
    rootNode.add(new StructureTreeNode(new Band(ReportLayout.HEADER_BAND_NAME)));
    rootNode.add(new StructureTreeNode(new Band(ReportLayout.DETAIL_BAND_NAME)));
    rootNode.add(new StructureTreeNode(new Band(ReportLayout.FOOTER_BAND_NAME)));
    structureTreeModel = new StructureTreeModel(rootNode);

    structureTree = new JXTree(structureTreeModel);
    structureTree.setShowsRootHandles(true);
    structureTree.setCellRenderer(new StructureTreeCellRenderer());
    structureTree.setRolloverEnabled(true);
    structureTree.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED));

    createPopup();/*  ww  w  .j  a v a  2  s .c o m*/

    // by default do not show empty cells
    Action showEmptyAction = new AbstractAction() {

        public void actionPerformed(ActionEvent event) {
            TreePath lastPath = structureTree.getSelectionPath();
            structureTreeModel.activateFilter(!showEmptyButton.isSelected());
            structureTreeModel.reload();
            if (lastPath != null) {
                structureTree.expandPath(lastPath.getParentPath());
                structureTree.setSelectionPath(lastPath);
            }
        }

    };
    showEmptyAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("empty_cell"));
    showEmptyAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("report.structure.show.empty"));
    showEmptyButton = new JToggleButton(showEmptyAction);
    structureTreeModel.activateFilter(true);

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

    // add expand action
    toolBar.add(new AbstractAction() {

        public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
                return ImageUtil.getImageIcon("expandall");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
                return I18NSupport.getString("querybuilder.expand.all");
            }

            return super.getValue(key);
        }

        public void actionPerformed(ActionEvent e) {
            TreeUtil.expandAll(structureTree);
        }

    });

    // add collapse action
    toolBar.add(new AbstractAction() {

        public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
                return ImageUtil.getImageIcon("collapseall");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
                return I18NSupport.getString("querybuilder.collapse.all");
            }

            return super.getValue(key);
        }

        public void actionPerformed(ActionEvent e) {
            TreeUtil.collapseAll(structureTree);
        }

    });

    toolBar.add(showEmptyButton);

    add(toolBar, BorderLayout.NORTH);
    add(new JScrollPane(structureTree), BorderLayout.CENTER);
}

From source file:ro.nextreports.designer.wizrep.SelectAlarmSettingsWizardPanel.java

License:Apache License

private void init() {
    setLayout(new GridBagLayout());

    shadow = new JCheckBox(I18NSupport.getString("wizard.panel.display.shadow"));

    panel = new FormattingConditionsPanel(null, I18NSupport.getString("wizard.panel.alarm.conditions.name"));

    model = new DefaultListModel();
    list = new JList();
    list.setModel(model);// w  w w . j ava 2  s.c  om
    JScrollPane scrollPane = new JScrollPane(list);
    scrollPane.setPreferredSize(dim);

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

    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("wizard.panel.alarm.message.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("edit");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
                return I18NSupport.getString("wizard.panel.alarm.message.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("wizard.panel.alarm.message.delete");
            }

            return super.getValue(key);
        }

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

    });

    toolBar.add(new JLabel(I18NSupport.getString("wizard.panel.alarm.messages.name")));

    JLabel imageLabel = new JLabel(ImageUtil.getImageIcon("alarm_main"));
    imageLabel.setPreferredSize(new Dimension(300, 80));

    add(panel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5), 0, 0));
    add(toolBar, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
    add(scrollPane, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
    add(shadow, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5), 0, 0));
    add(imageLabel, new GridBagConstraints(1, 0, 1, 4, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
}

From source file:xapps.browser.gsea.GseaFijiTabsApplicationFrame.java

License:Open Source License

/**
 * @return//w w  w. j  ava  2  s  .co  m
 * @note Placing this here rather in ActionFactory as a developing aid
 * - > quicker launch of XReg isnt initialized at startup
 * The applications menu bar is defined here.
 * @maint if new actions are added -> need to review to see if they should also
 * be added to the menu bar.
 */

private JMenuBar createMenuBar() {

    JMenuBar menuBar = new JMenuBar();

    // @note JGOODIES SUGGESTIONS
    menuBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.SINGLE);

    if (!SystemUtils.IS_OS_MAC_OSX) {
        menuBar.add(createJMenu("File", new Object[] { new MyExitAction() }));
    }

    menuBar.add(createJMenu("Help", new Object[] {
            new GseaHelpAction("GSEA web site", "Open the GSEA website in a web browser",
                    GseaWebResources.getGseaBaseURL()),
            new GseaHelpAction(),
            new BrowserAction("GSEA & MSigDB License Terms", "GSEA & MSigDB License Terms",
                    GuiHelper.ICON_HELP16, GseaWebResources.getGseaBaseURL() + "/" + "license_terms_list.jsp"),
            null, new ShowAppRuntimeHomeDirAction("Show GSEA home folder"),
            new ShowDefaultOutputDirAction("Show GSEA output folder (default location)"), null,
            new ContactAction(), null, formatBuildInfoForHelp(), formatBuildTimestampForHelp() }));

    return menuBar;
}