forked from fanruan/design
Hades
5 years ago
5 changed files with 327 additions and 4 deletions
@ -0,0 +1,62 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.widget.UITitleSplitLine; |
||||
import com.fr.form.ui.mobile.MobileCollapsedStyle; |
||||
import com.fr.form.ui.mobile.MobileFormCollapsedStyle; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/2/13 |
||||
*/ |
||||
public class MobileCollapsedStyleExpandPane extends MobileCollapsedStylePane { |
||||
|
||||
private UISpinner rowSpinner; |
||||
|
||||
public MobileCollapsedStyleExpandPane() { |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected JPanel createLinePane() { |
||||
UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Line_Number"), 520); |
||||
splitLine.setPreferredSize(new Dimension(520, 20)); |
||||
this.rowSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 1); |
||||
JPanel panel = new JPanel(); |
||||
panel.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); |
||||
panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Start_From"))); |
||||
panel.add(rowSpinner); |
||||
panel.add(new UILabel("Fine-Design_Mobile_Collapse_Row_To_Fold")); |
||||
JPanel linePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
linePane.add(splitLine, BorderLayout.NORTH); |
||||
linePane.add(panel, BorderLayout.CENTER); |
||||
return linePane; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MobileCollapsedStyle ob) { |
||||
super.populateBean(ob); |
||||
rowSpinner.setValue(((MobileFormCollapsedStyle) ob).getLineAttr().getNumber()); |
||||
} |
||||
|
||||
@Override |
||||
public MobileCollapsedStyle updateBean() { |
||||
MobileCollapsedStyle style = super.updateBean(); |
||||
((MobileFormCollapsedStyle) style).getLineAttr().setNumber((int) rowSpinner.getValue()); |
||||
return style; |
||||
} |
||||
|
||||
@Override |
||||
protected MobileCollapsedStyle updateDiffBean() { |
||||
return new MobileFormCollapsedStyle(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,125 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.gui.ibutton.ModeButtonGroup; |
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.layout.VerticalFlowLayout; |
||||
import com.fr.design.mainframe.widget.UITitleSplitLine; |
||||
import com.fr.design.style.color.NewColorSelectBox; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.form.ui.mobile.CollapseState; |
||||
import com.fr.form.ui.mobile.MobileChartCollapsedStyle; |
||||
import com.fr.form.ui.mobile.MobileCollapsedStyle; |
||||
|
||||
import javax.swing.JPanel; |
||||
import javax.swing.border.TitledBorder; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/2/13 |
||||
*/ |
||||
public class MobileCollapsedStylePane extends BasicBeanPane<MobileCollapsedStyle> { |
||||
|
||||
private UICheckBox showButtonCheck; |
||||
private NewColorSelectBox buttonColorBox; |
||||
private UITextField foldedTextFiled; |
||||
private UITextField unfoldedTextFiled; |
||||
private ModeButtonGroup<CollapseState> buttonGroup; |
||||
|
||||
|
||||
public MobileCollapsedStylePane() { |
||||
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null); |
||||
VerticalFlowLayout layout = new VerticalFlowLayout(FlowLayout.LEADING, 0, 10); |
||||
layout.setAlignLeft(true); |
||||
this.setBorder(titledBorder); |
||||
this.setLayout(layout); |
||||
this.add(createLinePane()); |
||||
this.add(createSettingPane()); |
||||
} |
||||
|
||||
private JPanel createSettingPane() { |
||||
JPanel settingPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button"), 520); |
||||
splitLine.setPreferredSize(new Dimension(520, 20)); |
||||
UILabel showButtonLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button")); |
||||
showButtonCheck = new UICheckBox(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button_On_Right")); |
||||
UILabel buttonColorLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button_Color")); |
||||
buttonColorBox = new NewColorSelectBox(137); |
||||
UILabel foldedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Folded_Hint")); |
||||
foldedTextFiled = new UITextField(); |
||||
UILabel unfoldedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_UnFolded_Hint")); |
||||
unfoldedTextFiled = new UITextField(); |
||||
UILabel defaultStateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Default_State")); |
||||
buttonGroup = new ModeButtonGroup<>(); |
||||
UIRadioButton foldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Fold")); |
||||
foldedButton.setSelected(true); |
||||
UIRadioButton unfoldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Unfold")); |
||||
buttonGroup.put(CollapseState.FOLDED, foldedButton); |
||||
buttonGroup.put(CollapseState.UNFOLDED, unfoldedButton); |
||||
JPanel flowLeftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); |
||||
flowLeftPane.add(foldedButton); |
||||
flowLeftPane.add(unfoldedButton); |
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p, p, p, p, p}; |
||||
double[] colSize = {p, f}; |
||||
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; |
||||
Component[][] components = new Component[][] { |
||||
new Component[] {showButtonLabel, showButtonCheck}, |
||||
new Component[] {buttonColorLabel, buttonColorBox}, |
||||
new Component[] {foldedLabel, foldedTextFiled}, |
||||
new Component[] {unfoldedLabel, unfoldedTextFiled}, |
||||
new Component[] {defaultStateLabel, flowLeftPane}, |
||||
}; |
||||
JPanel buttonPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, colSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); |
||||
settingPane.add(splitLine, BorderLayout.NORTH); |
||||
settingPane.add(buttonPane, BorderLayout.CENTER); |
||||
return settingPane; |
||||
} |
||||
|
||||
protected JPanel createLinePane() { |
||||
return FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MobileCollapsedStyle ob) { |
||||
showButtonCheck.setSelected(ob.getCollapseButton().isShowButton()); |
||||
buttonColorBox.setSelectObject(ob.getCollapseButton().getButtonColor()); |
||||
foldedTextFiled.setText(ob.getCollapseButton().getFoldedHint()); |
||||
unfoldedTextFiled.setText(ob.getCollapseButton().getUnfoldedHint()); |
||||
buttonGroup.setSelectButton(ob.getCollapseButton().getDefaultState()); |
||||
} |
||||
|
||||
@Override |
||||
public MobileCollapsedStyle updateBean() { |
||||
MobileCollapsedStyle style = updateDiffBean(); |
||||
style.getCollapseButton().setShowButton(showButtonCheck.isSelected()); |
||||
style.getCollapseButton().setButtonColor(buttonColorBox.getSelectObject()); |
||||
style.getCollapseButton().setFoldedHint(foldedTextFiled.getText()); |
||||
style.getCollapseButton().setUnfoldedHint(unfoldedTextFiled.getText()); |
||||
style.getCollapseButton().setDefaultState(buttonGroup.getCurrentSelected()); |
||||
return style; |
||||
} |
||||
|
||||
protected MobileCollapsedStyle updateDiffBean() { |
||||
return new MobileChartCollapsedStyle(); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Mobile_Collapse_Expand"); |
||||
} |
||||
} |
@ -0,0 +1,100 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.form.ui.mobile.MobileCollapsedStyle; |
||||
import com.fr.general.ComparatorUtils; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/2/13 |
||||
*/ |
||||
public class MobileComboBoxDialogEditor extends BasicPane { |
||||
|
||||
private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400); |
||||
private static final Dimension COMBOX_DIMENSION = new Dimension(135,20); |
||||
private static final String NONE = Toolkit.i18nText("无"); |
||||
private static final String CUSTOM = Toolkit.i18nText("自定义"); |
||||
|
||||
|
||||
private MobileCollapsedStyle style; |
||||
private MobileCollapsedStylePane stylePane; |
||||
private UIComboBox comboBox; |
||||
private ActionListener listener; |
||||
|
||||
public MobileComboBoxDialogEditor(MobileCollapsedStylePane stylePane) { |
||||
this.stylePane = stylePane; |
||||
this.comboBox = new UIComboBox(new Object[] {NONE, CUSTOM}); |
||||
this.comboBox.setPreferredSize(COMBOX_DIMENSION); |
||||
this.comboBox.setSelectedItem(NONE); |
||||
listener = new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
if (ComparatorUtils.equals(MobileComboBoxDialogEditor.this.comboBox.getSelectedItem(), CUSTOM)) { |
||||
showEditorPane(); |
||||
} |
||||
} |
||||
}; |
||||
this.comboBox.addActionListener(listener); |
||||
this.add(comboBox); |
||||
|
||||
} |
||||
|
||||
public boolean isSelectedCustom() { |
||||
return ComparatorUtils.equals(CUSTOM, this.comboBox.getSelectedItem()); |
||||
} |
||||
|
||||
public void setSelected(boolean selectedCustom) { |
||||
this.comboBox.removeActionListener(listener); |
||||
this.comboBox.setSelectedItem(selectedCustom ? CUSTOM : NONE); |
||||
this.comboBox.addActionListener(listener); |
||||
} |
||||
|
||||
private void showEditorPane() { |
||||
stylePane.setPreferredSize(DEFAULT_DIMENSION); |
||||
BasicDialog dialog = stylePane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||
dialog.addDialogActionListener(new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
MobileCollapsedStyle style = stylePane.updateBean(); |
||||
style.setCollapsedWork(true); |
||||
setStyle(style); |
||||
MobileComboBoxDialogEditor.this.firePropertyChanged(); |
||||
} |
||||
}); |
||||
stylePane.populateBean(getStyle()); |
||||
dialog.setVisible(true); |
||||
} |
||||
|
||||
|
||||
protected void firePropertyChanged() { |
||||
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); |
||||
} |
||||
|
||||
public MobileCollapsedStyle getStyle() { |
||||
return style; |
||||
} |
||||
|
||||
public void setStyle(MobileCollapsedStyle style) { |
||||
this.style = style; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
Loading…
Reference in new issue