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;
}
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);
}
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;
}
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);
}
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;
});
}
Aggregations