forked from fanruan/design
Harrison
5 years ago
16 changed files with 695 additions and 12 deletions
@ -0,0 +1,34 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.form.ui.mobile.MobileBookMarkStyle; |
||||
import com.fr.stable.fun.mark.Mutable; |
||||
|
||||
/** |
||||
* 移动端书签样式扩展接口 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2019/12/23 |
||||
*/ |
||||
public interface MobileBookMarkStyleProvider extends Mutable { |
||||
|
||||
String XML_TAG = "MobileBookMarkStyleProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* 书签样式 |
||||
* @return |
||||
*/ |
||||
Class<? extends MobileBookMarkStyle> classForMobileBookMarkStyle(); |
||||
|
||||
/** |
||||
* 书签样式面板 |
||||
* @return |
||||
*/ |
||||
Class<? extends BasicBeanPane<MobileBookMarkStyle>> classForMobileBookMarkStyleAppearance(); |
||||
|
||||
String displayName(); |
||||
|
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.MobileBookMarkStyleProvider; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2019/12/24 |
||||
*/ |
||||
@API(level = MobileBookMarkStyleProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractMobileBookMarkStyleProvider extends AbstractProvider implements MobileBookMarkStyleProvider { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String mark4Provider() { |
||||
return getClass().getName(); |
||||
} |
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.form.ui.mobile.MobileBookMarkStyle; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2019/12/24 |
||||
*/ |
||||
public class DefaultMobileBookMarkStyleCustomDefinePane extends BasicBeanPane<MobileBookMarkStyle> { |
||||
|
||||
@Override |
||||
public void populateBean(MobileBookMarkStyle ob) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public MobileBookMarkStyle updateBean() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.impl.AbstractMobileBookMarkStyleProvider; |
||||
import com.fr.form.ui.mobile.impl.DefaultMobileBookMarkStyle; |
||||
import com.fr.form.ui.mobile.MobileBookMarkStyle; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2019/12/24 |
||||
*/ |
||||
public class DefaultMobileBookMarkStyleProvider extends AbstractMobileBookMarkStyleProvider { |
||||
|
||||
@Override |
||||
public Class<? extends MobileBookMarkStyle> classForMobileBookMarkStyle() { |
||||
return DefaultMobileBookMarkStyle.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BasicBeanPane<MobileBookMarkStyle>> classForMobileBookMarkStyleAppearance() { |
||||
return DefaultMobileBookMarkStyleCustomDefinePane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String displayName() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"); |
||||
} |
||||
} |
@ -0,0 +1,57 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.MobileBookMarkStyleProvider; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.form.ui.mobile.MobileBookMarkStyle; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.invoke.Reflect; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2019/12/23 |
||||
*/ |
||||
public class MobileBookMarkStyleDefinePane extends BasicBeanPane<MobileBookMarkStyle> { |
||||
|
||||
private BasicBeanPane<MobileBookMarkStyle> customDefinePane; |
||||
private String displayName; |
||||
|
||||
MobileBookMarkStyleDefinePane(MobileBookMarkStyleProvider bookMarkStyleProvider) { |
||||
this.customDefinePane = Reflect.on( |
||||
bookMarkStyleProvider.classForMobileBookMarkStyleAppearance()).create().get(); |
||||
this.displayName = bookMarkStyleProvider.displayName(); |
||||
initComponent(); |
||||
} |
||||
|
||||
private void initComponent() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
JPanel settingPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
if (!ComparatorUtils.equals(displayName, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"))) { |
||||
UILabel hintLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Hint")); |
||||
hintLabel.setForeground(Color.GRAY); |
||||
settingPane.add(hintLabel, BorderLayout.NORTH); |
||||
} |
||||
settingPane.add(this.customDefinePane, BorderLayout.CENTER); |
||||
this.add(settingPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MobileBookMarkStyle ob) { |
||||
this.customDefinePane.populateBean(ob); |
||||
} |
||||
|
||||
@Override |
||||
public MobileBookMarkStyle updateBean() { |
||||
return this.customDefinePane.updateBean(); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "MobileBookMarkStyleDefinePane"; |
||||
} |
||||
} |
@ -0,0 +1,136 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.MobileBookMarkStyleProvider; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.form.ui.mobile.MobileBookMarkStyle; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2019/12/23 |
||||
*/ |
||||
public class MobileBookMarkStylePane extends BasicBeanPane<MobileBookMarkStyle> { |
||||
|
||||
public static ListCellRenderer renderer = new DefaultListCellRenderer() { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, |
||||
boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
if (value instanceof MobileBookMarkStyle) { |
||||
this.setText((value.toString())); |
||||
} |
||||
return this; |
||||
} |
||||
}; |
||||
|
||||
private DefaultListModel<String> listModel; |
||||
private JList bookMarkList; |
||||
private JPanel rightPane; |
||||
private CardLayout card; |
||||
private Map<String, BasicBeanPane<MobileBookMarkStyle>> map = new HashMap<>(); |
||||
|
||||
public MobileBookMarkStylePane() { |
||||
initComponent(); |
||||
} |
||||
|
||||
private void initComponent() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.listModel = new DefaultListModel<>(); |
||||
this.card = new CardLayout(); |
||||
this.rightPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||
this.rightPane.setLayout(card); |
||||
initDefaultAndExtraPanel(); |
||||
initLeftListPanel(); |
||||
initRightPanel(); |
||||
} |
||||
|
||||
private void initDefaultAndExtraPanel() { |
||||
List<MobileBookMarkStyleProvider> list = getMobileBookMarkStyleProvider(); |
||||
for (MobileBookMarkStyleProvider bookMarkStyleProvider : list) { |
||||
String displayName = bookMarkStyleProvider.displayName(); |
||||
MobileBookMarkStyleDefinePane mobileBookMarkStyleDefinePane = new MobileBookMarkStyleDefinePane( |
||||
bookMarkStyleProvider); |
||||
listModel.addElement(displayName); |
||||
rightPane.add(displayName, mobileBookMarkStyleDefinePane); |
||||
map.put(displayName, mobileBookMarkStyleDefinePane); |
||||
} |
||||
} |
||||
|
||||
private void initLeftListPanel() { |
||||
bookMarkList = new JList<>(listModel); |
||||
bookMarkList.setCellRenderer(renderer); |
||||
bookMarkList.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
card.show(rightPane, (String) bookMarkList.getSelectedValue()); |
||||
} |
||||
}); |
||||
JPanel leftPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
leftPanel.add(bookMarkList, BorderLayout.CENTER); |
||||
leftPanel.setPreferredSize(new Dimension(100, 500)); |
||||
this.add(leftPanel, BorderLayout.WEST); |
||||
} |
||||
|
||||
private void initRightPanel() { |
||||
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
centerPane.setPreferredSize(new Dimension(500, 500)); |
||||
centerPane.add(rightPane, BorderLayout.CENTER); |
||||
this.add(centerPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
|
||||
private List<MobileBookMarkStyleProvider> getMobileBookMarkStyleProvider() { |
||||
DefaultMobileBookMarkStyleProvider defaultMobileBookMarkStyleProvider = new DefaultMobileBookMarkStyleProvider(); |
||||
Set<MobileBookMarkStyleProvider> mobileBookMarkStyleProviders = ExtraDesignClassManager.getInstance().getArray( |
||||
MobileBookMarkStyleProvider.XML_TAG); |
||||
List<MobileBookMarkStyleProvider> list = new ArrayList<>(); |
||||
list.add(defaultMobileBookMarkStyleProvider); |
||||
list.addAll(mobileBookMarkStyleProviders); |
||||
return Collections.unmodifiableList(list); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void populateBean(MobileBookMarkStyle mobileBookMarkStyle) { |
||||
if (mobileBookMarkStyle != null) { |
||||
List<MobileBookMarkStyleProvider> bookMarkStyleProviders = getMobileBookMarkStyleProvider(); |
||||
int i = 0; |
||||
for (MobileBookMarkStyleProvider bookMarkStyleProvider : bookMarkStyleProviders) { |
||||
if (mobileBookMarkStyle.getClass() == bookMarkStyleProvider.classForMobileBookMarkStyle()) { |
||||
String displayName = bookMarkStyleProvider.displayName(); |
||||
bookMarkList.setSelectedIndex(i); |
||||
map.get(displayName).populateBean(mobileBookMarkStyle); |
||||
card.show(rightPane, displayName); |
||||
return; |
||||
} |
||||
i++; |
||||
} |
||||
} |
||||
bookMarkList.setSelectedIndex(0); |
||||
} |
||||
|
||||
@Override |
||||
public MobileBookMarkStyle updateBean() { |
||||
return map.get(bookMarkList.getSelectedValue()).updateBean(); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.design.mainframe.widget.wrappers; |
||||
|
||||
import com.fr.design.Exception.ValidationException; |
||||
import com.fr.design.designer.properties.Decoder; |
||||
import com.fr.design.designer.properties.Encoder; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2019/12/24 |
||||
*/ |
||||
public class MobileBookMarkStyleWrapper implements Encoder, Decoder { |
||||
@Override |
||||
public Object decode(String txt) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void validate(String txt) throws ValidationException { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public String encode(Object v) { |
||||
if (v == null) { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"); |
||||
} |
||||
return v.toString(); |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; |
||||
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||
import com.fr.design.widget.ui.designer.mobile.MobileAdvanceDefinePane; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2019/12/24 |
||||
*/ |
||||
public class MobileBookMarkPropertyUI extends AbstractWidgetPropertyUIProvider { |
||||
|
||||
private XCreator xCreator; |
||||
|
||||
public MobileBookMarkPropertyUI(XCreator xCreator) { |
||||
this.xCreator = xCreator; |
||||
} |
||||
|
||||
@Override |
||||
public AbstractPropertyTable createWidgetAttrTable() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public BasicPane createWidgetAttrPane() { |
||||
return new MobileAdvanceDefinePane(xCreator); |
||||
} |
||||
|
||||
@Override |
||||
public String tableTitle() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr"); |
||||
} |
||||
} |
@ -0,0 +1,167 @@
|
||||
package com.fr.design.widget.ui.designer.mobile; |
||||
|
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
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.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.WidgetPropertyPane; |
||||
import com.fr.form.main.Form; |
||||
import com.fr.form.ui.FormWidgetHelper; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.form.ui.container.WLayout; |
||||
import com.fr.form.ui.container.WSortLayout; |
||||
import com.fr.form.ui.mobile.MobileBookMark; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.*; |
||||
import java.awt.event.FocusAdapter; |
||||
import java.awt.event.FocusEvent; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
import java.util.Iterator; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2019/12/24 |
||||
*/ |
||||
public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { |
||||
|
||||
private XCreator xCreator; |
||||
private UICheckBox useBookMarkCheck; |
||||
private UITextField bookMarkNameField; |
||||
|
||||
public MobileAdvanceDefinePane(XCreator xCreator) { |
||||
this.xCreator = xCreator; |
||||
} |
||||
|
||||
@Override |
||||
public void initPropertyGroups(Object source) { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
this.useBookMarkCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Use_BookMark")); |
||||
this.bookMarkNameField = new UITextField() { |
||||
@Override |
||||
protected void initListener() { |
||||
if (shouldResponseChangeListener()) { |
||||
addFocusListener(new FocusAdapter() { |
||||
@Override |
||||
public void focusLost(FocusEvent e) { |
||||
attributeChange(); |
||||
} |
||||
}); |
||||
addKeyListener(new KeyAdapter() { |
||||
@Override |
||||
public void keyTyped(KeyEvent e) { |
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
||||
attributeChange(); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
}; |
||||
JPanel useBookMarkPane = TableLayoutHelper.createGapTableLayoutPane( |
||||
new Component[][]{new Component[]{useBookMarkCheck}}, |
||||
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE); |
||||
final JPanel bookMarkNamePane = TableLayoutHelper.createGapTableLayoutPane( |
||||
new Component[][]{new Component[]{new UILabel( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Name")), bookMarkNameField}}, |
||||
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE); |
||||
this.useBookMarkCheck.addChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
bookMarkNamePane.setVisible(MobileAdvanceDefinePane.this.useBookMarkCheck.isSelected()); |
||||
} |
||||
}); |
||||
contentPane.add(useBookMarkPane, BorderLayout.NORTH); |
||||
contentPane.add(bookMarkNamePane, BorderLayout.CENTER); |
||||
UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark"), 280, 20, contentPane); |
||||
JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
wrapPane.add(uiExpandablePane, BorderLayout.NORTH); |
||||
this.add(wrapPane, BorderLayout.NORTH); |
||||
} |
||||
|
||||
private void bindListeners2Widgets() { |
||||
reInitAllListeners(); |
||||
AttributeChangeListener changeListener = new AttributeChangeListener() { |
||||
@Override |
||||
public void attributeChange() { |
||||
update(); |
||||
} |
||||
}; |
||||
this.addAttributeChangeListener(changeListener); |
||||
} |
||||
|
||||
private void reInitAllListeners() { |
||||
initListener(this); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(super.getPreferredSize().width, 80); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getMaximumSize() { |
||||
return new Dimension(400, 200); |
||||
} |
||||
|
||||
@Override |
||||
public void populate(FormDesigner designer) { |
||||
MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); |
||||
this.bookMarkNameField.setText(bookMark.getBookMarkName()); |
||||
if (bookMark.isFrozen()) { |
||||
this.useBookMarkCheck.setSelected(false); |
||||
this.useBookMarkCheck.setEnabled(false); |
||||
} else { |
||||
this.useBookMarkCheck.setSelected(bookMark.isUseBookMark()); |
||||
} |
||||
this.bindListeners2Widgets(); |
||||
} |
||||
|
||||
@Override |
||||
public void update() { |
||||
MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); |
||||
bookMark.setUseBookMark(this.useBookMarkCheck.isSelected()); |
||||
String newBookMarkName = this.bookMarkNameField.getText(); |
||||
if (!isExist(newBookMarkName)) { |
||||
bookMark.setBookMarkName(newBookMarkName); |
||||
} else { |
||||
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Rename_Failure"), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), |
||||
JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); |
||||
this.bookMarkNameField.setText(bookMark.getBookMarkName()); |
||||
} |
||||
} |
||||
|
||||
private boolean isExist(String name) { |
||||
Form form = WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); |
||||
WLayout container = form.getContainer(); |
||||
WSortLayout wSortLayout = (WSortLayout) container.getWidget(container.getWidgetCount() - 1); |
||||
Iterator<String> iterator = wSortLayout.getMobileWidgetIterator(); |
||||
while (iterator.hasNext()) { |
||||
Widget widget = form.getWidgetByName(iterator.next()); |
||||
if (widget != null && ComparatorUtils.equals(widget.getMobileBookMark().getBookMarkName(), name)) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,117 @@
|
||||
package com.fr.design.widget.ui.designer.mobile.component; |
||||
|
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.WidgetPropertyPane; |
||||
import com.fr.design.mainframe.mobile.ui.MobileBookMarkStylePane; |
||||
import com.fr.design.mainframe.widget.accessibles.UneditableAccessibleEditor; |
||||
import com.fr.design.mainframe.widget.wrappers.MobileBookMarkStyleWrapper; |
||||
import com.fr.form.ui.container.WSortLayout; |
||||
import com.fr.form.ui.mobile.MobileBookMarkStyle; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2019/12/18 |
||||
*/ |
||||
public class MobileBookMarkSettingPane extends BasicPane { |
||||
|
||||
private AccessibleMobileBookMarkStyleEditor mobileBookMarkStyleEditor; |
||||
private UICheckBox showHierarchicalBookmarksCheck; |
||||
|
||||
public MobileBookMarkSettingPane() { |
||||
initComponent(); |
||||
} |
||||
|
||||
private void initComponent() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.mobileBookMarkStyleEditor = new AccessibleMobileBookMarkStyleEditor(new MobileBookMarkStylePane()); |
||||
this.showHierarchicalBookmarksCheck = new UICheckBox( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Show_BookMark")); |
||||
JPanel booKMarkPane = TableLayoutHelper.createGapTableLayoutPane( |
||||
new Component[][]{new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText( |
||||
"Fine-Design_Mobile_BookMark_Style")), this.mobileBookMarkStyleEditor}}, |
||||
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE |
||||
); |
||||
UILabel hintLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Show_BookMark_Hint")); |
||||
hintLabel.setForeground(Color.GRAY); |
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p, p}; |
||||
double[] columnSize = {f}; |
||||
int[][] rowCount = {{1}, {1}}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{this.showHierarchicalBookmarksCheck}, |
||||
new Component[]{hintLabel} |
||||
}; |
||||
JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
JPanel showBookMarkPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, |
||||
IntervalConstants.INTERVAL_L1, |
||||
IntervalConstants.INTERVAL_L1); |
||||
showBookMarkPane.setBorder( |
||||
BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); |
||||
wrapPane.add(booKMarkPane, BorderLayout.NORTH); |
||||
wrapPane.add(showBookMarkPane, BorderLayout.CENTER); |
||||
this.add(wrapPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "MobileBookMarkSettingPane"; |
||||
} |
||||
|
||||
public void populate(XCreator xCreator) { |
||||
WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); |
||||
this.mobileBookMarkStyleEditor.setValue(wSortLayout.getMobileBookMarkStyle()); |
||||
this.showHierarchicalBookmarksCheck.setSelected(wSortLayout.isShowBookmarks()); |
||||
} |
||||
|
||||
public void update(XCreator xCreator) { |
||||
WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); |
||||
wSortLayout.setMobileBookMarkStyle((MobileBookMarkStyle) mobileBookMarkStyleEditor.getValue()); |
||||
wSortLayout.setShowBookmarks(showHierarchicalBookmarksCheck.isSelected()); |
||||
} |
||||
|
||||
|
||||
class AccessibleMobileBookMarkStyleEditor extends UneditableAccessibleEditor { |
||||
|
||||
private MobileBookMarkStylePane mobileBookMarkStylePane; |
||||
|
||||
public AccessibleMobileBookMarkStyleEditor(MobileBookMarkStylePane mobileBookMarkStylePane) { |
||||
super(new MobileBookMarkStyleWrapper()); |
||||
this.mobileBookMarkStylePane = mobileBookMarkStylePane; |
||||
} |
||||
|
||||
@Override |
||||
public void showEditorPane() { |
||||
mobileBookMarkStylePane.setPreferredSize(BasicDialog.MEDIUM); |
||||
BasicDialog dialog = mobileBookMarkStylePane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||
dialog.addDialogActionListener(new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
MobileBookMarkStyle mobileBookMarkStyle = mobileBookMarkStylePane.updateBean(); |
||||
WSortLayout wSortLayout = (WSortLayout) WidgetPropertyPane.getInstance().getEditingFormDesigner().getSelectionModel().getSelection().getSelectedCreator().toData(); |
||||
setValue(mobileBookMarkStyle); |
||||
wSortLayout.setMobileBookMarkStyle(mobileBookMarkStyle); |
||||
fireStateChanged(); |
||||
} |
||||
}); |
||||
mobileBookMarkStylePane.populateBean((MobileBookMarkStyle) getValue()); |
||||
dialog.setVisible(true); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue