Search in sources :

Example 86 with TitledBorder

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

the class ResourceBundleEditor method updateEditorsFromProperties.

void updateEditorsFromProperties(final boolean checkIsUnderUndoRedoAction) {
    String propertyName = getSelectedPropertyName();
    ((CardLayout) myValuesPanel.getLayout()).show(myValuesPanel, propertyName == null ? NO_PROPERTY_SELECTED : VALUES);
    if (propertyName == null)
        return;
    final UndoManagerImpl undoManager = (UndoManagerImpl) UndoManager.getInstance(myProject);
    for (final PropertiesFile propertiesFile : myResourceBundle.getPropertiesFiles()) {
        final EditorEx editor = myEditors.get(propertiesFile.getVirtualFile());
        if (editor == null)
            continue;
        final IProperty property = propertiesFile.findPropertyByKey(propertyName);
        final Document document = editor.getDocument();
        CommandProcessor.getInstance().executeCommand(null, () -> ApplicationManager.getApplication().runWriteAction(() -> {
            if (!checkIsUnderUndoRedoAction || !undoManager.isActive() || !(undoManager.isRedoInProgress() || undoManager.isUndoInProgress())) {
                updateDocumentFromPropertyValue(getPropertyEditorValue(property), document, propertiesFile.getVirtualFile());
            }
        }), "", this);
        JPanel titledPanel = myTitledPanels.get(propertiesFile.getVirtualFile());
        ((TitledBorder) titledPanel.getBorder()).setTitleColor(property == null ? JBColor.RED : UIUtil.getLabelTextForeground());
        titledPanel.repaint();
    }
}
Also used : UndoManagerImpl(com.intellij.openapi.command.impl.UndoManagerImpl) EditorEx(com.intellij.openapi.editor.ex.EditorEx) IProperty(com.intellij.lang.properties.IProperty) XmlPropertiesFile(com.intellij.lang.properties.xml.XmlPropertiesFile) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile) TitledBorder(javax.swing.border.TitledBorder)

Example 87 with TitledBorder

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

the class GuiUtils method enableComponent.

private static void enableComponent(Component component, boolean enabled) {
    if (component.isEnabled() == enabled)
        return;
    component.setEnabled(enabled);
    if (component instanceof JPanel) {
        final Border border = ((JPanel) component).getBorder();
        if (border instanceof TitledBorder) {
            Color color = enabled ? component.getForeground() : UIUtil.getInactiveTextColor();
            ((TitledBorder) border).setTitleColor(color);
        }
    } else if (component instanceof JLabel) {
        Color color = UIUtil.getInactiveTextColor();
        if (color == null)
            color = component.getForeground();
        @NonNls String changeColorString = "<font color=#" + colorToHex(color) + ">";
        final JLabel label = (JLabel) component;
        @NonNls String text = label.getText();
        if (text != null && text.startsWith("<html>")) {
            if (StringUtil.startsWithConcatenation(text, "<html>", changeColorString) && enabled) {
                text = "<html>" + text.substring(("<html>" + changeColorString).length());
            } else if (!StringUtil.startsWithConcatenation(text, "<html>", changeColorString) && !enabled) {
                text = "<html>" + changeColorString + text.substring("<html>".length());
            }
            label.setText(text);
        }
    } else if (component instanceof JTable) {
        TableColumnModel columnModel = ((JTable) component).getColumnModel();
        for (int i = 0; i < columnModel.getColumnCount(); i++) {
            TableCellRenderer cellRenderer = columnModel.getColumn(0).getCellRenderer();
            if (cellRenderer instanceof Component) {
                enableComponent((Component) cellRenderer, enabled);
            }
        }
    }
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) TableColumnModel(javax.swing.table.TableColumnModel) TitledBorder(javax.swing.border.TitledBorder) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder)

Example 88 with TitledBorder

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

the class SearchUtil method processComponent.

private static void processComponent(JComponent component, Set<OptionDescription> configurableOptions, String path) {
    if (component instanceof SkipSelfSearchComponent)
        return;
    final Border border = component.getBorder();
    if (border instanceof TitledBorder) {
        final TitledBorder titledBorder = (TitledBorder) border;
        final String title = titledBorder.getTitle();
        if (title != null) {
            processUILabel(title, configurableOptions, path);
        }
    }
    if (component instanceof JLabel) {
        final String label = ((JLabel) component).getText();
        if (label != null) {
            processUILabel(label, configurableOptions, path);
        }
    } else if (component instanceof JCheckBox) {
        final String checkBoxTitle = ((JCheckBox) component).getText();
        if (checkBoxTitle != null) {
            processUILabel(checkBoxTitle, configurableOptions, path);
        }
    } else if (component instanceof JRadioButton) {
        final String radioButtonTitle = ((JRadioButton) component).getText();
        if (radioButtonTitle != null) {
            processUILabel(radioButtonTitle, configurableOptions, path);
        }
    } else if (component instanceof JButton) {
        final String buttonTitle = ((JButton) component).getText();
        if (buttonTitle != null) {
            processUILabel(buttonTitle, configurableOptions, path);
        }
    }
    if (component instanceof JTabbedPane) {
        final JTabbedPane tabbedPane = (JTabbedPane) component;
        final int tabCount = tabbedPane.getTabCount();
        for (int i = 0; i < tabCount; i++) {
            final String title = path != null ? path + '.' + tabbedPane.getTitleAt(i) : tabbedPane.getTitleAt(i);
            processUILabel(title, configurableOptions, title);
            final Component tabComponent = tabbedPane.getComponentAt(i);
            if (tabComponent instanceof JComponent) {
                processComponent((JComponent) tabComponent, configurableOptions, title);
            }
        }
    } else if (component instanceof TabbedPaneWrapper.TabbedPaneHolder) {
        final TabbedPaneWrapper tabbedPane = ((TabbedPaneWrapper.TabbedPaneHolder) component).getTabbedPaneWrapper();
        final int tabCount = tabbedPane.getTabCount();
        for (int i = 0; i < tabCount; i++) {
            String tabTitle = tabbedPane.getTitleAt(i);
            final String title = path != null ? path + '.' + tabTitle : tabTitle;
            processUILabel(title, configurableOptions, title);
            final JComponent tabComponent = tabbedPane.getComponentAt(i);
            if (tabComponent != null) {
                processComponent(tabComponent, configurableOptions, title);
            }
        }
    } else {
        final Component[] components = component.getComponents();
        if (components != null) {
            for (Component child : components) {
                if (child instanceof JComponent) {
                    processComponent((JComponent) child, configurableOptions, path);
                }
            }
        }
    }
}
Also used : TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) TitledBorder(javax.swing.border.TitledBorder) SkipSelfSearchComponent(com.intellij.application.options.SkipSelfSearchComponent) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent) SkipSelfSearchComponent(com.intellij.application.options.SkipSelfSearchComponent) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder)

Example 89 with TitledBorder

use of javax.swing.border.TitledBorder in project ACS by ACS-Community.

the class LogLevelSelectorPanel method initMimimumLevelsPanel.

/**
	 * Setup the panel to show minimum levels
	 * 
	 * @return
	 */
private JPanel initMimimumLevelsPanel() {
    TitledBorder border = BorderFactory.createTitledBorder("Minimum Log Levels");
    JPanel mainPnl = new JPanel();
    GridBagLayout gl = new GridBagLayout();
    GridBagConstraints gc = new GridBagConstraints();
    mainPnl.setLayout(gl);
    mainPnl.setBorder(border);
    JLabel localLbl = new JLabel("Current minimum local level");
    minLocal = new JLabel("");
    JLabel globalLbl = new JLabel("Current minimum remote level");
    minGlobal = new JLabel("");
    gc.insets = new Insets(5, 10, 5, 10);
    gc.gridx = 0;
    gc.gridy = 0;
    gl.setConstraints(localLbl, gc);
    mainPnl.add(localLbl);
    gc.gridx++;
    gc.insets.right *= 2;
    gl.setConstraints(minLocal, gc);
    mainPnl.add(minLocal);
    gc.gridx++;
    gc.insets.right /= 2;
    gl.setConstraints(globalLbl, gc);
    mainPnl.add(globalLbl);
    gc.gridx++;
    gl.setConstraints(minGlobal, gc);
    mainPnl.add(minGlobal);
    updateMinLevels();
    return mainPnl;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder)

Example 90 with TitledBorder

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

the class GroovyEditor method jbInit.

/**
	 *  Static Layout
	 *  @throws Exception
	 */
void jbInit() throws Exception {
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    titledBorder2 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)), Msg.getMsg(Env.getCtx(), "ScriptEditor"));
    mainPanel.setLayout(borderLayout1);
    bOK.addActionListener(this);
    bCancel.addActionListener(this);
    bProcess.addActionListener(this);
    bHelp.addActionListener(this);
    editorPane.setBorder(titledBorder2);
    editorPane.setPreferredSize(new Dimension(500, 500));
    southPanel.setLayout(southLayout);
    resultPanel.setLayout(resultLayout);
    lResult.setText(Msg.getMsg(Env.getCtx(), "ScriptResult"));
    fResult.setBackground(Color.lightGray);
    fResult.setEditable(false);
    fResult.setText("");
    okPanel.setLayout(okLayout);
    getContentPane().add(mainPanel);
    editorPane.getViewport().add(editor, null);
    mainPanel.add(southPanel, BorderLayout.SOUTH);
    southPanel.add(okPanel, BorderLayout.EAST);
    okPanel.add(bCancel, null);
    okPanel.add(bOK, null);
    southPanel.add(resultPanel, BorderLayout.CENTER);
    resultPanel.add(bProcess, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    resultPanel.add(lResult, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    resultPanel.add(fResult, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    resultPanel.add(bHelp, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    mainPanel.add(editorPane, BorderLayout.CENTER);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) Color(java.awt.Color) Dimension(java.awt.Dimension) TitledBorder(javax.swing.border.TitledBorder)

Aggregations

TitledBorder (javax.swing.border.TitledBorder)143 JPanel (javax.swing.JPanel)94 GridBagConstraints (java.awt.GridBagConstraints)59 GridBagLayout (java.awt.GridBagLayout)50 JLabel (javax.swing.JLabel)50 BorderLayout (java.awt.BorderLayout)45 Insets (java.awt.Insets)43 JScrollPane (javax.swing.JScrollPane)34 Dimension (java.awt.Dimension)30 JButton (javax.swing.JButton)29 EtchedBorder (javax.swing.border.EtchedBorder)28 ActionEvent (java.awt.event.ActionEvent)25 EmptyBorder (javax.swing.border.EmptyBorder)25 Border (javax.swing.border.Border)23 ActionListener (java.awt.event.ActionListener)21 JCheckBox (javax.swing.JCheckBox)19 GridLayout (java.awt.GridLayout)18 JTextField (javax.swing.JTextField)16 Color (java.awt.Color)15 Box (javax.swing.Box)12