Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modeler/cayenne-modeler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
<artifactId>forms</artifactId>
</dependency>
<dependency>
<groupId>com.jgoodies</groupId>
<artifactId>jgoodies-looks</artifactId>
<groupId>com.formdev</groupId>
<artifactId>flatlaf</artifactId>
</dependency>
<dependency>
<groupId>com.fifesoft</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package org.apache.cayenne.modeler.platform;

import com.jgoodies.forms.layout.ConstantSize;
import com.jgoodies.forms.layout.Size;
import com.jgoodies.forms.layout.Sizes;
import com.jgoodies.forms.util.LayoutStyle;

public final class FlatLafLayoutStyle extends LayoutStyle {

public static final FlatLafLayoutStyle INSTANCE = new FlatLafLayoutStyle();

private FlatLafLayoutStyle() {
}

private static final Size BUTTON_WIDTH = Sizes.dluX(39);
private static final Size BUTTON_HEIGHT = Sizes.dluY(14);

private static final ConstantSize DIALOG_MARGIN_X = Sizes.DLUX9;
private static final ConstantSize DIALOG_MARGIN_Y = Sizes.DLUY9;

private static final ConstantSize TABBED_DIALOG_MARGIN_X = Sizes.DLUX4;
private static final ConstantSize TABBED_DIALOG_MARGIN_Y = Sizes.DLUY4;

private static final ConstantSize LABEL_COMPONENT_PADX = Sizes.DLUX3;
private static final ConstantSize RELATED_COMPONENTS_PADX = Sizes.DLUX4;
private static final ConstantSize UNRELATED_COMPONENTS_PADX = Sizes.DLUX8;

private static final ConstantSize RELATED_COMPONENTS_PADY = Sizes.DLUY6;
private static final ConstantSize UNRELATED_COMPONENTS_PADY = Sizes.DLUY6;
private static final ConstantSize NARROW_LINE_PAD = Sizes.DLUY2;
private static final ConstantSize LINE_PAD = Sizes.DLUY6;
private static final ConstantSize PARAGRAPH_PAD = Sizes.DLUY9;
private static final ConstantSize BUTTON_BAR_PAD = Sizes.DLUY4;

@Override
public Size getDefaultButtonWidth() {
return BUTTON_WIDTH;
}

@Override
public Size getDefaultButtonHeight() {
return BUTTON_HEIGHT;
}

@Override
public ConstantSize getDialogMarginX() {
return DIALOG_MARGIN_X;
}

@Override
public ConstantSize getDialogMarginY() {
return DIALOG_MARGIN_Y;
}

@Override
public ConstantSize getTabbedDialogMarginX() {
return TABBED_DIALOG_MARGIN_X;
}

@Override
public ConstantSize getTabbedDialogMarginY() {
return TABBED_DIALOG_MARGIN_Y;
}

@Override
public ConstantSize getLabelComponentPadX() {
return LABEL_COMPONENT_PADX;
}

@Override
public ConstantSize getRelatedComponentsPadX() {
return RELATED_COMPONENTS_PADX;
}

@Override
public ConstantSize getRelatedComponentsPadY() {
return RELATED_COMPONENTS_PADY;
}

@Override
public ConstantSize getUnrelatedComponentsPadX() {
return UNRELATED_COMPONENTS_PADX;
}

@Override
public ConstantSize getUnrelatedComponentsPadY() {
return UNRELATED_COMPONENTS_PADY;
}

@Override
public ConstantSize getNarrowLinePad() {
return NARROW_LINE_PAD;
}

@Override
public ConstantSize getLinePad() {
return LINE_PAD;
}

@Override
public ConstantSize getParagraphPad() {
return PARAGRAPH_PAD;
}

@Override
public ConstantSize getButtonBarPad() {
return BUTTON_BAR_PAD;
}

@Override
public boolean isLeftToRightButtonOrder() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
****************************************************************/
package org.apache.cayenne.modeler.platform;

import com.jgoodies.forms.util.LayoutStyle;
import org.apache.cayenne.modeler.Application;
import org.apache.cayenne.modeler.toolkit.filechooser.CMFileChooserFactory;
import org.apache.cayenne.modeler.toolkit.filechooser.SwingFileChooser;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,81 +18,52 @@
****************************************************************/
package org.apache.cayenne.modeler.platform.generic;

import com.jgoodies.looks.plastic.PlasticLookAndFeel;
import com.jgoodies.looks.plastic.PlasticTheme;
import com.jgoodies.looks.plastic.PlasticXPLookAndFeel;
import com.formdev.flatlaf.FlatLightLaf;
import com.jgoodies.forms.util.LayoutStyle;
import org.apache.cayenne.modeler.platform.FlatLafLayoutStyle;
import org.apache.cayenne.modeler.platform.UIInitializer;
import org.apache.cayenne.modeler.toolkit.icon.IconFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.*;
import java.awt.*;

public class GenericUIInitializer implements UIInitializer {

private static final Logger LOGGER = LoggerFactory.getLogger(GenericUIInitializer.class);

private static final String DEFAULT_LAF_NAME = PlasticXPLookAndFeel.class.getName();

// note that another theme - "Desert Blue" doesn't support Chinese and Japanese chars
private static final String DEFAULT_THEME_NAME = "Sky Bluer";

@Override
public void beforeSwingLaunch() {

PlasticTheme theme = findTheme();

if (theme != null) {
PlasticLookAndFeel.setCurrentTheme(theme);
}

try {
UIManager.setLookAndFeel(DEFAULT_LAF_NAME);
// override some default styles and colors
overrideUIDefaults();
} catch (Exception e) {
LOGGER.warn("Error installing L&F: {}", DEFAULT_LAF_NAME, e);
}
FlatLightLaf.setup();
LayoutStyle.setCurrent(FlatLafLayoutStyle.INSTANCE);
// override some default styles and colors
overrideUIDefaults();
}

private void overrideUIDefaults() {
Color greyHighlight = new Color(0xCBCBCB);

UIManager.put("ButtonUI", GenericButtonUI.class.getName());
UIManager.put("HiResGrayFilterEnabled", Boolean.TRUE);
UIManager.put("Tree.expandedIcon", IconFactory.buildIcon("icon-arrow-open.png"));
UIManager.put("Tree.collapsedIcon", IconFactory.buildIcon("icon-arrow-closed.png"));
UIManager.put("Tree.paintLines", Boolean.FALSE);
UIManager.put("Tree.selectionForeground", Color.BLACK);
UIManager.put("Tree.selectionBackground", greyHighlight);
UIManager.put("Tree.selectionBorderColor", UIManager.get("Tree.selectionBackground"));
UIManager.put("Table.selectionForeground", Color.BLACK);
UIManager.put("Table.selectionBackground", greyHighlight);
UIManager.put("Tree.expandedIcon", IconFactory.buildIcon("icon-arrow-open.png"));
UIManager.put("Tree.collapsedIcon", IconFactory.buildIcon("icon-arrow-closed.png"));
UIManager.put("Tree.paintLines", Boolean.FALSE);
UIManager.put("Tree.selectionForeground", Color.BLACK);
UIManager.put("Tree.selectionBackground", greyHighlight);
UIManager.put("Tree.selectionBorderColor", UIManager.get("Tree.selectionBackground"));
UIManager.put("Table.selectionForeground", Color.BLACK);
UIManager.put("Table.selectionBackground", greyHighlight);
UIManager.put("Table.focusCellHighlightBorder", BorderFactory.createEmptyBorder());
UIManager.put("ScrollPane.border", BorderFactory.createEmptyBorder());
UIManager.put("Table.scrollPaneBorder", BorderFactory.createEmptyBorder());
UIManager.put("SplitPane.border", BorderFactory.createEmptyBorder());
UIManager.put("ToolBar.border", BorderFactory.createEmptyBorder(1, 1, 1, 1));
UIManager.put("CheckBoxHeader.border", BorderFactory.createEmptyBorder(0, 15, 0, 0));
UIManager.put("MenuItem.selectionBackground", greyHighlight);
UIManager.put("CheckBoxMenuItem.selectionBackground", greyHighlight);
UIManager.put("ScrollPane.border", BorderFactory.createEmptyBorder());
UIManager.put("Table.scrollPaneBorder", BorderFactory.createEmptyBorder());
UIManager.put("SplitPane.border", BorderFactory.createEmptyBorder());
UIManager.put("ToolBar.border", BorderFactory.createEmptyBorder(1, 1, 1, 1));
UIManager.put("CheckBoxHeader.border", BorderFactory.createEmptyBorder(0, 15, 0, 0));
UIManager.put("MenuItem.selectionBackground", greyHighlight);
UIManager.put("CheckBoxMenuItem.selectionBackground", greyHighlight);
UIManager.put("RadioButtonMenuItem.selectionBackground", greyHighlight);
UIManager.put("MenuItem.selectionForeground", Color.BLACK);
UIManager.put("CheckBoxMenuItem.selectionForeground", Color.BLACK);
UIManager.put("MenuItem.selectionForeground", Color.BLACK);
UIManager.put("CheckBoxMenuItem.selectionForeground", Color.BLACK);
UIManager.put("RadioButtonMenuItem.selectionForeground", Color.BLACK);
UIManager.put("ToolBar.buttonMargin", new Insets(4, 8, 4, 8));
UIManager.put("Table.showHorizontalLines", Boolean.TRUE);
UIManager.put("Table.showVerticalLines", Boolean.TRUE);
// this one is custom for MainToolBar
UIManager.put("MainToolBar.border", BorderFactory.createLineBorder(Color.GRAY));
}

private PlasticTheme findTheme() {

for (Object object : PlasticLookAndFeel.getInstalledThemes()) {
PlasticTheme theme = (PlasticTheme) object;
if (DEFAULT_THEME_NAME.equals(theme.getName())) {
return theme;
}
}
return null;
UIManager.put("MainToolBar.border", BorderFactory.createLineBorder(Color.GRAY));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package org.apache.cayenne.modeler.platform.mac;

import org.apache.cayenne.modeler.ui.SearchPanel;

import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicPanelUI;
Expand Down Expand Up @@ -59,11 +57,7 @@ public static ComponentUI createUI(JComponent c) {
@Override
protected void installDefaults(JPanel p) {
super.installDefaults(p);
if (p instanceof SearchPanel) {
SwingUtilities.invokeLater(((SearchPanel) p)::hideSearchLabel);
} else {
p.setBackground(BACKGROUND);
}
p.setBackground(BACKGROUND);
}

@Override
Expand Down
Loading
Loading