|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.fr.design.gui.controlpane; |
|
|
|
package com.fr.design.gui.controlpane; |
|
|
|
|
|
|
|
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
|
|
|
|
import com.fine.theme.utils.FineUIUtils; |
|
|
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
|
|
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
|
|
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
|
|
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
|
|
|
import com.fr.design.border.FineBorderFactory; |
|
|
|
import com.fr.design.border.FineBorderFactory; |
|
|
@ -21,7 +22,9 @@ import javax.swing.JSplitPane; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.CardLayout; |
|
|
|
import java.awt.CardLayout; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
import java.awt.Dimension; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.Objects; |
|
|
|
import java.util.stream.Stream; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -47,6 +50,11 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S |
|
|
|
|
|
|
|
|
|
|
|
protected JPanel cardPane; |
|
|
|
protected JPanel cardPane; |
|
|
|
protected AbstractShortCutFactory shortCutFactory; |
|
|
|
protected AbstractShortCutFactory shortCutFactory; |
|
|
|
|
|
|
|
protected JSplitPane mainSplitPane; |
|
|
|
|
|
|
|
// split pane 左边组件最小宽度
|
|
|
|
|
|
|
|
protected int leftComponentMin; |
|
|
|
|
|
|
|
// split pane 左边组件最大宽度
|
|
|
|
|
|
|
|
protected int leftComponentMax; |
|
|
|
|
|
|
|
|
|
|
|
JControlPane() { |
|
|
|
JControlPane() { |
|
|
|
this.initShortCutFactory(); |
|
|
|
this.initShortCutFactory(); |
|
|
@ -110,7 +118,10 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S |
|
|
|
this.creators = this.createNameableCreators(); |
|
|
|
this.creators = this.createNameableCreators(); |
|
|
|
initCardPane(); |
|
|
|
initCardPane(); |
|
|
|
// SplitPane
|
|
|
|
// SplitPane
|
|
|
|
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane); |
|
|
|
JPanel leftComponentPane = getLeftPane(); |
|
|
|
|
|
|
|
leftComponentMin = FineUIUtils.getAndScaleInt("SplitPane.leftComponent.minimumSize", 120); |
|
|
|
|
|
|
|
leftComponentPane.setMinimumSize(FineUIScale.createScaleDimension(leftComponentMin, 0)); |
|
|
|
|
|
|
|
mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, leftComponentPane, cardPane); |
|
|
|
mainSplitPane.setOneTouchExpandable(true); |
|
|
|
mainSplitPane.setOneTouchExpandable(true); |
|
|
|
|
|
|
|
|
|
|
|
this.add(mainSplitPane, BorderLayout.CENTER); |
|
|
|
this.add(mainSplitPane, BorderLayout.CENTER); |
|
|
@ -123,11 +134,12 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void initCardPane() { |
|
|
|
protected void initCardPane() { |
|
|
|
|
|
|
|
leftComponentMax = FineUIUtils.getAndScaleInt("SplitPane.leftComponent.maximumSize", 240); |
|
|
|
this.controlUpdatePane = createControlUpdatePane(); |
|
|
|
this.controlUpdatePane = createControlUpdatePane(); |
|
|
|
|
|
|
|
|
|
|
|
// p: edit card layout
|
|
|
|
// p: edit card layout
|
|
|
|
this.cardLayout = new CardLayout(); |
|
|
|
this.cardLayout = new CardLayout(); |
|
|
|
cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
|
|
|
initCardPaneWithMinSize(); |
|
|
|
cardPane.setLayout(this.cardLayout); |
|
|
|
cardPane.setLayout(this.cardLayout); |
|
|
|
// p:选择的Label
|
|
|
|
// p:选择的Label
|
|
|
|
UILabel selectLabel = new UILabel(); |
|
|
|
UILabel selectLabel = new UILabel(); |
|
|
@ -135,6 +147,29 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S |
|
|
|
cardPane.add(controlUpdatePane, EDIT); |
|
|
|
cardPane.add(controlUpdatePane, EDIT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 初始化一个 rightComponent,且指定 minimumSize |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* {@link javax.swing.plaf.basic.BasicSplitPaneDivider#DragController} 拖拽的时候会调用 getMinimumSize 方法 |
|
|
|
|
|
|
|
* split pane driver 拖拽范围取自 leftComponent 的 minimumSize 和 rightComponent 的 minimumSize |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void initCardPaneWithMinSize() { |
|
|
|
|
|
|
|
cardPane = new JPanel(new CardLayout()) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Dimension getMinimumSize() { |
|
|
|
|
|
|
|
Dimension size = super.getMinimumSize(); |
|
|
|
|
|
|
|
if (mainSplitPane == null) { |
|
|
|
|
|
|
|
return size; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Dimension parentSize = mainSplitPane.getSize(); |
|
|
|
|
|
|
|
if (parentSize.width != 0 && Objects.equals(JSplitPane.HORIZONTAL_SPLIT, mainSplitPane.getOrientation())) { |
|
|
|
|
|
|
|
size.width = parentSize.width - FineUIScale.scale(leftComponentMax); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return size; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void showEditPane() { |
|
|
|
public void showEditPane() { |
|
|
|
this.cardLayout.show(cardPane, EDIT); |
|
|
|
this.cardLayout.show(cardPane, EDIT); |
|
|
|
} |
|
|
|
} |
|
|
|