diff --git a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java index 0f1c50a5f..d8ae98bbc 100644 --- a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java +++ b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java @@ -1,7 +1,7 @@ package com.fr.design.editor.editor; -import com.fr.design.data.DesignTableDataManager; import com.fr.data.SimpleDSColumn; +import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.icombobox.UIComboBox; @@ -36,9 +36,13 @@ public class ColumnSelectedEditor extends Editor { @Override public void itemStateChanged(ItemEvent e) { - //这边需要重新初始化columnNames, 否则nameList长度和columnNames长度不同导致出錯。 - List nameList = tableDataComboBox.getSelectedItem().calculateColumnNameList(); - columnNames = new String[nameList.size()]; + TableDataWrapper tableDataWrapper = tableDataComboBox.getSelectedItem(); + if (tableDataWrapper == null) { + return; + } + //这边需要重新初始化columnNames, 否则nameList长度和columnNames长度不同导致出錯。 + List nameList = tableDataWrapper.calculateColumnNameList(); + columnNames = new String[nameList.size()]; columnNames = tableDataComboBox.getSelectedItem().calculateColumnNameList().toArray(columnNames); columnNameComboBox.removeAllItems(); for (int i = 0; i < columnNames.length; i++) { @@ -64,7 +68,7 @@ public class ColumnSelectedEditor extends Editor { dsColumn.setDsName(tableDataWrappe.getTableDataName()); TableDataColumn column; String columnExp = (String) this.columnNameComboBox.getSelectedItem(); - if (StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#")) { + if (StringUtils.isNotBlank(columnExp) && checkColumnExp(columnExp)) { String number = columnExp.substring(1); Pattern pattern = Pattern.compile("[^\\d]"); if (pattern.matcher(number).find()) { @@ -80,6 +84,10 @@ public class ColumnSelectedEditor extends Editor { return dsColumn; } + private boolean checkColumnExp (String columnExp) { + return (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#"); + } + public String getIconName() { return "ds_column"; } diff --git a/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java b/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java index 36a760b5b..f3fec1fba 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java +++ b/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.design.beans.BasicBeanPane; import com.fr.general.ComparatorUtils; import com.fr.general.NameObject; +import com.fr.js.JavaScript; import javax.swing.*; @@ -14,7 +15,7 @@ public abstract class AbstractNameableCreator implements NameableCreator { protected Class clazzOfObject; protected Class clazzOfInitCase; protected Class clazzOfEditor; - + public AbstractNameableCreator(String menuName, Class clazz, Class clazzOfEditor) { this.menuName = menuName; this.clazzOfObject = clazz; @@ -28,7 +29,7 @@ public abstract class AbstractNameableCreator implements NameableCreator { this.clazzOfObject = clazz; this.clazzOfInitCase = clazz; } - + public AbstractNameableCreator(String menuName, String iconPath, Class clazz, Class clazzOfEditor) { this.menuName = menuName; this.menuIcon = BaseUtils.readIcon(iconPath); @@ -36,7 +37,7 @@ public abstract class AbstractNameableCreator implements NameableCreator { this.clazzOfEditor = clazzOfEditor; this.clazzOfInitCase = clazz; } - + public AbstractNameableCreator(String menuName, String iconPath, Class clazz, Class clazz4Init, Class clazzOfEditor) { this.menuName = menuName; this.menuIcon = BaseUtils.readIcon(iconPath); @@ -50,7 +51,7 @@ public abstract class AbstractNameableCreator implements NameableCreator { * get menuName * @return */ - public String menuName() { + public String menuName() { return this.menuName; } @@ -70,6 +71,14 @@ public abstract class AbstractNameableCreator implements NameableCreator { return this.clazzOfEditor; } + /** + * get clazzOfObject + * @return clazzOfObject + */ + public Class getHyperlink() { + return this.clazzOfObject; + } + /** * * @param ob @@ -83,12 +92,12 @@ public abstract class AbstractNameableCreator implements NameableCreator { doSthChanged4Icon(ob); return ob; } - + return null; } protected void doSthChanged4Icon(Object ob){ - + } /** @@ -99,9 +108,9 @@ public abstract class AbstractNameableCreator implements NameableCreator { return null; } - public boolean isNeedParameterWhenPopulateJControlPane(){ - return false; - } + public boolean isNeedParameterWhenPopulateJControlPane(){ + return false; + } public boolean equals(Object obj) { return obj instanceof AbstractNameableCreator diff --git a/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java b/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java index f497be1e6..09d1833b1 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java +++ b/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java @@ -2,24 +2,27 @@ package com.fr.design.gui.controlpane; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilist.ListModelElement; +import com.fr.js.JavaScript; import com.fr.stable.Nameable; import javax.swing.*; public interface NameableCreator { public String menuName(); - + public Icon menuIcon(); - + public String createTooltip(); - + public Nameable createNameable(UnrepeatedNameHelper helper); - + public Class getUpdatePane(); - + + public Class getHyperlink(); + public Object acceptObject2Populate(Object ob); - + public void saveUpdatedBean(ListModelElement wrapper, Object bean); - public boolean isNeedParameterWhenPopulateJControlPane(); + public boolean isNeedParameterWhenPopulateJControlPane(); } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java index f1f1b3deb..a1207717b 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java @@ -1 +1,484 @@ -package com.fr.design.chart.series.PlotSeries; import com.fr.base.*; import com.fr.chart.base.MapSvgAttr; import com.fr.chart.base.MapSvgXMLHelper; import com.fr.chart.chartattr.MapPlot; import com.fr.chart.chartglyph.MapShapeValue; import com.fr.design.constants.UIConstants; import com.fr.design.DesignerEnvManager; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.SvgProvider; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.geom.RoundRectangle2D; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-29 * Time: 下午2:41 */ public class MapGroupExtensionPane extends BasicPane implements UIObserver { private static final String[] TYPE_NAMES = new String[]{ Inter.getLocText("FR-Chart-World_Map"), Inter.getLocText("FR-Chart-State_Map"), Inter.getLocText("FR-Chart-Province_Map"), Inter.getLocText("FR-Chart-Custom_Map")}; private static final int WORD = 0; private static final int NATION = 1; private static final int STATE = 2; private static final int USER = 3; private static final int OFFSET_X = 800; private static final int OFFSET_Y = 200; private UIGroupExtensionPane groupExtensionPane; private UIButton addButton; private JPopupMenu popupMenu; private ArrayList changeListeners = new ArrayList(); private boolean hasPopulated = false; @Override protected String title4PopupWindow() { return "Map"; } public MapGroupExtensionPane() { setLayout(new BorderLayout()); groupExtensionPane = new UIGroupExtensionPane(TYPE_NAMES){ /** * 新添加的数据的序号 * @param data 数据 */ protected void dealNewAddedDataIndex(Object data){ String newName = (String)data; MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance(); if(helper.getNewMapAttr(newName) != null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + newName + ".svg"); helper.addNewSvgMaps(attr.getName(), attr); } /** * 一次鼠标的点击会有两次事件响应(按下和释放)。前者的事件属性中getValueIsAdjusting()=true,后者是false。 * 是否响应list值改变 * @return 鼠标按下时不响应,先响应mousePress事件,在鼠标释放是再响应list值改编的事件,并且点击删除不触发更新,并且populate后触发更新 */ protected boolean isRespondToValueChange(ListSelectionEvent e){ return !e.getValueIsAdjusting() && !this.isPressOnDelete() && hasPopulated; } }; groupExtensionPane.addSelectionChangeListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { fireStateChange(); } }); groupExtensionPane.addItemEditListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { doEdit(event); } }); groupExtensionPane.addDeleteListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { //这么写有点问题 String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); saveMapInfo(oldName); } }); setPreferredSize(new Dimension(400, 210)); add(groupExtensionPane, BorderLayout.CENTER); addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")) { @Override protected void paintBorder(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setStroke(UIConstants.BS); Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); g2d.setColor(UIConstants.LINE_COLOR); g2d.draw(shape); } }; addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { popupMenu.show(MapGroupExtensionPane.this, addButton.getX() + 1, addButton.getY() + addButton.getHeight()); } }); add(addButton, BorderLayout.SOUTH); initPopupMenu(); } private void initPopupMenu() { popupMenu = new JPopupMenu() { @Override public Dimension getPreferredSize() { Dimension dimension = new Dimension(); dimension.height = super.getPreferredSize().height; dimension.width = addButton.getWidth() - 2; return dimension; } }; JMenuItem worldMap = new JMenuItem(TYPE_NAMES[WORD]); popupMenu.add(worldMap); worldMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[WORD], TYPE_NAMES[WORD], true); } }); JMenuItem countMap = new JMenuItem(TYPE_NAMES[NATION]); popupMenu.add(countMap); countMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[NATION], TYPE_NAMES[NATION], true); } }); JMenuItem proMap = new JMenuItem(TYPE_NAMES[STATE]); popupMenu.add(proMap); proMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[STATE], TYPE_NAMES[STATE], true); } }); JMenuItem menu = new JMenuItem(TYPE_NAMES[USER]); popupMenu.add(menu); menu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[USER], TYPE_NAMES[USER], true); } }); } private void doEdit(ChangeEvent e) { MouseEvent event = (MouseEvent) e.getSource(); JPopupMenu editPopMenu = new JPopupMenu(); final String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); editPopMenu.add(createAreaItem(oldName)); editPopMenu.add(createMarkerItem(oldName)); editPopMenu.add(createLayerItem(oldName)); editPopMenu.add(createRenameItem()); editPopMenu.show(MapGroupExtensionPane.this, event.getXOnScreen() - OFFSET_X, event.getYOnScreen() - OFFSET_Y); } private void mapCheckBeforeEdit(String name){ if(MapSvgXMLHelper.getInstance().containsMapName(name) || MapSvgXMLHelper.getInstance().getNewMapAttr(name)!=null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + name + ".svg"); MapSvgXMLHelper.getInstance().addNewSvgMaps(name,attr); } private JMenuItem createAreaItem(final String oldName) { JMenuItem editFileItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Filed"})); editFileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.AREA); image.populateBean(oldName); image.setTypeNameAndMapName(groupExtensionPane.getSelectedType(), Utils.objectToString(groupExtensionPane.getSelectedObject())); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(MapGroupExtensionPane.this), new DialogActionAdapter() { public void doOk() { image.updateBean(); // 比较两个前后的名字是否相同, 是图片 如果图片不同, 则直接比较 Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editFileItem; } //根据地图的名字返回地图的图片 private Image getMapImage(String mapName) { if (MapSvgXMLHelper.getInstance().containsMapName(mapName)) { MapSvgAttr mapAttr = MapSvgXMLHelper.getInstance().getMapAttr(mapName); if(mapAttr == null) { return null; } return mapAttr.getMapImage(); } return null; } private JMenuItem createMarkerItem(final String oldName) { JMenuItem editMarkerItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Marker"})); editMarkerItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.POINT); image.populateBean(oldName); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(image), new DialogActionAdapter() { public void doOk() { image.updateBean(); Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editMarkerItem; } private JMenuItem createLayerItem(final String oldName) { JMenuItem corrItem = new JMenuItem(Inter.getLocText(new String[]{"Filed", "Corresponding_Fields"})); corrItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapDefiAreaNamePane namedPane = new MapDefiAreaNamePane(); namedPane.populateBean(oldName); mapCheckBeforeEdit(oldName); BasicDialog dialog = namedPane.showMediumWindow(SwingUtilities.getWindowAncestor(namedPane), new DialogActionAdapter() { public void doOk() { namedPane.updateBean();// 地图的名称 value对应情况 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); } }); dialog.setVisible(true); refresh(); } }); return corrItem; } private void showRenameWaring(String newName){ JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + Inter.getLocText("Utils-has_been_existed") + "!", Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); } private JMenuItem createRenameItem() { JMenuItem renameItem = new JMenuItem(Inter.getLocText("FR-Chart-Map_Rename")); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newName = JOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), Inter.getLocText("FR-Chart-Map_Rename"), groupExtensionPane.getSelectedObject()); if (StringUtils.isNotBlank(newName)) { String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); if(ComparatorUtils.equals(oldName, newName)){ return; } //本地在看看临时的helper里面有没有 if(MapSvgXMLHelper.getInstance().getNewMapAttr(newName) != null){ showRenameWaring(newName); return; } try{//提醒名字已存在 if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } MapSvgAttr editingAttr = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(editingAttr == null){ editingAttr = MapSvgXMLHelper.getInstance().getNewMapAttr(oldName); } if( editingAttr == null) { return; } editingAttr.renameMap(newName); groupExtensionPane.setValueAtCurrentSelectIndex(newName); fireStateChange(); saveMapInfo(newName); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION})); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION})); refresh(); }catch (Exception exp){ FRLogger.getLogger().error(exp.getMessage()); } } } }); return renameItem; } private void refresh() { this.validate(); this.repaint(); DesignerFrame frame = DesignerContext.getDesignerFrame(); if(frame != null) { frame.repaint();//kunsnat: 图表属性没变, 只是读取时 内容变化. } } //保存修改过的地图信息 private void saveMapInfo(final String mapName) { SwingWorker worker = new SwingWorker() { @Override protected Integer doInBackground() throws Exception { MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(mapName);// 只有在编辑地图时才需要储存相关数据 @kuns if(attr != null){ attr.writeBack(mapName); } return 0; } @Override protected void done() { FRLogger.getLogger().info(Inter.getLocText("FR-Chart-Map_Saved")); // 地图已经保存. } }; worker.execute(); DesignerEnvManager.addWorkers(worker); } private void fireStateChange() { for (int i = changeListeners.size(); i > 0; i--) { changeListeners.get(i - 1).stateChanged(new javax.swing.event.ChangeEvent(this)); } } /** * 更新地图属性 * @return 返回地图名称. */ public String updateBean(MapPlot plot) { if(!hasPopulated){ this.populateBean(plot); hasPopulated = true; } MapHelper helper = plot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); helper.clearCateNames(); for (String type : TYPE_NAMES) { Object[] datas = groupExtensionPane.getData(type); for (Object name : datas) { helper.addCateNames(type, name); } } return Utils.objectToString(groupExtensionPane.getSelectedObject()); } /** * 更新地图名称 * @param mapPlot 地图 */ public void populateBean(MapPlot mapPlot) { hasPopulated = false; groupExtensionPane.clearData(); for (String type : TYPE_NAMES) { MapHelper helper = mapPlot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); java.util.List list = helper.getNamesListWithCateName(type); for (Object name : list) { groupExtensionPane.addData(name, type); } } groupExtensionPane.setSelectedObject(mapPlot.getMapName()); hasPopulated = true; } /** * 给组件登记一个观察者监听事件 * * @param listener 观察者监听事件 */ public void registerChangeListener(final UIObserverListener listener) { changeListeners.add(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { listener.doChange(); } }); } /** * 组件是否需要响应添加的观察者事件 * * @return 如果需要响应观察者事件则返回true,否则返回false */ public boolean shouldResponseChangeListener() { return true; } public void setEnabled(boolean isEnabled){ super.setEnabled(isEnabled); addButton.setEnabled(isEnabled); popupMenu.setEnabled(isEnabled); groupExtensionPane.setEnabled(isEnabled); } } \ No newline at end of file +package com.fr.design.chart.series.PlotSeries; + +import com.fr.base.*; +import com.fr.chart.base.MapSvgAttr; +import com.fr.chart.base.MapSvgXMLHelper; +import com.fr.chart.chartattr.MapPlot; +import com.fr.chart.chartglyph.MapShapeValue; +import com.fr.design.DesignerEnvManager; +import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.event.ChangeEvent; +import com.fr.design.event.ChangeListener; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; +import com.fr.general.ComparatorUtils; +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import com.fr.stable.CoreConstants; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.SvgProvider; + +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.geom.RoundRectangle2D; +import java.util.ArrayList; + +/** + * Created by IntelliJ IDEA. + * Author : Richer + * Version: 7.0.3 + * Date: 12-12-29 + * Time: 下午2:41 + */ +public class MapGroupExtensionPane extends BasicPane implements UIObserver { + private static final String[] TYPE_NAMES = new String[]{ + Inter.getLocText("FR-Chart-World_Map"), + Inter.getLocText("FR-Chart-State_Map"), + Inter.getLocText("FR-Chart-Province_Map"), + Inter.getLocText("FR-Chart-Custom_Map")}; + private static final int WORD = 0; + private static final int NATION = 1; + private static final int STATE = 2; + private static final int USER = 3; + private static final int OFFSET_X = 800; + private static final int OFFSET_Y = 200; + + private UIGroupExtensionPane groupExtensionPane; + private UIButton addButton; + private JPopupMenu popupMenu; + private ArrayList changeListeners = new ArrayList(); + private boolean hasPopulated = false; + + @Override + protected String title4PopupWindow() { + return "Map"; + } + + public MapGroupExtensionPane() { + setLayout(new BorderLayout()); + groupExtensionPane = new UIGroupExtensionPane(TYPE_NAMES){ + + /** + * 新添加的数据的序号 + * @param data 数据 + */ + protected void dealNewAddedDataIndex(Object data){ + String newName = (String)data; + MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance(); + if(helper.getNewMapAttr(newName) != null){ + return; + } + MapSvgAttr attr = new MapSvgAttr(); + attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + newName + ".svg"); + helper.addNewSvgMaps(attr.getName(), attr); + } + + + /** + * 一次鼠标的点击会有两次事件响应(按下和释放)。前者的事件属性中getValueIsAdjusting()=true,后者是false。 + * 是否响应list值改变 + * @return 鼠标按下时不响应,先响应mousePress事件,在鼠标释放是再响应list值改编的事件,并且点击删除不触发更新,并且populate后触发更新 + */ + protected boolean isRespondToValueChange(ListSelectionEvent e){ + return !e.getValueIsAdjusting() && !this.isPressOnDelete() && hasPopulated; + } + }; + groupExtensionPane.addSelectionChangeListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + fireStateChange(); + } + }); + groupExtensionPane.addItemEditListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + doEdit(event); + } + }); + groupExtensionPane.addDeleteListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + //这么写有点问题 + String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); + saveMapInfo(oldName); + } + }); + setPreferredSize(new Dimension(400, 210)); + add(groupExtensionPane, BorderLayout.CENTER); + + addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")) { + @Override + protected void paintBorder(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + g2d.setStroke(UIConstants.BS); + Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); + g2d.setColor(UIConstants.LINE_COLOR); + g2d.draw(shape); + } + }; + addButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + popupMenu.show(MapGroupExtensionPane.this, addButton.getX() + 1, addButton.getY() + addButton.getHeight()); + } + }); + add(addButton, BorderLayout.SOUTH); + initPopupMenu(); + } + + private void initPopupMenu() { + popupMenu = new JPopupMenu() { + @Override + public Dimension getPreferredSize() { + Dimension dimension = new Dimension(); + dimension.height = super.getPreferredSize().height; + dimension.width = addButton.getWidth() - 2; + return dimension; + } + }; + JMenuItem worldMap = new JMenuItem(TYPE_NAMES[WORD]); + popupMenu.add(worldMap); + worldMap.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + groupExtensionPane.addData(TYPE_NAMES[WORD], TYPE_NAMES[WORD], true); + } + }); + + JMenuItem countMap = new JMenuItem(TYPE_NAMES[NATION]); + popupMenu.add(countMap); + countMap.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + groupExtensionPane.addData(TYPE_NAMES[NATION], + TYPE_NAMES[NATION], true); + } + }); + + JMenuItem proMap = new JMenuItem(TYPE_NAMES[STATE]); + popupMenu.add(proMap); + proMap.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + groupExtensionPane.addData(TYPE_NAMES[STATE], + TYPE_NAMES[STATE], true); + } + }); + + JMenuItem menu = new JMenuItem(TYPE_NAMES[USER]); + popupMenu.add(menu); + menu.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + groupExtensionPane.addData(TYPE_NAMES[USER], + TYPE_NAMES[USER], true); + } + }); + } + + private void doEdit(ChangeEvent e) { + MouseEvent event = (MouseEvent) e.getSource(); + JPopupMenu editPopMenu = new JPopupMenu(); + + final String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); + editPopMenu.add(createAreaItem(oldName)); + editPopMenu.add(createMarkerItem(oldName)); + editPopMenu.add(createLayerItem(oldName)); + editPopMenu.add(createRenameItem()); + + editPopMenu.show(MapGroupExtensionPane.this, event.getXOnScreen() - OFFSET_X, event.getYOnScreen() - OFFSET_Y); + } + + private void mapCheckBeforeEdit(String name){ + if(MapSvgXMLHelper.getInstance().containsMapName(name) || MapSvgXMLHelper.getInstance().getNewMapAttr(name)!=null){ + return; + } + MapSvgAttr attr = new MapSvgAttr(); + attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + name + ".svg"); + MapSvgXMLHelper.getInstance().addNewSvgMaps(name,attr); + } + + private JMenuItem createAreaItem(final String oldName) { + JMenuItem editFileItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Filed"})); + editFileItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final MapCustomPane image = new MapCustomPane(); + image.setImageSelectType(MapShapeValue.AREA); + image.populateBean(oldName); + image.setTypeNameAndMapName(groupExtensionPane.getSelectedType(), Utils.objectToString(groupExtensionPane.getSelectedObject())); + mapCheckBeforeEdit(oldName); + final Image oldImage = getMapImage(oldName); + BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(MapGroupExtensionPane.this), new DialogActionAdapter() { + public void doOk() { + image.updateBean(); // 比较两个前后的名字是否相同, 是图片 如果图片不同, 则直接比较 + + Image newImage = getMapImage(oldName); + if(!ComparatorUtils.equals(oldImage, newImage)) { + fireStateChange(); + } + + //versionID递增 + MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); + if(old != null) { + old.addVersionID(); + } + + saveMapInfo(oldName); + refresh(); + } + }); + dialog.setVisible(true); + } + }); + return editFileItem; + } + + //根据地图的名字返回地图的图片 + private Image getMapImage(String mapName) { + if (MapSvgXMLHelper.getInstance().containsMapName(mapName)) { + MapSvgAttr mapAttr = MapSvgXMLHelper.getInstance().getMapAttr(mapName); + if(mapAttr == null) { + return null; + } + return mapAttr.getMapImage(); + } + + return null; + } + + private JMenuItem createMarkerItem(final String oldName) { + JMenuItem editMarkerItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Marker"})); + editMarkerItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final MapCustomPane image = new MapCustomPane(); + image.setImageSelectType(MapShapeValue.POINT); + image.populateBean(oldName); + mapCheckBeforeEdit(oldName); + final Image oldImage = getMapImage(oldName); + BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(image), new DialogActionAdapter() { + public void doOk() { + image.updateBean(); + + Image newImage = getMapImage(oldName); + if(!ComparatorUtils.equals(oldImage, newImage)) { + fireStateChange(); + } + + //versionID递增 + MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); + if(old != null) { + old.addVersionID(); + } + + saveMapInfo(oldName); + refresh(); + } + }); + dialog.setVisible(true); + } + }); + return editMarkerItem; + } + + private JMenuItem createLayerItem(final String oldName) { + JMenuItem corrItem = new JMenuItem(Inter.getLocText(new String[]{"Filed", "Corresponding_Fields"})); + corrItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final MapDefiAreaNamePane namedPane = new MapDefiAreaNamePane(); + namedPane.populateBean(oldName); + mapCheckBeforeEdit(oldName); + BasicDialog dialog = namedPane.showMediumWindow(SwingUtilities.getWindowAncestor(namedPane), new DialogActionAdapter() { + public void doOk() { + namedPane.updateBean();// 地图的名称 value对应情况 + + MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); + if(old != null) { + old.addVersionID(); + } + + saveMapInfo(oldName); + } + }); + dialog.setVisible(true); + refresh(); + } + }); + + return corrItem; + } + + private void showRenameWaring(String newName){ + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + Inter.getLocText("Utils-has_been_existed") + + "!", Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); + } + + private JMenuItem createRenameItem() { + JMenuItem renameItem = new JMenuItem(Inter.getLocText("FR-Chart-Map_Rename")); + renameItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String newName = JOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), + Inter.getLocText("FR-Chart-Map_Rename"), groupExtensionPane.getSelectedObject()); + if (StringUtils.isNotBlank(newName)) { + String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); + if(ComparatorUtils.equals(oldName, newName)){ + return; + } + //本地在看看临时的helper里面有没有 + if(MapSvgXMLHelper.getInstance().getNewMapAttr(newName) != null){ + showRenameWaring(newName); + return; + } + try{//提醒名字已存在 + if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( + new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION}))){ + showRenameWaring(newName); + return; + } + if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( + new String[]{MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION}))){ + showRenameWaring(newName); + return; + } + MapSvgAttr editingAttr = MapSvgXMLHelper.getInstance().getMapAttr(oldName); + if(editingAttr == null){ + editingAttr = MapSvgXMLHelper.getInstance().getNewMapAttr(oldName); + } + if( editingAttr == null) { + return; + } + editingAttr.renameMap(newName); + groupExtensionPane.setValueAtCurrentSelectIndex(newName); + fireStateChange(); + saveMapInfo(newName); + FRContext.getCurrentEnv().deleteFile( + StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION})); + FRContext.getCurrentEnv().deleteFile( + StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION})); + refresh(); + }catch (Exception exp){ + FRLogger.getLogger().error(exp.getMessage()); + } + } + } + }); + return renameItem; + } + + private void refresh() { + this.validate(); + this.repaint(); + + DesignerFrame frame = DesignerContext.getDesignerFrame(); + if(frame != null) { + frame.repaint();//kunsnat: 图表属性没变, 只是读取时 内容变化. + } + } + + //保存修改过的地图信息 + private void saveMapInfo(final String mapName) { + SwingWorker worker = new SwingWorker() { + @Override + protected Integer doInBackground() throws Exception { + MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(mapName);// 只有在编辑地图时才需要储存相关数据 @kuns + if(attr != null){ + attr.writeBack(mapName); + } + return 0; + } + + @Override + protected void done() { + FRLogger.getLogger().info(Inter.getLocText("FR-Chart-Map_Saved")); // 地图已经保存. + } + + }; + worker.execute(); + DesignerEnvManager.addWorkers(worker); + } + + private void fireStateChange() { + for (int i = changeListeners.size(); i > 0; i--) { + changeListeners.get(i - 1).stateChanged(new javax.swing.event.ChangeEvent(this)); + } + } + + /** + * 更新地图属性 + * @return 返回地图名称. + */ + public String updateBean(MapPlot plot) { + if(!hasPopulated){ + this.populateBean(plot); + hasPopulated = true; + } + + MapHelper helper = plot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); + + helper.clearCateNames(); + for (String type : TYPE_NAMES) { + Object[] datas = groupExtensionPane.getData(type); + for (Object name : datas) { + helper.addCateNames(type, name); + } + } + + return Utils.objectToString(groupExtensionPane.getSelectedObject()); + } + + /** + * 更新地图名称 + * @param mapPlot 地图 + */ + public void populateBean(MapPlot mapPlot) { + hasPopulated = false; + groupExtensionPane.clearData(); + + for (String type : TYPE_NAMES) { + MapHelper helper = mapPlot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); + java.util.List list = helper.getNamesListWithCateName(type); + for (Object name : list) { + groupExtensionPane.addData(name, type); + } + } + + groupExtensionPane.setSelectedObject(mapPlot.getMapName()); + + hasPopulated = true; + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + changeListeners.add(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent e) { + listener.doChange(); + } + }); + } + + /** + * 组件是否需要响应添加的观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + public boolean shouldResponseChangeListener() { + return true; + } + + public void setEnabled(boolean isEnabled){ + super.setEnabled(isEnabled); + addButton.setEnabled(isEnabled); + popupMenu.setEnabled(isEnabled); + groupExtensionPane.setEnabled(isEnabled); + } +} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java index 7d8b6c8ce..3a200ee3c 100644 --- a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java +++ b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java @@ -96,7 +96,7 @@ public class DataLabelPane extends TooltipContentsPane { } delimiterBox.setPreferredSize(new Dimension(70, 20)); JPanel boxPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); - boxPane.add(new UILabel(Inter.getLocText("Form-Delimiter") + ":")); + boxPane.add(new UILabel(Inter.getLocText("FR-Designer_Dismenber") + ":")); boxPane.add(delimiterBox); return boxPane; } @@ -111,34 +111,9 @@ public class DataLabelPane extends TooltipContentsPane { } protected JPanel createJPanel4Position() { - // 标签位置:上下左右中. - bottomButton = new UIRadioButton(Inter.getLocText("StyleAlignment-Bottom")); - leftButton = new UIRadioButton(Inter.getLocText("StyleAlignment-Left")); - rigtButton = new UIRadioButton(Inter.getLocText("StyleAlignment-Right")); - topButton = new UIRadioButton(Inter.getLocText("StyleAlignment-Top")); - centerButton = new UIRadioButton(Inter.getLocText("Center")); - - ButtonGroup bg = new ButtonGroup(); - bg.add(bottomButton); - bg.add(leftButton); - bg.add(rigtButton); - bg.add(topButton); - bg.add(centerButton); - topButton.setSelected(true); - - JPanel buttonPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); - buttonPane.add(new UILabel(Inter.getLocText(new String[]{"Label", "Layout"}) + ":")); - buttonPane.add(bottomButton); - buttonPane.add(leftButton); - buttonPane.add(rigtButton); - buttonPane.add(topButton); - buttonPane.add(centerButton); - - return buttonPane; + return null; } - - public void populate(AttrContents seriesAttrContents) { super.populate(seriesAttrContents); String dataLabel = seriesAttrContents.getSeriesLabel(); diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java index 07d699dae..96d4af867 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java @@ -5,6 +5,7 @@ import com.fr.base.Utils; import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Plot; import com.fr.chart.chartdata.NormalReportDataDefinition; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; @@ -21,6 +22,7 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; +import java.util.List; /** @@ -30,125 +32,133 @@ import java.util.ArrayList; */ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotReportDataContentPane implements UIObserver{ private static final long serialVersionUID = -1122313353777460534L; - + private JPanel boxPane; private UIButton addButton; - + private ArrayList formualList = new ArrayList(); private UIObserverListener uiobListener = null; + public List getFormualList() { + return formualList; + } + public CategoryPlotMoreCateReportDataContentPane() { - + } - + public CategoryPlotMoreCateReportDataContentPane(ChartDataPane parent) { - initEveryPane(); - categoryName = initCategoryBox(Inter.getLocText("FR-Chart-Category_Name") + ":"); - - JPanel catePane = new JPanel(); - catePane.setLayout(new BorderLayout(2, 2)); - - catePane.add(categoryName); - - addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); - addButton.setPreferredSize(new Dimension(20, 20)); - catePane.add(addButton, BorderLayout.EAST); - - boxPane = new JPanel(); - boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS)); - - boxPane.setBackground(Color.red); - - catePane.add(boxPane, BorderLayout.SOUTH); - - this.add(catePane, "0,0,2,0"); - this.add(new BoldFontTextLabel(Inter.getLocText("FR-Chart-Data_Filter")), "0,4,2,4"); - this.add(filterPane = new ChartDataFilterPane(new Bar2DPlot(), parent), "0,6,2,4"); - - addButton.addActionListener(new ActionListener() { + initEveryPane(); + categoryName = initCategoryBox(Inter.getLocText("FR-Chart-Category_Name") + ":"); + + JPanel catePane = new JPanel(); + catePane.setLayout(new BorderLayout(2, 2)); + + catePane.add(categoryName); + + addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); + addButton.setPreferredSize(new Dimension(20, 20)); + catePane.add(addButton, BorderLayout.EAST); + + boxPane = new JPanel(); + boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS)); + + boxPane.setBackground(Color.red); + + catePane.add(boxPane, BorderLayout.SOUTH); + + this.add(catePane, "0,0,2,0"); + this.add(new BoldFontTextLabel(Inter.getLocText("FR-Chart-Data_Filter")), "0,4,2,4"); + this.add(filterPane = new ChartDataFilterPane(new Bar2DPlot(), parent), "0,6,2,4"); + + addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addNewCatePane(); } }); - + + } + + /** + * 检查box 是否应该可用状态. + */ + public void checkBoxUse() { + super.checkBoxUse(); + String text = categoryName.getUITextField().getText(); + addButton.setEnabled(StringUtils.isNotEmpty(text)); } - - /** - * 检查box 是否应该可用状态. - */ - public void checkBoxUse() { - super.checkBoxUse(); - String text = categoryName.getUITextField().getText(); - addButton.setEnabled(StringUtils.isNotEmpty(text)); - } - + private TinyFormulaPane addNewCatePane() { final TinyFormulaPane pane = initCategoryBox(StringUtils.EMPTY); pane.setPreferredSize(new Dimension(122, 16)); - + pane.registerChangeListener(uiobListener); - + formualList.add(pane); - + final JPanel newButtonPane = new JPanel(); newButtonPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); newButtonPane.add(pane); - + UIButton delButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); newButtonPane.add(delButton); - + boxPane.add(newButtonPane); - + delButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boxPane.remove(newButtonPane); formualList.remove(pane); - checkAddButton(); + checkComponent(); relayoutPane(); } }); delButton.registerChangeListener(uiobListener); - - checkAddButton(); + + checkComponent(); relayoutPane(); - + return pane; } - + private void checkAddButton() { int size = formualList.size(); addButton.setEnabled(size < 2); } - + + protected void checkComponent() { + checkAddButton(); + } + private void relayoutPane() { this.revalidate(); } - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ public void registerChangeListener(UIObserverListener listener) { uiobListener = listener; } - /** - * 组件是否需要响应添加的观察者事件 - * - * @return 如果需要响应观察者事件则返回true,否则返回false - */ + /** + * 组件是否需要响应添加的观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ public boolean shouldResponseChangeListener() { return true; } - + public void populateBean(ChartCollection collection) { super.populateBean(collection); - + formualList.clear(); - + TopDefinitionProvider definition = collection.getSelectedChart().getFilterDefinition(); if (definition instanceof NormalReportDataDefinition) { NormalReportDataDefinition reportDefinition = (NormalReportDataDefinition) definition; @@ -160,23 +170,28 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor } } } - + checkAddButton(); } - + public void updateBean(ChartCollection collection) { super.updateBean(collection); - + TopDefinitionProvider definition = collection.getSelectedChart().getFilterDefinition(); + Plot plot = collection.getSelectedChart().getPlot(); if (definition instanceof NormalReportDataDefinition) { NormalReportDataDefinition reportDefinition = (NormalReportDataDefinition) definition; - + reportDefinition.clearMoreCate(); - - for(int i = 0, size = formualList.size(); i < size; i++) { - TinyFormulaPane pane = formualList.get(i); - reportDefinition.addMoreCate(canBeFormula(pane.updateBean())); - } + updateMoreCate(reportDefinition, plot); + + } + } + + protected void updateMoreCate(NormalReportDataDefinition reportDefinition, Plot plot) { + for (int i = 0, size = formualList.size(); i < size; i++) { + TinyFormulaPane pane = formualList.get(i); + reportDefinition.addMoreCate(canBeFormula(pane.updateBean())); } } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java index 9ae7696d9..0b1909f98 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Plot; import com.fr.chart.chartdata.NormalTableDataDefinition; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; @@ -36,40 +37,44 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD private static final int COMBOX_HEIGHT = 20; private JPanel boxPane; - + private ArrayList boxList = new ArrayList(); private UIButton addButton; - + private UIObserverListener uiobListener = null; - + + public List getBoxList() { + return boxList; + } + public CategoryPlotMoreCateTableDataContentPane() { // do nothing } - + public CategoryPlotMoreCateTableDataContentPane(ChartDataPane parent) { categoryCombox = new UIComboBox(); categoryCombox.setPreferredSize(new Dimension(100,20)); - + JPanel categoryPane = new JPanel(new BorderLayout(4,0)); categoryPane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground())); - UILabel categoryLabel = new BoldFontTextLabel(Inter.getLocText("FR-Chart-Category_Name") + ":", SwingConstants.RIGHT) ; - categoryLabel.setPreferredSize(new Dimension(75,20)); - - addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); - addButton.setPreferredSize(new Dimension(20, 20)); - - categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryCombox, addButton,null,categoryLabel,null})); - - boxPane = new JPanel(); - boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS)); - - categoryPane.add(boxPane, BorderLayout.SOUTH); - + UILabel categoryLabel = new BoldFontTextLabel(Inter.getLocText("FR-Chart-Category_Name") + ":", SwingConstants.RIGHT) ; + categoryLabel.setPreferredSize(new Dimension(75,20)); + + addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); + addButton.setPreferredSize(new Dimension(20, 20)); + + categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryCombox, addButton,null,categoryLabel,null})); + + boxPane = new JPanel(); + boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS)); + + categoryPane.add(boxPane, BorderLayout.SOUTH); + this.setLayout(new BorderLayout()); this.add(categoryPane, BorderLayout.NORTH); seriesTypeComboxPane = new SeriesTypeUseComboxPane(parent, new Bar2DPlot()); this.add(seriesTypeComboxPane, BorderLayout.SOUTH); - + addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -77,81 +82,85 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD addNewCombox(); relayoutPane(); } - + checkSeriseUse(categoryCombox.getSelectedItem() != null); } }); - + categoryCombox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { checkSeriseUse(categoryCombox.getSelectedItem() != null); makeToolTipUse(categoryCombox); - - checkAddButton(); + + checkComponent(); } }); } - + protected void checkSeriseUse(boolean hasUse) { super.checkSeriseUse(hasUse); - + addButton.setEnabled(hasUse); } - + private UIComboBox addNewCombox() { - final JPanel buttonPane = new JPanel(); - buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); - - final UIComboBox combox = new UIComboBox(); - combox.setPreferredSize(new Dimension(COMBOX_WIDTH, COMBOX_HEIGHT)); - - int count = categoryCombox.getItemCount(); - for(int i = 0; i < count; i++) { - combox.addItem(categoryCombox.getItemAt(i)); - } - - combox.registerChangeListener(uiobListener); - combox.addItemListener(new ItemListener() { + final JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); + + final UIComboBox combox = new UIComboBox(); + combox.setPreferredSize(new Dimension(COMBOX_WIDTH, COMBOX_HEIGHT)); + + int count = categoryCombox.getItemCount(); + for(int i = 0; i < count; i++) { + combox.addItem(categoryCombox.getItemAt(i)); + } + + combox.registerChangeListener(uiobListener); + combox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { makeToolTipUse(combox); } }); - - combox.setSelectedItem(categoryCombox.getItemAt(0)); - makeToolTipUse(combox); - - buttonPane.add(combox); - UIButton delButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); - buttonPane.add(delButton); - boxPane.add(buttonPane); - boxList.add(combox); - - checkAddButton(); - - delButton.addActionListener(new ActionListener() { + + combox.setSelectedItem(categoryCombox.getItemAt(0)); + makeToolTipUse(combox); + + buttonPane.add(combox); + UIButton delButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); + buttonPane.add(delButton); + boxPane.add(buttonPane); + boxList.add(combox); + + checkComponent(); + + delButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boxPane.remove(buttonPane); boxList.remove(combox); - checkAddButton(); + checkComponent(); relayoutPane(); } }); - delButton.registerChangeListener(uiobListener); - - return combox; + delButton.registerChangeListener(uiobListener); + + return combox; } - + private void checkAddButton() { int size = boxList.size(); addButton.setEnabled(size < 2 && categoryCombox.getSelectedItem() != null); } - + + protected void checkComponent() { + checkAddButton(); + } + private void relayoutPane() { this.revalidate(); } - + /** *检查 某些Box是否可用 @@ -159,17 +168,17 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD */ public void checkBoxUse(boolean hasUse) { super.checkBoxUse(hasUse); - - checkAddButton(); + + checkComponent(); + } + + protected void refreshBoxListWithSelectTableData(List list) { + super.refreshBoxListWithSelectTableData(list); + + for(int i = 0, size = boxList.size(); i < size; i++) { + refreshBoxItems(boxList.get(i), list); + } } - - protected void refreshBoxListWithSelectTableData(List list) { - super.refreshBoxListWithSelectTableData(list); - - for(int i = 0, size = boxList.size(); i < size; i++) { - refreshBoxItems(boxList.get(i), list); - } - } /** * 给组件登记一个观察者监听事件 @@ -195,9 +204,9 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD */ public void populateBean(ChartCollection collection) { super.populateBean(collection); - + boxList.clear(); - + TopDefinitionProvider top = collection.getSelectedChart().getFilterDefinition(); if(top instanceof NormalTableDataDefinition) { NormalTableDataDefinition normal = (NormalTableDataDefinition)top; @@ -207,28 +216,34 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD box.setSelectedItem(normal.getMoreCateWithIndex(i)); } } - + checkAddButton(); checkSeriseUse(categoryCombox.getSelectedItem() != null); } - + /** * 保存多分类界面到collection * @param collection */ public void updateBean(ChartCollection collection) { super.updateBean(collection); - + TopDefinitionProvider top = collection.getSelectedChart().getFilterDefinition(); - if(top instanceof NormalTableDataDefinition) { - NormalTableDataDefinition normal = (NormalTableDataDefinition)top; + Plot plot = collection.getSelectedChart().getPlot(); + if (top instanceof NormalTableDataDefinition) { + NormalTableDataDefinition normal = (NormalTableDataDefinition) top; normal.clearMoreCate(); - for(int i = 0, size = boxList.size(); i < size; i++) { - UIComboBox box = boxList.get(i); - if(box.getSelectedItem() != null) { - normal.addMoreCate(box.getSelectedItem().toString()); - } + updateMoreCate(normal, plot); + } + } + + protected void updateMoreCate(NormalTableDataDefinition normal, Plot plot) { + for (int i = 0, size = boxList.size(); i < size; i++) { + UIComboBox box = boxList.get(i); + if (box.getSelectedItem() != null) { + normal.addMoreCate(box.getSelectedItem().toString()); } } } + } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java index f8b002bcf..0f0df0e7c 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java @@ -12,6 +12,7 @@ import com.fr.chart.chartdata.GisMapTableDefinition; import com.fr.chart.web.ChartHyperPoplink; import com.fr.chart.web.ChartHyperRelateCellLink; import com.fr.chart.web.ChartHyperRelateFloatLink; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.javascript.ChartEmailPane; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPoplinkPane; @@ -21,6 +22,8 @@ import com.fr.design.chart.series.SeriesCondition.impl.FormHyperlinkPane; import com.fr.design.dialog.BasicScrollPane; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; +import com.fr.design.fun.HyperlinkProvider; +import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.frpane.UIBubbleFloatPane; import com.fr.design.gui.frpane.UICorrelationComboBoxPane; import com.fr.design.gui.ibutton.UIButton; @@ -53,9 +56,10 @@ import java.text.DecimalFormat; import java.text.Format; import java.util.ArrayList; import java.util.List; +import java.util.Set; public class ChartInteractivePane extends BasicScrollPane implements UIObserver{ - private static final long serialVersionUID = 3477409806918835992L; + private static final long serialVersionUID = 3477409806918835992L; private static HashMap normalMap = new HashMap(); private static HashMap gisMap = new HashMap(); private static HashMap mapMap = new HashMap(); @@ -69,16 +73,16 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb private static final int TIME_SWITCH_GAP = 40; - private UICheckBox isChartAnimation;// 动态 + private UICheckBox isChartAnimation;// 动态 private UICheckBox isSeriesDragEnable; //系列拖拽 private UICheckBox isAxisZoom;// 缩放 - private UICheckBox isDatapointValue;// 数据点提示 - private UIButton dataPointValueFormat; + private UICheckBox isDatapointValue;// 数据点提示 + private UIButton dataPointValueFormat; - private UICheckBox isDatapointPercent; - private UIButton dataPointPercentFormat; + private UICheckBox isDatapointPercent; + private UIButton dataPointPercentFormat; private UILabel tooltipStyleLabel; private UIComboBox tooltipStyle; @@ -90,55 +94,55 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb private UICheckBox isAddress; private UICheckBox isAddressName; - private UICheckBox isAxisShowToolTip;// 坐标轴提示 + private UICheckBox isAxisShowToolTip;// 坐标轴提示 - protected UICheckBox isAutoRefresh;// 自动刷新 - protected UISpinner autoRefreshTime; + protected UICheckBox isAutoRefresh;// 自动刷新 + protected UISpinner autoRefreshTime; - private UICorrelationComboBoxPane superLink;// 超链 + private UICorrelationComboBoxPane superLink;// 超链 - private FormatPane valueFormatPane; - private FormatPane percentFormatPane; - private Format valueFormat; - private Format percentFormat; + private FormatPane valueFormatPane; + private FormatPane percentFormatPane; + private Format valueFormat; + private Format percentFormat; - private JPanel tooltipPane; - private JPanel axisShowPane; - private JPanel autoRefreshPane; - private JPanel superlinkPane; + private JPanel tooltipPane; + private JPanel axisShowPane; + private JPanel autoRefreshPane; + private JPanel superlinkPane; - private ChartOtherPane parent; + private ChartOtherPane parent; private UICheckBox timeSwitch; private JPanel timeSwitchContainer; private TimeSwitchPane timeSwitchPane; - private static final int SIZEX = 258; - private static final int SIZEY = 209; - private static final int DET = 20; - public ChartInteractivePane(ChartOtherPane parent) { - super(); - this.parent = parent; - } + private static final int SIZEX = 258; + private static final int SIZEY = 209; + private static final int DET = 20; + public ChartInteractivePane(ChartOtherPane parent) { + super(); + this.parent = parent; + } - /** - * 界面标题. + /** + * 界面标题. * @return 返回标题. - */ - public String title4PopupWindow() { - return Inter.getLocText("Chart-Interactive_Tab"); - } - - @Override - protected JPanel createContentPane() { - isChartAnimation = new UICheckBox(Inter.getLocText("Chart-Animation_JSShow")); + */ + public String title4PopupWindow() { + return Inter.getLocText("Chart-Interactive_Tab"); + } + + @Override + protected JPanel createContentPane() { + isChartAnimation = new UICheckBox(Inter.getLocText("Chart-Animation_JSShow")); isSeriesDragEnable = new UICheckBox(Inter.getLocText("Chart-Series_Drag")); - isDatapointValue = new UICheckBox(Inter.getLocText("Chart-Use_Value")); - dataPointValueFormat = new UIButton(Inter.getLocText("Chart-Use_Format")); - isDatapointPercent = new UICheckBox(Inter.getLocText("Chart-Value_Percent")); - dataPointPercentFormat = new UIButton(Inter.getLocText("Chart-Use_Format")); + isDatapointValue = new UICheckBox(Inter.getLocText("Chart-Use_Value")); + dataPointValueFormat = new UIButton(Inter.getLocText("Chart-Use_Format")); + isDatapointPercent = new UICheckBox(Inter.getLocText("Chart-Value_Percent")); + dataPointPercentFormat = new UIButton(Inter.getLocText("Chart-Use_Format")); tooltipStyle = new UIComboBox(new String []{Inter.getLocText("Chart-White_Black"), Inter.getLocText("Chart-Black_White")}); tooltipStyleLabel = new UILabel(Inter.getLocText("Chart-Style_Name")); tooltipShowType = new UIComboBox(new String []{Inter.getLocText("Chart-Series_SingleData"), Inter.getLocText("Chart-Series_AllData")}); @@ -148,13 +152,13 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb isAddress = new UICheckBox(Inter.getLocText("Chart-Gis_Address")); isAddressName = new UICheckBox(Inter.getLocText("Chart-Address_Name")); - isAxisShowToolTip = new UICheckBox(Inter.getLocText("Chart-Interactive_AxisTooltip")); - isAxisZoom = new UICheckBox(Inter.getLocText("Chart-Use_Zoom")); - isAutoRefresh = new UICheckBox(Inter.getLocText(new String[]{"Chart-Use_Auto", "Chart-Use_Refresh"})); - autoRefreshTime = new UISpinner(1, Integer.MAX_VALUE, 1); - superLink = new UICorrelationComboBoxPane(); + isAxisShowToolTip = new UICheckBox(Inter.getLocText("Chart-Interactive_AxisTooltip")); + isAxisZoom = new UICheckBox(Inter.getLocText("Chart-Use_Zoom")); + isAutoRefresh = new UICheckBox(Inter.getLocText(new String[]{"Chart-Use_Auto", "Chart-Use_Refresh"})); + autoRefreshTime = new UISpinner(1, Integer.MAX_VALUE, 1); + superLink = new UICorrelationComboBoxPane(); - isAutoRefresh.addActionListener(new ActionListener() { + isAutoRefresh.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { checkAutoRefresh(); @@ -162,9 +166,9 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb }); timeSwitch = new UICheckBox(Inter.getLocText("FR-Chart-Interactive_timeSwitch")); timeSwitchPane = new TimeSwitchPane(); - initFormatListener(); - return initPaneWithListener(); - } + initFormatListener(); + return initPaneWithListener(); + } private void initFormatListener() { @@ -240,19 +244,19 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb }); } - private void checkAutoRefresh() { - GUICoreUtils.setEnabled(autoRefreshTime, isAutoRefresh.isSelected()); - } - - /** - * 反正后面还有relayout,这边init一下就好了 保证所有的init 加入界面 并且加载入事件. - * @return - */ - private JPanel initPaneWithListener() { - initDataPointToolTipPane(); - initAxisShowPane(); - initAutoRefreshPane(); - initSuperlinkPane(); + private void checkAutoRefresh() { + GUICoreUtils.setEnabled(autoRefreshTime, isAutoRefresh.isSelected()); + } + + /** + * 反正后面还有relayout,这边init一下就好了 保证所有的init 加入界面 并且加载入事件. + * @return + */ + private JPanel initPaneWithListener() { + initDataPointToolTipPane(); + initAxisShowPane(); + initAutoRefreshPane(); + initSuperlinkPane(); initTimeSwitchPane(); @@ -271,7 +275,7 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb }; //初始化界面时 加载事件 return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - } + } private void initTimeSwitchPane(){ timeSwitchContainer = new JPanel(new BorderLayout()); @@ -283,11 +287,11 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb /** * 全部初始化, 对所有的界面 都加入, 然后会加载事件响应. 后续再relayout. */ - private void initDataPointToolTipPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = new double[]{p, f}; - double[] rowSize = new double[]{p, p, p, p, p, p, p}; + private void initDataPointToolTipPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = new double[]{p, f}; + double[] rowSize = new double[]{p, p, p, p, p, p, p}; Component[][] components = new Component[][]{ new Component[]{isDatapointValue, dataPointValueFormat}, new Component[]{isDatapointPercent, dataPointPercentFormat}, @@ -298,7 +302,7 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb new Component[]{tooltipStyleLabel, tooltipStyle} }; tooltipPane = TableLayoutHelper.createTableLayoutPane4Chart(new String[]{"ChartData-Tooltip"},components, rowSize, columnSize); - } + } private void relayoutDataPointToolTipPane(Plot plot) { double p = TableLayout.PREFERRED; @@ -333,8 +337,8 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb } else { rowSize = new double[]{p, p, p}; components = new Component[][]{ - new Component[]{isDatapointValue, dataPointValueFormat}, - new Component[]{isDatapointPercent, dataPointPercentFormat}, + new Component[]{isDatapointValue, dataPointValueFormat}, + new Component[]{isDatapointPercent, dataPointPercentFormat}, getTooltipStyleComponent() }; } @@ -370,49 +374,49 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb return new Component[] {TableLayoutHelper.createTableLayoutPane(newComponents, newRowSize, newColumnSize), null}; } - private void initAxisShowPane() { - double p = TableLayout.PREFERRED; - double[] columnSize = new double[]{p}; - double[] rowSize = new double[]{p}; - Component[][] components = new Component[][]{ - new Component[]{isAxisShowToolTip}, - }; - axisShowPane = TableLayoutHelper.createTableLayoutPane4Chart(new String[]{"ChartF-Axis", "Chart-Interactive"},components, rowSize, columnSize); - } - - private void initAutoRefreshPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = new double[]{p, f}; - double[] rowSize = new double[]{p, p, p,p}; - - Component[][] components = new Component[][]{ - new Component[]{isAutoRefresh,null}, - new Component[]{GUICoreUtils.createFlowPane(new Component[]{ - new UILabel(Inter.getLocText("Chart-Time_Interval")), - autoRefreshTime, - new UILabel(Inter.getLocText("Chart-Time_Seconds")) - }, 1)}, + private void initAxisShowPane() { + double p = TableLayout.PREFERRED; + double[] columnSize = new double[]{p}; + double[] rowSize = new double[]{p}; + Component[][] components = new Component[][]{ + new Component[]{isAxisShowToolTip}, + }; + axisShowPane = TableLayoutHelper.createTableLayoutPane4Chart(new String[]{"ChartF-Axis", "Chart-Interactive"},components, rowSize, columnSize); + } + + private void initAutoRefreshPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = new double[]{p, f}; + double[] rowSize = new double[]{p, p, p,p}; + + Component[][] components = new Component[][]{ + new Component[]{isAutoRefresh,null}, + new Component[]{GUICoreUtils.createFlowPane(new Component[]{ + new UILabel(Inter.getLocText("Chart-Time_Interval")), + autoRefreshTime, + new UILabel(Inter.getLocText("Chart-Time_Seconds")) + }, 1)}, new Component[]{new UILabel("" + Inter.getLocText("FR-Chart-AutoRefresh_NotSupportIMGAndReportData") + ""), null}, - }; - autoRefreshPane = TableLayoutHelper.createTableLayoutPane4Chart(new String[]{"Data-Check"},components, rowSize, columnSize); - } - - private void initSuperlinkPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = new double[]{p, f}; - double[] rowSize = new double[]{p}; - Component[][] components = new Component[][]{ - new Component[]{superLink, null}, - - }; - superlinkPane = TableLayoutHelper.createTableLayoutPane4Chart(new String[]{"Hyperlink"},components, rowSize, columnSize); - } - - private void relayoutWithPlot(Plot plot) { - this.removeAll(); - double p = TableLayout.PREFERRED; + }; + autoRefreshPane = TableLayoutHelper.createTableLayoutPane4Chart(new String[]{"Data-Check"},components, rowSize, columnSize); + } + + private void initSuperlinkPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = new double[]{p, f}; + double[] rowSize = new double[]{p}; + Component[][] components = new Component[][]{ + new Component[]{superLink, null}, + + }; + superlinkPane = TableLayoutHelper.createTableLayoutPane4Chart(new String[]{"Hyperlink"},components, rowSize, columnSize); + } + + private void relayoutWithPlot(Plot plot) { + this.removeAll(); + double p = TableLayout.PREFERRED; double[] columnSize = new double[]{TableLayout.FILL}; double[] rowSize = new double[]{p, p, p}; @@ -427,7 +431,7 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb double[] row = new double[]{p, p, p, p, p, p}; reloaPane(TableLayoutHelper.createTableLayoutPane(components, row, columnSize)); - } + } private Component[] getChartAnimatePane(Plot plot, double[] row, double[] col) { @@ -455,9 +459,9 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb timeSwitchContainer.add(timeSwitch, BorderLayout.CENTER); if(timeSwitch.isSelected()){ double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = new double[]{TIME_SWITCH_GAP,f}; - double[] rowSize = new double[]{p}; + double f = TableLayout.FILL; + double[] columnSize = new double[]{TIME_SWITCH_GAP,f}; + double[] rowSize = new double[]{p}; Component[][] components = new Component[][]{ new Component[]{null, timeSwitchPane}, }; @@ -523,15 +527,15 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb return new Component[]{superlinkPane}; } - @Override - public void populateBean(Chart chart) { - if (chart == null || chart.getPlot() == null) { - return; - } + @Override + public void populateBean(Chart chart) { + if (chart == null || chart.getPlot() == null) { + return; + } - Plot plot = chart.getPlot(); + Plot plot = chart.getPlot(); relayoutWithGis(chart, plot); - relayoutWithPlot(plot); + relayoutWithPlot(plot); populateChartAnimate(chart, plot); populateChartScale(plot); @@ -540,8 +544,8 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb populateAutoRefresh(chart); populateHyperlink(plot); - checkAutoRefresh(); - } + checkAutoRefresh(); + } private void relayoutWithGis(Chart chart, Plot plot) { if(plot.isSupportAddress4Gis()) { @@ -579,7 +583,7 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb timeSwitch.setEnabled(false); //只有坐标轴为时间坐标轴,并且勾选了图表缩放的时候,才支持时间切换 if(!plot.isSupportZoomCategoryAxis() || !isAxisZoom.isSelected()){ - return; + return; } if(plot.getxAxis() ==null && !plot.getxAxis().isDate()){ @@ -655,6 +659,13 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb private void populateHyperlink(Plot plot) { HashMap paneMap = renewMapWithPlot(plot); + //安装平台内打开插件时,添加相应按钮 + Set providers = ExtraDesignClassManager.getInstance().getArray(HyperlinkProvider.XML_TAG); + for (HyperlinkProvider provider : providers) { + NameableCreator nc = provider.createHyperlinkCreator(); + paneMap.put(nc.getHyperlink(), nc.getUpdatePane()); + } + List list = refreshList(paneMap); superLink.refreshMenuAndAddMenuAction(list); @@ -672,13 +683,13 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb superLink.doLayout(); } - @Override - public void updateBean(Chart chart) { - if (chart == null || chart.getPlot() == null) { - return; - } + @Override + public void updateBean(Chart chart) { + if (chart == null || chart.getPlot() == null) { + return; + } - Plot plot = chart.getPlot(); + Plot plot = chart.getPlot(); updateChartAnimate(chart, plot); updateChartScale(plot); @@ -686,7 +697,7 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb updateAxisTip(plot); updateAutoRefresh(plot); updateHyperlink(plot); - } + } private void updateChartAnimate(Chart chart, Plot plot) { if(plot.isSupportAnimate()) { @@ -818,7 +829,7 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb } - protected Class getUseMap(HashMap map, Object key) { + protected Class getUseMap(HashMap map, Object key) { if(map.get(key) != null){ return (Class)map.get(key); } @@ -832,33 +843,33 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb } } return null; - } - - protected List refreshList(HashMap map) { - List list = new ArrayList(); + } - list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Reportlet"), + protected List refreshList(HashMap map) { + List list = new ArrayList(); + + list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Reportlet"), new ReportletHyperlink(), getUseMap(map, ReportletHyperlink.class))); - list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Mail"), new EmailJavaScript(), ChartEmailPane.class)); - list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Web"), + list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Mail"), new EmailJavaScript(), ChartEmailPane.class)); + list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Web"), new WebHyperlink(), getUseMap(map, WebHyperlink.class))); - list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Dynamic_Parameters"), + list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Dynamic_Parameters"), new ParameterJavaScript(), getUseMap(map, ParameterJavaScript.class))); - list.add(new UIMenuNameableCreator("JavaScript", new JavaScriptImpl(), getUseMap(map, JavaScriptImpl.class))); + list.add(new UIMenuNameableCreator("JavaScript", new JavaScriptImpl(), getUseMap(map, JavaScriptImpl.class))); - list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Float_Chart"), + list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Float_Chart"), new ChartHyperPoplink(), getUseMap(map, ChartHyperPoplink.class))); - list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Cell"), + list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Cell"), new ChartHyperRelateCellLink(), getUseMap(map, ChartHyperRelateCellLink.class))); - list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Float"), + list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Float"), new ChartHyperRelateFloatLink(), getUseMap(map, ChartHyperRelateFloatLink.class))); - - FormHyperlinkProvider hyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); + + FormHyperlinkProvider hyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); list.add(new UIMenuNameableCreator(Inter.getLocText("Chart-Link_Form"), - hyperlink, getUseMap(map, FormHyperlinkProvider.class))); - - return list; - } + hyperlink, getUseMap(map, FormHyperlinkProvider.class))); + + return list; + } private HashMap renewMapWithPlot(Plot plot) { if(plot instanceof PiePlot) { @@ -1021,8 +1032,8 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb private HashMap getNormalPlotHyperMap() { if(normalMap.isEmpty()) { - FormHyperlinkProvider fp = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); - + FormHyperlinkProvider fp = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); + normalMap.put(ReportletHyperlink.class, ReportletHyperlinkPane.CHART.class); normalMap.put(EmailJavaScript.class, ChartEmailPane.class); normalMap.put(WebHyperlink.class, WebHyperlinkPane.CHART.class); @@ -1041,27 +1052,27 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb } return normalMap; } - - @Override - public Chart updateBean() { - return null; - } + + @Override + public Chart updateBean() { + return null; + } /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ public void registerChangeListener(UIObserverListener listener) { timeSwitch.registerChangeListener(listener); timeSwitchPane.registerChangeListener(listener); } /** - * 组件是否需要响应添加的观察者事件 - * - * @return 如果需要响应观察者事件则返回true,否则返回false - */ + * 组件是否需要响应添加的观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ public boolean shouldResponseChangeListener() { return true; } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java index 0afd0cd60..299d878d0 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java @@ -133,7 +133,7 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ } //子类覆盖 - protected Plot getSelectedClonedPlot(){ + protected T getSelectedClonedPlot(){ return null; }