Search in sources :

Example 11 with CompoundBorder

use of javax.swing.border.CompoundBorder in project intellij-community by JetBrains.

the class MultilinePopupBuilder method createTextField.

@NotNull
private static EditorTextField createTextField(@NotNull Project project, Collection<String> values, boolean supportsNegativeValues, @NotNull String initialValue) {
    TextFieldWithCompletion textField = new TextFieldWithCompletion(project, new MyCompletionProvider(values, supportsNegativeValues), initialValue, false, true, false) {

        @Override
        protected EditorEx createEditor() {
            EditorEx editor = super.createEditor();
            SoftWrapsEditorCustomization.ENABLED.customize(editor);
            return editor;
        }
    };
    textField.setBorder(new CompoundBorder(JBUI.Borders.empty(2), textField.getBorder()));
    return textField;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) TextFieldWithCompletion(com.intellij.util.textCompletion.TextFieldWithCompletion) CompoundBorder(javax.swing.border.CompoundBorder) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with CompoundBorder

use of javax.swing.border.CompoundBorder in project adempiere by adempiere.

the class MiniTable method getCellRenderer.

public TableCellRenderer getCellRenderer(int row, int column) {
    Object editorClass = null;
    try {
        editorClass = this.getColumnModel().getColumn(column).getCellEditor().getClass();
    }//  Possible NPE if the table was not setup properly.
     catch (Exception e) {
    }
    boolean editable = this.isCellEditable(row, column);
    if (editable && editorClass == MiniCellEditor.class) {
        Color borderColor = AdempierePLAF.getFieldBackground_Mandatory();
        CompoundBorder cb = null;
        //  Set the borders on the editor
        MiniCellEditor jc = ((MiniCellEditor) this.getColumnModel().getColumn(column).getCellEditor());
        if (column == 0) {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 0, 0, 1)), new MatteBorder(1, 1, 1, 0, borderColor));
            jc.setBorder(cb);
        } else if (column == this.getColumnCount() - 1) {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 0)), new MatteBorder(1, 0, 1, 1, borderColor));
            jc.setBorder(cb);
        } else {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 1)), new MatteBorder(1, 0, 1, 0, borderColor));
            jc.setBorder(cb);
        }
    }
    return super.getCellRenderer(row, column);
}
Also used : MatteBorder(javax.swing.border.MatteBorder) Insets(java.awt.Insets) Color(java.awt.Color) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) SQLException(java.sql.SQLException)

Example 13 with CompoundBorder

use of javax.swing.border.CompoundBorder in project adempiere by adempiere.

the class MiniTable method prepareRenderer.

public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    Component c = super.prepareRenderer(renderer, row, column);
    JComponent jc = (JComponent) c;
    if (c == null)
        return c;
    //  Row is selected
    Color selectedColor = AdempierePLAF.getFieldBackground_Selected();
    //  Even row
    Color normalColor = AdempierePLAF.getFieldBackground_Normal();
    //  Odd row
    Color backColor = AdempierePLAF.getInfoBackground();
    //  Lead row border
    Color borderColor = AdempierePLAF.getFieldBackground_Mandatory();
    CompoundBorder cb = null;
    ListSelectionModel rsm = this.getSelectionModel();
    boolean readOnly = !this.isCellEditable(row, column);
    if (!(row == rsm.getLeadSelectionIndex())) {
        if (//  Highlighted but not the lead
        rsm.isSelectedIndex(row)) {
            c.setBackground(selectedColor);
            jc.setBorder(new MatteBorder(1, 1, 1, 1, selectedColor));
        } else if (//  Not selected but even in number
        row % 2 == 0) {
            c.setBackground(normalColor);
            jc.setBorder(new MatteBorder(1, 1, 1, 1, normalColor));
        } else //  Not selected and odd in number
        {
            // If not shaded, match the table's background
            c.setBackground(backColor);
            jc.setBorder(new MatteBorder(1, 1, 1, 1, backColor));
        }
        //  Buttons and checkboxes need to have the border turned on
        if (c.getClass().equals(JCheckBox.class)) {
            ((JCheckBox) c).setBorderPainted(false);
        } else if (c.getClass().equals(JButton.class)) {
            ((JButton) c).setBorderPainted(false);
        }
    } else {
        if (c.getClass().equals(JCheckBox.class)) {
            ((JCheckBox) c).setBorderPainted(true);
        } else if (c.getClass().equals(JButton.class)) {
            ((JButton) c).setBorderPainted(true);
        }
        //  Define border - compond border maintains the spacing of 1px around the field
        if (column == 0) {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 0, 0, 1)), new MatteBorder(1, 1, 1, 0, borderColor));
        } else if (column == this.getColumnCount() - 1) {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 0)), new MatteBorder(1, 0, 1, 1, borderColor));
        } else {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 1)), new MatteBorder(1, 0, 1, 0, borderColor));
        }
        //  Set border
        jc.setBorder(cb);
        //  Set background color
        if (!readOnly && this.isRowChecked(row))
            c.setBackground(normalColor);
        else
            c.setBackground(selectedColor);
    }
    return c;
}
Also used : JCheckBox(javax.swing.JCheckBox) MatteBorder(javax.swing.border.MatteBorder) Insets(java.awt.Insets) Color(java.awt.Color) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) ListSelectionModel(javax.swing.ListSelectionModel) CompoundBorder(javax.swing.border.CompoundBorder) Component(java.awt.Component) JComponent(javax.swing.JComponent) EmptyBorder(javax.swing.border.EmptyBorder)

Example 14 with CompoundBorder

use of javax.swing.border.CompoundBorder in project adempiere by adempiere.

the class ContrastTheme method addCustomEntriesToTable.

public void addCustomEntriesToTable(UIDefaults table) {
    Border blackLineBorder = new BorderUIResource(new LineBorder(getBlack()));
    Border whiteLineBorder = new BorderUIResource(new LineBorder(getWhite()));
    //
    Object textBorder = new BorderUIResource(new CompoundBorder(blackLineBorder, new BasicBorders.MarginBorder()));
    //	Enhancements
    Object[] defaults = new Object[] { "ToolTip.border", blackLineBorder, "TitledBorder.border", blackLineBorder, "TextField.border", textBorder, "PasswordField.border", textBorder, "TextArea.border", textBorder, "TextPane.border", textBorder, "EditorPane.border", textBorder, //
    "ComboBox.background", getWindowBackground(), "ComboBox.foreground", getUserTextColor(), "ComboBox.selectionBackground", getTextHighlightColor(), "ComboBox.selectionForeground", getHighlightedTextColor(), "ProgressBar.foreground", getUserTextColor(), "ProgressBar.background", getWindowBackground(), "ProgressBar.selectionForeground", getWindowBackground(), "ProgressBar.selectionBackground", getUserTextColor(), "OptionPane.errorDialog.border.background", getPrimary1(), "OptionPane.errorDialog.titlePane.foreground", getPrimary3(), "OptionPane.errorDialog.titlePane.background", getPrimary1(), "OptionPane.errorDialog.titlePane.shadow", getPrimary2(), "OptionPane.questionDialog.border.background", getPrimary1(), "OptionPane.questionDialog.titlePane.foreground", getPrimary3(), "OptionPane.questionDialog.titlePane.background", getPrimary1(), "OptionPane.questionDialog.titlePane.shadow", getPrimary2(), "OptionPane.warningDialog.border.background", getPrimary1(), "OptionPane.warningDialog.titlePane.foreground", getPrimary3(), "OptionPane.warningDialog.titlePane.background", getPrimary1(), "OptionPane.warningDialog.titlePane.shadow", getPrimary2() };
    table.putDefaults(defaults);
}
Also used : BorderUIResource(javax.swing.plaf.BorderUIResource) LineBorder(javax.swing.border.LineBorder) CompoundBorder(javax.swing.border.CompoundBorder) CompoundBorder(javax.swing.border.CompoundBorder) LineBorder(javax.swing.border.LineBorder) Border(javax.swing.border.Border)

Example 15 with CompoundBorder

use of javax.swing.border.CompoundBorder in project intellij-community by JetBrains.

the class ImplementationViewComponent method update.

public void update(@NotNull final PsiElement[] elements, final int index) {
    update(elements, (psiElements, fileDescriptors) -> {
        if (myEditor.isDisposed())
            return false;
        if (psiElements.length == 0)
            return false;
        final Project project = psiElements[0].getProject();
        myElements = psiElements;
        myIndex = index < myElements.length ? index : 0;
        PsiFile psiFile = getContainingFile(myElements[myIndex]);
        VirtualFile virtualFile = psiFile.getVirtualFile();
        EditorHighlighter highlighter;
        if (virtualFile != null)
            highlighter = HighlighterFactory.createHighlighter(project, virtualFile);
        else {
            // some artificial psi file, lets do best we can
            String fileName = psiFile.getName();
            highlighter = HighlighterFactory.createHighlighter(project, fileName);
        }
        ((EditorEx) myEditor).setHighlighter(highlighter);
        if (myElements.length > 1) {
            myFileChooser.setVisible(true);
            myCountLabel.setVisible(true);
            myLabel.setVisible(false);
            myFileChooser.setModel(new DefaultComboBoxModel(fileDescriptors.toArray(new FileDescriptor[fileDescriptors.size()])));
            updateRenderer(project);
        } else {
            myFileChooser.setVisible(false);
            myCountLabel.setVisible(false);
            VirtualFile file = psiFile.getVirtualFile();
            if (file != null) {
                myLabel.setIcon(getIconForFile(psiFile));
                myLabel.setForeground(FileStatusManager.getInstance(project).getStatus(file).getColor());
                myLabel.setText(file.getPresentableName());
                myLabel.setBorder(new CompoundBorder(IdeBorderFactory.createRoundedBorder(), IdeBorderFactory.createEmptyBorder(0, 0, 0, 5)));
                myLabel.setVisible(true);
            }
        }
        updateControls();
        revalidate();
        repaint();
        return true;
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) EditorEx(com.intellij.openapi.editor.ex.EditorEx) CompoundBorder(javax.swing.border.CompoundBorder) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter)

Aggregations

CompoundBorder (javax.swing.border.CompoundBorder)43 EmptyBorder (javax.swing.border.EmptyBorder)23 Border (javax.swing.border.Border)20 BorderLayout (java.awt.BorderLayout)14 JLabel (javax.swing.JLabel)13 JPanel (javax.swing.JPanel)13 Insets (java.awt.Insets)10 LineBorder (javax.swing.border.LineBorder)9 GridBagConstraints (java.awt.GridBagConstraints)8 GridBagLayout (java.awt.GridBagLayout)8 JButton (javax.swing.JButton)8 TitledBorder (javax.swing.border.TitledBorder)8 ActionEvent (java.awt.event.ActionEvent)7 EtchedBorder (javax.swing.border.EtchedBorder)7 CustomLineBorder (com.intellij.ui.border.CustomLineBorder)5 ActionListener (java.awt.event.ActionListener)5 File (java.io.File)5 JTextField (javax.swing.JTextField)5 NotNull (org.jetbrains.annotations.NotNull)5 Color (java.awt.Color)4