forked from fanruan/design
neil
9 years ago
16 changed files with 508 additions and 18 deletions
@ -0,0 +1,74 @@
|
||||
package com.fr.design.actions.report; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.JWorkBookAction; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.JWorkBook; |
||||
import com.fr.design.menu.MenuKeySet; |
||||
import com.fr.design.report.mobile.ReportMobileAttrPane; |
||||
import com.fr.general.Inter; |
||||
import com.fr.main.TemplateWorkBook; |
||||
import com.fr.report.mobile.ElementCaseMobileAttr; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* 设置cpt在移动端的一些属性, 包括自适应以及以后可能加展示区域之类的东西. |
||||
* |
||||
* Created by Administrator on 2016/5/12/0012. |
||||
*/ |
||||
public class ReportMobileAttrAction extends JWorkBookAction{ |
||||
|
||||
public ReportMobileAttrAction(JWorkBook jwb) { |
||||
super(jwb); |
||||
this.setMenuKeySet(REPORT_APP_ATTR); |
||||
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/mobile.png")); |
||||
} |
||||
|
||||
/** |
||||
* 执行动作 |
||||
* |
||||
* @return 是否执行成功 |
||||
*/ |
||||
public void actionPerformed(ActionEvent evt) { |
||||
final JWorkBook jwb = getEditingComponent(); |
||||
if (jwb == null) { |
||||
return; |
||||
} |
||||
final TemplateWorkBook wbTpl = jwb.getTarget(); |
||||
ElementCaseMobileAttr mobileAttr = wbTpl.getReportMobileAttr(); |
||||
|
||||
final ReportMobileAttrPane mobileAttrPane = new ReportMobileAttrPane(); |
||||
mobileAttrPane.populateBean(mobileAttr); |
||||
BasicDialog dialog = mobileAttrPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
wbTpl.setReportMobileAttr(mobileAttrPane.updateBean()); |
||||
jwb.fireTargetModified(); |
||||
} |
||||
}); |
||||
dialog.setVisible(true); |
||||
} |
||||
|
||||
private static final MenuKeySet REPORT_APP_ATTR = new MenuKeySet() { |
||||
@Override |
||||
public char getMnemonic() { |
||||
return 'P'; |
||||
} |
||||
|
||||
@Override |
||||
public String getMenuName() { |
||||
return Inter.getLocText("FR-Designer_Mobile-Attr"); |
||||
} |
||||
|
||||
@Override |
||||
public KeyStroke getKeyStroke() { |
||||
return null; |
||||
} |
||||
}; |
||||
} |
@ -0,0 +1,118 @@
|
||||
package com.fr.design.report.mobile; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.base.mobile.MobileFitAttrState; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by Administrator on 2016/5/16/0016. |
||||
*/ |
||||
public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ |
||||
|
||||
private List<UIRadioButton> radioButtons = new ArrayList<UIRadioButton>(); |
||||
|
||||
public MobileRadioGroupPane(String title) { |
||||
initComponents(title); |
||||
} |
||||
|
||||
private void initComponents(String title) { |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p}; |
||||
double[] columnSize = {p, p, p, p, p}; |
||||
|
||||
UIRadioButton defaultRadio = new UIRadioButton(MobileFitAttrState.DEFAULT.description()); |
||||
defaultRadio.setSelected(true); |
||||
UIRadioButton horizonRadio = new UIRadioButton(MobileFitAttrState.HORIZONTAL.description()); |
||||
UIRadioButton verticalRadio = new UIRadioButton(MobileFitAttrState.VERTICAL.description()); |
||||
UIRadioButton notFitRadio = new UIRadioButton(MobileFitAttrState.NONE.description()); |
||||
|
||||
addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio); |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(title), defaultRadio, horizonRadio, verticalRadio, notFitRadio} |
||||
}; |
||||
JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10)); |
||||
|
||||
this.add(fitOpsPane); |
||||
} |
||||
|
||||
private void addToButtonGroup(UIRadioButton... radios) { |
||||
ButtonGroup buttonGroup = new ButtonGroup(); |
||||
for (UIRadioButton radio : radios) { |
||||
radioButtons.add(radio); |
||||
buttonGroup.add(radio); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置按钮状态 |
||||
*/ |
||||
public void setEnabled(boolean enabled) { |
||||
for (UIRadioButton radioButton : radioButtons) { |
||||
radioButton.setEnabled(enabled); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取当前选中的按钮index |
||||
* |
||||
* @return 按钮index |
||||
*/ |
||||
public int getSelectRadioIndex() { |
||||
for (int i = 0, len = radioButtons.size(); i < len; i++) { |
||||
if (radioButtons.get(i).isSelected()) { |
||||
return i; |
||||
} |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
/** |
||||
* 选中指定index的按钮 |
||||
*/ |
||||
public void selectIndexButton(int index) { |
||||
if (index < 0 || index > radioButtons.size() - 1) { |
||||
return; |
||||
} |
||||
|
||||
UIRadioButton button = radioButtons.get(index); |
||||
button.setSelected(true); |
||||
} |
||||
|
||||
/** |
||||
* 给所有的按钮加上监听 |
||||
*/ |
||||
public void addActionListener(ActionListener actionListener) { |
||||
for (UIRadioButton radioButton : radioButtons) { |
||||
radioButton.addActionListener(actionListener); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MobileFitAttrState ob) { |
||||
selectIndexButton(ob.getState()); |
||||
} |
||||
|
||||
@Override |
||||
public MobileFitAttrState updateBean() { |
||||
int index = getSelectRadioIndex(); |
||||
return MobileFitAttrState.parse(index); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
} |
@ -0,0 +1,62 @@
|
||||
package com.fr.design.report.mobile; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.general.Inter; |
||||
import com.fr.report.mobile.ElementCaseMobileAttr; |
||||
import com.fr.base.mobile.MobileFitAttrState; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* Created by Administrator on 2016/5/12/0012. |
||||
*/ |
||||
public class ReportMobileAttrPane extends BasicBeanPane<ElementCaseMobileAttr>{ |
||||
|
||||
//横屏设置面板
|
||||
private MobileRadioGroupPane horizionPane; |
||||
//竖屏设置面板
|
||||
private MobileRadioGroupPane verticalPane; |
||||
|
||||
public ReportMobileAttrPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
JPanel borderPane = FRGUIPaneFactory.createTitledBorderPane(this.title4PopupWindow()); |
||||
|
||||
JPanel fitOpsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
horizionPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Horizontal")); |
||||
verticalPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Vertical")); |
||||
fitOpsPane.add(horizionPane, BorderLayout.NORTH); |
||||
fitOpsPane.add(verticalPane, BorderLayout.SOUTH); |
||||
|
||||
borderPane.add(fitOpsPane); |
||||
this.add(borderPane); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(ElementCaseMobileAttr ob) { |
||||
if (ob == null) { |
||||
ob = new ElementCaseMobileAttr(); |
||||
} |
||||
|
||||
horizionPane.populateBean(ob.getHorziontalAttr()); |
||||
verticalPane.populateBean(ob.getVerticalAttr()); |
||||
} |
||||
|
||||
@Override |
||||
public ElementCaseMobileAttr updateBean() { |
||||
MobileFitAttrState horizonState = horizionPane.updateBean(); |
||||
MobileFitAttrState verticalState = verticalPane.updateBean(); |
||||
|
||||
return new ElementCaseMobileAttr(horizonState, verticalState); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Designer_Fit-App"); |
||||
} |
||||
} |
After Width: | Height: | Size: 928 B |
@ -0,0 +1,68 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.form.util.XCreatorConstants; |
||||
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||
import com.fr.design.gui.itable.PropertyGroup; |
||||
import com.fr.design.gui.xtable.PropertyGroupModel; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.WidgetPropertyPane; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.table.TableModel; |
||||
import java.beans.IntrospectionException; |
||||
import java.util.ArrayList; |
||||
|
||||
/** |
||||
* Created by Administrator on 2016/5/16/0016. |
||||
*/ |
||||
public class ElementCasePropertyTable extends AbstractPropertyTable{ |
||||
|
||||
private XCreator xCreator; |
||||
private FormDesigner designer; |
||||
|
||||
public ElementCasePropertyTable(XCreator xCreator) { |
||||
this.xCreator = xCreator; |
||||
} |
||||
|
||||
@Override |
||||
public void initPropertyGroups(Object source) { |
||||
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||
|
||||
groups = new ArrayList<PropertyGroup>(); |
||||
CRPropertyDescriptor[] propertyTableEditor = null; |
||||
try { |
||||
propertyTableEditor = new CRPropertyDescriptor[]{ |
||||
new CRPropertyDescriptor("horziontalAttr", this.xCreator.toData().getClass()).setEditorClass(MobileFitEditor.class) |
||||
.setRendererClass(MobileFitRender.class) |
||||
.setI18NName(Inter.getLocText("FR-Designer_Mobile-Horizontal")) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, Inter.getLocText("FR-Designer_Fit-App")), |
||||
new CRPropertyDescriptor("verticalAttr", this.xCreator.toData().getClass()).setEditorClass(MobileFitEditor.class) |
||||
.setRendererClass(MobileFitRender.class) |
||||
.setI18NName(Inter.getLocText("FR-Designer_Mobile-Vertical")) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, Inter.getLocText("FR-Designer_Fit-App")) |
||||
|
||||
}; |
||||
} catch (IntrospectionException e) { |
||||
FRContext.getLogger().error(e.getMessage()); |
||||
} |
||||
|
||||
|
||||
groups.add(new PropertyGroup(new PropertyGroupModel(Inter.getLocText("FR-Designer_Fit-App"), xCreator, propertyTableEditor, designer))); |
||||
|
||||
TableModel model = new BeanTableModel(); |
||||
setModel(model); |
||||
this.repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public void firePropertyEdit() { |
||||
} |
||||
|
||||
public void populate(FormDesigner designer) { |
||||
this.designer = designer; |
||||
initPropertyGroups(this.designer.getTarget()); |
||||
} |
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.designer.creator.XElementCase; |
||||
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; |
||||
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||
import com.fr.general.Inter; |
||||
|
||||
/** |
||||
* Created by Administrator on 2016/5/16/0016. |
||||
*/ |
||||
public class ElementCasePropertyUI extends AbstractWidgetPropertyUIProvider{ |
||||
|
||||
private XCreator xCreator; |
||||
|
||||
public ElementCasePropertyUI(XElementCase xElementCase) { |
||||
this.xCreator = xElementCase; |
||||
} |
||||
|
||||
@Override |
||||
public AbstractPropertyTable createWidgetAttrTable() { |
||||
return new ElementCasePropertyTable(xCreator); |
||||
} |
||||
|
||||
@Override |
||||
public String tableTitle() { |
||||
return Inter.getLocText("FR-Designer_Mobile-Attr"); |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.base.mobile.MobileFitAttrState; |
||||
import com.fr.design.designer.properties.items.Item; |
||||
import com.fr.design.designer.properties.items.ItemProvider; |
||||
|
||||
public class MobileFitAlignmentItems implements ItemProvider{ |
||||
|
||||
private static Item[] VALUE_ITEMS; |
||||
|
||||
static { |
||||
MobileFitAttrState[] allStates = MobileFitAttrState.values(); |
||||
int len = allStates.length; |
||||
VALUE_ITEMS = new Item[len]; |
||||
for (int i = 0; i < len ; i++) { |
||||
VALUE_ITEMS[i] = new Item(allStates[i].description(), allStates[i]); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Item[] getItems() { |
||||
return VALUE_ITEMS; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.design.designer.properties.items.Item; |
||||
import com.fr.design.designer.properties.items.ItemProvider; |
||||
import com.fr.design.mainframe.widget.editors.ComboEditor; |
||||
|
||||
import java.util.Vector; |
||||
|
||||
public class MobileFitEditor extends ComboEditor{ |
||||
public MobileFitEditor() { |
||||
this(new MobileFitAlignmentItems()); |
||||
} |
||||
|
||||
public MobileFitEditor(ItemProvider provider) { |
||||
this(provider.getItems()); |
||||
} |
||||
|
||||
public MobileFitEditor(Item[] items) { |
||||
super(items); |
||||
} |
||||
|
||||
public MobileFitEditor(Vector<Item> items) { |
||||
super(items); |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(Object value) { |
||||
if (value == null) { |
||||
return; |
||||
} |
||||
|
||||
Item item = new Item(value.toString(), value); |
||||
comboBox.setSelectedItem(item); |
||||
} |
||||
|
||||
@Override |
||||
public Object getValue() { |
||||
Item item = (Item) comboBox.getSelectedItem(); |
||||
return item.getValue(); |
||||
} |
||||
|
||||
/** |
||||
* 是否立即刷新 |
||||
* @return 是或者否 |
||||
*/ |
||||
@Override |
||||
public boolean refreshInTime() { |
||||
return false; |
||||
} |
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; |
||||
|
||||
public class MobileFitRender extends EncoderCellRenderer{ |
||||
|
||||
public MobileFitRender(){ |
||||
super(new MobileFitWrapper()); |
||||
} |
||||
} |
@ -0,0 +1,9 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.design.designer.properties.ItemWrapper; |
||||
|
||||
public class MobileFitWrapper extends ItemWrapper{ |
||||
public MobileFitWrapper(){ |
||||
super(new MobileFitAlignmentItems()); |
||||
} |
||||
} |
Loading…
Reference in new issue