|
|
|
@ -1,11 +1,14 @@
|
|
|
|
|
package com.fr.design.gui.controlpane; |
|
|
|
|
|
|
|
|
|
import com.fine.theme.light.ui.FineButtonBorder; |
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
|
import com.fine.theme.utils.FineUIStyle; |
|
|
|
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
|
import com.fr.design.gui.controlpane.shortcutfactory.ShortCutFactory; |
|
|
|
|
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.gui.itoolbar.UIToolBarUI; |
|
|
|
|
import com.fr.design.gui.itoolbar.UIToolbar; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
@ -46,15 +49,15 @@ import java.awt.event.MouseMotionListener;
|
|
|
|
|
import java.awt.event.WindowAdapter; |
|
|
|
|
import java.awt.event.WindowEvent; |
|
|
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell; |
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.row; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Created by plough on 2017/7/21. |
|
|
|
|
*/ |
|
|
|
|
public abstract class UIControlPane extends JControlPane { |
|
|
|
|
private UIToolbar topToolBar; |
|
|
|
|
protected Window popupEditDialog; |
|
|
|
|
private static final int TOP_TOOLBAR_HEIGHT = 20; |
|
|
|
|
private static final int TOP_TOOLBAR_WIDTH = 156; // 可能因为用了tablelayout,要比其他地方多一个像素,看起来才正常
|
|
|
|
|
private static final int TOP_TOOLBAR_WIDTH_SHORT = 76; |
|
|
|
|
|
|
|
|
|
UIControlPane() { |
|
|
|
|
super(); |
|
|
|
@ -135,40 +138,26 @@ public abstract class UIControlPane extends JControlPane {
|
|
|
|
|
leftContentPane.add(toolBarPane, BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
// 顶部标签及add按钮
|
|
|
|
|
topToolBar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI() { |
|
|
|
|
@Override |
|
|
|
|
public void paint(Graphics g, JComponent c) { |
|
|
|
|
Graphics2D g2 = (Graphics2D) g; |
|
|
|
|
g2.setColor(UIConstants.SELECT_TAB); |
|
|
|
|
g2.fillRect(0, 0, c.getWidth(), c.getHeight()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
topToolBar.setBorder(null); |
|
|
|
|
topToolBar = new UIToolbar(); |
|
|
|
|
topToolBar.setLayout(new BorderLayout()); |
|
|
|
|
ShortCut addItem = shortCutFactory.addItemShortCut().getShortCut(); |
|
|
|
|
addItem.intoJToolBar(topToolBar); |
|
|
|
|
JPanel leftTopPane = getLeftTopPane(topToolBar); |
|
|
|
|
leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0)); |
|
|
|
|
leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); |
|
|
|
|
leftPane.add(leftTopPane, BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
return leftPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected JPanel getLeftTopPane(UIToolbar topToolBar) { |
|
|
|
|
UILabel addItemLabel = FRWidgetFactory.createLineWrapLabel(getAddItemText()); |
|
|
|
|
|
|
|
|
|
topToolBar.setPreferredSize( |
|
|
|
|
new Dimension( |
|
|
|
|
isNewStyle() ? TOP_TOOLBAR_WIDTH : TOP_TOOLBAR_WIDTH_SHORT, |
|
|
|
|
TOP_TOOLBAR_HEIGHT |
|
|
|
|
)); |
|
|
|
|
JPanel toolBarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
toolBarPane.add(topToolBar, BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
JPanel leftTopPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
leftTopPane.add(toolBarPane, BorderLayout.EAST); |
|
|
|
|
leftTopPane.add(addItemLabel, BorderLayout.CENTER); |
|
|
|
|
return leftTopPane; |
|
|
|
|
return row(10, |
|
|
|
|
cell(FRWidgetFactory.createLineWrapLabel(getAddItemText())), |
|
|
|
|
cell(topToolBar).with(it -> { |
|
|
|
|
it.setBorderPainted(true); |
|
|
|
|
it.setBorder(new FineButtonBorder()); |
|
|
|
|
it.setBackground(FlatUIUtils.getUIColor("fill.normal", Color.WHITE)); |
|
|
|
|
}).weight(1.0) |
|
|
|
|
).getComponent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -179,7 +168,6 @@ public abstract class UIControlPane extends JControlPane {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected ShortCut4JControlPane[] createShortcuts() { |
|
|
|
|
// return AbstractShortCutFactory.getInstance(this).createNewShortCuts();
|
|
|
|
|
return shortCutFactory.createShortCuts(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -219,8 +207,7 @@ public abstract class UIControlPane extends JControlPane {
|
|
|
|
|
editPaneWrapper.add(editPane, BorderLayout.CENTER); |
|
|
|
|
editPaneWrapper.setBorder(BorderFactory.createLineBorder(UIConstants.POP_DIALOG_BORDER, 1)); |
|
|
|
|
this.getContentPane().add(editPaneWrapper, BorderLayout.CENTER); |
|
|
|
|
setSize(WIDTH, HEIGHT); |
|
|
|
|
// pack();
|
|
|
|
|
setSize(FineUIScale.scale(new Dimension(WIDTH, HEIGHT))); |
|
|
|
|
this.setVisible(false); |
|
|
|
|
initListener(); |
|
|
|
|
} |
|
|
|
@ -386,6 +373,7 @@ public abstract class UIControlPane extends JControlPane {
|
|
|
|
|
contentPane.setBackground(originColor); |
|
|
|
|
contentPane.setLayout(new BorderLayout()); |
|
|
|
|
titleLabel = new UILabel(title); |
|
|
|
|
FineUIStyle.setStyle(titleLabel, FineUIStyle.LABEL_BOLD); |
|
|
|
|
contentPane.add(titleLabel, BorderLayout.WEST); |
|
|
|
|
contentPane.setBorder(new EmptyBorder(5, 14, 6, 0)); |
|
|
|
|
|
|
|
|
|