Search in sources :

Example 1 with BasicArrowButton

use of javax.swing.plaf.basic.BasicArrowButton in project intellij-community by JetBrains.

the class DarculaComboBoxUI method createArrowButton.

protected JButton createArrowButton() {
    final Color bg = myComboBox.getBackground();
    final Color fg = myComboBox.getForeground();
    JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) {

        @Override
        public void paint(Graphics g2) {
            final Graphics2D g = (Graphics2D) g2;
            final GraphicsConfig config = new GraphicsConfig(g);
            final int w = getWidth();
            final int h = getHeight();
            if (!isTableCellEditor(myComboBox)) {
                g.setColor(getArrowButtonFillColor(UIUtil.getControlColor()));
                g.fillRect(0, 0, w, h);
            }
            g.setColor(new JBColor(Gray._255, comboBox.isEnabled() ? getForeground() : getBorderColor()));
            config.setupRoundedBorderAntialiasing();
            final int tW = JBUI.scale(8);
            final int tH = JBUI.scale(6);
            final int xU = (w - tW) / 2;
            final int yU = (h - tH) / 2;
            g.translate(JBUI.scale(2), JBUI.scale(1));
            final Path2D.Double path = new Path2D.Double();
            path.moveTo(xU, yU);
            path.lineTo(xU + tW, yU);
            path.lineTo(xU + tW / 2, yU + tH);
            path.lineTo(xU, yU);
            //path.moveTo(xU + 1, yU + 2);
            //path.lineTo(3 * xU + 1, yU + 2);
            //path.lineTo(2 * xU + 1, 3 * yU);
            //path.lineTo(xU + 1, yU + 2);
            path.closePath();
            g.fill(path);
            g.translate(-JBUI.scale(2), -JBUI.scale(1));
            if (!isTableCellEditor(myComboBox)) {
                g.setColor(getArrowButtonFillColor(getBorderColor()));
                g.drawLine(0, -1, 0, h);
            }
            config.restore();
        }

        @Override
        public Dimension getPreferredSize() {
            int size = getFont().getSize() + 4;
            if (size % 2 == 1)
                size++;
            return new DimensionUIResource(size, size);
        }
    };
    button.setBorder(BorderFactory.createEmptyBorder());
    button.setOpaque(false);
    return button;
}
Also used : BasicArrowButton(javax.swing.plaf.basic.BasicArrowButton) JBColor(com.intellij.ui.JBColor) Path2D(java.awt.geom.Path2D) JBColor(com.intellij.ui.JBColor) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig) DimensionUIResource(javax.swing.plaf.DimensionUIResource)

Example 2 with BasicArrowButton

use of javax.swing.plaf.basic.BasicArrowButton in project intellij-community by JetBrains.

the class DarculaSpinnerUI method createArrow.

private JButton createArrow(@MagicConstant(intValues = { SwingConstants.NORTH, SwingConstants.SOUTH }) int direction) {
    final Color shadow = UIUtil.getPanelBackground();
    final Color enabledColor = new JBColor(Gray._255, UIUtil.getLabelForeground());
    final Color disabledColor = new JBColor(Gray._200, UIUtil.getLabelForeground().darker());
    BasicArrowButton b = new BasicArrowButton(direction, shadow, shadow, enabledColor, shadow) {

        @Override
        public void paint(Graphics g) {
            paintArrowButton(g, this, direction);
        }

        @Override
        public boolean isOpaque() {
            return false;
        }

        @Override
        public void paintTriangle(Graphics g, int x, int y, int size, int direction, boolean isEnabled) {
            final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
            int mid;
            final int w = 8;
            final int h = 6;
            mid = w / 2;
            g.setColor(isEnabled ? enabledColor : disabledColor);
            g.translate(x, y);
            switch(direction) {
                case SOUTH:
                    g.fillPolygon(new int[] { 0, w, mid }, new int[] { 1, 1, h }, 3);
                    break;
                case NORTH:
                    g.fillPolygon(new int[] { 0, w, mid }, new int[] { h - 1, h - 1, 0 }, 3);
                    break;
                case WEST:
                case EAST:
            }
            g.translate(-x, -y);
            config.restore();
        }
    };
    Border buttonBorder = UIManager.getBorder("Spinner.arrowButtonBorder");
    if (buttonBorder instanceof UIResource) {
        // Wrap the border to avoid having the UIResource be replaced by
        // the ButtonUI. This is the opposite of using BorderUIResource.
        b.setBorder(new CompoundBorder(buttonBorder, null));
    } else {
        b.setBorder(buttonBorder);
    }
    b.setInheritsPopupMenu(true);
    return b;
}
Also used : BasicArrowButton(javax.swing.plaf.basic.BasicArrowButton) JBColor(com.intellij.ui.JBColor) JBColor(com.intellij.ui.JBColor) CompoundBorder(javax.swing.border.CompoundBorder) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig) Border(javax.swing.border.Border) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) UIResource(javax.swing.plaf.UIResource)

Example 3 with BasicArrowButton

use of javax.swing.plaf.basic.BasicArrowButton in project java-swing-tips by aterai.

the class NoPopupComboBoxUI method createArrowButton.

private static JButton createArrowButton(int direction) {
    return new BasicArrowButton(direction) {

        @Override
        public void updateUI() {
            super.updateUI();
            Border buttonBorder = UIManager.getBorder("Spinner.arrowButtonBorder");
            if (buttonBorder instanceof UIResource) {
                // Wrap the border to avoid having the UIResource be replaced by
                // the ButtonUI. This is the opposite of using BorderUIResource.
                setBorder(new CompoundBorder(buttonBorder, null));
            } else {
                setBorder(buttonBorder);
            }
            setInheritsPopupMenu(true);
        }
    };
}
Also used : BasicArrowButton(javax.swing.plaf.basic.BasicArrowButton) CompoundBorder(javax.swing.border.CompoundBorder) CompoundBorder(javax.swing.border.CompoundBorder) Border(javax.swing.border.Border) UIResource(javax.swing.plaf.UIResource)

Example 4 with BasicArrowButton

use of javax.swing.plaf.basic.BasicArrowButton in project mondrian by pentaho.

the class SchemaExplorer method initComponents.

/**
 * Called from within the constructor to initialize the form.
 */
private void initComponents() {
    jPanelXML = new JPanel();
    jScrollPaneXML = new JScrollPane();
    footer = new JPanel();
    databaseLabel = new javax.swing.JLabel();
    jSeparator1 = new JSeparator();
    jSeparator2 = new JSeparator();
    jSplitPane1 = new JSplitPane();
    jPanel1 = new JPanel();
    jScrollPane2 = new JScrollPane();
    // propertyTable includes changeSelection and processKeyEvent
    // processing for keyboard navigation
    propertyTable = new JTable() {

        public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
            if (columnIndex == 0) {
                AWTEvent currentEvent = EventQueue.getCurrentEvent();
                if (currentEvent instanceof KeyEvent) {
                    KeyEvent ke = (KeyEvent) currentEvent;
                    int kcode = ke.getKeyCode();
                    if (kcode == KeyEvent.VK_TAB) {
                        if ((ke.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK) {
                            rowIndex -= 1;
                            if (rowIndex < 0) {
                                rowIndex = propertyTable.getRowCount() - 1;
                            }
                        }
                        setTableCellFocus(rowIndex);
                        return;
                    }
                }
            }
            super.changeSelection(rowIndex, columnIndex, toggle, extend);
        }

        public void processKeyEvent(KeyEvent e) {
            int kcode = e.getKeyCode();
            if (kcode == KeyEvent.VK_UP || kcode == KeyEvent.VK_DOWN) {
                int row = propertyTable.getSelectedRow();
                setTableCellFocus(row);
                return;
            }
            super.processKeyEvent(e);
        }
    };
    targetLabel = new javax.swing.JLabel();
    validStatusLabel = new javax.swing.JLabel();
    targetLabel2 = new javax.swing.JLabel();
    validStatusLabel2 = new javax.swing.JLabel();
    jPanel2 = new JPanel();
    jScrollPane1 = new JScrollPane();
    tree = new JTree();
    tree.getSelectionModel().setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
    ToolTipManager.sharedInstance().registerComponent(tree);
    jToolBar1 = new JToolBar();
    addCubeButton = new JButton();
    addDimensionButton = new JButton();
    addDimensionUsageButton = new JButton();
    addHierarchyButton = new JButton();
    addNamedSetButton = new JButton();
    addUserDefinedFunctionButton = new JButton();
    addRoleButton = new JButton();
    addMeasureButton = new JButton();
    addCalculatedMemberButton = new JButton();
    addLevelButton = new JButton();
    addPropertyButton = new JButton();
    addCalculatedMemberPropertyButton = new JButton();
    addVirtualCubeButton = new JButton();
    addVirtualCubeDimensionButton = new JButton();
    addVirtualCubeMeasureButton = new JButton();
    cutButton = new JButton(new DefaultEditorKit.CutAction());
    copyButton = new JButton(new DefaultEditorKit.CopyAction());
    pasteButton = new JButton(new DefaultEditorKit.PasteAction());
    deleteButton = new JButton();
    editModeButton = new JToggleButton();
    setLayout(new BorderLayout());
    jSplitPane1.setDividerLocation(200);
    jPanel1.setLayout(new BorderLayout());
    propertyTable.setModel(new DefaultTableModel(new Object[][] {}, new String[] { getResourceConverter().getString("schemaExplorer.propertyTable.attribute", "Attribute"), getResourceConverter().getString("schemaExplorer.propertyTable.value", "Value") }) {

        Class[] types = { String.class, Object.class };

        boolean[] canEdit = { false, true };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });
    // Set property table column headers to bold.
    propertyTable.getTableHeader().setFont(new Font("Dialog", Font.BOLD, 12));
    jScrollPane2.setViewportView(propertyTable);
    jPanel1.add(jScrollPane2, java.awt.BorderLayout.CENTER);
    targetLabel.setFont(new Font("Dialog", 1, 14));
    targetLabel.setForeground((Color) UIManager.getDefaults().get("CheckBoxMenuItem.acceleratorForeground"));
    targetLabel.setHorizontalAlignment(SwingConstants.CENTER);
    targetLabel.setText(getResourceConverter().getString("schemaExplorer.targetLabel.title", "Schema"));
    targetLabel.setBorder(new EtchedBorder());
    // up arrow button for property table heading
    jPanel3 = new JPanel();
    jPanel3.setLayout(new BorderLayout());
    BasicArrowButton arrowButtonUp = new BasicArrowButton(SwingConstants.NORTH);
    BasicArrowButton arrowButtonDown = new BasicArrowButton(SwingConstants.SOUTH);
    arrowButtonUp.setToolTipText(getResourceConverter().getString("schemaExplorer.arrowButtonUp.toolTip", "move to parent element"));
    arrowButtonDown.setToolTipText(getResourceConverter().getString("schemaExplorer.arrowButtonDown.toolTip", "move to child element"));
    arrowButtonUpAction = new AbstractAction(getResourceConverter().getString("schemaExplorer.arrowButtonUp.title", "Arrow button up")) {

        public void actionPerformed(ActionEvent e) {
            arrowButtonUpAction(e);
        }
    };
    arrowButtonDownAction = new AbstractAction(getResourceConverter().getString("schemaExplorer.arrowButtonDown.title", "Arrow button down")) {

        public void actionPerformed(ActionEvent e) {
            arrowButtonDownAction(e);
        }
    };
    arrowButtonUp.addActionListener(arrowButtonUpAction);
    arrowButtonDown.addActionListener(arrowButtonDownAction);
    jPanel3.add(arrowButtonDown, java.awt.BorderLayout.EAST);
    jPanel3.add(arrowButtonUp, java.awt.BorderLayout.WEST);
    jPanel3.add(targetLabel, java.awt.BorderLayout.CENTER);
    jPanel1.add(jPanel3, java.awt.BorderLayout.NORTH);
    validStatusLabel.setFont(new Font("Dialog", Font.PLAIN, 12));
    validStatusLabel.setForeground(Color.RED);
    validStatusLabel.setHorizontalAlignment(SwingConstants.CENTER);
    jPanel1.add(validStatusLabel, java.awt.BorderLayout.SOUTH);
    // for XML viewing
    targetLabel2.setFont(new Font("Dialog", 1, 14));
    targetLabel2.setForeground((Color) UIManager.getDefaults().get("CheckBoxMenuItem.acceleratorForeground"));
    targetLabel2.setHorizontalAlignment(SwingConstants.CENTER);
    targetLabel2.setText(getResourceConverter().getString("schemaExplorer.targetLabel.title", "Schema"));
    targetLabel2.setBorder(new EtchedBorder());
    validStatusLabel2.setFont(new Font("Dialog", Font.PLAIN, 12));
    validStatusLabel2.setForeground(Color.RED);
    validStatusLabel2.setHorizontalAlignment(SwingConstants.CENTER);
    jSplitPane1.setRightComponent(jPanel1);
    jPanel2.setLayout(new java.awt.BorderLayout());
    jScrollPane1.setViewportView(tree);
    jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);
    jSplitPane1.setLeftComponent(jPanel2);
    // ========================================================
    // actions
    // ========================================================
    addCube = new AbstractAction(getResourceConverter().getString("schemaExplorer.addCube.title", "Add Cube")) {

        public void actionPerformed(ActionEvent e) {
            addCube(e);
        }
    };
    addParameter = new AbstractAction(getResourceConverter().getString("schemaExplorer.addParameter.title", "Add Parameter")) {

        public void actionPerformed(ActionEvent e) {
            addParameter(e);
        }
    };
    addDimension = new AbstractAction(getResourceConverter().getString("schemaExplorer.addDimension.title", "Add Dimension")) {

        public void actionPerformed(ActionEvent e) {
            addDimension(e);
        }
    };
    addDimensionUsage = new AbstractAction(getResourceConverter().getString("schemaExplorer.addDimensionUsage.title", "Add Dimension Usage")) {

        public void actionPerformed(ActionEvent e) {
            addDimensionUsage(e);
        }
    };
    addHierarchy = new AbstractAction(getResourceConverter().getString("schemaExplorer.addHierarchy.title", "Add Hierarchy")) {

        public void actionPerformed(ActionEvent e) {
            addHierarchy(e);
        }
    };
    addNamedSet = new AbstractAction(getResourceConverter().getString("schemaExplorer.addNamedSet.title", "Add Named Set")) {

        public void actionPerformed(ActionEvent e) {
            addNamedSet(e);
        }
    };
    addMeasure = new AbstractAction(getResourceConverter().getString("schemaExplorer.addMeasure.title", "Add Measure")) {

        public void actionPerformed(ActionEvent e) {
            addMeasure(e);
        }
    };
    addCalculatedMember = new AbstractAction(getResourceConverter().getString("schemaExplorer.addCalculatedMember.title", "Add Calculated Member")) {

        public void actionPerformed(ActionEvent e) {
            addCalculatedMember(e);
        }
    };
    addUserDefinedFunction = new AbstractAction(getResourceConverter().getString("schemaExplorer.addUserDefinedFunction.title", "Add User Defined Function")) {

        public void actionPerformed(ActionEvent e) {
            addUserDefinedFunction(e);
        }
    };
    addScript = new AbstractAction(getResourceConverter().getString("schemaExplorer.addScript.title", "Add Script")) {

        public void actionPerformed(ActionEvent e) {
            addScript(e);
        }
    };
    addCellFormatter = new AbstractAction(getResourceConverter().getString("schemaExplorer.addCellFormatter.title", "Add Cell Formatter")) {

        public void actionPerformed(ActionEvent e) {
            addCellFormatter(e);
        }
    };
    addPropertyFormatter = new AbstractAction(getResourceConverter().getString("schemaExplorer.addPropertyFormatter.title", "Add Property Formatter")) {

        public void actionPerformed(ActionEvent e) {
            addPropertyFormatter(e);
        }
    };
    addMemberFormatter = new AbstractAction(getResourceConverter().getString("schemaExplorer.addMemberFormatter.title", "Add Member Formatter")) {

        public void actionPerformed(ActionEvent e) {
            addMemberFormatter(e);
        }
    };
    addRole = new AbstractAction(getResourceConverter().getString("schemaExplorer.addRole.title", "Add Role")) {

        public void actionPerformed(ActionEvent e) {
            addRole(e);
        }
    };
    addSchemaGrant = new AbstractAction(getResourceConverter().getString("schemaExplorer.addSchemaGrant.title", "Add Schema Grant")) {

        public void actionPerformed(ActionEvent e) {
            addSchemaGrant(e);
        }
    };
    addCubeGrant = new AbstractAction(getResourceConverter().getString("schemaExplorer.addCubeGrant.title", "Add Cube Grant")) {

        public void actionPerformed(ActionEvent e) {
            addCubeGrant(e);
        }
    };
    addDimensionGrant = new AbstractAction(getResourceConverter().getString("schemaExplorer.addDimensionGrant.title", "Add Dimension Grant")) {

        public void actionPerformed(ActionEvent e) {
            addDimensionGrant(e);
        }
    };
    addHierarchyGrant = new AbstractAction(getResourceConverter().getString("schemaExplorer.addHierarchyGrant.title", "Add Hierarchy Grant")) {

        public void actionPerformed(ActionEvent e) {
            addHierarchyGrant(e);
        }
    };
    addMemberGrant = new AbstractAction(getResourceConverter().getString("schemaExplorer.addMemberGrant.title", "Add Member Grant")) {

        public void actionPerformed(ActionEvent e) {
            addMemberGrant(e);
        }
    };
    addAnnotations = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAnnotations.title", "Add Annotations")) {

        public void actionPerformed(ActionEvent e) {
            addAnnotations(e);
        }
    };
    addAnnotation = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAnnotation.title", "Add Annotation")) {

        public void actionPerformed(ActionEvent e) {
            addAnnotation(e);
        }
    };
    addLevel = new AbstractAction(getResourceConverter().getString("schemaExplorer.addLevel.title", "Add Level")) {

        public void actionPerformed(ActionEvent e) {
            addLevel(e);
        }
    };
    addClosure = new AbstractAction(getResourceConverter().getString("schemaExplorer.addClosure.title", "Add Closure")) {

        public void actionPerformed(ActionEvent e) {
            addClosure(e);
        }
    };
    addKeyExp = new AbstractAction(getResourceConverter().getString("schemaExplorer.addKeyExpression.title", "Add Key Expression")) {

        public void actionPerformed(ActionEvent e) {
            addKeyExp(e);
        }
    };
    addNameExp = new AbstractAction(getResourceConverter().getString("schemaExplorer.addNameExpression.title", "Add Name Expression")) {

        public void actionPerformed(ActionEvent e) {
            addNameExp(e);
        }
    };
    addOrdinalExp = new AbstractAction(getResourceConverter().getString("schemaExplorer.addOrdinalExpression.title", "Add Ordinal Expression")) {

        public void actionPerformed(ActionEvent e) {
            addOrdinalExp(e);
        }
    };
    addCaptionExp = new AbstractAction(getResourceConverter().getString("schemaExplorer.addCaptionExpression.title", "Add Caption Expression")) {

        public void actionPerformed(ActionEvent e) {
            addCaptionExp(e);
        }
    };
    addParentExp = new AbstractAction(getResourceConverter().getString("schemaExplorer.addParentExpression.title", "Add Parent Expression")) {

        public void actionPerformed(ActionEvent e) {
            addParentExp(e);
        }
    };
    addMeasureExp = new AbstractAction(getResourceConverter().getString("schemaExplorer.addMeasureExpression.title", "Add Measure Expression")) {

        public void actionPerformed(ActionEvent e) {
            addMeasureExp(e);
        }
    };
    addFormula = new AbstractAction(getResourceConverter().getString("schemaExplorer.addFormula.title", "Add Formula")) {

        public void actionPerformed(ActionEvent e) {
            addFormula(e);
        }
    };
    addSQL = new AbstractAction(getResourceConverter().getString("schemaExplorer.addSQL.title", "Add SQL")) {

        public void actionPerformed(ActionEvent e) {
            addSQL(e);
        }
    };
    addTable = new AbstractAction(getResourceConverter().getString("schemaExplorer.addTable.title", "Add Table")) {

        public void actionPerformed(ActionEvent e) {
            addTable(e);
        }
    };
    addJoin = new AbstractAction(getResourceConverter().getString("schemaExplorer.addJoin.title", "Add Join")) {

        public void actionPerformed(ActionEvent e) {
            addJoin(e);
        }
    };
    addView = new AbstractAction(getResourceConverter().getString("schemaExplorer.addView.title", "Add View")) {

        public void actionPerformed(ActionEvent e) {
            addView(e);
        }
    };
    addInlineTable = new AbstractAction(getResourceConverter().getString("schemaExplorer.addInlineTable.title", "Add Inline Table")) {

        public void actionPerformed(ActionEvent e) {
            addInlineTable(e);
        }
    };
    moveLevelUp = new AbstractAction(getResourceConverter().getString("schemaExplorer.moveLevelUp.title", "Move Up")) {

        public void actionPerformed(ActionEvent e) {
            moveLevelUp(e);
        }
    };
    moveLevelDown = new AbstractAction(getResourceConverter().getString("schemaExplorer.moveLevelDown.title", "Move Down")) {

        public void actionPerformed(ActionEvent e) {
            moveLevelDown(e);
        }
    };
    addProperty = new AbstractAction(getResourceConverter().getString("schemaExplorer.addProperty.title", "Add Property")) {

        public void actionPerformed(ActionEvent e) {
            addProperty(e);
        }
    };
    addCalculatedMemberProperty = new AbstractAction(getResourceConverter().getString("schemaExplorer.addCalculatedMemberProperty.title", "Add Calculated Member Property")) {

        public void actionPerformed(ActionEvent e) {
            addCalculatedMemberProperty(e);
        }
    };
    addVirtualCube = new AbstractAction(getResourceConverter().getString("schemaExplorer.addVirtualCube.title", "Add Virtual Cube")) {

        public void actionPerformed(ActionEvent e) {
            addVirtualCube(e);
        }
    };
    addVirtualCubeDimension = new AbstractAction(getResourceConverter().getString("schemaExplorer.addVirtualCubeDimension.title", "Add Virtual Cube Dimension")) {

        public void actionPerformed(ActionEvent e) {
            addVirtualCubeDimension(e);
        }
    };
    addVirtualCubeMeasure = new AbstractAction(getResourceConverter().getString("schemaExplorer.addVirtualCubeMeasure.title", "Add Virtual Cube Measure")) {

        public void actionPerformed(ActionEvent e) {
            addVirtualCubeMeasure(e);
        }
    };
    addAggPattern = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAggregatePattern.title", "Add Aggregate Pattern")) {

        public void actionPerformed(ActionEvent e) {
            addAggPattern(e);
        }
    };
    addAggExclude = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAggregateExcludeTable.title", "Add Aggregate Exclude Table")) {

        public void actionPerformed(ActionEvent e) {
            addAggExclude(e);
        }
    };
    addAggName = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAggregateName.title", "Add Aggregate Name")) {

        public void actionPerformed(ActionEvent e) {
            addAggName(e);
        }
    };
    addAggIgnoreColumn = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAggregateIgnoreColumn.title", "Add Aggregate Ignore Column")) {

        public void actionPerformed(ActionEvent e) {
            addAggIgnoreColumn(e);
        }
    };
    addAggForeignKey = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAggregateForeignKey.title", "Add Aggregate Foreign Key")) {

        public void actionPerformed(ActionEvent e) {
            addAggForeignKey(e);
        }
    };
    addAggMeasure = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAggregateMeasure.title", "Add Aggregate Measure")) {

        public void actionPerformed(ActionEvent e) {
            addAggMeasure(e);
        }
    };
    addAggLevel = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAggregateLevel.title", "Add Aggregate Level")) {

        public void actionPerformed(ActionEvent e) {
            addAggLevel(e);
        }
    };
    addAggLevelProperty = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAggregateLevelProperty.title", "Add Aggregate Level Property")) {

        public void actionPerformed(ActionEvent e) {
            addAggLevelProperty(e);
        }
    };
    addAggFactCount = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAggregateFactCount.title", "Add Aggregate Fact Count")) {

        public void actionPerformed(ActionEvent e) {
            addAggFactCount(e);
        }
    };
    addAggMeasureFactCount = new AbstractAction(getResourceConverter().getString("schemaExplorer.addAggregateMeasureFactCount.title", "Add Aggregate Measure Fact Count")) {

        public void actionPerformed(ActionEvent e) {
            addAggMeasureFactCount(e);
        }
    };
    delete = new AbstractAction(getResourceConverter().getString("schemaExplorer.actionDelete.title", "Delete")) {

        public void actionPerformed(ActionEvent e) {
            delete(e);
        }
    };
    editMode = new AbstractAction(getResourceConverter().getString("schemaExplorer.actionEdit.title", "EditMode")) {

        public void actionPerformed(ActionEvent e) {
            editMode(e);
        }
    };
    // ========================================================
    // toolbar buttons
    // ========================================================
    addCubeButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addCube"))));
    addCubeButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addCube.title", "Add cube"));
    addCubeButton.addActionListener(addCube);
    addDimensionButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addDimension"))));
    addDimensionButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addDimension.title", "Add Dimension"));
    addDimensionButton.addActionListener(addDimension);
    addDimensionUsageButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addDimensionUsage"))));
    addDimensionUsageButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addDimensionUsage.title", "Add Dimension Usage"));
    addDimensionUsageButton.addActionListener(addDimensionUsage);
    addHierarchyButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addHierarchy"))));
    addHierarchyButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addHierarchy.title", "Add Hierarchy"));
    addHierarchyButton.addActionListener(addHierarchy);
    addNamedSetButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addNamedSet"))));
    addNamedSetButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addNamedSet.title", "Add Named Set"));
    addNamedSetButton.addActionListener(addNamedSet);
    addUserDefinedFunctionButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addUserDefinedFunction"))));
    addUserDefinedFunctionButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addUserDefinedFunction.title", "Add User defined Function"));
    addUserDefinedFunctionButton.addActionListener(addUserDefinedFunction);
    addCalculatedMemberButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addCalculatedMember"))));
    addCalculatedMemberButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addCalculatedMember.title", "Add Calculated Member"));
    addCalculatedMemberButton.addActionListener(addCalculatedMember);
    addMeasureButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addMeasure"))));
    addMeasureButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addMeasure.title", "Add Measure"));
    addMeasureButton.addActionListener(addMeasure);
    addLevelButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addLevel"))));
    addLevelButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addLevel.title", "Add Level"));
    addLevelButton.addActionListener(addLevel);
    addPropertyButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addProperty"))));
    addPropertyButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addProperty.title", "Add Property"));
    addPropertyButton.addActionListener(addProperty);
    addCalculatedMemberPropertyButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addCalculatedMemberProperty"))));
    addCalculatedMemberPropertyButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addCalculatedMemberProperty.title", "Add Calculated Member Property"));
    addCalculatedMemberPropertyButton.addActionListener(addCalculatedMemberProperty);
    addVirtualCubeButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addVirtualCube"))));
    addVirtualCubeButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addVirtualCube.title", "Add Virtual Cube"));
    addVirtualCubeButton.addActionListener(addVirtualCube);
    addVirtualCubeDimensionButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addVirtualCubeDimension"))));
    addVirtualCubeDimensionButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addVirtualCubeDimension.title", "Add Virtual Dimension"));
    addVirtualCubeDimensionButton.addActionListener(addVirtualCubeDimension);
    addVirtualCubeMeasureButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addVirtualCubeMeasure"))));
    addVirtualCubeMeasureButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addVirtualCubeMeasure.title", "Add Virtual Measure"));
    addVirtualCubeMeasureButton.addActionListener(addVirtualCubeMeasure);
    addRoleButton.setIcon(new ImageIcon(myClassLoader.getResource(getResourceConverter().getGUIReference("addRole"))));
    addRoleButton.setToolTipText(getResourceConverter().getString("schemaExplorer.addRole.title", "Add Role"));
    addRoleButton.addActionListener(addRole);
    cutButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("cut"))));
    cutButton.setText("");
    cutButton.setToolTipText(getResourceConverter().getString("schemaExplorer.actionCut.title", "Cut"));
    copyButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("copy"))));
    copyButton.setText("");
    copyButton.setToolTipText(getResourceConverter().getString("schemaExplorer.actionCopy.title", "Copy"));
    pasteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("paste"))));
    pasteButton.setText("");
    pasteButton.setToolTipText(getResourceConverter().getString("schemaExplorer.actionPaste.title", "Paste"));
    deleteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("delete"))));
    deleteButton.setToolTipText(getResourceConverter().getString("schemaExplorer.actionDelete.title", "Delete"));
    deleteButton.addActionListener(delete);
    editModeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("edit"))));
    editModeButton.setToolTipText(getResourceConverter().getString("schemaExplorer.actionEdit.title", "Edit Mode"));
    editModeButton.addActionListener(editMode);
    databaseLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("database"))));
    jToolBar1.add(addCubeButton);
    jToolBar1.add(addDimensionButton);
    jToolBar1.add(addDimensionUsageButton);
    jToolBar1.add(addHierarchyButton);
    jToolBar1.add(addNamedSetButton);
    jToolBar1.add(addUserDefinedFunctionButton);
    jToolBar1.add(addCalculatedMemberButton);
    jToolBar1.add(addMeasureButton);
    jToolBar1.add(addLevelButton);
    jToolBar1.add(addPropertyButton);
    jToolBar1.add(addCalculatedMemberPropertyButton);
    jToolBar1.addSeparator();
    jToolBar1.add(addVirtualCubeButton);
    jToolBar1.add(addVirtualCubeDimensionButton);
    jToolBar1.add(addVirtualCubeMeasureButton);
    jToolBar1.addSeparator();
    jToolBar1.add(addRoleButton);
    jToolBar1.addSeparator();
    jToolBar1.add(cutButton);
    jToolBar1.add(copyButton);
    jToolBar1.add(pasteButton);
    jToolBar1.addSeparator();
    jToolBar1.add(deleteButton);
    jToolBar1.addSeparator();
    jToolBar1.add(editModeButton);
    // ========================================================
    // popup menu
    // ========================================================
    jPopupMenu = new CustomJPopupMenu();
    // ========================================================
    // tree mouse listener
    // ========================================================
    tree.addMouseListener(new PopupTrigger());
    tree.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            // keytext=Delete
            // keycode=127
            // keytext=NumPad .
            // keycode=110
            int kcode = e.getKeyCode();
            if (kcode == 127 || kcode == 110) {
                delete(e);
            }
        }
    });
    // add footer for connected database
    footer.setLayout(new java.awt.BorderLayout());
    footer.add(databaseLabel, java.awt.BorderLayout.CENTER);
    // ========================================================
    // jpanel
    // ========================================================
    this.add(jSplitPane1, java.awt.BorderLayout.CENTER);
    this.add(jToolBar1, java.awt.BorderLayout.NORTH);
    this.add(footer, java.awt.BorderLayout.SOUTH);
    updater = new JTreeUpdater(tree);
}
Also used : BasicArrowButton(javax.swing.plaf.basic.BasicArrowButton) javax.swing(javax.swing) EtchedBorder(javax.swing.border.EtchedBorder) java.awt(java.awt)

Example 5 with BasicArrowButton

use of javax.swing.plaf.basic.BasicArrowButton in project google-cloud-intellij by GoogleCloudPlatform.

the class CustomizableComboBox method createArrowButton.

/*
   * We do custom rendering of the arrow button because there are too many
   * hacks in each theme's combobox UI.
   * We also cannot forward paint of the arrow button to a stock combobox
   * because each LAF and theme may render different parts of the
   * arrow button with different sizes.  For example, in Mac, the arrow button is
   * drawn with a border (the responsibility of the border
   * near the arrow button belongs to the button).  However in IntelliJ and Darcula,
   * the arrow button is drawn without a border and it's the responsibility of the
   * outer control to draw a border.  In addition, darcula renders part of the arrow
   * button outside the button.  That is, the arrow button looks like it's about 20x20,
   * but actually, it's only 16x16, with part of the rendering done via paint on the combobox itself.
   * So while this creates some small inconsistencies,
   * it reduces the chance of a major UI issue such as a completely poorly drawn button with a
   * double border.
   */
private JButton createArrowButton() {
    final Color bg = getBackground();
    final Color fg = getForeground();
    JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) {

        @Override
        public void paint(Graphics g2) {
            final Graphics2D g = (Graphics2D) g2;
            final GraphicsConfig config = new GraphicsConfig(g);
            final int w = getWidth();
            final int h = getHeight();
            g.setColor(getButtonBackgroundColor());
            g.fillRect(0, 0, w, h);
            g.setColor(getArrowColor());
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
            g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
            final int midx = (int) Math.ceil((w - 1) / 2.0) + 1;
            final int midy = (int) Math.ceil(h / 2.0);
            final Path2D.Double path = new Path2D.Double();
            path.moveTo(midx - 4, midy - 2);
            path.lineTo(midx + 4, midy - 2);
            path.lineTo(midx, midy + 4);
            path.lineTo(midx - 4, midy - 2);
            path.closePath();
            g.fill(path);
            g.setColor(getBorderColor());
            if (UIUtil.isUnderGTKLookAndFeel()) {
                g.drawLine(0, 1, 0, h - 2);
                g.drawLine(0, 1, w - 2, 1);
                g.drawLine(0, h - 2, w - 2, h - 2);
                g.drawLine(w - 2, 1, w - 2, h - 2);
            } else {
                g.drawLine(0, 0, 0, h);
            }
            config.restore();
        }

        @Override
        public Dimension getPreferredSize() {
            int newSize = CustomizableComboBox.this.getHeight() - (CustomizableComboBox.this.getInsets().bottom + CustomizableComboBox.this.getInsets().top);
            return new Dimension(newSize, newSize);
        }
    };
    button.setOpaque(false);
    button.setFocusable(false);
    button.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 1));
    return button;
}
Also used : Graphics(java.awt.Graphics) BasicStroke(java.awt.BasicStroke) BasicArrowButton(javax.swing.plaf.basic.BasicArrowButton) Color(java.awt.Color) JBColor(com.intellij.ui.JBColor) Path2D(java.awt.geom.Path2D) JButton(javax.swing.JButton) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig) Dimension(java.awt.Dimension) Point(java.awt.Point) RelativePoint(com.intellij.ui.awt.RelativePoint) Graphics2D(java.awt.Graphics2D)

Aggregations

BasicArrowButton (javax.swing.plaf.basic.BasicArrowButton)8 GraphicsConfig (com.intellij.openapi.ui.GraphicsConfig)3 JBColor (com.intellij.ui.JBColor)3 java.awt (java.awt)2 Color (java.awt.Color)2 Path2D (java.awt.geom.Path2D)2 javax.swing (javax.swing)2 JButton (javax.swing.JButton)2 Border (javax.swing.border.Border)2 CompoundBorder (javax.swing.border.CompoundBorder)2 UIResource (javax.swing.plaf.UIResource)2 RelativePoint (com.intellij.ui.awt.RelativePoint)1 BasicStroke (java.awt.BasicStroke)1 Dimension (java.awt.Dimension)1 Graphics (java.awt.Graphics)1 Graphics2D (java.awt.Graphics2D)1 Point (java.awt.Point)1 EmptyBorder (javax.swing.border.EmptyBorder)1 EtchedBorder (javax.swing.border.EtchedBorder)1 DimensionUIResource (javax.swing.plaf.DimensionUIResource)1