event) {
- showAlert(event.getData());
- }
- });
- JSObject obj = (JSObject) webEngine.executeScript("window");
- obj.setMember("ReuseHelper", ReuseWebBridge.getHelper(webEngine));
- webView.setContextMenuEnabled(false);//屏蔽右键
- root.setCenter(webView);
- }
- });
- }
-
- private void showAlert(final String message) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- JOptionPane.showMessageDialog(ReuseWebPane.this, message);
- }
- });
- }
-}
diff --git a/designer_base/src/com/fr/design/extra/WebDialog.java b/designer_base/src/com/fr/design/extra/WebViewDlgHelper.java
similarity index 75%
rename from designer_base/src/com/fr/design/extra/WebDialog.java
rename to designer_base/src/com/fr/design/extra/WebViewDlgHelper.java
index ed7d73563..481498fc8 100644
--- a/designer_base/src/com/fr/design/extra/WebDialog.java
+++ b/designer_base/src/com/fr/design/extra/WebViewDlgHelper.java
@@ -24,14 +24,14 @@ import java.util.concurrent.ExecutionException;
/**
* Created by vito on 2016/9/28.
*/
-public class WebDialog {
+public class WebViewDlgHelper {
private static final String LATEST = "latest";
private static final String SHOP_SCRIPTS = "shop_scripts";
private static final int VERSION_8 = 8;
+ // 调试时,使用installHome = ClassLoader.getSystemResource("").getPath()代替下面
private static String installHome = StableUtils.getInstallHome();
public static void createPluginDialog() {
- UIDialog dlg;
if (StableUtils.getMajorJavaVersion() >= VERSION_8) {
String relativePath = "/scripts/store/web/index.html";
String mainJsPath = StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath);
@@ -49,10 +49,7 @@ public class WebDialog {
}
} else {
updateShopScripts(SHOP_SCRIPTS);
- BasicPane managerPane = new ShopManagerPane(new PluginWebPane(mainJsPath));
- dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
- PluginWebBridge.getHelper().setDialogHandle(dlg);
- dlg.setVisible(true);
+ showPluginDlg(mainJsPath);
}
} else {
BasicPane traditionalStorePane = new BasicPane() {
@@ -63,21 +60,62 @@ public class WebDialog {
};
traditionalStorePane.setLayout(new BorderLayout());
traditionalStorePane.add(initTraditionalStore(), BorderLayout.CENTER);
- dlg = new ShopDialog(DesignerContext.getDesignerFrame(), traditionalStorePane);
+ UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), traditionalStorePane);
dlg.setVisible(true);
}
}
/**
* 以关键词打开设计器商店
- *
- * // * @param keyword 关键词
+ *
+ * @param keyword 关键词
*/
- public void createPluginDialog(String keyword) {
+ public static void createPluginDialog(String keyword) {
PluginWebBridge.getHelper().openWithSearch(keyword);
createPluginDialog();
}
+ public static void createLoginDialog() {
+ if (StableUtils.getMajorJavaVersion() == VERSION_8) {
+ File file = new File(StableUtils.pathJoin(installHome, "scripts"));
+ if (!file.exists()) {
+ int rv = JOptionPane.showConfirmDialog(
+ null,
+ Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"),
+ Inter.getLocText("FR-Designer-Plugin_Warning"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.INFORMATION_MESSAGE
+ );
+ if (rv == JOptionPane.OK_OPTION) {
+ downloadShopScripts(SHOP_SCRIPTS);
+ }
+ } else {
+ showLoginDlg();
+ updateShopScripts(SHOP_SCRIPTS);
+ }
+ }
+ }
+
+ public static void createQQLoginDialog() {
+ QQLoginWebPane webPane = new QQLoginWebPane(new File(installHome).getAbsolutePath());
+ UIDialog qqlog = new QQLoginDialog(DesignerContext.getDesignerFrame(), webPane);
+ LoginWebBridge.getHelper().setQqDialog(qqlog);
+ qqlog.setVisible(true);
+ }
+
+ private static void showPluginDlg(String mainJsPath) {
+ BasicPane managerPane = new ShopManagerPane(new PluginWebPane(mainJsPath));
+ UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
+ PluginWebBridge.getHelper().setDialogHandle(dlg);
+ dlg.setVisible(true);
+ }
+
+ private static void showLoginDlg() {
+ LoginWebPane webPane = new LoginWebPane(new File(installHome).getAbsolutePath());
+ UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(), webPane);
+ LoginWebBridge.getHelper().setDialogHandle(qqdlg);
+ qqdlg.setVisible(true);
+ }
private static Component initTraditionalStore() {
UITabbedPane tabbedPane = new UITabbedPane();
diff --git a/designer_base/src/com/fr/design/formula/FormulaPane.java b/designer_base/src/com/fr/design/formula/FormulaPane.java
index d7e3f21be..9ef2e4b2b 100644
--- a/designer_base/src/com/fr/design/formula/FormulaPane.java
+++ b/designer_base/src/com/fr/design/formula/FormulaPane.java
@@ -22,6 +22,7 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.parser.FRLexer;
import com.fr.parser.FRParser;
+import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.script.Expression;
@@ -32,16 +33,20 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.*;
+
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.Locale;
+import java.util.Set;
+
/**
* 公式编辑面板
+ *
* @editor zhou
* @since 2012-3-29下午1:50:53
*/
-public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
+public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
protected VariableTreeAndDescriptionArea variableTreeAndDescriptionArea;
protected RSyntaxTextArea formulaTextArea;
@@ -61,38 +66,26 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
initComponents();
}
- protected void initComponents() {
- this.setLayout(new BorderLayout(4, 4));
-
- // text
- JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
- this.add(textPane, BorderLayout.CENTER);
-
- JPanel checkBoxandbuttonPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
-
- UILabel formulaLabel = new UILabel(Inter.getLocText("FormulaD-Input_formula_in_the_text_area_below") + ":"
- + " ");
- formulaLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
- formulaTextArea = new RSyntaxTextArea();
- configFormulaArea();
+ private void initFormulaTextAreaKeyListener() {
formulaTextArea.addKeyListener(this);
-
formulaTextArea.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
formulaTextArea.setForeground(Color.black);
String text = formulaTextArea.getText();
// 判断在中文输入状态是否还包含提示符 要删掉
- String tip = "\n\n\n" + Inter.getLocText("Tips:You_Can_Input_B1_To_Input_The_Data_Of_The_First_Row_Second_Column");
- if(text.contains(tip)) {
+ //Tips:You_Can_Input_B1_To_Input_The_Data_Of_The_First_Row_Second_Column
+ String tip = "\n\n\n" + Inter.getLocText("FR-Designer_FormulaPane_Tips");
+ if (text.contains(tip)) {
text = text.substring(0, text.indexOf(tip));
insertPosition = 0;
formulaTextArea.setText(text);
}
}
});
+ }
+ private void initFormulaTextAreaMouseListener() {
formulaTextArea.addMouseListener(new MouseAdapter() {
-
@Override
public void mousePressed(MouseEvent e) {
insertPosition = formulaTextArea.getCaretPosition();
@@ -115,24 +108,17 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
}
}
});
- UIScrollPane formulaTextAreaScrollPane = new UIScrollPane(formulaTextArea);
- formulaTextAreaScrollPane.setBorder(null);
- textPane.add(formulaLabel, BorderLayout.NORTH);
- textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER);
- textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH);
-
- // tipsPane
- JPanel tipsPane = new JPanel(new BorderLayout(4, 4));
- this.add(tipsPane, BorderLayout.EAST);
+ }
- JPanel searchPane = new JPanel(new BorderLayout(4, 4));
- searchPane.add(keyWordTextField, BorderLayout.CENTER);
- UIButton searchButton = new UIButton(Inter.getLocText("Search"));
- searchPane.add(searchButton, BorderLayout.EAST);
- tipsPane.add(searchPane, BorderLayout.NORTH);
+ private void initFormulaTextArea() {
+ formulaTextArea = new RSyntaxTextArea();
+ configFormulaArea();
+ initFormulaTextAreaKeyListener();
+ initFormulaTextAreaMouseListener();
+ }
+ private void initKeyWordTextFieldKeyListener() {
keyWordTextField.addKeyListener(new KeyListener() {
-
@Override
public void keyTyped(KeyEvent e) {
}
@@ -146,21 +132,59 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
String toFind = keyWordTextField.getText();
search(toFind, false);
-
fixFunctionNameList();
e.consume();
}
}
});
+ }
+ private void initTipsPane() {
+ // tipsPane
+ JPanel tipsPane = new JPanel(new BorderLayout(4, 4));
+ this.add(tipsPane, BorderLayout.EAST);
+
+ JPanel searchPane = new JPanel(new BorderLayout(4, 4));
+ searchPane.add(keyWordTextField, BorderLayout.CENTER);
+ UIButton searchButton = new UIButton(Inter.getLocText("FR-Designer_FormulaPane_Search"));
+ searchPane.add(searchButton, BorderLayout.EAST);
+ tipsPane.add(searchPane, BorderLayout.NORTH);
+ initKeyWordTextFieldKeyListener();
tipsList = new JList(listModel);
tipsList.addMouseListener(new DoubleClick());
UIScrollPane tipsScrollPane = new UIScrollPane(tipsList);
tipsScrollPane.setPreferredSize(new Dimension(170, 75));
tipsScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
-
tipsPane.add(tipsScrollPane, BorderLayout.CENTER);
+ searchButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ String toFind = keyWordTextField.getText();
+ search(toFind, false);
+ formulaTextArea.requestFocusInWindow();
+ fixFunctionNameList();
+ }
+ });
+ }
+ protected void initComponents() {
+ this.setLayout(new BorderLayout(4, 4));
+ // text
+ JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
+ this.add(textPane, BorderLayout.CENTER);
+ JPanel checkBoxandbuttonPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
+ UILabel formulaLabel = new UILabel(Inter.getLocText("FormulaD-Input_formula_in_the_text_area_below") + ":"
+ + " ");
+ formulaLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
+ initFormulaTextArea();
+
+ UIScrollPane formulaTextAreaScrollPane = new UIScrollPane(formulaTextArea);
+ formulaTextAreaScrollPane.setBorder(null);
+ textPane.add(formulaLabel, BorderLayout.NORTH);
+ textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER);
+ textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH);
+
+ initTipsPane();
UIButton checkValidButton = new UIButton(Inter.getLocText("FormulaD-Check_Valid"));
checkValidButton.addActionListener(checkValidActionListener);
@@ -169,20 +193,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
checkBoxPane.setPreferredSize(new Dimension(450, 30));
checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST);
checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST);
-
extendCheckBoxPane(checkBoxPane);
-
- searchButton.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- String toFind = keyWordTextField.getText();
- search(toFind, false);
- formulaTextArea.requestFocusInWindow();
-
- fixFunctionNameList();
- }
- });
variableTreeAndDescriptionArea = new VariableTreeAndDescriptionArea();
this.add(variableTreeAndDescriptionArea, BorderLayout.SOUTH);
}
@@ -254,10 +265,18 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
}
}
+ //hugh:为啥会是10呢?搞不懂~~~
+ private static final int KEY_10 = 10;
+ //上下左右
+ private static final int KEY_37 = 37;
+ private static final int KEY_38 = 38;
+ private static final int KEY_39 = 39;
+ private static final int KEY_40 = 40;
+
@Override
public void keyReleased(KeyEvent e) {
int key = e.getKeyCode();
- if (key == 38 || key == 40 || key == 37 || key == 39 || key == 10) //如果是删除符号 ,为了可读性 没有和其他按键的程序相融合
+ if (key == KEY_38 || key == KEY_40 || key == KEY_37 || key == KEY_39 || key == KEY_10) //如果是删除符号 ,为了可读性 没有和其他按键的程序相融合
{
listModel.removeAllElements();
currentPosition = formulaTextArea.getCaretPosition();
@@ -440,10 +459,10 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
formulaTextArea.requestFocus();
insertPosition = formulaTextArea.getCaretPosition();
}
-
+
@Override
protected String title4PopupWindow() {
- return Inter.getLocText("FormulaD-Formula_Definition");
+ return Inter.getLocText("FormulaD-Formula_Definition");
}
/**
@@ -461,7 +480,8 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
String content = formula.getContent();
if (content.trim().equals("=")) {
this.formulaTextArea.setForeground(Color.gray);
- this.formulaTextArea.setText("\n\n\n" + Inter.getLocText("Tips:You_Can_Input_B1_To_Input_The_Data_Of_The_First_Row_Second_Column"));
+ //Tips:You_Can_Input_B1_To_Input_The_Data_Of_The_First_Row_Second_Column
+ this.formulaTextArea.setText("\n\n\n" + Inter.getLocText("FR-Designer_FormulaPane_Tips"));
this.formulaTextArea.setCaretPosition(0);
ifHasBeenWriten = 0;
this.listModel.removeAllElements();
@@ -549,71 +569,66 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
this.initComponents();
}
- private void initComponents() {
- this.setLayout(new BorderLayout(4, 4));
-
- // Function
- JPanel functionPane = new JPanel(new BorderLayout(4, 4));
- this.add(functionPane, BorderLayout.WEST);
-
-
+ private void initFunctionTypeList(JPanel functionPane) {
functionTypeList = new QuickList(functionTypeListModel);
UIScrollPane functionTypeScrollPane = new UIScrollPane(functionTypeList);
functionTypeScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
functionTypeScrollPane.setPreferredSize(new Dimension(140, 200));
functionPane.add(this.createNamePane(Inter.getLocText("FormulaD-Function_category") + ":", functionTypeScrollPane), BorderLayout.WEST);
- functionTypeList.setCellRenderer(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 FunctionGroup) {
- this.setText(((FunctionGroup) value).getGroupName());
- }
- return this;
- }
- });
-
- functionTypeListModel.addElement(FunctionConstants.COMMON);
- for (int i = 0; i < FunctionConstants.EMBFUNCTIONS.length; i++) {
- functionTypeListModel.addElement(FunctionConstants.EMBFUNCTIONS[i]);
- }
- functionTypeListModel.addElement(FunctionConstants.ALL);
- functionTypeListModel.addElement(FunctionConstants.CUSTOM);
- functionTypeListModel.addElement(FunctionConstants.PLUGIN);
+ initTypeListCellRenderer();
+ initGroupTypeModel();
+ initTypeListSelectionListener();
+ }
+
+ private void initTypeListCellRenderer() {
+ functionTypeList.setCellRenderer(
+ 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 FunctionGroup) {
+ this.setText(((FunctionGroup) value).getGroupName());
+ }
+ return this;
+ }
+ });
+ }
+ private void initTypeListSelectionListener() {
functionTypeList.addListSelectionListener(new ListSelectionListener() {
-
public void valueChanged(ListSelectionEvent evt) {
Object selectedValue = ((JList) evt.getSource()).getSelectedValue();
if (!(selectedValue instanceof FunctionGroup)) {
return;
}
-
NameAndDescription[] nads = ((FunctionGroup) selectedValue).getDescriptions();
functionNameModel = (DefaultListModel) functionNameList.getModel();
-
functionNameModel.clear();
-
for (NameAndDescription nad : nads) {
functionNameModel.addElement(nad);
}
-
if (functionNameModel.size() > 0) {
functionNameList.setSelectedIndex(0);
functionNameList.ensureIndexIsVisible(0);
}
}
});
+ }
- functionNameList = new JList(new DefaultListModel());
- UIScrollPane functionNameScrollPane = new UIScrollPane(functionNameList);
- functionNameScrollPane.setPreferredSize(new Dimension(140, 200));
- functionPane.add(
- this.createNamePane(Inter.getLocText("FormulaD-Function_name") + ":", functionNameScrollPane),
- BorderLayout.CENTER);
- functionNameScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
+ private void initGroupTypeModel() {
+ functionTypeListModel.addElement(FunctionConstants.COMMON);
+ for (int i = 0; i < FunctionConstants.EMBFUNCTIONS.length; i++) {
+ functionTypeListModel.addElement(FunctionConstants.EMBFUNCTIONS[i]);
+ }
+ functionTypeListModel.addElement(FunctionConstants.ALL);
+ functionTypeListModel.addElement(FunctionConstants.CUSTOM);
+ functionTypeListModel.addElement(FunctionConstants.PLUGIN);
+
+ //hugh: 从函数分组插件中添加分组
+ FunctionConstants.addFunctionGroupFromPlugins(functionTypeListModel);
+ }
+ private void initFunctionNameListCellRenderer() {
functionNameList.setCellRenderer(new DefaultListCellRenderer() {
@Override
@@ -625,7 +640,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
return this;
}
});
+ }
+ private void initFunctionNameListSelectionListener() {
functionNameList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
@@ -640,11 +657,11 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
descriptionTextArea.moveCaretPosition(0);
}
});
+ }
+ private void initFunctionNameListMouseListener() {
functionNameList.addMouseListener(new MouseAdapter() {
-
public void mouseClicked(MouseEvent evt) {
-
if (evt.getClickCount() >= 2) {
Object selectedValue = functionNameList.getSelectedValue();
if (!(selectedValue instanceof NameAndDescription)) {
@@ -654,7 +671,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
applyText(insert);
}
-
if (SwingUtilities.isRightMouseButton(evt)) {
JPopupMenu popupMenu = new JPopupMenu();
LookDetailAction lookDetailAction = new LookDetailAction();
@@ -665,24 +681,28 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
}
}
});
+ }
- // vairable.
- variablesTree = new JTree();
- UIScrollPane variablesTreePane = new UIScrollPane(variablesTree);
- variablesTreePane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
- this.add(this.createNamePane(
- Inter.getLocText("Variables") + ":", variablesTreePane), BorderLayout.CENTER);
- variablesTree.setRootVisible(false);
- variablesTree.setShowsRootHandles(true);
- variablesTree.addMouseListener(applyTextMouseListener);
- variablesTree.setCellRenderer(applyTreeCellRenderer);
+ private void initFunctionNameList(JPanel functionPane) {
+ functionNameList = new JList(new DefaultListModel());
+ UIScrollPane functionNameScrollPane = new UIScrollPane(functionNameList);
+ functionNameScrollPane.setPreferredSize(new Dimension(140, 200));
+ functionPane.add(
+ this.createNamePane(Inter.getLocText("FormulaD-Function_name") + ":", functionNameScrollPane),
+ BorderLayout.CENTER);
+ functionNameScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
+ initFunctionNameListCellRenderer();
+ initFunctionNameListSelectionListener();
+ initFunctionNameListMouseListener();
+ }
+ private void initDescriptionTextArea() {
// Description
descriptionTextArea = new UITextArea(16, 27);
UIScrollPane desScrollPane = new UIScrollPane(descriptionTextArea);
desScrollPane.setBorder(null);
- this.add(this.createNamePane(Inter.getLocText("Formula_Description") + ":", desScrollPane), BorderLayout.EAST);
+ this.add(this.createNamePane(Inter.getLocText("FR-Designer_FormulaPane_Formula_Description") + ":", desScrollPane), BorderLayout.EAST);
descriptionTextArea.setBackground(new Color(255, 255, 225));
descriptionTextArea.setLineWrap(true);
descriptionTextArea.setWrapStyleWord(true);
@@ -696,19 +716,41 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
}
});
- variablesTree.addTreeSelectionListener(new TreeSelectionListener() {
+ }
+
+ private StringBuilder getText(TextUserObject selectedValue, String path) throws IOException {
+ Reader desReader;
+ StringBuilder desBuf = new StringBuilder();
+ InputStream desInputStream = BaseUtils.readResource(path + ((TextUserObject) selectedValue).displayText + ".txt");
+ if (desInputStream == null) {
+ String description = "";
+ desReader = new StringReader(description);
+ } else {
+ desReader = new InputStreamReader(desInputStream, EncodeConstants.ENCODING_UTF_8);
+ }
+ BufferedReader reader = new BufferedReader(desReader);
+ String lineText;
+ while ((lineText = reader.readLine()) != null) {
+ if (desBuf.length() > 0) {
+ desBuf.append('\n');
+ }
+ desBuf.append(lineText);
+ }
+ reader.close();
+ desReader.close();
+ return desBuf;
+ }
+ private void initVariablesTreeSelectionListener() {
+ variablesTree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
Object selectedValue = ((DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent()).getUserObject();
if (selectedValue == null) {
return;
}
-
StringBuilder desBuf = new StringBuilder();
try {
- Reader desReader;
String path;
-
Locale locale = FRContext.getLocale();
if (locale.equals(Locale.CHINA)) {
path = "/com/fr/design/insert/formula/variable/cn/";
@@ -716,43 +758,42 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
path = "/com/fr/design/insert/formula/variable/en/";
}
if (selectedValue instanceof TextUserObject) {
-
- InputStream desInputStream = BaseUtils.readResource(path
- + ((TextUserObject) selectedValue).displayText
- + ".txt");
- if (desInputStream == null) {
- String description = "";
-
- desReader = new StringReader(description);
- } else {
- desReader = new InputStreamReader(
- desInputStream);
- }
-
- BufferedReader reader = new BufferedReader(
- desReader);
- String lineText;
- while ((lineText = reader.readLine()) != null) {
- if (desBuf.length() > 0) {
- desBuf.append('\n');
- }
-
- desBuf.append(lineText);
- }
-
- reader.close();
- desReader.close();
+ desBuf = getText((TextUserObject) selectedValue, path);
}
} catch (IOException exp) {
FRContext.getLogger().error(exp.getMessage(), exp);
}
-
descriptionTextArea.setText(desBuf.toString());
-
descriptionTextArea.moveCaretPosition(0);
}
});
+ }
+ private void initVariablesTree() {
+ // vairable.
+ variablesTree = new JTree();
+ UIScrollPane variablesTreePane = new UIScrollPane(variablesTree);
+ variablesTreePane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
+ this.add(this.createNamePane(
+ Inter.getLocText("FR-Designer_FormulaPane_Variables") + ":", variablesTreePane), BorderLayout.CENTER);
+ variablesTree.setRootVisible(false);
+ variablesTree.setShowsRootHandles(true);
+ variablesTree.addMouseListener(applyTextMouseListener);
+ variablesTree.setCellRenderer(applyTreeCellRenderer);
+
+ initDescriptionTextArea();
+
+ initVariablesTreeSelectionListener();
+ }
+
+ private void initComponents() {
+ this.setLayout(new BorderLayout(4, 4));
+ // Function
+ JPanel functionPane = new JPanel(new BorderLayout(4, 4));
+ this.add(functionPane, BorderLayout.WEST);
+ initFunctionTypeList(functionPane);
+ initFunctionNameList(functionPane);
+ initVariablesTree();
// 选择:
functionTypeList.setSelectedIndex(0);
}
@@ -763,7 +804,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
private class LookDetailAction extends UpdateAction {
public LookDetailAction() {
- this.setName(Inter.getLocText("Function_Detail"));
+ this.setName(Inter.getLocText("FR-Designer_FormulaPane_Function_Detail"));
this.setMnemonic('L');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
}
@@ -776,10 +817,10 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
private void showPopupPane() {
BasicPane basicPane = new BasicPane() {
- @Override
- protected String title4PopupWindow() {
- return Inter.getLocText("Function_Detail");
- }
+ @Override
+ protected String title4PopupWindow() {
+ return Inter.getLocText("FR-Designer_FormulaPane_Function_Detail");
+ }
};
basicPane.setLayout(FRGUIPaneFactory.createBorderLayout());
UITextArea desArea = new UITextArea();
@@ -869,52 +910,28 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
rootNode.add(bindCellNode);
}
- {
- MutableTreeNode tableTreeNode = new TextFolderUserObject(
- Inter.getLocText("FormulaD-Data_Fields"),
- BaseUtils.readIcon("/com/fr/design/images/dialog/table.png"),
- variableResolver.resolveColumnNames()).createMutableTreeNode();
+ rootNode.add(new TextFolderUserObject(Inter.getLocText("FormulaD-Data_Fields"),
+ BaseUtils.readIcon("/com/fr/design/images/dialog/table.png"),
+ variableResolver.resolveColumnNames()).createMutableTreeNode());
- rootNode.add(tableTreeNode);
- }
+ // Set cutReport Variable
+ rootNode.add(new TextFolderUserObject(Inter.getLocText("FR-Designer_FormulaPane_Variables"),
+ BaseUtils.readIcon("/com/fr/design/images/dialog/variable.png"),
+ variableResolver.resolveCurReportVariables()).createMutableTreeNode());
- {
- // Set cutReport Variable
- rootNode.add(new TextFolderUserObject(
- Inter.getLocText("Variables"),
- BaseUtils.readIcon("/com/fr/design/images/dialog/variable.png"),
- variableResolver.resolveCurReportVariables()).createMutableTreeNode());
- }
-
-
- {
- rootNode.add(new TextFolderUserObject(
- Inter.getLocText(new String[]{"Datasource-Datasource", "Parameter"}),
- BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"),
- variableResolver.resolveTableDataParameterVariables()).createMutableTreeNode());
- }
+ rootNode.add(new TextFolderUserObject(Inter.getLocText(new String[]{"Datasource-Datasource", "Parameter"}),
+ BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"),
+ variableResolver.resolveTableDataParameterVariables()).createMutableTreeNode());
+ rootNode.add(new TextFolderUserObject(Inter.getLocText("ParameterD-Report_Parameter"),
+ BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif"),
+ variableResolver.resolveReportParameterVariables()).createMutableTreeNode());
- {
- MutableTreeNode reportParameterTreeNode = new TextFolderUserObject(
- Inter.getLocText("ParameterD-Report_Parameter"),
- BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif"),
- variableResolver.resolveReportParameterVariables()).createMutableTreeNode();
-
- rootNode.add(reportParameterTreeNode);
- }
-
- {
- MutableTreeNode globalParameterTreeNode = new TextFolderUserObject(
- Inter.getLocText("M_Server-Global_Parameters"),
- BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"),
- variableResolver.resolveGlobalParameterVariables()).createMutableTreeNode();
- rootNode.add(globalParameterTreeNode);
- }
-
+ rootNode.add(new TextFolderUserObject(Inter.getLocText("M_Server-Global_Parameters"),
+ BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"),
+ variableResolver.resolveGlobalParameterVariables()).createMutableTreeNode());
variableModel.reload();
-
// Expand
for (int row = 0; row < this.variablesTree.getRowCount(); row++) {
this.variablesTree.expandRow(row);
@@ -993,6 +1010,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
buffer.append("|");
buffer.append("\n");
}
- System.out.println(buffer.toString());
+ FRContext.getLogger().debug(buffer.toString());
}
}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/formula/FunctionConstants.java b/designer_base/src/com/fr/design/formula/FunctionConstants.java
index cfb983dd7..8a0675897 100644
--- a/designer_base/src/com/fr/design/formula/FunctionConstants.java
+++ b/designer_base/src/com/fr/design/formula/FunctionConstants.java
@@ -11,6 +11,8 @@ import com.fr.stable.EncodeConstants;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
+import com.fr.stable.fun.FunctionDefContainer;
+import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.Function;
import com.fr.stable.script.FunctionDef;
@@ -23,8 +25,49 @@ import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import javax.swing.DefaultListModel;
+
public abstract class FunctionConstants {
+
+ /**
+ * 将函数分组插件中的函数添加到对应的列表中
+ * @param listModel
+ */
+ public static void addFunctionGroupFromPlugins(DefaultListModel listModel){
+ //hugh:自定义函数分组
+ Set containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
+ if(!containers.isEmpty()){
+ for(Mutable container : containers){
+ listModel.addElement(createFunctionGroup((FunctionDefContainer)container));
+ }
+ }
+ }
+
+ /**
+ * 创建一个新的分组
+ * @param container
+ * @return
+ */
+ private static FunctionGroup createFunctionGroup(final FunctionDefContainer container){
+ return new FunctionGroup() {
+ @Override
+ public String getGroupName() {
+ return container.getGroupName();
+ }
+ @Override
+ public NameAndDescription[] getDescriptions() {
+ FunctionDef[] fs = container.getFunctionDefs();
+ int count = fs.length;
+ FunctionDefNAD[] nads = new FunctionDefNAD[count];
+ for (int i = 0; i < count; i ++) {
+ nads[i] = new FunctionDefNAD(fs[i]);
+ }
+ return nads;
+ }
+ };
+ }
+
public static FunctionGroup PLUGIN = new FunctionGroup() {
@Override
public String getGroupName() {
@@ -96,7 +139,13 @@ public abstract class FunctionConstants {
}
Collections.addAll(all, PLUGIN.getDescriptions());
Collections.addAll(all, CUSTOM.getDescriptions());
-
+ //hugh:自定义函数分组
+ Set containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
+ if(!containers.isEmpty()){
+ for(Mutable container : containers){
+ Collections.addAll(all,createFunctionGroup(((FunctionDefContainer)container)).getDescriptions());
+ }
+ }
java.util.Collections.sort(all, NameAndDescriptionComparator);
return all.toArray(new NameAndDescription[all.size()]);
diff --git a/designer_base/src/com/fr/design/formula/FunctionDefNAD.java b/designer_base/src/com/fr/design/formula/FunctionDefNAD.java
index c7c2177b5..715660169 100644
--- a/designer_base/src/com/fr/design/formula/FunctionDefNAD.java
+++ b/designer_base/src/com/fr/design/formula/FunctionDefNAD.java
@@ -6,7 +6,7 @@ import com.fr.stable.StringUtils;
public class FunctionDefNAD extends AbstractNameAndDescription {
private FunctionDef def;
- FunctionDefNAD(FunctionDef def) {
+ public FunctionDefNAD(FunctionDef def) {
this.def = def;
}
diff --git a/designer_base/src/com/fr/design/formula/FunctionManagerPane.java b/designer_base/src/com/fr/design/formula/FunctionManagerPane.java
index 3fffe594e..001bd5626 100644
--- a/designer_base/src/com/fr/design/formula/FunctionManagerPane.java
+++ b/designer_base/src/com/fr/design/formula/FunctionManagerPane.java
@@ -20,6 +20,7 @@ import com.fr.file.FunctionManagerProvider;
import com.fr.general.Inter;
import com.fr.general.NameObject;
import com.fr.stable.Nameable;
+import com.fr.stable.ProductConstants;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.script.FunctionDef;
@@ -159,10 +160,11 @@ public class FunctionManagerPane extends BasicPane {
descriptionArea.setWrapStyleWord(true);
descriptionArea.setLineWrap(true);
northPane.add(descriptionArea);
- descriptionArea.setText(Inter.getLocText(new String[]{"Function-The_class_must_inherit","Fuction-The_compiled_class_should_be_copied_to",
- "Function-J2EE_server", "Directory", "Function-Source_Code", "Example"},
- new String[]{" \"com.fr.script.AbstractFunction\".", "\n", " \"" + File.separator + "WEB-INF" + File.separator + "classes\"",
- ",", ".\n", ":" + FRContext.getCurrentEnv().getPath() + File.separator + "classes"}));
+
+ String path1 = getEscapePath(File.separator + ProjectConstants.WEBINF_NAME + File.separator + ProjectConstants.CLASSES_NAME);
+ String path2 = getEscapePath(FRContext.getCurrentEnv().getPath() + File.separator + ProjectConstants.CLASSES_NAME);
+ descriptionArea.setText(Inter.getLocText("FR-Designer_Function_Description_Area_Text", path1, path2));
+
JPanel descriptionPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); //Description Pane
this.add(descriptionPane, BorderLayout.SOUTH);
descriptionPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
@@ -170,6 +172,10 @@ public class FunctionManagerPane extends BasicPane {
this.descriptionTextArea = new UITextArea(6, 24);
descriptionPane.add(new JScrollPane(this.descriptionTextArea), BorderLayout.CENTER);
}
+
+ private String getEscapePath(String path) {
+ return path.replace("\\", "\\\\");
+ }
private ActionListener createEditorButtonActionListener() {
return new ActionListener() {
diff --git a/designer_base/src/com/fr/design/formula/VariableResolverAdapter.java b/designer_base/src/com/fr/design/formula/VariableResolverAdapter.java
index eb80600ac..623b1cbf4 100644
--- a/designer_base/src/com/fr/design/formula/VariableResolverAdapter.java
+++ b/designer_base/src/com/fr/design/formula/VariableResolverAdapter.java
@@ -4,12 +4,16 @@ import com.fr.base.ConfigManager;
import com.fr.base.Parameter;
import com.fr.design.DesignModelAdapter;
import com.fr.base.ConfigManagerProvider;
+import com.fr.plugin.ExtraClassManager;
import com.fr.script.ScriptConstants;
+import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
+import com.fr.stable.fun.BuiltInParametersProvider;
import com.fr.stable.script.CalculatorProvider;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
public abstract class VariableResolverAdapter implements VariableResolver {
private static final int TABLE_DATA_PARA = 0;
@@ -21,7 +25,7 @@ public abstract class VariableResolverAdapter implements VariableResolver {
* @return 内置参数
*/
public String[] resolveCurReportVariables() {
- return new String[] { ScriptConstants.SUMMARY_TAG + "page_number",
+ String [] variables = new String[] { ScriptConstants.SUMMARY_TAG + "page_number",
ScriptConstants.SUMMARY_TAG + "totalPage_number",
// 下面是权限相关的参数
ScriptConstants.DETAIL_TAG + Constants.P.PRIVILEGE_USERNAME, ScriptConstants.DETAIL_TAG + Constants.P.PRIVILEGE_AUTHORITY,
@@ -32,6 +36,13 @@ public abstract class VariableResolverAdapter implements VariableResolver {
CalculatorProvider.REPORT_NAME, CalculatorProvider.FORMLET_NAME, CalculatorProvider.SERVLET_URL, CalculatorProvider.SERVER_SCHEMA, CalculatorProvider.SERVER_NAME,
CalculatorProvider.SERVER_PORT, CalculatorProvider.SERVER_URL, CalculatorProvider.CONTEXT_PATH, CalculatorProvider.SESSION_ID
};
+ Set set = ExtraClassManager.getInstance().getArray(BuiltInParametersProvider.XML_TAG);
+ for (BuiltInParametersProvider provider : set) {
+ return (String[]) ArrayUtils.addAll(variables, new String []{
+ ScriptConstants.DETAIL_TAG + provider.getParametersName()
+ });
+ }
+ return variables;
}
private Parameter[] getCurrentModeParameters(int type) {
diff --git a/designer_base/src/com/fr/design/fun/ConnectionProvider.java b/designer_base/src/com/fr/design/fun/ConnectionProvider.java
index c6bd2fca2..766f7d414 100644
--- a/designer_base/src/com/fr/design/fun/ConnectionProvider.java
+++ b/designer_base/src/com/fr/design/fun/ConnectionProvider.java
@@ -12,7 +12,8 @@ public interface ConnectionProvider extends Mutable {
public static final String XML_TAG = "ConnectionProvider";
- int CURRENT_LEVEL = 1;
+ // 2016-12-14 1 -> 2 , 增加connection.feature方法导致不兼容.
+ int CURRENT_LEVEL = 2;
/**
* 数据连接弹出菜单的名字
diff --git a/designer_base/src/com/fr/design/fun/ExtraButtonToolBarProvider.java b/designer_base/src/com/fr/design/fun/ExtraButtonToolBarProvider.java
new file mode 100644
index 000000000..09bff1f1a
--- /dev/null
+++ b/designer_base/src/com/fr/design/fun/ExtraButtonToolBarProvider.java
@@ -0,0 +1,41 @@
+package com.fr.design.fun;
+
+import com.fr.form.ui.Widget;
+import com.fr.stable.fun.mark.Mutable;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * 报表工具栏设计器端拓展,用于配置按钮额外属性
+ * Created by harry on 2016-12-23.
+ */
+public interface ExtraButtonToolBarProvider extends Mutable {
+
+ String XML_TAG = "ExtraButtonToolBarProvider";
+
+ int CURRENT_LEVEL = 1;
+
+ /**
+ * 用于添加属性面板
+ *
+ * @param centerPane 面板
+ */
+ void updateCenterPane(JPanel centerPane);
+
+ /**
+ * 更新界面
+ *
+ * @param widget 控件
+ * @param card 卡片布局
+ * @param centerPane 面板
+ */
+ void populate(Widget widget, CardLayout card, JPanel centerPane);
+
+ /**
+ * 保存界面设置
+ *
+ * @param widget 控件
+ */
+ void update(Widget widget);
+}
diff --git a/designer_base/src/com/fr/design/fun/HyperlinkProvider.java b/designer_base/src/com/fr/design/fun/HyperlinkProvider.java
index e6eccc882..9f0a53cfa 100644
--- a/designer_base/src/com/fr/design/fun/HyperlinkProvider.java
+++ b/designer_base/src/com/fr/design/fun/HyperlinkProvider.java
@@ -10,7 +10,7 @@ import com.fr.stable.fun.mark.Mutable;
public interface HyperlinkProvider extends Mutable {
String XML_TAG = "HyperlinkProvider";
- int CURRENT_LEVEL = 1;
+ int CURRENT_LEVEL = 2;
/**
diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractExtraButtonToolBarProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractExtraButtonToolBarProvider.java
new file mode 100644
index 000000000..064d72d1c
--- /dev/null
+++ b/designer_base/src/com/fr/design/fun/impl/AbstractExtraButtonToolBarProvider.java
@@ -0,0 +1,19 @@
+package com.fr.design.fun.impl;
+
+import com.fr.design.fun.ExtraButtonToolBarProvider;
+import com.fr.stable.fun.impl.AbstractProvider;
+import com.fr.stable.fun.mark.API;
+
+/**
+ * Created by harry on 2016-12-23.
+ */
+@API(level = ExtraButtonToolBarProvider.CURRENT_LEVEL)
+public abstract class AbstractExtraButtonToolBarProvider extends AbstractProvider implements ExtraButtonToolBarProvider {
+ public int currentAPILevel() {
+ return ExtraButtonToolBarProvider.CURRENT_LEVEL;
+ }
+
+ public String mark4Provider() {
+ return getClass().getName();
+ }
+}
diff --git a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java
index dd91b7824..52802921a 100644
--- a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java
+++ b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java
@@ -109,6 +109,10 @@ public abstract class JListControlPane extends JControlPane {
}
+ protected void doBeforePopulate(ListModelElement el, Object obj) {
+
+ }
+
@Override
protected ShortCut4JControlPane addItemShortCut() {
ShortCut addItemShortCut;
@@ -832,6 +836,7 @@ public abstract class JListControlPane extends JControlPane {
cardPane.add(updatePanes[i], String.valueOf(i));
}
card.show(cardPane, String.valueOf(i));
+ doBeforePopulate(el, ob2Populate);
updatePanes[i].populateBean(ob2Populate);
doWhenPopulate(updatePanes[i]);
break;
diff --git a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java
index 112fa54dc..99fc5948e 100644
--- a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java
+++ b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java
@@ -13,6 +13,7 @@ import com.fr.js.JavaScript;
import com.fr.js.NameJavaScript;
import com.fr.js.NameJavaScriptGroup;
import com.fr.plugin.PluginManager;
+import com.fr.stable.ListMap;
import com.fr.stable.Nameable;
import java.util.ArrayList;
@@ -34,7 +35,7 @@ public class HyperlinkGroupPane extends JListControlPane {
* @return 返回Nameable按钮数组.
*/
public NameableCreator[] createNameableCreators() {
- Map nameCreators = new TreeMap();
+ Map nameCreators = new ListMap<>();
NameableCreator[] creators = DesignModuleFactory.getHyperlinkGroupType().getHyperlinkCreators();
for (NameableCreator creator : creators) {
nameCreators.put(creator.menuName(), creator);
diff --git a/designer_base/src/com/fr/design/gui/ibutton/UIButtonGroup.java b/designer_base/src/com/fr/design/gui/ibutton/UIButtonGroup.java
index 8a266a2a1..636f72858 100644
--- a/designer_base/src/com/fr/design/gui/ibutton/UIButtonGroup.java
+++ b/designer_base/src/com/fr/design/gui/ibutton/UIButtonGroup.java
@@ -28,6 +28,7 @@ import com.fr.design.utils.gui.GUICoreUtils;
public class UIButtonGroup extends JPanel implements GlobalNameObserver {
private boolean isTwoLine = false;
+ private boolean isFourLine = false;
private static final long serialVersionUID = 1L;
protected List labelButtonList;
protected int selectedIndex = -1;
@@ -176,6 +177,10 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver {
this.isTwoLine = true;
}
+ public void setFourLine() {
+ this.isFourLine = true;
+ }
+
/**
* paintComponent
*
@@ -201,32 +206,40 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver {
}
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(UIConstants.LINE_COLOR);
- if (!isTwoLine) {
+ if (isTwoLine) {
int width = 0;
- for (int i = 0; i < labelButtonList.size() - 1; i++) {
+ int upCount = (labelButtonList.size() - 1) / 2 + 1;
+ for (int i = 0; i < upCount - 1; i++) {
width += labelButtonList.get(i).getWidth() + 1;
- int height = labelButtonList.get(i).getHeight();
+ int height = labelButtonList.get(i).getHeight() * 2 + 1;
g.drawLine(width, 0, width, height);
}
- width += labelButtonList.get(labelButtonList.size() - 1).getWidth() + 1;
-
+ width += labelButtonList.get(upCount).getWidth() + 1;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawRoundRect(0, 0, width, getHeight() - 1, UIConstants.ARC, UIConstants.ARC);
+ g2d.drawLine(0, getHeight() / 2, width, getHeight() / 2);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ } else if (isFourLine) {
+ // 4 * 1
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC);
+ for (int i = 1; i <= 3; i++) {
+ g2d.drawLine(0, getHeight() / 4 * i, getWidth() - 1, getHeight() / 4 * i);
+ }
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
} else {
int width = 0;
- int upCount = (labelButtonList.size() - 1) / 2 + 1;
- for (int i = 0; i < upCount - 1; i++) {
+ for (int i = 0; i < labelButtonList.size() - 1; i++) {
width += labelButtonList.get(i).getWidth() + 1;
- int height = labelButtonList.get(i).getHeight() * 2 + 1;
+ int height = labelButtonList.get(i).getHeight();
g.drawLine(width, 0, width, height);
}
- width += labelButtonList.get(upCount).getWidth() + 1;
+ width += labelButtonList.get(labelButtonList.size() - 1).getWidth() + 1;
+
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawRoundRect(0, 0, width, getHeight() - 1, UIConstants.ARC, UIConstants.ARC);
- g2d.drawLine(0, getHeight() / 2, width, getHeight() / 2);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
diff --git a/designer_base/src/com/fr/design/gui/icombobox/UIComboBox.java b/designer_base/src/com/fr/design/gui/icombobox/UIComboBox.java
index d6d149674..350b99ead 100644
--- a/designer_base/src/com/fr/design/gui/icombobox/UIComboBox.java
+++ b/designer_base/src/com/fr/design/gui/icombobox/UIComboBox.java
@@ -160,6 +160,14 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
uiObserverListener = listener;
}
+ public void removeChangeListener(){
+ uiObserverListener = null;
+ }
+
+ public UIObserverListener getUiObserverListener(){
+ return uiObserverListener;
+ }
+
/**
* @return
*/
diff --git a/designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java b/designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java
index 02a6f547b..36e9cc17d 100644
--- a/designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java
+++ b/designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java
@@ -26,32 +26,39 @@ import com.fr.general.Inter;
*/
public abstract class AbstractPropertyTable extends JTable {
- // 属性分组
+ // // 所有数据组, 把数据分组,一个可折叠的项里面的所有行 为一组
protected ArrayList groups;
- protected TableModel default_table_model;
// 属性表被选中的行加一个浅蓝色的背景
public static final Color PROPERTY_SELECTION_BACKGROUND = new Color(153, 204, 255);
// 属性表的行高
public static final int PROPERTY_TABLE_ROW_HEIGHT = 22;
+ private static final int PROPERTY_ICON_WIDTH = 10;
public AbstractPropertyTable() {
- this.setRowHeight(PROPERTY_TABLE_ROW_HEIGHT);
+ this.setTableProperties();
+ this.initPopup();
+ this.setModel(new DefaultTableModel());
+ }
+
+ private void setTableProperties() {
JTableHeader header = getTableHeader();
header.setReorderingAllowed(false);
header.setPreferredSize(new Dimension(0, PROPERTY_TABLE_ROW_HEIGHT));
header.setDefaultRenderer(new HeaderRenderer());
+ this.setRowHeight(PROPERTY_TABLE_ROW_HEIGHT);
this.setGridColor(new Color(212, 208, 200));
this.setSelectionBackground(PROPERTY_SELECTION_BACKGROUND);
this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.setColumnSelectionAllowed(false);
this.setRowSelectionAllowed(true);
this.setFillsViewportHeight(true);
- this.initPopup();
- default_table_model = new DefaultTableModel();
- this.setModel(default_table_model);
this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
}
+ /**
+ * 在这个函数里面初始化表格数据再repaint
+ * @param source
+ */
public abstract void initPropertyGroups(Object source);
public void fireValueChanged(Object old_value, boolean success, Object newValue) {
@@ -64,12 +71,15 @@ public abstract class AbstractPropertyTable extends JTable {
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
+ //如果数据组不为空
if (groups != null) {
Point pIndex = getGroupIndex(row);
if (pIndex == null){
return super.getCellRenderer(row, column);
}
+ //拿出当前行所在的那个属性组
PropertyGroup group = groups.get(pIndex.x);
+ //如果是标题行
if (pIndex.y == 0) {
if (column == 0) {
return group.getFirstRenderer();
@@ -77,11 +87,13 @@ public abstract class AbstractPropertyTable extends JTable {
return group.getSecondRenderer();
}
} else {
+ //如果是非标题行第一列,采用默认渲染器
if (column == 0) {
return super.getCellRenderer(row, column);
} else {
TableCellRenderer renderer = group.getModel().getRenderer(pIndex.y - 1);
if (renderer instanceof Component) {
+ //如果这个渲染器是继承自Component,根据当前行列是否可编辑决定该控件是否可用
((Component) renderer).setEnabled(isCellEditable(row, column));
}
return renderer;
@@ -115,6 +127,12 @@ public abstract class AbstractPropertyTable extends JTable {
}
}
+ /**
+ * 看懂了。。写个注释先
+ * 获取当前row行的Point(x, y), x代表当前row行是属于groups中的第x个组,y代表当前row行所在的第x组里面的第y行
+ * @param row
+ * @return
+ */
private Point getGroupIndex(int row) {
int count = 0;
for (int i = 0; i < groups.size(); i++) {
@@ -135,6 +153,10 @@ public abstract class AbstractPropertyTable extends JTable {
this.addMouseListener(new MouseAdapter() {
+ /**
+ * 如果点到标题行就要触发折叠事件
+ * @param e
+ */
@Override
public void mouseClicked(MouseEvent e) {
if (!e.isPopupTrigger() && groups != null) {
@@ -148,13 +170,18 @@ public abstract class AbstractPropertyTable extends JTable {
}
}
+ /**
+ * 这个mousePressed和上面的mouseClicked唯一不同的地方是单双击和e.getX() < 10 的判断
+ * 这个意思应该就是说点到图标(加号减号),立即触发折叠效果,否则点其他处要双击才能触发
+ * @param e
+ */
@Override
public void mousePressed(MouseEvent e) {
if (!e.isPopupTrigger() && groups != null) {
int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint());
if (row != -1) {
Point pIndex = getGroupIndex(row);
- if (pIndex.y == 0 && e.getClickCount() == 1 && e.getX() < 10) {
+ if (pIndex.y == 0 && e.getClickCount() == 1 && e.getX() < PROPERTY_ICON_WIDTH) {
toggleCollapse(pIndex.x);
}
}
@@ -163,16 +190,27 @@ public abstract class AbstractPropertyTable extends JTable {
});
}
+ /**
+ * 切换属性组折叠属性true/false
+ * @param groupIndex
+ */
private void toggleCollapse(int groupIndex) {
PropertyGroup group = groups.get(groupIndex);
group.setCollapsed(!group.isCollapsed());
+ //这里获取表格的父控件是为了当表格被折叠了后,装表格的父控件也要相应的重新布局一下
+ //比如折叠之后表格行数应该比原来的少,占用父容器空间应该小点,不重新布局父容器,表格大小不会改变
Container parent = AbstractPropertyTable.this.getParent();
if (parent != null) {
- parent.doLayout();
+// parent.doLayout(); // 这里还是用revalidate吧。。daLayout有时候会失效不知道为什么
+ parent.revalidate();
}
repaint();
}
+ /**
+ * BeanTableModel类,提供表格数据
+ * 它的所有数据来源均来自PropertyGroup中的AbstractPropertyGroupModel中的descriptor
+ */
public class BeanTableModel extends AbstractTableModel {
@Override
diff --git a/designer_base/src/com/fr/design/gui/itable/PropertyGroup.java b/designer_base/src/com/fr/design/gui/itable/PropertyGroup.java
index f66288e39..c863c882d 100644
--- a/designer_base/src/com/fr/design/gui/itable/PropertyGroup.java
+++ b/designer_base/src/com/fr/design/gui/itable/PropertyGroup.java
@@ -4,11 +4,14 @@ import javax.swing.table.TableCellRenderer;
import com.fr.design.beans.GroupModel;
+/**
+ * PropertyGroup类描述了属性表中一个属性分组
+ */
public class PropertyGroup {
- private GroupModel model;
- private String name;
- private boolean collapsed;
+ private GroupModel model; // 描述这个属性组中的数据model
+ private String name; // 这组属性的标题名称
+ private boolean collapsed; // 这组属性是否折叠
private GroupRenderer renderer1;
private GroupRenderer renderer2;
@@ -55,4 +58,5 @@ public class PropertyGroup {
public TableCellRenderer getSecondRenderer() {
return renderer2;
}
+
}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/gui/style/BorderPane.java b/designer_base/src/com/fr/design/gui/style/BorderPane.java
index 60989aedd..cb37f1c1a 100644
--- a/designer_base/src/com/fr/design/gui/style/BorderPane.java
+++ b/designer_base/src/com/fr/design/gui/style/BorderPane.java
@@ -51,34 +51,16 @@ public class BorderPane extends AbstractBasicStylePane {
}
protected void initComponents() {
- topToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/top.png"));
- leftToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/left.png"));
- bottomToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/bottom.png"));
- rightToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/right.png"));
- horizontalToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/horizontal.png"));
- verticalToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/vertical.png"));
- this.currentLineCombo = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY);
- this.currentLineColorPane = new NewColorSelectBox(100);
-
+ initButtonsWithIcon();
this.setLayout(new BorderLayout(0, 6));
-
- double p = TableLayout.PREFERRED;
- double f = TableLayout.FILL;
-
- double[] columnSize1 = {p, f};
- double[] rowSize1 = {p, p};
-
-
+ double p = TableLayout.PREFERRED, f = TableLayout.FILL;
+ double[] columnSize1 = {p, f}, rowSize1 = {p, p};
Component[][] components1 = new Component[][]{
- new Component[]{new UILabel(Inter.getLocText("Style") + ":"), currentLineCombo},
- new Component[]{new UILabel(Inter.getLocText("Color") + ":"), currentLineColorPane},
+ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Style") + ":"), currentLineCombo},
+ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Color") + ":"), currentLineColorPane},
};
-
JPanel northPane = TableLayoutHelper.createTableLayoutPane(components1, rowSize1, columnSize1);
-
-
- double[] columnSize2 = {p, f};
- double[] rowSize2 = {p, p};
+ double[] columnSize2 = {p, f}, rowSize2 = {p, p};
JPanel externalPane = new JPanel(new GridLayout(0, 4));
externalPane.add(topToggleButton);
externalPane.add(leftToggleButton);
@@ -87,23 +69,15 @@ public class BorderPane extends AbstractBasicStylePane {
JPanel insidePane = new JPanel(new GridLayout(0, 2));
insidePane.add(horizontalToggleButton);
insidePane.add(verticalToggleButton);
-
-
Component[][] components2 = new Component[][]{
new Component[]{outerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/out.png")), innerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/in.png"))},
new Component[]{externalPane, insidePane,}
};
JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components2, rowSize2, columnSize2);
-
this.setLayout(new BorderLayout(0, 6));
this.add(northPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
-
-
- this.currentLineColorPane.setSelectObject(Color.BLACK);
-
outerToggleButton.addChangeListener(new ChangeListener() {
-
@Override
public void stateChanged(ChangeEvent e) {
boolean value = outerToggleButton.isSelected();
@@ -113,9 +87,7 @@ public class BorderPane extends AbstractBasicStylePane {
rightToggleButton.setSelected(value);
}
});
-
innerToggleButton.addChangeListener(new ChangeListener() {
-
@Override
public void stateChanged(ChangeEvent e) {
boolean value = innerToggleButton.isSelected();
@@ -123,12 +95,22 @@ public class BorderPane extends AbstractBasicStylePane {
verticalToggleButton.setSelected(value);
}
});
+ }
+ private void initButtonsWithIcon(){
+ topToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/top.png"));
+ leftToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/left.png"));
+ bottomToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/bottom.png"));
+ rightToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/right.png"));
+ horizontalToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/horizontal.png"));
+ verticalToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/vertical.png"));
+ this.currentLineCombo = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY);
+ this.currentLineColorPane = new NewColorSelectBox(100);
}
@Override
public String title4PopupWindow() {
- return Inter.getLocText("Border");
+ return Inter.getLocText("FR-Designer_Border");
}
public void populate(Style style) {
diff --git a/designer_base/src/com/fr/design/images/control/tab/end.png b/designer_base/src/com/fr/design/images/control/tab/end.png
new file mode 100644
index 000000000..da848239f
Binary files /dev/null and b/designer_base/src/com/fr/design/images/control/tab/end.png differ
diff --git a/designer_base/src/com/fr/design/images/control/tab/end_not.png b/designer_base/src/com/fr/design/images/control/tab/end_not.png
new file mode 100644
index 000000000..1f08bdf35
Binary files /dev/null and b/designer_base/src/com/fr/design/images/control/tab/end_not.png differ
diff --git a/designer_base/src/com/fr/design/images/control/tab/first.png b/designer_base/src/com/fr/design/images/control/tab/first.png
new file mode 100644
index 000000000..5bdb04402
Binary files /dev/null and b/designer_base/src/com/fr/design/images/control/tab/first.png differ
diff --git a/designer_base/src/com/fr/design/images/control/tab/first_not.png b/designer_base/src/com/fr/design/images/control/tab/first_not.png
new file mode 100644
index 000000000..50d048a19
Binary files /dev/null and b/designer_base/src/com/fr/design/images/control/tab/first_not.png differ
diff --git a/designer_base/src/com/fr/design/images/control/tab/next.png b/designer_base/src/com/fr/design/images/control/tab/next.png
new file mode 100644
index 000000000..495a51805
Binary files /dev/null and b/designer_base/src/com/fr/design/images/control/tab/next.png differ
diff --git a/designer_base/src/com/fr/design/images/control/tab/next_not.png b/designer_base/src/com/fr/design/images/control/tab/next_not.png
new file mode 100644
index 000000000..f002a0b9e
Binary files /dev/null and b/designer_base/src/com/fr/design/images/control/tab/next_not.png differ
diff --git a/designer_base/src/com/fr/design/images/control/tab/prev.png b/designer_base/src/com/fr/design/images/control/tab/prev.png
new file mode 100644
index 000000000..5923d5794
Binary files /dev/null and b/designer_base/src/com/fr/design/images/control/tab/prev.png differ
diff --git a/designer_base/src/com/fr/design/images/control/tab/prev_not.png b/designer_base/src/com/fr/design/images/control/tab/prev_not.png
new file mode 100644
index 000000000..2530395fd
Binary files /dev/null and b/designer_base/src/com/fr/design/images/control/tab/prev_not.png differ
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/$$$.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/$$$.txt
index ea95070da..48d884dc4 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/$$$.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/$$$.txt
@@ -1 +1 @@
-ǰֵ
\ No newline at end of file
+当前值
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/$$page_number.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/$$page_number.txt
index 322c867f4..0e45e0871 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/$$page_number.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/$$page_number.txt
@@ -1 +1 @@
-ǰҳ
+当前的页数。
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/$$totalPage_number.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/$$totalPage_number.txt
index a6a8244be..11c6fb59b 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/$$totalPage_number.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/$$totalPage_number.txt
@@ -1 +1 @@
-ҳ
\ No newline at end of file
+总页数。
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_authority.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_authority.txt
index eadf192eb..abafe8eff 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_authority.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_authority.txt
@@ -1 +1 @@
-ʹȨʱɫIJ
\ No newline at end of file
+使用权限时保存角色的参数
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_username.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_username.txt
index 586198ed0..9dadd3883 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_username.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_username.txt
@@ -1 +1 @@
-ʹȨʱûIJ
\ No newline at end of file
+使用权限时保存用户名的参数
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_userposition.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_userposition.txt
index 07b3122ab..73cb5a6d2 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_userposition.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/$fr_userposition.txt
@@ -1,3 +1 @@
-ʹȨʱ,$fr_userpositionDzŽɫ
-ʽ磺{"departments":"","jobTitle":"۾"}
-ŽɫԲźְɵ顣
\ No newline at end of file
+使用权限时,$fr_userposition就是部门角色,格式如:{"jobTitle":"销售经理","departments":"销售"},部门角色是以部门和职务组成的数组。
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/NOFILTER.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/NOFILTER.txt
index ccda7162b..13caca6bc 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/NOFILTER.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/NOFILTER.txt
@@ -1 +1 @@
-NOFILTERһֵȽ϶ΪtrueIJ
+NOFILTER是一个与任意值比较都为true的参数。
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/NULL.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/NULL.txt
index 90e31a9b2..40ea67ca4 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/NULL.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/NULL.txt
@@ -1 +1 @@
-ֵIJ
\ No newline at end of file
+空值的参数。
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/contextPath.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/contextPath.txt
index 0257c7e84..2faf5629e 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/contextPath.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/contextPath.txt
@@ -1,3 +1 @@
-contextPathָ·ķĿ¼.
-ʣhttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-contextPath/WebReport
\ No newline at end of file
+contextPath是指绝对路径的服务器别名,即虚拟目录.假如访问:http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,contextPath是/WebReport
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/curReport.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/curReport.txt
index cc01b6726..4a0b82a92 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/curReport.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/curReport.txt
@@ -1 +1 @@
-ǰ
\ No newline at end of file
+当前报表。
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/formletName.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/formletName.txt
index 95c5feec3..c9921354a 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/formletName.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/formletName.txt
@@ -1,3 +1 @@
-
-ʣhttp://localhost:8080/WebReport/ReportServer?formlet=Form1.frm
-formNameForm1.frm
\ No newline at end of file
+表单名字假如访问:http://localhost:8080/WebReport/ReportServer?formlet=Form1.frm,formName就是Form1.frm
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/fr_submitinfo.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/fr_submitinfo.txt
index 4a1e38b99..41212da23 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/fr_submitinfo.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/fr_submitinfo.txt
@@ -1 +1 @@
-ύ¼ķϢ
fr_submitinfo.success¼ɹ
fr_submitinfo.failinfo¼Ϣ
\ No newline at end of file
+提交入库事件的返回信息。fr_submitinfo.success记录成功与否fr_submitinfo.failinfo简单记录出错信息
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/reportName.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/reportName.txt
index 982b43b72..d2bb66ad3 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/reportName.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/reportName.txt
@@ -1,3 +1 @@
-
-ʣhttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-reportNameWorkBook1.cpt
\ No newline at end of file
+报表名字假如访问:http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,reportName就是WorkBook1.cpt
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/serverName.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/serverName.txt
index 89eb2f98d..d6fca7188 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/serverName.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/serverName.txt
@@ -1,3 +1 @@
-serverNameַָ.
-ʣhttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-serverNameָǣlocalhostʻӵIP
\ No newline at end of file
+serverName,是指服务器地址或名称.假如访问:http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,serverName指的是:localhost,即访问机子的IP
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/serverPort.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/serverPort.txt
index 8a0dd40cf..24552e730 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/serverPort.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/serverPort.txt
@@ -1 +1 @@
-serverPortָǷʵĶ˿
\ No newline at end of file
+serverPort指的是访问的端口
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/serverSchema.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/serverSchema.txt
index 02cecc67e..15bcc7e9f 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/serverSchema.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/serverSchema.txt
@@ -1,3 +1 @@
-serverSchemaָЭ.
-ʣhttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-serverSchemaָǣhttp
\ No newline at end of file
+serverSchema,是指协议名称.假如访问:http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,serverSchema指的是:http
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/serverURL.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/serverURL.txt
index 5fd3852e9..02c7db49f 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/serverURL.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/serverURL.txt
@@ -1,3 +1 @@
-serverURLָʷURL
-ʣhttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-serverURLhttp://localhost:8080
+serverURL是指访问服务的URL假如访问:http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,serverURL就是http://localhost:8080
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/servletURL.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/servletURL.txt
index 73a1c0fff..2a1e5dfd4 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/servletURL.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/servletURL.txt
@@ -1,2 +1 @@
-ʣhttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-servletURLָǣ/WebReport/ReportServer
\ No newline at end of file
+假如访问:http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,servletURL指的是:/WebReport/ReportServer
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/cn/sessionID.txt b/designer_base/src/com/fr/design/insert/formula/variable/cn/sessionID.txt
index a27a6b408..eb0b42cf6 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/cn/sessionID.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/cn/sessionID.txt
@@ -1,4 +1 @@
-SessionIDǷûỰıʶ
-ڴỰʱΪÿһỰһıʶ
-ỰʶԳͷءSessionIDڱλỰIDļ¼
-SessionID WEBҳͳơ
\ No newline at end of file
+SessionID属性是返回用户会话的标识。在创建会话时,服务器会为每一个会话生成一个单独的标识,会话标识以长整形数据类型返回。SessionID等于本次会话ID的记录,SessionID 多数情况是用于WEB页面的统计。
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/$$$.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/$$$.txt
index 4148f61d3..7f4e9bf6a 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/$$$.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/$$$.txt
@@ -1 +1 @@
-The current value
\ No newline at end of file
+The current value
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_authority.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_authority.txt
index c7c8074a0..4cd04a675 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_authority.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_authority.txt
@@ -1 +1 @@
-Parameter of user authority
\ No newline at end of file
+Parameter of user authority
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_username.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_username.txt
index 8b8e172de..4acc4b6a8 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_username.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_username.txt
@@ -1 +1 @@
-Parameter of username
\ No newline at end of file
+Parameter of username
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_userposition.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_userposition.txt
index 1071578ed..065c00081 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_userposition.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/$fr_userposition.txt
@@ -1 +1 @@
-department role of user
\ No newline at end of file
+department role of user
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/NOFILTER.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/NOFILTER.txt
index 8902cd963..e2fdaa0c6 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/NOFILTER.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/NOFILTER.txt
@@ -1 +1 @@
-The result is aways true when NOFILTER is compared with any other values.
+The result is aways true when NOFILTER is compared with any other values.
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/contextPath.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/contextPath.txt
index 8b37a4d9e..7c6256035 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/contextPath.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/contextPath.txt
@@ -1 +1 @@
-absolute path of the server
http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
contextPath is /WebReport
\ No newline at end of file
+absolute path of the serverhttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,contextPath is /WebReport
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/formletName.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/formletName.txt
index 320a270d6..48e90583c 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/formletName.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/formletName.txt
@@ -1,3 +1 @@
-form name
-http://localhost:8080/WebReport/ReportServer?formlet=Form1.frm
-formName is Form1.frm
\ No newline at end of file
+form namehttp://localhost:8080/WebReport/ReportServer?formlet=Form1.frm,formName is Form1.frm
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/fr_submitinfo.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/fr_submitinfo.txt
index a4dc1dc07..ce8c81728 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/fr_submitinfo.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/fr_submitinfo.txt
@@ -1 +1 @@
-callback status of form submit
contains fr_submitinfo.success and fr_submitinfo.failinfo
\ No newline at end of file
+callback status of form submitcontains fr_submitinfo.success and fr_submitinfo.failinfo
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/reportName.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/reportName.txt
index bd15a4025..88afaad37 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/reportName.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/reportName.txt
@@ -1,3 +1 @@
-report name
-http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-reportName is WorkBook1.cpt
\ No newline at end of file
+report namehttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,reportName is WorkBook1.cpt
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/serverName.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/serverName.txt
index 666c13b64..265bd4ad0 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/serverName.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/serverName.txt
@@ -1,3 +1 @@
-address or name of the server
-http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-serverName means localhost
\ No newline at end of file
+address or name of the serverhttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,serverName means localhost
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/serverSchema.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/serverSchema.txt
index 2b06eaa23..85072e652 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/serverSchema.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/serverSchema.txt
@@ -1,3 +1 @@
-serverSchema
-http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-serverSchema is http
\ No newline at end of file
+serverSchemahttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,serverSchema is http
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/serverURL.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/serverURL.txt
index 347114b08..f14f92583 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/serverURL.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/serverURL.txt
@@ -1,3 +1 @@
-URL of the server
-http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-serverURL is http://localhost:8080
+URL of the serverhttp://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,serverURL is http://localhost:8080
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/insert/formula/variable/en/servletURL.txt b/designer_base/src/com/fr/design/insert/formula/variable/en/servletURL.txt
index b5ed4ec75..b9149deff 100644
--- a/designer_base/src/com/fr/design/insert/formula/variable/en/servletURL.txt
+++ b/designer_base/src/com/fr/design/insert/formula/variable/en/servletURL.txt
@@ -1,2 +1 @@
-http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt
-servletURL is /WebReport/ReportServer
\ No newline at end of file
+http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,servletURL is /WebReport/ReportServer
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/mainframe/BaseJForm.java b/designer_base/src/com/fr/design/mainframe/BaseJForm.java
index c0fd09f17..559387b20 100644
--- a/designer_base/src/com/fr/design/mainframe/BaseJForm.java
+++ b/designer_base/src/com/fr/design/mainframe/BaseJForm.java
@@ -1 +1,66 @@
-package com.fr.design.mainframe;
import javax.swing.JComponent;
import com.fr.form.FormElementCaseContainerProvider;
/**
* Author : Shockway
* Date: 13-7-15
* Time: 上午10:28
*/
public interface BaseJForm extends JTemplateProvider{
public static final String XML_TAG = "JForm";
public static final int FORM_TAB = 0;
public static final int ELEMENTCASE_TAB = 1;
public static final int ELEMENTCASE_CHANGE_TAB = 2;
/**
* 刷新所有控件
*/
public void refreshAllNameWidgets();
/**
* 刷新参数
*/
public void populateParameter();
/**
* 刷新选中的控件
*/
public void refreshSelectedWidget();
/**
* 获取当前的Target
*/
public Object getTarget();
/**
* 执行撤销
*
* @param o 之前保存的状态
*/
public void applyUndoState4Form(BaseUndoState o);
/**
* 获取当前编辑的组件
*/
public JComponent getEditingPane();
/**
* 只在Form和ElementCase之间切换
* @param index 切换位置
*/
public void tabChanged(int index);
/**
* 在Form和ElementCase, 以及ElementCase和ElementCase之间切换
* @param index 切换位置
* @param ecContainer ElementCase所在container
*/
public void tabChanged(int index, FormElementCaseContainerProvider ecContainer);
}
\ No newline at end of file
+package com.fr.design.mainframe;
+
+import javax.swing.JComponent;
+
+import com.fr.form.FormElementCaseContainerProvider;
+
+
+/**
+ * Author : Shockway
+ * Date: 13-7-15
+ * Time: 上午10:28
+ */
+public interface BaseJForm extends JTemplateProvider {
+
+ String XML_TAG = "JForm";
+ int FORM_TAB = 0;
+ int ELEMENTCASE_TAB = 1;
+ int ELEMENTCASE_CHANGE_TAB = 2;
+
+ /**
+ * 刷新所有控件
+ */
+ void refreshAllNameWidgets();
+
+ /**
+ * 刷新参数
+ */
+ void populateParameter();
+
+ /**
+ * 刷新选中的控件
+ */
+ void refreshSelectedWidget();
+
+ /**
+ * 获取当前的Target
+ */
+ Object getTarget();
+
+ /**
+ * 执行撤销
+ *
+ * @param o 之前保存的状态
+ */
+ void applyUndoState4Form(BaseUndoState o);
+
+ /**
+ * 获取当前编辑的组件
+ */
+ JComponent getEditingPane();
+
+ /**
+ * 只在Form和ElementCase之间切换
+ *
+ * @param index 切换位置
+ */
+ void tabChanged(int index);
+
+ /**
+ * 在Form和ElementCase, 以及ElementCase和ElementCase之间切换
+ *
+ * @param index 切换位置
+ * @param ecContainer ElementCase所在container
+ */
+ void tabChanged(int index, FormElementCaseContainerProvider ecContainer);
+}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java
index f1c144d7c..f67608aca 100644
--- a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java
+++ b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java
@@ -169,7 +169,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/**
* 初始menuPane的方法 方便OEM时修改该组件
- * @param ad
*/
protected void initMenuPane(){
menuPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@@ -189,7 +188,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
GeneralContext.addPluginReadListener(new PluginReadListener() {
@Override
- public void success() {
+ public void success(Status status) {
TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING);
if (processor == null) {
processor = new DefaultTitlePlace();
diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
index 9355a3348..352fc1564 100644
--- a/designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
+++ b/designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
@@ -29,6 +29,7 @@ import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.Inter;
+import com.fr.plugin.proxy.PluginProxyCompatibleUtils;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
@@ -131,6 +132,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
toolbarDef.addShortCut(delFileAction);
Set extraShortCuts = ExtraDesignClassManager.getInstance().getArray(ShortCut.TEMPLATE_TREE);
+ extraShortCuts = PluginProxyCompatibleUtils.toOriObjectHashSet(extraShortCuts);
for (ShortCut shortCut : extraShortCuts){
toolbarDef.addShortCut(shortCut);
}
diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java
index 58060d91a..a275d3d5d 100644
--- a/designer_base/src/com/fr/design/mainframe/JTemplate.java
+++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java
@@ -27,6 +27,8 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.layout.FRGUIPaneFactory;
+import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
+import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.NameSeparator;
@@ -72,16 +74,27 @@ public abstract class JTemplate> ex
private UndoManager authorityUndoManager;
protected U undoState;
protected U authorityUndoState = null;
+ protected T template; // 当前模板
+ protected TemplateProcessInfo processInfo; // 模板过程的相关信息
private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复
private DesignModelAdapter designModel;
private PreviewProvider previewType;
+ private long openTime = 0L; // 打开模板的时间点(包括新建模板)
+ private TemplateInfoCollector tic = TemplateInfoCollector.getInstance();
+ private StringBuilder process = new StringBuilder(""); // 制作模板的过程
public JTemplate(T t, String defaultFileName) {
- this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)));
+ this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true);
+ openTime = System.currentTimeMillis();
}
public JTemplate(T t, FILE file) {
+ this(t, file, false);
+ }
+
+ public JTemplate(T t, FILE file, boolean isNewFile) {
super(t);
+ this.template = t;
this.previewType = parserPreviewProvider(t.getPreviewType());
this.editingFILE = file;
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@@ -89,6 +102,39 @@ public abstract class JTemplate> ex
this.add(createCenterPane(), BorderLayout.CENTER);
this.undoState = createUndoState();
designModel = createDesignModel();
+ // 如果不是新建模板,并且在收集列表中
+ if (!isNewFile && tic.inList(t)) {
+ openTime = System.currentTimeMillis();
+ process.append(tic.loadProcess(t));
+ }
+ }
+
+ // 为收集模版信息作准备
+ private void initForCollect() {
+ template.initTemplateID(); // 为新模板设置 templateID 属性
+ if (openTime == 0) {
+ openTime = System.currentTimeMillis();
+ }
+ }
+ private void collectInfo() { // 执行收集操作
+ if (openTime == 0) { // 旧模板,不收集数据
+ return;
+ }
+ long saveTime = System.currentTimeMillis(); // 保存模板的时间点
+ tic.collectInfo(template, this, openTime, saveTime);
+ openTime = saveTime; // 更新 openTime,准备下一次计算
+ }
+
+ public abstract TemplateProcessInfo getProcessInfo();
+
+ // 追加过程记录
+ public void appendProcess(String s) {
+ process.append(s);
+ }
+
+ // 获取过程记录
+ public String getProcess() {
+ return process.toString();
}
public U getUndoState() {
@@ -326,7 +372,7 @@ public abstract class JTemplate> ex
}
protected boolean accept(Object o){
- return true;
+ return true;
}
private void fireSuperTargetModified() {
@@ -439,17 +485,18 @@ public abstract class JTemplate> ex
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE);
return false;
}
+ collectInfo();
return this.saveFile();
}
-
+
private boolean isCancelOperation(int operation){
- return operation == FILEChooserPane.CANCEL_OPTION ||
- operation == FILEChooserPane.JOPTIONPANE_CANCEL_OPTION;
+ return operation == FILEChooserPane.CANCEL_OPTION ||
+ operation == FILEChooserPane.JOPTIONPANE_CANCEL_OPTION;
}
-
+
private boolean isOkOperation(int operation){
- return operation == FILEChooserPane.JOPTIONPANE_OK_OPTION ||
- operation == FILEChooserPane.OK_OPTION;
+ return operation == FILEChooserPane.JOPTIONPANE_OK_OPTION ||
+ operation == FILEChooserPane.OK_OPTION;
}
private boolean saveAsTemplate(boolean isShowLoc) {
@@ -466,8 +513,8 @@ public abstract class JTemplate> ex
if (isCancelOperation(chooseResult)) {
fileChooser = null;
return false;
- }
-
+ }
+
if (isOkOperation(chooseResult)) {
if (!FRContext.getCurrentEnv().hasFileFolderAllow(fileChooser.getSelectedFILE().getPath()) ) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE);
@@ -477,38 +524,41 @@ public abstract class JTemplate> ex
mkNewFile(editingFILE);
fileChooser = null;
}
-
+
return saveNewFile(editingFILE, oldName);
}
-
+
protected boolean saveNewFile(FILE editingFILE, String oldName){
- this.editingFILE = editingFILE;
+ // 在保存之前,初始化 templateID
+ initForCollect(); // 如果保存新模板(新建模板直接保存,或者另存为),则添加 templateID
+ this.editingFILE = editingFILE;
boolean result = this.saveFile();
if (result) {
DesignerFrameFileDealerPane.getInstance().refresh();
+ collectInfo();
}
//更换最近打开
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getFullPathName());
return result;
}
-
+
protected void mkNewFile(FILE file){
try {
- file.mkfile();
+ file.mkfile();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
-
+
/**
- * 将模板另存为可以分享出去的混淆后内置数据集模板
- *
- * @return 是否另存成功
- *
- */
+ * 将模板另存为可以分享出去的混淆后内置数据集模板
+ *
+ * @return 是否另存成功
+ *
+ */
public boolean saveShareFile(){
- return true;
+ return true;
}
public Widget getSelectElementCase(){
return new NoneWidget();
@@ -713,7 +763,7 @@ public abstract class JTemplate> ex
public void revert() {
}
-
+
private int getVersionCompare(String versionString){
if (StringUtils.isBlank(versionString)) {
return 0;
@@ -723,7 +773,7 @@ public abstract class JTemplate> ex
return ComparatorUtils.compare(versionString.substring(0, len), ProductConstants.DESIGNER_VERSION.substring(0, len));
}
-
+
private int getVersionCompareHBB(String versionString){
if (StringUtils.isBlank(versionString)) {
return 0;
@@ -731,17 +781,17 @@ public abstract class JTemplate> ex
return ComparatorUtils.compare(versionString, "HBB");
}
-
+
private boolean isHigherThanCurrent(String versionString) {
return getVersionCompare(versionString) > 0;
}
-
+
private boolean isLowerThanCurrent(String versionString) {
- return getVersionCompare(versionString) < 0;
+ return getVersionCompare(versionString) < 0;
}
-
+
private boolean isLowerThanHBB(String versionString) {
- return getVersionCompareHBB(versionString) < 0;
+ return getVersionCompareHBB(versionString) < 0;
}
/**
@@ -751,7 +801,7 @@ public abstract class JTemplate> ex
public boolean isNewDesigner() {
String xmlDesignerVersion = getTarget().getXMLDesignerVersion();
if (isLowerThanHBB(xmlDesignerVersion)) {
- String info = Inter.getLocText("FR-Designer_open-new-form-tip");
+ String info = Inter.getLocText("FR-Designer_open-new-form-tip");
String moreInfo = Inter.getLocText("FR-Designer_Server-version-tip-moreInfo");
new InformationWarnPane(info, moreInfo, Inter.getLocText("FR-Designer_Tooltips")).show();
return true;
@@ -805,13 +855,13 @@ public abstract class JTemplate> ex
* @return 是则返回true
*/
public abstract boolean isJWorkBook();
-
+
/**
* 返回当前支持的超链界面pane
* @return 超链连接界面
*/
public HyperlinkGroupPane getHyperLinkPane() {
- return new HyperlinkGroupPane();
+ return new HyperlinkGroupPane();
}
/**
@@ -866,29 +916,29 @@ public abstract class JTemplate> ex
public void requestGridFocus() {
}
-
+
/**
- * 创建内置sql提交的pane
- *
- * @return 内置sql提交的pane
- *
- *
- * @date 2014-10-14-下午7:39:27
- */
+ * 创建内置sql提交的pane
+ *
+ * @return 内置sql提交的pane
+ *
+ *
+ * @date 2014-10-14-下午7:39:27
+ */
public DBManipulationPane createDBManipulationPane(){
- return new DBManipulationPane();
+ return new DBManipulationPane();
}
-
+
/**
* 创建控件事件里内置sql提交的pane
- *
+ *
* @return 内置sql提交的pane
- *
+ *
*
* @date 2014-10-14-下午7:39:27
*/
public DBManipulationPane createDBManipulationPaneInWidget(){
- return new DBManipulationInWidgetEventPane();
+ return new DBManipulationInWidgetEventPane();
}
/**
@@ -916,15 +966,15 @@ public abstract class JTemplate> ex
public void styleChange(){
}
-
+
/**
- * 创建分享模板的按钮, 目前只有jworkbook实现了
- *
- * @return 分享模板按钮
- *
- */
+ * 创建分享模板的按钮, 目前只有jworkbook实现了
+ *
+ * @return 分享模板按钮
+ *
+ */
public UIButton[] createShareButton(){
- return new UIButton[0];
+ return new UIButton[0];
}
/**
@@ -979,4 +1029,4 @@ public abstract class JTemplate> ex
return uiButtons;
}
-}
\ No newline at end of file
+}
diff --git a/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java
index 917e4cbfc..7fa8012fe 100644
--- a/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java
+++ b/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java
@@ -29,7 +29,7 @@ public class WestRegionContainerPane extends UIResizableContainer {
super(DesignerFrameFileDealerPane.getInstance(), Constants.RIGHT);
GeneralContext.addPluginReadListener(new PluginReadListener() {
@Override
- public void success() {
+ public void success(Status status) {
setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
}
});
diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java
index 4e31405d1..16b294955 100644
--- a/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java
+++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java
@@ -26,17 +26,16 @@ import java.awt.geom.Rectangle2D;
public class PatternBackgroundQuickPane extends BackgroundQuickPane {
private int patternIndex = 0; // pattern setIndex.
+ private final static int DEFAULT_DIM_HEIGHT = 190;
private ColorSelectBox foregroundColorPane;
private ColorSelectBox backgroundColorPane;
private PatternButton[] patternButtonArray;
public PatternBackgroundQuickPane() {
this.setLayout(new BorderLayout(0, 4));
-
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(contentPane, BorderLayout.NORTH);
contentPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
-
JPanel typePane2 = new JPanel();
contentPane.add(typePane2);
typePane2.setLayout(new GridLayout(0, 8, 1, 1));
@@ -48,15 +47,11 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
patternButtonGroup.add(patternButtonArray[i]);
typePane2.add(patternButtonArray[i]);
}
-
JPanel colorPane = new JPanel(new GridLayout(0, 2));
foregroundColorPane = new ColorSelectBox(70);
backgroundColorPane = new ColorSelectBox(70);
- foregroundColorPane.setSelectObject(Color.lightGray);
- backgroundColorPane.setSelectObject(Color.black);
-
- colorPane.add(this.createLabelColorPane(Inter.getLocText("Foreground") + ":", foregroundColorPane));
- colorPane.add(this.createLabelColorPane(Inter.getLocText("Background") + ":", backgroundColorPane));
+ colorPane.add(this.createLabelColorPane(Inter.getLocText("FR-Designer_Foreground") + ":", foregroundColorPane));
+ colorPane.add(this.createLabelColorPane(Inter.getLocText("FR-Designer_Background") + ":", backgroundColorPane));
this.add(colorPane, BorderLayout.CENTER);
foregroundColorPane.addSelectChangeListener(colorChangeListener);
backgroundColorPane.addSelectChangeListener(colorChangeListener);
@@ -65,7 +60,7 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
- dim.height = 190;
+ dim.height = DEFAULT_DIM_HEIGHT;
return dim;
}
@@ -206,6 +201,6 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
@Override
public String title4PopupWindow() {
- return Inter.getLocText("Background-Pattern");
+ return Inter.getLocText("FR-Designer_Background-Pattern");
}
}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java
new file mode 100644
index 000000000..17d785a43
--- /dev/null
+++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java
@@ -0,0 +1,526 @@
+package com.fr.design.mainframe.templateinfo;
+
+import com.fr.base.FRContext;
+import com.fr.base.io.IOFile;
+import com.fr.design.DesignerEnvManager;
+import com.fr.design.mainframe.DesignerContext;
+import com.fr.design.mainframe.JTemplate;
+import com.fr.env.RemoteEnv;
+import com.fr.general.*;
+import com.fr.general.http.HttpClient;
+import com.fr.stable.*;
+import com.fr.stable.xml.*;
+import com.fr.third.javax.xml.stream.XMLStreamException;
+import com.fr.json.JSONObject;
+
+import java.io.*;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.HashMap;
+
+/**
+ * 做模板的过程和耗时收集,辅助类
+ * Created by plough on 2017/2/21.
+ */
+public class TemplateInfoCollector implements Serializable, XMLReadable, XMLWriter {
+ private static final String FILE_NAME = "tpl.info";
+ private static final String OBJECT_FILE_NAME = "tplInfo.ser";
+ private static TemplateInfoCollector instance;
+ private Map> templateInfoList;
+ private String designerOpenDate; //设计器最近一次打开日期
+ private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
+ private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
+ private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
+ private static final int ONE_THOUSAND = 1000;
+ static final long serialVersionUID = 2007L;
+ private static final String XML_DESIGNER_OPEN_DATE = "DesignerOpenDate";
+ private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList";
+ private static final String XML_TEMPLATE_INFO = "TemplateInfo";
+ private static final String XML_PROCESS_MAP = "processMap";
+ private static final String XML_CONSUMING_MAP = "consumingMap";
+ private static final String ATTR_DAY_COUNT = "day_count";
+ private static final String ATTR_TEMPLATE_ID = "templateID";
+ private static final String ATTR_PROCESS = "process";
+ private static final String ATTR_FLOAT_COUNT = "float_count";
+ private static final String ATTR_WIDGET_COUNT = "widget_count";
+ private static final String ATTR_CELL_COUNT = "cell_count";
+ private static final String ATTR_BLOCK_COUNT = "block_count";
+ private static final String ATTR_REPORT_TYPE = "report_type";
+ private static final String ATTR_ACTIVITYKEY = "activitykey";
+ private static final String ATTR_JAR_TIME = "jar_time";
+ private static final String ATTR_CREATE_TIME = "create_time";
+ private static final String ATTR_UUID = "uuid";
+ private static final String ATTR_TIME_CONSUME = "time_consume";
+ private static final String ATTR_VERSION = "version";
+ private static final String ATTR_USERNAME = "username";
+ private static final String JSON_CONSUMING_MAP = "jsonConsumingMap";
+ private static final String JSON_PROCESS_MAP = "jsonProcessMap";
+
+
+ @SuppressWarnings("unchecked")
+ private TemplateInfoCollector() {
+ templateInfoList = new HashMap<>();
+ setDesignerOpenDate();
+ }
+
+ /**
+ * 把设计器最近打开日期设定为当前日期
+ */
+ private void setDesignerOpenDate() {
+ designerOpenDate = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
+ }
+
+ /**
+ * 判断今天是否第一次打开设计器
+ */
+ private boolean designerOpenFirstTime() {
+ String today = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
+ return !ComparatorUtils.equals(today, designerOpenDate);
+ }
+
+ /**
+ * 获取缓存文件存放路径
+ */
+ private static File getInfoFile() {
+ return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME));
+ }
+
+ private static File getObjectInfoFile() {
+ return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), OBJECT_FILE_NAME));
+ }
+
+ public static TemplateInfoCollector getInstance() {
+ if (instance == null) {
+ instance = new TemplateInfoCollector();
+ readXMLFile(instance, getInfoFile());
+ // 兼容过渡。如果没有新文件,则从老文件读取数据。以后都是读写新的 xml 文件
+ if (!getInfoFile().exists() && getObjectInfoFile().exists()) {
+ try {
+ ObjectInputStream is = new ObjectInputStream(new FileInputStream(getObjectInfoFile()));
+ instance = (TemplateInfoCollector) is.readObject();
+ } catch (Exception ex) {
+ // 什么也不做,instance 使用新值
+ }
+ }
+ }
+ return instance;
+ }
+
+ private static void readXMLFile(XMLReadable xmlReadable, File xmlFile){
+ if (xmlFile == null || !xmlFile.exists()) {
+ return;
+ }
+ String charset = EncodeConstants.ENCODING_UTF_8;
+ try {
+ String fileContent = getFileContent(xmlFile);
+ InputStream xmlInputStream = new ByteArrayInputStream(fileContent.getBytes(charset));
+ InputStreamReader inputStreamReader = new InputStreamReader(xmlInputStream, charset);
+ XMLableReader xmlReader = XMLableReader.createXMLableReader(inputStreamReader);
+
+ if (xmlReader != null) {
+ xmlReader.readXMLObject(xmlReadable);
+ }
+ xmlInputStream.close();
+ } catch (FileNotFoundException e) {
+ FRContext.getLogger().error(e.getMessage());
+ } catch (IOException e) {
+ FRContext.getLogger().error(e.getMessage());
+ } catch (XMLStreamException e) {
+ FRContext.getLogger().error(e.getMessage());
+ }
+
+ }
+
+ private static String getFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException{
+ InputStream is = new FileInputStream(xmlFile);
+ return IOUtils.inputStream2String(is);
+ }
+
+ private boolean shouldCollectInfo() {
+ if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据
+ return false;
+ }
+ return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
+ }
+
+ public void appendProcess(String log) {
+ if (!shouldCollectInfo()) {
+ return;
+ }
+ // 获取当前编辑的模板
+ JTemplate jt = DesignerContext.getDesignerFrame().getSelectedJTemplate();
+ // 追加过程记录
+ jt.appendProcess(log);
+ }
+
+ /**
+ * 加载已经存储的模板过程
+ */
+ @SuppressWarnings("unchecked")
+ public String loadProcess(T t) {
+ HashMap processMap = (HashMap) templateInfoList.get(t.getTemplateID()).get(XML_PROCESS_MAP);
+ return (String)processMap.get(ATTR_PROCESS);
+ }
+
+ /**
+ * 根据模板ID是否在收集列表中,判断是否需要收集当前模板的信息
+ */
+ public boolean inList(T t) {
+ return templateInfoList.containsKey(t.getTemplateID());
+ }
+
+ /**
+ * 将包含所有信息的对象保存到文件
+ */
+ private void saveInfo() {
+ try {
+ FileOutputStream out = new FileOutputStream(getInfoFile());
+ XMLTools.writeOutputStreamXML(this, out);
+ } catch (Exception ex) {
+ FRLogger.getLogger().error(ex.getMessage());
+ }
+ }
+
+ /**
+ * 更新 day_count:打开设计器却未编辑模板的连续日子
+ */
+ private void addDayCount() {
+ if (designerOpenFirstTime()) {
+ for (String key : templateInfoList.keySet()) {
+ HashMap templateInfo = templateInfoList.get(key);
+ int dayCount = (int)templateInfo.get(ATTR_DAY_COUNT) + 1;
+ templateInfo.put(ATTR_DAY_COUNT, dayCount);
+ }
+ setDesignerOpenDate();
+ }
+ }
+
+ /**
+ * 收集模板信息。如果之前没有记录,则新增;如果已有记录,则更新。
+ * 同时将最新数据保存到文件中。
+ */
+ @SuppressWarnings("unchecked")
+ public void collectInfo(T t, JTemplate jt, long openTime, long saveTime) {
+ if (!shouldCollectInfo()) {
+ return;
+ }
+
+ HashMap templateInfo;
+
+ long timeConsume = ((saveTime - openTime) / ONE_THOUSAND); // 制作模板耗时(单位:s)
+ String templateID = t.getTemplateID();
+
+ if (inList(t)) { // 已有记录
+ templateInfo = templateInfoList.get(t.getTemplateID());
+ // 更新 conusmingMap
+ HashMap consumingMap = (HashMap) templateInfo.get(XML_CONSUMING_MAP);
+ timeConsume += (long)consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间
+ consumingMap.put(ATTR_TIME_CONSUME, timeConsume);
+ }
+ else { // 新增
+ templateInfo = new HashMap<>();
+ templateInfo.put(XML_CONSUMING_MAP, getNewConsumingMap(templateID, openTime, timeConsume));
+ }
+
+ // 直接覆盖 processMap
+ templateInfo.put(XML_PROCESS_MAP, getProcessMap(templateID, jt));
+
+ // 保存模板时,让 day_count 归零
+ templateInfo.put(ATTR_DAY_COUNT, 0);
+
+ templateInfoList.put(templateID, templateInfo);
+
+ saveInfo(); // 每次更新之后,都同步到暂存文件中
+ }
+
+ private HashMap getNewConsumingMap(String templateID, long openTime, long timeConsume) {
+ HashMap consumingMap = new HashMap<>();
+
+ String username = DesignerEnvManager.getEnvManager().getBBSName();
+ String uuid = DesignerEnvManager.getEnvManager().getUUID();
+ String activitykey = DesignerEnvManager.getEnvManager().getActivationKey();
+ String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());
+ String jarTime = GeneralUtils.readBuildNO();
+ String version = ProductConstants.VERSION;
+ consumingMap.put(ATTR_USERNAME, username);
+ consumingMap.put(ATTR_UUID, uuid);
+ consumingMap.put(ATTR_ACTIVITYKEY, activitykey);
+ consumingMap.put(ATTR_TEMPLATE_ID, templateID);
+ consumingMap.put(ATTR_CREATE_TIME, createTime);
+ consumingMap.put(ATTR_TIME_CONSUME, timeConsume);
+ consumingMap.put(ATTR_JAR_TIME, jarTime);
+ consumingMap.put(ATTR_VERSION, version);
+
+ return consumingMap;
+ }
+
+ private HashMap getProcessMap(String templateID, JTemplate jt) {
+ HashMap processMap = new HashMap<>();
+
+ processMap.put(ATTR_TEMPLATE_ID, templateID);
+ processMap.put(ATTR_PROCESS, jt.getProcess());
+
+ TemplateProcessInfo info = jt.getProcessInfo();
+ processMap.put(ATTR_REPORT_TYPE, info.getReportType());
+ processMap.put(ATTR_CELL_COUNT, info.getCellCount());
+ processMap.put(ATTR_FLOAT_COUNT, info.getFloatCount());
+ processMap.put(ATTR_BLOCK_COUNT, info.getBlockCount());
+ processMap.put(ATTR_WIDGET_COUNT, info.getWidgetCount());
+
+ return processMap;
+ }
+
+ /**
+ * 发送本地模板信息到服务器
+ */
+ public void sendTemplateInfo() {
+ addDayCount();
+ String consumingUrl = SiteCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single";
+ String processUrl = SiteCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single";
+ ArrayList> completeTemplatesInfo = getCompleteTemplatesInfo();
+ for (HashMap templateInfo : completeTemplatesInfo) {
+ String jsonConsumingMap = templateInfo.get(JSON_CONSUMING_MAP);
+ String jsonProcessMap = templateInfo.get(JSON_PROCESS_MAP);
+ if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) {
+ // 清空记录
+ removeFromTemplateInfoList(templateInfo.get(ATTR_TEMPLATE_ID));
+ }
+ }
+ saveInfo();
+ }
+
+ private boolean sendSingleTemplateInfo(String url, String content) {
+ HashMap para = new HashMap<>();
+ String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
+ para.put("token", CodeUtils.md5Encode(date, "", "MD5"));
+ para.put("content", content);
+ HttpClient httpClient = new HttpClient(url, para, true);
+ httpClient.setTimeout(5000);
+ httpClient.asGet();
+
+ if (!httpClient.isServerAlive()) {
+ return false;
+ }
+
+ String res = httpClient.getResponseText();
+ boolean success;
+ try {
+ success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
+ } catch (Exception ex) {
+ success = false;
+ }
+ return success;
+ }
+
+ /**
+ * 返回已完成的模板信息
+ */
+ @SuppressWarnings("unchecked")
+ private ArrayList> getCompleteTemplatesInfo() {
+ ArrayList> completeTemplatesInfo = new ArrayList<>();
+ ArrayList testTemplateKeys = new ArrayList<>(); // 保存测试模板的key
+ for (String key : templateInfoList.keySet()) {
+ HashMap templateInfo = templateInfoList.get(key);
+ if ((int)templateInfo.get(ATTR_DAY_COUNT) <= COMPLETE_DAY_COUNT) { // 未完成模板
+ continue;
+ }
+ if (isTestTemplate(templateInfo)) {
+ testTemplateKeys.add(key);
+ continue;
+ }
+ HashMap consumingMap = (HashMap) templateInfo.get(XML_CONSUMING_MAP);
+ HashMap processMap = (HashMap) templateInfo.get(XML_PROCESS_MAP);
+ String jsonConsumingMap = new JSONObject(consumingMap).toString();
+ String jsonProcessMap = new JSONObject(processMap).toString();
+ HashMap jsonTemplateInfo = new HashMap<>();
+ jsonTemplateInfo.put(JSON_CONSUMING_MAP, jsonConsumingMap);
+ jsonTemplateInfo.put(JSON_PROCESS_MAP, jsonProcessMap);
+ jsonTemplateInfo.put(ATTR_TEMPLATE_ID, key);
+ completeTemplatesInfo.add(jsonTemplateInfo);
+ }
+ // 删除测试模板
+ for (String key : testTemplateKeys) {
+ removeFromTemplateInfoList(key);
+ }
+ return completeTemplatesInfo;
+ }
+
+ private void removeFromTemplateInfoList(String key) {
+ templateInfoList.remove(key);
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean isTestTemplate(HashMap templateInfo) {
+ HashMap processMap = (HashMap) templateInfo.get(XML_PROCESS_MAP);
+ int reportType = (int)processMap.get(ATTR_REPORT_TYPE);
+ int cellCount = (int)processMap.get(ATTR_CELL_COUNT);
+ int floatCount = (int)processMap.get(ATTR_FLOAT_COUNT);
+ int blockCount = (int)processMap.get(ATTR_BLOCK_COUNT);
+ int widgetCount = (int)processMap.get(ATTR_WIDGET_COUNT);
+ boolean isTestTemplate = false;
+ if (reportType == 0) { // 普通报表
+ isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT;
+ } else if (reportType == 1) { // 聚合报表
+ isTestTemplate = blockCount <= 1 && widgetCount <= VALID_WIDGET_COUNT;
+ } else { // 表单(reportType == 2)
+ isTestTemplate = widgetCount <= 1;
+ }
+ return isTestTemplate;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void readXML(XMLableReader reader) {
+ if (reader.isChildNode()) {
+ try {
+ String name = reader.getTagName();
+ if (XML_DESIGNER_OPEN_DATE.equals(name)) {
+ this.designerOpenDate = reader.getElementValue();
+ } else if(XML_TEMPLATE_INFO_LIST.equals(name)){
+ readTemplateInfoList(reader);
+ }
+ } catch (Exception ex) {
+ // 什么也不做,使用默认值
+ }
+ }
+ }
+
+ private void readTemplateInfoList(XMLableReader reader) {
+ reader.readXMLObject(new XMLReadable() {
+ public void readXML(XMLableReader reader) {
+ if (XML_TEMPLATE_INFO.equals(reader.getTagName())) {
+ TemplateInfo templateInfo = new TemplateInfo();
+ reader.readXMLObject(templateInfo);
+ templateInfoList.put(templateInfo.getTemplateID(), templateInfo.getTemplateInfo());
+ }
+ }
+ });
+ }
+
+ @Override
+ public void writeXML(XMLPrintWriter writer) {
+ writer.startTAG("TplInfo");
+
+ writer.startTAG(XML_DESIGNER_OPEN_DATE);
+ writer.textNode(designerOpenDate);
+ writer.end();
+
+ writeTemplateInfoList(writer);
+
+ writer.end();
+ }
+
+ private void writeTemplateInfoList(XMLPrintWriter writer){
+ //启停
+ writer.startTAG(XML_TEMPLATE_INFO_LIST);
+ for (String templateID : templateInfoList.keySet()) {
+ new TemplateInfo(templateInfoList.get(templateID)).writeXML(writer);
+ }
+ writer.end();
+ }
+
+ private class TemplateInfo implements XMLReadable, XMLWriter {
+
+ private int dayCount;
+ private String templateID;
+ private HashMap processMap = new HashMap<>();
+ private HashMap consumingMap = new HashMap<>();
+
+ @SuppressWarnings("unchecked")
+ public TemplateInfo(HashMap templateInfo) {
+ this.dayCount = (int)templateInfo.get(ATTR_DAY_COUNT);
+ this.processMap = (HashMap) templateInfo.get(XML_PROCESS_MAP);
+ this.consumingMap = (HashMap) templateInfo.get(XML_CONSUMING_MAP);
+ this.templateID = (String) processMap.get(ATTR_TEMPLATE_ID);
+ }
+
+ public TemplateInfo() {}
+
+ public String getTemplateID() {
+ return templateID;
+ }
+
+ public HashMap getTemplateInfo() {
+ HashMap templateInfo = new HashMap<>();
+ templateInfo.put(XML_PROCESS_MAP, processMap);
+ templateInfo.put(XML_CONSUMING_MAP, consumingMap);
+ templateInfo.put(ATTR_DAY_COUNT, dayCount);
+ return templateInfo;
+ }
+
+ public void writeXML(XMLPrintWriter writer) {
+ writer.startTAG(XML_TEMPLATE_INFO);
+ if (StringUtils.isNotEmpty(templateID)) {
+ writer.attr(ATTR_TEMPLATE_ID, this.templateID);
+ }
+ if (dayCount >= 0) {
+ writer.attr(ATTR_DAY_COUNT, this.dayCount);
+ }
+ writeProcessMap(writer);
+ writeConsumingMap(writer);
+
+ writer.end();
+ }
+
+ private void writeProcessMap(XMLPrintWriter writer) {
+ writer.startTAG(XML_PROCESS_MAP);
+ writer.attr(ATTR_PROCESS, (String)processMap.get(ATTR_PROCESS));
+ writer.attr(ATTR_FLOAT_COUNT, (int)processMap.get(ATTR_FLOAT_COUNT));
+ writer.attr(ATTR_WIDGET_COUNT, (int)processMap.get(ATTR_WIDGET_COUNT));
+ writer.attr(ATTR_CELL_COUNT, (int)processMap.get(ATTR_CELL_COUNT));
+ writer.attr(ATTR_BLOCK_COUNT, (int)processMap.get(ATTR_BLOCK_COUNT));
+ writer.attr(ATTR_REPORT_TYPE, (int)processMap.get(ATTR_REPORT_TYPE));
+ writer.end();
+ }
+
+ private void writeConsumingMap(XMLPrintWriter writer) {
+ writer.startTAG(XML_CONSUMING_MAP);
+ writer.attr(ATTR_ACTIVITYKEY, (String)consumingMap.get(ATTR_ACTIVITYKEY));
+ writer.attr(ATTR_JAR_TIME, (String)consumingMap.get(ATTR_JAR_TIME));
+ writer.attr(ATTR_CREATE_TIME, (String)consumingMap.get(ATTR_CREATE_TIME));
+ writer.attr(ATTR_UUID, (String)consumingMap.get(ATTR_UUID));
+ writer.attr(ATTR_TIME_CONSUME, (long)consumingMap.get(ATTR_TIME_CONSUME));
+ writer.attr(ATTR_VERSION, (String)consumingMap.get(ATTR_VERSION));
+ writer.attr(ATTR_USERNAME, (String)consumingMap.get(ATTR_USERNAME));
+ writer.end();
+ }
+
+ public void readXML(XMLableReader reader) {
+ if (!reader.isChildNode()) {
+ dayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0);
+ templateID = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY);
+ } else {
+ try {
+ String name = reader.getTagName();
+ if (XML_PROCESS_MAP.equals(name)) {
+ processMap.put(ATTR_PROCESS, reader.getAttrAsString(ATTR_PROCESS, StringUtils.EMPTY));
+ processMap.put(ATTR_FLOAT_COUNT, reader.getAttrAsInt(ATTR_FLOAT_COUNT, 0));
+ processMap.put(ATTR_WIDGET_COUNT, reader.getAttrAsInt(ATTR_WIDGET_COUNT, 0));
+ processMap.put(ATTR_CELL_COUNT, reader.getAttrAsInt(ATTR_CELL_COUNT, 0));
+ processMap.put(ATTR_BLOCK_COUNT, reader.getAttrAsInt(ATTR_BLOCK_COUNT, 0));
+ processMap.put(ATTR_REPORT_TYPE, reader.getAttrAsInt(ATTR_REPORT_TYPE, 0));
+ processMap.put(ATTR_TEMPLATE_ID, templateID);
+ } else if(XML_CONSUMING_MAP.equals(name)){
+ consumingMap.put(ATTR_ACTIVITYKEY, reader.getAttrAsString(ATTR_ACTIVITYKEY, StringUtils.EMPTY));
+ consumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY));
+ consumingMap.put(ATTR_CREATE_TIME, reader.getAttrAsString(ATTR_CREATE_TIME, StringUtils.EMPTY));
+ consumingMap.put(ATTR_TEMPLATE_ID, templateID);
+ consumingMap.put(ATTR_UUID, reader.getAttrAsString(ATTR_UUID, StringUtils.EMPTY));
+ consumingMap.put(ATTR_TIME_CONSUME, reader.getAttrAsLong(ATTR_TIME_CONSUME, 0));
+ consumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0"));
+ consumingMap.put(ATTR_USERNAME, reader.getAttrAsString(ATTR_USERNAME, StringUtils.EMPTY));
+ }
+ } catch (Exception ex) {
+ // 什么也不做,使用默认值
+ }
+ }
+ }
+
+ }
+
+
+ public static void main(String[] args) {
+ TemplateInfoCollector tic = TemplateInfoCollector.getInstance();
+ tic.sendTemplateInfo();
+ }
+}
diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateProcessInfo.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateProcessInfo.java
new file mode 100644
index 000000000..d92ca7028
--- /dev/null
+++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateProcessInfo.java
@@ -0,0 +1,26 @@
+package com.fr.design.mainframe.templateinfo;
+
+import com.fr.base.io.IOFile;
+
+/**
+ * Created by plough on 2017/3/17.
+ */
+public abstract class TemplateProcessInfo {
+
+ protected T template;
+
+ public TemplateProcessInfo(T template) {
+ this.template = template;
+ }
+
+ // 获取模板类型。0 代表普通报表,1 代表聚合报表,2 代表表单
+ public abstract int getReportType();
+ // 获取模板格子数
+ public abstract int getCellCount();
+ // 获取模板悬浮元素个数
+ public abstract int getFloatCount();
+ // 获取模板聚合块个数
+ public abstract int getBlockCount();
+ // 获取模板控件数
+ public abstract int getWidgetCount();
+}
diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java
index 6c85ce214..ada075aeb 100644
--- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java
+++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java
@@ -12,52 +12,52 @@ public interface ToolBarMenuDockPlus {
*
* @return 工具
*/
- public ToolBarDef[] toolbars4Target();
+ ToolBarDef[] toolbars4Target();
/**
* 文件菜单的子菜单
*
* @return 子菜单
*/
- public ShortCut[] shortcut4FileMenu();
+ ShortCut[] shortcut4FileMenu();
/**
* 目标的菜单
*
* @return 菜单
*/
- public MenuDef[] menus4Target();
+ MenuDef[] menus4Target();
/**
* 表单的工具栏
*
* @return 表单工具栏
*/
- public JPanel[] toolbarPanes4Form();
+ JPanel[] toolbarPanes4Form();
/**
* 表单的工具按钮
*
* @return 工具按钮
*/
- public JComponent[] toolBarButton4Form();
+ JComponent[] toolBarButton4Form();
/**
* 权限细粒度状态下的工具面板
*
* @return 工具面板
*/
- public JComponent toolBar4Authority();
+ JComponent toolBar4Authority();
- public int getMenuState();
+ int getMenuState();
- public int getToolBarHeight();
+ int getToolBarHeight();
/**
* 导出菜单的子菜单 ,目前用于图表设计器
*
* @return 子菜单
*/
- public ShortCut[] shortcut4ExportMenu();
-
+ ShortCut[] shortcut4ExportMenu();
+
}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java b/designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java
index 2e2743048..3ba3d610d 100644
--- a/designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java
+++ b/designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java
@@ -1 +1,72 @@
-package com.fr.design.parameter;
import com.fr.base.Parameter;
import com.fr.base.parameter.ParameterUI;
import com.fr.design.mainframe.AuthorityEditPane;
import javax.swing.*;
import java.awt.*;
/**
* 参数设计界面接口
*/
public interface ParameterDesignerProvider {
public void addListener(ParaDefinitePane paraDefinitePane);
public Component createWrapper();
public void setDesignHeight(int height);
public Dimension getDesignSize();
public Dimension getPreferredSize();
public void populate(ParameterUI p);
public void refreshAllNameWidgets();
public void refresh4TableData(String oldName, String newName);
public void refreshParameter(ParaDefinitePane paraDefinitePane);
public boolean isWithQueryButton();
public java.util.List getAllXCreatorNameList();
public boolean isWithoutParaXCreator(Parameter[] ps);
public boolean isBlank();
public ParameterUI getParaTarget();
public boolean addingParameter2Editor(Parameter parameter, int index);
public boolean addingParameter2EditorWithQueryButton(Parameter parameter, int index);
public void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex);
public JPanel[] toolbarPanes4Form();
public JComponent[] toolBarButton4Form();
public void initBeforeUpEdit();
public void populateParameterPropertyPane(ParaDefinitePane p);
public void initWidgetToolbarPane();
public AuthorityEditPane getAuthorityEditPane();
public JPanel getEastUpPane();
public JPanel getEastDownPane();
public boolean isSupportAuthority();
public void removeSelection();
public ParameterBridge getParaComponent();
}
\ No newline at end of file
+package com.fr.design.parameter;
+
+import com.fr.base.Parameter;
+import com.fr.base.parameter.ParameterUI;
+import com.fr.design.mainframe.AuthorityEditPane;
+
+import javax.swing.*;
+import java.awt.*;
+
+
+/**
+ * 参数设计界面接口
+ */
+public interface ParameterDesignerProvider {
+
+ void addListener(ParaDefinitePane paraDefinitePane);
+
+ Component createWrapper();
+
+ void setDesignHeight(int height);
+
+ Dimension getDesignSize();
+
+ Dimension getPreferredSize();
+
+ void populate(ParameterUI p);
+
+ void refreshAllNameWidgets();
+
+ void refresh4TableData(String oldName, String newName);
+
+ void refreshParameter(ParaDefinitePane paraDefinitePane);
+
+ boolean isWithQueryButton();
+
+ java.util.List getAllXCreatorNameList();
+
+ boolean isWithoutParaXCreator(Parameter[] ps);
+
+ boolean isBlank();
+
+ ParameterUI getParaTarget();
+
+ boolean addingParameter2Editor(Parameter parameter, int index);
+
+ boolean addingParameter2EditorWithQueryButton(Parameter parameter, int index);
+
+ void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex);
+
+ JPanel[] toolbarPanes4Form();
+
+ JComponent[] toolBarButton4Form();
+
+ void initBeforeUpEdit();
+
+ void populateParameterPropertyPane(ParaDefinitePane p);
+
+ void initWidgetToolbarPane();
+
+ AuthorityEditPane getAuthorityEditPane();
+
+ JPanel getEastUpPane();
+
+ JPanel getEastDownPane();
+
+ boolean isSupportAuthority();
+
+ void removeSelection();
+
+ ParameterBridge getParaComponent();
+
+}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/present/dict/TableDataDictPane.java b/designer_base/src/com/fr/design/present/dict/TableDataDictPane.java
index 149118894..4e454ee9b 100644
--- a/designer_base/src/com/fr/design/present/dict/TableDataDictPane.java
+++ b/designer_base/src/com/fr/design/present/dict/TableDataDictPane.java
@@ -77,7 +77,7 @@ public class TableDataDictPane extends FurtherBasicBeanPane
}
});
keyColumnPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()});
- FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("Parameter-Formula"));
+ FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula"));
formulaEditor.setEnabled(true);
valueDictPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), formulaEditor});
}
@@ -95,9 +95,9 @@ public class TableDataDictPane extends FurtherBasicBeanPane
Component[][] components = new Component[][]{
- new Component[]{new UILabel(" " + Inter.getLocText("DS-TableData") + ":", UILabel.RIGHT), firstLine},
- new Component[]{new UILabel(Inter.getLocText("Actual_Value") + ":", UILabel.RIGHT), keyColumnPane},
- new Component[]{new UILabel(Inter.getLocText("Display_Value") + ":", UILabel.RIGHT), valueDictPane}
+ new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_DS_TableData") + ":", UILabel.RIGHT), firstLine},
+ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Actual_Value") + ":", UILabel.RIGHT), keyColumnPane},
+ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Display_Value") + ":", UILabel.RIGHT), valueDictPane}
};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
@@ -158,7 +158,7 @@ public class TableDataDictPane extends FurtherBasicBeanPane
columnIndexEditor1.addItemListener(itemListener);
keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]);
- FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("Parameter-Formula"));
+ FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula"));
formulaEditor.setEnabled(true);
formulaEditor.addChangeListener(new ChangeListener() {
diff --git a/designer_base/src/com/fr/design/roleAuthority/RoleTree.java b/designer_base/src/com/fr/design/roleAuthority/RoleTree.java
index 3ee627987..1af8c1caa 100644
--- a/designer_base/src/com/fr/design/roleAuthority/RoleTree.java
+++ b/designer_base/src/com/fr/design/roleAuthority/RoleTree.java
@@ -1 +1 @@
-package com.fr.design.roleAuthority;
import com.fr.general.NameObject;
import com.fr.design.constants.UIConstants;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree;
import com.fr.design.mainframe.AuthorityPropertyPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.*;
import java.awt.*;
import java.util.Enumeration;
/**
* Author : daisy
* Date: 13-8-30
* Time: 下午3:32
*/
public class RoleTree extends UserObjectRefreshJTree {
private static final long serialVersionUID = 2L;
private String roleName = null;
public RoleTree() {
super();
this.setCellRenderer(roleTreeRenderer);
this.setEnabled(true);
this.setEditable(true);
this.setRowHeight(20);
this.setDigIn(true);
this.removeMouseListener(treeMouseListener);
this.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
doWithValueChanged(e);
}
});
}
public boolean isCheckBoxVisible(TreePath path) {
return true;
}
/**
* 更新UI
*/
public void updateUI() {
super.updateUI();
setUI(new UIRoleTreeUI());
}
protected void doWithValueChanged(TreeSelectionEvent e) {
if (e.getNewLeadSelectionPath() != null) {
if (e.getNewLeadSelectionPath().getLastPathComponent().toString() != Inter.getLocText("Role")) {
roleName = e.getNewLeadSelectionPath().getLastPathComponent().toString();
setTabRoleName(roleName);
refreshRoleTree(roleName);
refreshElementAndAuthorityPane();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().judgeSheetAuthority(roleName);
}
}
}
protected void setTabRoleName(String roleName) {
}
/**
* 刷新角色树
*
* @param selectedRole 角色
*/
public void refreshRoleTree(String selectedRole) {
if (EastRegionContainerPane.getInstance().getUpPane() instanceof AuthorityPropertyPane) {
AuthorityPropertyPane authorityPropertyPane = (AuthorityPropertyPane) EastRegionContainerPane.getInstance().getUpPane();
authorityPropertyPane.populate();
EastRegionContainerPane.getInstance().replaceUpPane(authorityPropertyPane);
}
}
public void setSelectedRole(String selectedRole, TreePath parent) {
ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent();
if (node.children() != null && node.getChildCount() >= 0) {
for (Enumeration e = node.children(); e.hasMoreElements(); ) {
ExpandMutableTreeNode n = (ExpandMutableTreeNode) e.nextElement();
Object userObj = n.getUserObject();
String chilld = null;
if (userObj instanceof String) {
chilld = (String) userObj;
} else if (userObj instanceof NameObject) {
NameObject nameObject = (NameObject) userObj;
chilld = nameObject.getName();
}
if (ComparatorUtils.equals(chilld, selectedRole)) {
this.setSelectionPath(parent.pathByAddingChild(n));
return;
} else {
setSelectedRole(selectedRole, parent.pathByAddingChild(n));
}
}
}
}
private void refreshElementAndAuthorityPane() {
JComponent authorityToolBar = DesignerContext.getDesignerFrame().getToolbarComponent();
if (authorityToolBar instanceof BasicBeanPane) {
//说明是工具栏的
((BasicBeanPane) authorityToolBar).populateAuthority();
}
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().repaint();
}
public String getSelectedRoleName() {
return roleName;
}
public void setSelectedRoleName(String name) {
roleName = name;
}
private DefaultTreeCellRenderer roleTreeRenderer = new DefaultTreeCellRenderer() {
private static final long serialVersionUID = 2L;
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
ExpandMutableTreeNode treeNode = (ExpandMutableTreeNode) value;
Object userObj = treeNode.getUserObject();
if (userObj instanceof String) {
// p:这个是column field.
this.setIcon(null);
this.setText((String) userObj);
} else if (userObj instanceof NameObject) {
NameObject nameObject = (NameObject) userObj;
this.setText(nameObject.getName());
this.setIcon(null);
}
// 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..."
this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND);
this.setForeground(UIConstants.FONT_COLOR);
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE);
return this;
}
};
/*
* p:获得选中的NameObject = name + role.
*/
public NameObject getSelectedNameObject() {
TreePath selectedTreePath = this.getSelectionPath();
if (selectedTreePath == null) {
return null;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
Object selectedUserObject = selectedTreeNode.getUserObject();
return new NameObject(selectedUserObject.toString(), "");
}
/**
* p:添加一个NameObject节点
* @param no 需要添加的节点
*/
public void addNameObject(NameObject no) {
if (no == null) {
return;
}
DefaultTreeModel treeModel = (DefaultTreeModel) this.getModel();
// 新建一个放着NameObject的newChildTreeNode,加到Root下面
ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot();
ExpandMutableTreeNode newChildTreeNode = new ExpandMutableTreeNode(no);
root.add(newChildTreeNode);
newChildTreeNode.add(new ExpandMutableTreeNode());
treeModel.reload(root);
}
/**
* 刷新树节点
*/
public void refreshTreeNode() {
DefaultTreeModel treeModel = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot();
if (interceptRefresh(root)) {
return;
}
ExpandMutableTreeNode[] new_nodes = loadChildTreeNodes(root);
java.util.List childTreeNodeList = new java.util.ArrayList();
for (int i = 0, len = root.getChildCount(); i < len; i++) {
if (root.getChildAt(i) instanceof ExpandMutableTreeNode) {
childTreeNodeList.add((ExpandMutableTreeNode) root.getChildAt(i));
} else {
childTreeNodeList.add((DefaultMutableTreeNode) root.getChildAt(i));
}
}
root.removeAllChildren();
for (int ci = 0; ci < new_nodes.length; ci++) {
Object cUserObject = new_nodes[ci].getUserObject();
for (int ni = 0, nlen = childTreeNodeList.size(); ni < nlen; ni++) {
ExpandMutableTreeNode cTreeNode = (ExpandMutableTreeNode) childTreeNodeList.get(ni);
if (ComparatorUtils.equals(cTreeNode.getUserObject(), cUserObject)) {
new_nodes[ci].setExpanded(cTreeNode.isExpanded());
if (cTreeNode.getFirstChild() instanceof ExpandMutableTreeNode && cTreeNode.isExpanded()) {
checkChildNodes(cTreeNode, new_nodes[ci]);
}
break;
}
}
root.add(new_nodes[ci]);
}
}
protected void checkChildNodes(ExpandMutableTreeNode oldNode, ExpandMutableTreeNode newNode) {
for (int i = 0; i < oldNode.getChildCount(); i++) {
ExpandMutableTreeNode oldChild = (ExpandMutableTreeNode) oldNode.getChildAt(i);
for (int j = 0; j < newNode.getChildCount(); j++) {
ExpandMutableTreeNode newChild = (ExpandMutableTreeNode) newNode.getChildAt(j);
ExpandMutableTreeNode[] nodes = RoleTree.this.loadChildTreeNodes(newChild);
for (int k = 0; k < nodes.length; k++) {
newChild.add(nodes[k]);
}
if (newChild.getChildCount() > 1 && ((ExpandMutableTreeNode) newChild.getFirstChild()).getUserObject() == PENDING) {
newChild.remove(0);
}
if (ComparatorUtils.equals(oldChild.getUserObject(), newChild.getUserObject())) {
newChild.setExpanded(oldChild.isExpanded());
}
}
}
}
public NameObject getRealSelectedNameObject() {
TreePath selectedTreePath = this.getSelectionPath();
if (selectedTreePath == null) {
return null;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
Object selectedUserObject = selectedTreeNode.getUserObject();
if (selectedUserObject instanceof NameObject) {
return (NameObject) selectedUserObject;
}
selectedTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
selectedUserObject = selectedTreeNode.getUserObject();
if (selectedUserObject instanceof NameObject) {
return (NameObject) selectedUserObject;
}
return null;
}
}
\ No newline at end of file
+package com.fr.design.roleAuthority;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.itree.checkboxtree.CheckBoxTree;
import com.fr.design.gui.itree.checkboxtree.CheckBoxTreeSelectionModel;
import com.fr.general.NameObject;
import com.fr.design.constants.UIConstants;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree;
import com.fr.design.mainframe.AuthorityPropertyPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import javax.swing.SwingUtilities;
import javax.swing.JTree;
import javax.swing.JComponent;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.Component;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
/**
* Author : daisy
* Time: 下午3:32
* Date: 13-8-30
*/
public class RoleTree extends UserObjectRefreshJTree {
private static final long serialVersionUID = 2L;
private String roleName = null;
public RoleTree() {
super();
this.setCellRenderer(roleTreeRenderer);
this.setEnabled(true);
this.setEditable(true);
this.setRowHeight(20);
this.setDigIn(true);
Handler handler = createHandlerForRoleTree();
this.replaceMouseListener(this, handler, 0);
this.replaceKeyListener(this, handler, 0);
this.addTreeSelectionListener(handler);
// this.removeMouseListener(treeMouseListener);
// this.addTreeSelectionListener(new TreeSelectionListener() {
// public void valueChanged(TreeSelectionEvent e) {
// doWithValueChanged(e);
// }
// });
}
public boolean isCheckBoxVisible(TreePath path) {
return true;
}
/**
* Creates the mouse listener and key listener used by RoleTree.
*
* @return the Handler.
*/
protected Handler createHandlerForRoleTree() {
return new Handler(this);
}
protected static class Handler implements MouseListener, KeyListener, TreeSelectionListener {
protected RoleTree _tree;
int _hotspot = new UICheckBox().getPreferredSize().width;
private int _toggleCount = -1;
public Handler(RoleTree tree) {
_tree = tree;
}
protected TreePath getTreePathForMouseEvent(MouseEvent e) {
if (!SwingUtilities.isLeftMouseButton(e)) {
return null;
}
if (!_tree.isCheckBoxEnabled()) {
return null;
}
TreePath path = _tree.getPathForLocation(e.getX(), e.getY());
if (path == null) {
return null;
}
// if (clicksInCheckBox(e, path)) {
return path;
// } else {
// return null;
// }
}
// protected boolean clicksInCheckBox(MouseEvent e, TreePath path) {
// if (!_tree.isCheckBoxVisible(path)) {
// return false;
// } else {
// Rectangle bounds = _tree.getPathBounds(path);
// if (_tree.getComponentOrientation().isLeftToRight()) {
// return e.getX() < bounds.x + _hotspot;
// } else {
// return e.getX() > bounds.x + bounds.width - _hotspot;
// }
// }
// }
private TreePath preventToggleEvent(MouseEvent e) {
TreePath pathForMouseEvent = getTreePathForMouseEvent(e);
if (pathForMouseEvent != null) {
int toggleCount = _tree.getToggleClickCount();
if (toggleCount != -1) {
_toggleCount = toggleCount;
_tree.setToggleClickCount(-1);
}
}
return pathForMouseEvent;
}
public void mouseClicked(MouseEvent e) {
preventToggleEvent(e);
}
public void mousePressed(MouseEvent e) {
TreePath path = preventToggleEvent(e);
if (path != null) {
toggleSelection(path);
e.consume();
}
}
public void mouseReleased(MouseEvent e) {
TreePath path = preventToggleEvent(e);
if (path != null) {
e.consume();
}
if (_toggleCount != -1) {
_tree.setToggleClickCount(_toggleCount);
}
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void keyPressed(KeyEvent e) {
if (e.isConsumed()) {
return;
}
if (!_tree.isCheckBoxEnabled()) {
return;
}
if (e.getModifiers() == 0 && e.getKeyChar() == KeyEvent.VK_SPACE) {
toggleSelections();
}
}
public void keyTyped(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
}
public void valueChanged(TreeSelectionEvent e) {
_tree.treeDidChange();
_tree.doWithValueChanged(e);
}
private void toggleSelection(TreePath path) {
if (!_tree.isEnabled() || !_tree.isCheckBoxEnabled(path)) {
return;
}
CheckBoxTreeSelectionModel selectionModel = _tree.getCheckBoxTreeSelectionModel();
boolean selected = selectionModel.isPathSelected(path, selectionModel.isDigIn());
selectionModel.removeTreeSelectionListener(this);
try {
if (!selectionModel.isSingleEventMode()) {
selectionModel.setBatchMode(true);
}
if (selected)
selectionModel.removeSelectionPath(path);
else
selectionModel.addSelectionPath(path);
} finally {
if (!selectionModel.isSingleEventMode()) {
selectionModel.setBatchMode(false);
}
selectionModel.addTreeSelectionListener(this);
_tree.treeDidChange();
_tree.doWithValueChanged(path);
}
}
protected void toggleSelections() {
TreePath[] treePaths = _tree.getSelectionPaths();
if (treePaths == null) {
return;
}
for (int i = 0, length = treePaths.length; i < length; i++) {
TreePath tmpTreePath = treePaths[i];
toggleSelection(tmpTreePath);
}
// for (TreePath treePath : treePaths) {
// toggleSelection(treePath);
// }
}
}
/**
* 更新UI
*/
public void updateUI() {
super.updateUI();
setUI(new UIRoleTreeUI());
}
/**
* @param e 选中事件
*/
protected void doWithValueChanged(TreeSelectionEvent e) {
if (e.getNewLeadSelectionPath() != null) {
if (!e.getNewLeadSelectionPath().getLastPathComponent().toString().equals(Inter.getLocText("FR-Designer_Role"))) {
roleName = e.getNewLeadSelectionPath().getLastPathComponent().toString();
setTabRoleName(roleName);
refreshRoleTree(roleName);
refreshElementAndAuthorityPane();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().judgeSheetAuthority(roleName);
}
}
}
/**
* @param treepath 所选的节点路径
*/
protected void doWithValueChanged(TreePath treepath) {
if (treepath != null && !treepath.getLastPathComponent().toString().equals(Inter.getLocText("FR-Designer_Role"))) {
roleName = treepath.getLastPathComponent().toString();
setTabRoleName(roleName);
refreshRoleTree(roleName);
refreshElementAndAuthorityPane();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().judgeSheetAuthority(roleName);
}
}
protected void setTabRoleName(String roleName) {
}
/**
* 刷新角色树
*
* @param selectedRole 角色
*/
public void refreshRoleTree(String selectedRole) {
if (EastRegionContainerPane.getInstance().getUpPane() instanceof AuthorityPropertyPane) {
AuthorityPropertyPane authorityPropertyPane = (AuthorityPropertyPane) EastRegionContainerPane.getInstance().getUpPane();
authorityPropertyPane.populate();
EastRegionContainerPane.getInstance().replaceUpPane(authorityPropertyPane);
}
}
public void setSelectedRole(String selectedRole, TreePath parent) {
ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent();
if (node.children() != null && node.getChildCount() >= 0) {
for (Enumeration e = node.children(); e.hasMoreElements(); ) {
ExpandMutableTreeNode n = (ExpandMutableTreeNode) e.nextElement();
Object userObj = n.getUserObject();
String chilld = null;
if (userObj instanceof String) {
chilld = (String) userObj;
} else if (userObj instanceof NameObject) {
NameObject nameObject = (NameObject) userObj;
chilld = nameObject.getName();
}
if (ComparatorUtils.equals(chilld, selectedRole)) {
this.setSelectionPath(parent.pathByAddingChild(n));
return;
} else {
setSelectedRole(selectedRole, parent.pathByAddingChild(n));
}
}
}
}
private void refreshElementAndAuthorityPane() {
JComponent authorityToolBar = DesignerContext.getDesignerFrame().getToolbarComponent();
if (authorityToolBar instanceof BasicBeanPane) {
//说明是工具栏的
((BasicBeanPane) authorityToolBar).populateAuthority();
}
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().repaint();
}
public String getSelectedRoleName() {
return roleName;
}
public void setSelectedRoleName(String name) {
roleName = name;
}
private DefaultTreeCellRenderer roleTreeRenderer = new DefaultTreeCellRenderer() {
private static final long serialVersionUID = 2L;
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
ExpandMutableTreeNode treeNode = (ExpandMutableTreeNode) value;
Object userObj = treeNode.getUserObject();
if (userObj instanceof String) {
// p:这个是column field.
this.setIcon(null);
this.setText((String) userObj);
} else if (userObj instanceof NameObject) {
NameObject nameObject = (NameObject) userObj;
this.setText(nameObject.getName());
this.setIcon(null);
}
// 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..."
this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND);
this.setForeground(UIConstants.FONT_COLOR);
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE);
return this;
}
};
/**
* 去除不需要的鼠标监听器
*
* @param component 组件
* @param l 所需的鼠标监听器
* @param index 插入的索引
*/
private void replaceMouseListener(Component component, MouseListener l, int index) {
component.removeMouseListener(treeMouseListener);
MouseListener[] listeners = component.getMouseListeners();
for (int i = 0, length = listeners.length; i < length; i++) {
component.removeMouseListener(listeners[i]);
}
// for (MouseListener listener : listeners) {
// component.removeMouseListener(listener);
// }
for (int i = 0; i < listeners.length; i++) {
MouseListener listener = listeners[i];
if (index == i) {
component.addMouseListener(l);
}
if (listener instanceof CheckBoxTree.Handler) {
continue;
}
component.addMouseListener(listener);
}
// index is too large, add to the end.
if (index > listeners.length - 1) {
component.addMouseListener(l);
}
}
/**
* 去除一些不需要的键盘监听器
*
* @param component 组件
* @param l 所需的键盘监听器
* @param index 插入的索引
*/
private void replaceKeyListener(Component component, KeyListener l, int index) {
KeyListener[] listeners = component.getKeyListeners();
for (int i = 0, length = listeners.length; i < length; i++) {
component.removeKeyListener(listeners[i]);
}
// for (MouseListener listener : listeners) {
// component.removeMouseListener(listener);
// }
for (int i = 0; i < listeners.length; i++) {
KeyListener listener = listeners[i];
if (index == i) {
component.addKeyListener(l);
}
if (listener instanceof CheckBoxTree.Handler) {
continue;
}
component.addKeyListener(listener);
}
// index is too large, add to the end.
if (index > listeners.length - 1) {
component.addKeyListener(l);
}
}
/*
* p:获得选中的NameObject = name + role.
*/
public NameObject getSelectedNameObject() {
TreePath selectedTreePath = this.getSelectionPath();
if (selectedTreePath == null) {
return null;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
Object selectedUserObject = selectedTreeNode.getUserObject();
return new NameObject(selectedUserObject.toString(), "");
}
/**
* p:添加一个NameObject节点
*
* @param no 需要添加的节点
*/
public void addNameObject(NameObject no) {
if (no == null) {
return;
}
DefaultTreeModel treeModel = (DefaultTreeModel) this.getModel();
// 新建一个放着NameObject的newChildTreeNode,加到Root下面
ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot();
ExpandMutableTreeNode newChildTreeNode = new ExpandMutableTreeNode(no);
root.add(newChildTreeNode);
newChildTreeNode.add(new ExpandMutableTreeNode());
treeModel.reload(root);
}
/**
* 刷新树节点
*/
public void refreshTreeNode() {
DefaultTreeModel treeModel = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot();
if (interceptRefresh(root)) {
return;
}
ExpandMutableTreeNode[] new_nodes = loadChildTreeNodes(root);
List childTreeNodeList = new ArrayList();
for (int i = 0, len = root.getChildCount(); i < len; i++) {
if (root.getChildAt(i) instanceof ExpandMutableTreeNode) {
childTreeNodeList.add((ExpandMutableTreeNode) root.getChildAt(i));
} else {
childTreeNodeList.add((DefaultMutableTreeNode) root.getChildAt(i));
}
}
root.removeAllChildren();
for (int ci = 0; ci < new_nodes.length; ci++) {
Object cUserObject = new_nodes[ci].getUserObject();
for (int ni = 0, nlen = childTreeNodeList.size(); ni < nlen; ni++) {
ExpandMutableTreeNode cTreeNode = (ExpandMutableTreeNode) childTreeNodeList.get(ni);
if (ComparatorUtils.equals(cTreeNode.getUserObject(), cUserObject)) {
new_nodes[ci].setExpanded(cTreeNode.isExpanded());
if (cTreeNode.getFirstChild() instanceof ExpandMutableTreeNode && cTreeNode.isExpanded()) {
checkChildNodes(cTreeNode, new_nodes[ci]);
}
break;
}
}
root.add(new_nodes[ci]);
}
}
protected void checkChildNodes(ExpandMutableTreeNode oldNode, ExpandMutableTreeNode newNode) {
for (int i = 0; i < oldNode.getChildCount(); i++) {
ExpandMutableTreeNode oldChild = (ExpandMutableTreeNode) oldNode.getChildAt(i);
for (int j = 0; j < newNode.getChildCount(); j++) {
ExpandMutableTreeNode newChild = (ExpandMutableTreeNode) newNode.getChildAt(j);
ExpandMutableTreeNode[] nodes = RoleTree.this.loadChildTreeNodes(newChild);
for (int k = 0; k < nodes.length; k++) {
newChild.add(nodes[k]);
}
if (newChild.getChildCount() > 1 && ((ExpandMutableTreeNode) newChild.getFirstChild()).getUserObject() == PENDING) {
newChild.remove(0);
}
if (ComparatorUtils.equals(oldChild.getUserObject(), newChild.getUserObject())) {
newChild.setExpanded(oldChild.isExpanded());
}
}
}
}
public NameObject getRealSelectedNameObject() {
TreePath selectedTreePath = this.getSelectionPath();
if (selectedTreePath == null) {
return null;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
Object selectedUserObject = selectedTreeNode.getUserObject();
if (selectedUserObject instanceof NameObject) {
return (NameObject) selectedUserObject;
}
selectedTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
selectedUserObject = selectedTreeNode.getUserObject();
if (selectedUserObject instanceof NameObject) {
return (NameObject) selectedUserObject;
}
return null;
}
}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/style/background/gradient/GradientBackgroundPane.java b/designer_base/src/com/fr/design/style/background/gradient/GradientBackgroundPane.java
index 9ab11eb14..ee0cd3385 100644
--- a/designer_base/src/com/fr/design/style/background/gradient/GradientBackgroundPane.java
+++ b/designer_base/src/com/fr/design/style/background/gradient/GradientBackgroundPane.java
@@ -43,7 +43,7 @@ public class GradientBackgroundPane extends BackgroundDetailPane {
JPanel blankJp = new JPanel();
gradientBar = new GradientBar(4, 254);
blankJp.add(gradientBar);
- UILabel jl = new UILabel(Inter.getLocText("Drag_to_select_gradient"));
+ UILabel jl = new UILabel(Inter.getLocText("FR-Designer_Drag_To_Select_Gradient"));
jl.setHorizontalAlignment(SwingConstants.CENTER);
gradientPanel.add(jl, BorderLayout.NORTH);
gradientPanel.add(blankJp, BorderLayout.SOUTH);
@@ -53,14 +53,14 @@ public class GradientBackgroundPane extends BackgroundDetailPane {
JPanel innercenterPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
centerPane.add(new UILabel(" "));
centerPane.add(innercenterPane);
- innercenterPane.add(new UILabel(Inter.getLocText("Gradient-Direction") + ":"));
+ innercenterPane.add(new UILabel(Inter.getLocText("FR-Designer_Gradient_Direction") + ":"));
- left2right = new UIRadioButton(Inter.getLocText("PageSetup-Landscape"));
+ left2right = new UIRadioButton(Inter.getLocText("FR-Designer_PageSetup_Horizontal"));
innercenterPane.add(left2right);
left2right.setSelected(true);
left2right.addActionListener(reviewListener);
- top2bottom = new UIRadioButton(Inter.getLocText("PageSetup-Portrait"));
+ top2bottom = new UIRadioButton(Inter.getLocText("FR-Designer_PageSetup_Vertical"));
innercenterPane.add(top2bottom);
top2bottom.addActionListener(reviewListener);
diff --git a/designer_base/src/com/fr/design/style/color/ColorPicker.java b/designer_base/src/com/fr/design/style/color/ColorPicker.java
index 8807e1f40..e91968675 100644
--- a/designer_base/src/com/fr/design/style/color/ColorPicker.java
+++ b/designer_base/src/com/fr/design/style/color/ColorPicker.java
@@ -7,11 +7,14 @@ package com.fr.design.style.color;
import com.fr.base.BaseUtils;
import com.fr.general.FRLogger;
+import javax.swing.*;
import java.awt.*;
-import java.awt.event.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage;
-import javax.swing.*;
/**
* 取色框
diff --git a/designer_base/src/com/fr/design/style/color/ColorSelectBox.java b/designer_base/src/com/fr/design/style/color/ColorSelectBox.java
index f926775ee..2dd5d51c3 100644
--- a/designer_base/src/com/fr/design/style/color/ColorSelectBox.java
+++ b/designer_base/src/com/fr/design/style/color/ColorSelectBox.java
@@ -63,6 +63,7 @@ public class ColorSelectBox extends AbstractSelectBox implements UIObserv
fireDisplayComponent(ColorBackground.getInstance(color));
}
});
+ colorPane.setColor(color);
return colorPane;
}
diff --git a/designer_base/src/com/fr/design/style/color/ColorSelectConfigManager.java b/designer_base/src/com/fr/design/style/color/ColorSelectConfigManager.java
index 4d20c1207..e135b17c6 100644
--- a/designer_base/src/com/fr/design/style/color/ColorSelectConfigManager.java
+++ b/designer_base/src/com/fr/design/style/color/ColorSelectConfigManager.java
@@ -1,56 +1,195 @@
package com.fr.design.style.color;
+import com.fr.file.XMLFileManager;
+
+
+import com.fr.base.FRContext;
+import com.fr.cluster.rpc.RPC;
+import com.fr.file.BaseClusterHelper;
+import com.fr.general.ComparatorUtils;
+import com.fr.general.GeneralContext;
+import com.fr.stable.EnvChangedListener;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLTools;
+import com.fr.stable.xml.XMLableReader;
+import com.fr.general.FRLogger;
+
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
+import java.io.InputStream;
/**
* 最近使用颜色
- * @author focus
*
+ * @author focus
*/
-public class ColorSelectConfigManager{
-
- // 最近使用的颜色个数
- private int colorNums = 20;
- // 最近使用颜色
- private List colors;
-
- private static ColorSelectConfigManager colorSelectConfigManager = null;
-
- public Color[] getColors() {
- if(colors == null){
- colors = new ArrayList();
- }
- return colors.toArray(new Color[colors.size()]);
- }
-
- public int getColorNum() {
- return colorNums;
- }
- public void setColorNum(int colorNums) {
- this.colorNums = colorNums;
- }
-
- public synchronized static ColorSelectConfigManager getInstance() {
- if (colorSelectConfigManager == null) {
- colorSelectConfigManager = new ColorSelectConfigManager();
- }
- return colorSelectConfigManager;
- }
-
- /**
- * 添加颜色到最近使用队列中
- *
- * @param color 颜色
- *
- */
- public void addToColorQueue(Color color){
- // 过滤重复的最近使用颜色
- // 因为有个后进先出的问题,最近使用的颜色需要放到最前面所以没用set
- if(colors.contains(color)){
- colors.remove(color);
- }
- colors.add(color);
- }
-}
\ No newline at end of file
+public class ColorSelectConfigManager extends XMLFileManager implements ColorSelectConfigManagerProvider {
+
+ // 最近使用的颜色个数
+ private int colorNums = 20;
+
+ private static ColorSelectConfigManagerProvider configManager = null;
+ private static ColorSelectConfigManager colorSelectConfigManager = null;
+ private boolean init = true;
+ // 最近使用颜色
+ private List colors = new ArrayList();
+ private static final String RECENT_COLOR_TAG = "RecentColors";
+ private static final String COLOR_TAG = "Color";
+
+ static {
+ GeneralContext.addEnvChangedListener(new EnvChangedListener() {
+ public void envChanged() {
+ ColorSelectConfigManager.envChanged();
+ }
+ });
+ }
+
+ private static void envChanged() {
+ configManager = null;
+ }
+
+ public Color[] getColors() {
+
+ //初次打开软件时从xml文件中获取历史颜色信息
+ if (init) {
+ ColorSelectConfigManagerProvider manager = ColorSelectConfigManager.getProviderInstance();
+ this.colors = manager.getColorsFromFile();
+ init = false;
+ }
+ if (colors == null) {
+ colors = new ArrayList();
+ }
+ return colors.toArray(new Color[colors.size()]);
+ }
+
+ public int getColorNum() {
+ return colorNums;
+ }
+
+ public void setColorNum(int colorNums) {
+ this.colorNums = colorNums;
+ }
+
+ public synchronized static ColorSelectConfigManager getInstance() {
+ if (colorSelectConfigManager == null) {
+ colorSelectConfigManager = new ColorSelectConfigManager();
+ }
+ return colorSelectConfigManager;
+ }
+
+ /**
+ * 添加颜色到最近使用队列中
+ *
+ * @param color 颜色
+ */
+ public void addToColorQueue(Color color) {
+ if(color == null){
+ return;
+ }
+ // 过滤重复的最近使用颜色
+ // 因为有个后进先出的问题,最近使用的颜色需要放到最前面所以没用set
+ if (colors.contains(color)) {
+ colors.remove(color);
+ }
+ colors.add(color);
+
+ /*@author yaohwu*/
+ //将历史颜色信息保存到xml文件中去
+ ColorSelectConfigManagerProvider manager = ColorSelectConfigManager.getProviderInstance();
+ if (colors != null && !colors.isEmpty()) {
+ manager.setColorsToFile(colors);
+ }
+ try {
+ FRContext.getCurrentEnv().writeResource(manager);
+ } catch (Exception e) {
+ FRLogger.getLogger().error(e.getMessage());
+ }
+ }
+
+
+ /**
+ * 读取配置文件流
+ *
+ * @param input 流
+ * @throws Exception 异常
+ */
+ @Override
+ public void readFromInputStream(InputStream input) throws Exception {
+ ColorSelectConfigManager manager = new ColorSelectConfigManager();
+ XMLTools.readInputStreamXML(manager, input);
+ configManager = manager;
+ FRContext.getCurrentEnv().writeResource(configManager);
+ }
+
+
+ /**
+ * 获取配置管理接口
+ *
+ * @return 配置管理接口ConfigManagerProvider
+ */
+ public synchronized static ColorSelectConfigManagerProvider getProviderInstance() {
+ if (configManager == null) {
+ if (isClusterMember()) {
+ return configManager;
+ }
+ configManager.readXMLFile();
+ }
+ return configManager;
+ }
+
+ private synchronized static boolean isClusterMember() {
+ switch (BaseClusterHelper.getClusterState()) {
+ case LEADER:
+ configManager = new ColorSelectConfigManager();
+ RPC.registerSkeleton(configManager);
+ return false;
+ case MEMBER:
+ String ip = BaseClusterHelper.getMainServiceIP();
+ configManager = (ColorSelectConfigManagerProvider) RPC.getProxy(ColorSelectConfigManager.class, ip);
+ return true;
+ default:
+ configManager = new ColorSelectConfigManager();
+ break;
+ }
+ return false;
+ }
+
+ public boolean writeResource() throws Exception {
+ return FRContext.getCurrentEnv().writeResource(ColorSelectConfigManager.getProviderInstance());
+ }
+
+ public String fileName() {
+ return "recentcolors.xml";
+ }
+
+ public void readXML(XMLableReader reader) {
+ String name = reader.getTagName();
+ if (reader.isChildNode()) {
+ if (ComparatorUtils.equals(COLOR_TAG, name)) {
+ Color color = null;
+ colors.add(reader.getAttrAsColor("colors", color));
+ }
+ }
+ }
+
+ public void writeXML(XMLPrintWriter writer) {
+ writer.startTAG(RECENT_COLOR_TAG);
+ if (this.colors != null && !this.colors.isEmpty()) {
+ for (int i = 0; i < this.colors.size(); i++) {
+ writer.startTAG(COLOR_TAG);
+ writer.attr("colors", colors.get(i).getRGB());
+ writer.end();
+ }
+ }
+ writer.end();
+ }
+
+ public List getColorsFromFile() {
+ return this.colors;
+ }
+
+ public void setColorsToFile(List colors) {
+ this.colors = colors;
+ }
+}
diff --git a/designer_base/src/com/fr/design/style/color/ColorSelectConfigManagerProvider.java b/designer_base/src/com/fr/design/style/color/ColorSelectConfigManagerProvider.java
new file mode 100644
index 000000000..f9b2ec988
--- /dev/null
+++ b/designer_base/src/com/fr/design/style/color/ColorSelectConfigManagerProvider.java
@@ -0,0 +1,17 @@
+package com.fr.design.style.color;
+
+import com.fr.stable.file.RemoteXMLFileManagerProvider;
+
+import java.awt.Color;
+import java.util.List;
+
+
+/**
+ * Created by yaohwu on 2017/2/8.
+ */
+public interface ColorSelectConfigManagerProvider extends RemoteXMLFileManagerProvider {
+
+ List getColorsFromFile();
+
+ void setColorsToFile(List colors);
+}
diff --git a/designer_base/src/com/fr/design/style/color/ColorSelectDetailPane.java b/designer_base/src/com/fr/design/style/color/ColorSelectDetailPane.java
index 5c6c505a3..a84b772ca 100644
--- a/designer_base/src/com/fr/design/style/color/ColorSelectDetailPane.java
+++ b/designer_base/src/com/fr/design/style/color/ColorSelectDetailPane.java
@@ -1,112 +1,104 @@
package com.fr.design.style.color;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dimension;
+import com.fr.design.dialog.BasicPane;
+import com.fr.design.layout.FRGUIPaneFactory;
+import com.fr.general.Inter;
-import javax.swing.JColorChooser;
-import javax.swing.JPanel;
+import javax.swing.*;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-
-import com.fr.design.dialog.BasicPane;
-import com.fr.design.layout.FRGUIPaneFactory;
-import com.fr.general.Inter;
+import java.awt.*;
/**
* 颜色选择器更多颜色面板
- * @author focus
*
+ * @author focus
*/
-public class ColorSelectDetailPane extends BasicPane{
- private static final int SELECT_PANEL_HEIGHT = 245;
- // Selected color
- private Color color;
-
- // 颜色选择器面板
- JColorChooser selectedPanel;
-
- // 最近使用颜色面板
- JPanel recentUsePanel;
-
- // 预览
- JPanel previewPanel;
-
- public JColorChooser getSelectedPanel() {
- return selectedPanel;
- }
-
- public void setSelectedPanel(JColorChooser selectedPanel) {
- this.selectedPanel = selectedPanel;
- }
-
- public Color getColor() {
- return color;
- }
-
- public void setColor(Color color) {
- this.color = color;
- }
-
- public ColorSelectDetailPane() {
- super();
- }
-
- public ColorSelectDetailPane(Color color){
- if(color == null){
- color = Color.white;
- }
- this.color = color;
- initComponents();
- }
-
- @Override
- protected String title4PopupWindow() {
- return null;
- }
-
- protected void initComponents() {
- this.setLayout(FRGUIPaneFactory.createBorderLayout());
-
- // 颜色选择器面板
- selectedPanel = new JColorChooser(this.color);
- selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(),SELECT_PANEL_HEIGHT));
- AbstractColorChooserPanel[] choosers = selectedPanel.getChooserPanels();
- for(int i=0;i colorChangeListenerList = new ArrayList();
-
- ColorSelectDetailPane pane;
-
+
+
+ /* default */ ColorSelectDetailPane pane;
+
/**
* Constructor.
*/
public ColorSelectPane() {
- super(true);
- initialCompents(true);
+ super(true);
+ initialCompents(true);
}
public ColorSelectPane(boolean isSupportTransparent) {
super(isSupportTransparent);
initialCompents(isSupportTransparent);
}
-
+
private void initialCompents(boolean isSupportTransparent) {
- this.setLayout(FRGUIPaneFactory.createBorderLayout());
- this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
- if (isSupportTransparent) {
- UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency"));
- this.add(transpanrentButton, BorderLayout.NORTH);
- transpanrentButton.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- doTransparent();
- }
- });
- }
-
- // center
- JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
- this.add(centerPane, BorderLayout.CENTER);
-
- centerPane.add(getRow1Pane());
-
- JPanel menuColorPane1 = getMenuColorPane();
- centerPane.add(menuColorPane1);
+ this.setLayout(FRGUIPaneFactory.createBorderLayout());
+ this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
+ if (isSupportTransparent) {
+ UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency"));
+ this.add(transpanrentButton, BorderLayout.NORTH);
+ transpanrentButton.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ doTransparent();
+ }
+ });
+ }
+
+ // center
+ JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
+ this.add(centerPane, BorderLayout.CENTER);
+
+ centerPane.add(getRow1Pane());
+
+ JPanel menuColorPane1 = getMenuColorPane();
+ centerPane.add(menuColorPane1);
Color[] colorArray = this.getColorArray();
- for (int i = 0; i < colorArray.length; i++) {
- Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i];
- menuColorPane1.add(new ColorCell(color, this));
- }
-
- centerPane.add(Box.createVerticalStrut(1));
-
- UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color"));
-
- customButton.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent e) {
- customButtonPressed();
- }
- });
- customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
- JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
- centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8));
- centerPane1.add(customButton, BorderLayout.NORTH);
- centerPane.add(centerPane1);
- }
-
- protected JPanel getMenuColorPane() {
- JPanel menuColorPane = new JPanel();
- menuColorPane.setLayout(new GridLayout(5, 8, 1, 1));
- menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
-
- return menuColorPane;
- }
-
- // 第一行,1个取色按钮 + 7个最近使用的颜色
- protected JPanel getRow1Pane() {
- JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
- row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
- row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7
-
- // 最近使用
- UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, ColorSelectConfigManager.getInstance().getColors(), this, true, true);
- usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
- row1Pane.add(usedColorPane.getPane());
- return row1Pane;
- }
-
- protected Color[] getColorArray(){
+ for (int i = 0; i < colorArray.length; i++) {
+ Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i];
+ menuColorPane1.add(new ColorCell(color, this));
+ }
+
+ centerPane.add(Box.createVerticalStrut(1));
+
+ UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color"));
+
+ customButton.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mousePressed(MouseEvent e) {
+ customButtonPressed();
+ }
+ });
+ customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
+ JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
+ centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8));
+ centerPane1.add(customButton, BorderLayout.NORTH);
+ centerPane.add(centerPane1);
+ }
+
+ protected JPanel getMenuColorPane() {
+ JPanel menuColorPane = new JPanel();
+ menuColorPane.setLayout(new GridLayout(5, 8, 1, 1));
+ menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
+
+ return menuColorPane;
+ }
+
+ // 第一行,1个取色按钮 + 1个留空的单元格 + 6个最近使用的颜色
+ protected JPanel getRow1Pane() {
+ JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
+ row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
+ row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7
+
+ // 最近使用
+ UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, this, true, true);
+ usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
+ row1Pane.add(usedColorPane.getPane());
+ return row1Pane;
+ }
+
+ protected Color[] getColorArray() {
return ColorFactory.MenuColors;
}
@@ -125,15 +123,16 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
/**
* Add change listener.
* 增加监听
- * @param 监听
+ *
+ * @param changeListener
*/
public void addChangeListener(ChangeListener changeListener) {
this.colorChangeListenerList.add(changeListener);
}
-
+
@Override
protected String title4PopupWindow() {
- return "Color";
+ return "Color";
}
/**
@@ -166,38 +165,36 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
/**
* 选中颜色
- * @param 颜色单元格
- *
*/
- @Override
- public void colorSetted(ColorCell colorCell) {
- colorCell.repaint();
- }
-
- /**
- * 初始化中央面板
- * @param centerPane 中央面板
- *
- */
- @Override
- public void initCenterPaneChildren(JPanel centerPane) {
- GUICoreUtils.initCenterPaneChildren(centerPane, this);
- }
-
- /**
- * 透明
- */
- @Override
- public void doTransparent() {
- this.setColor(null);
- }
-
- /**
- * 更多颜色
- */
- @Override
- public void customButtonPressed() {
- pane = new ColorSelectDetailPane(Color.WHITE);
- ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
- }
+ @Override
+ public void colorSetted(ColorCell colorCell) {
+ colorCell.repaint();
+ }
+
+ /**
+ * 初始化中央面板
+ *
+ * @param centerPane 中央面板
+ */
+ @Override
+ public void initCenterPaneChildren(JPanel centerPane) {
+ GUICoreUtils.initCenterPaneChildren(centerPane, this);
+ }
+
+ /**
+ * 透明
+ */
+ @Override
+ public void doTransparent() {
+ this.setColor(null);
+ }
+
+ /**
+ * 更多颜色
+ */
+ @Override
+ public void customButtonPressed() {
+ pane = new ColorSelectDetailPane(Color.WHITE);
+ ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
+ }
}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java b/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java
index b9903a81f..cb4398fd9 100644
--- a/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java
+++ b/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java
@@ -1,215 +1,205 @@
package com.fr.design.style.color;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.JPanel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import com.fr.design.constants.UIConstants;
import com.fr.design.border.UIRoundedBorder;
+import com.fr.design.constants.UIConstants;
+import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
-import com.fr.design.dialog.BasicPane;
import com.fr.general.Inter;
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+
/**
- *
* @author zhou
* @since 2012-5-29上午10:39:35
*/
public class NewColorSelectPane extends BasicPane implements ColorSelectable {
- private static final long serialVersionUID = -8634152305687249392L;
-
- private Color color = null; // color
- // color setting action.
- private ArrayList colorChangeListenerList = new ArrayList();
-
- // 颜色选择器
- private ColorSelectDetailPane pane;
- // 是否支持透明
- private boolean isSupportTransparent;
-
- private final static int TRANSPANENT_WINDOW_HEIGHT = 165;
- private final static int WINDWO_HEIGHT = 150;
-
- // 最近使用颜色
- UsedColorPane usedColorPane;
-
- /**
- * Constructor.
- */
- public NewColorSelectPane() {
- this(false);
- }
-
- /**
- * Constructor.
- */
- public NewColorSelectPane(boolean isSupportTransparent) {
- this.isSupportTransparent = isSupportTransparent;
- this.setLayout(FRGUIPaneFactory.createBorderLayout());
- this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
- if (isSupportTransparent) {
- UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency"));
- this.add(transpanrentButton, BorderLayout.NORTH);
- transpanrentButton.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- doTransparent();
- }
- });
- }
-
- // center
- JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
- this.add(centerPane, BorderLayout.CENTER);
-
- // 第一行
- JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
- row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
- row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7
- centerPane.add(row1Pane);
- // 最近使用
- usedColorPane = new UsedColorPane(1, 8, 1, ColorSelectConfigManager.getInstance().getColors(), this, true, false);
- usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
- row1Pane.add(usedColorPane.getPane());
-
- JPanel menuColorPane1 = new JPanel();
- centerPane.add(menuColorPane1);
-
- menuColorPane1.setLayout(new GridLayout(5, 8, 1, 1));
- menuColorPane1.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
- for (int i = 0; i < ColorFactory.MenuColors.length; i++) {
- menuColorPane1.add(new ColorCell(ColorFactory.MenuColors[i], this));
- }
-
- centerPane.add(Box.createVerticalStrut(1));
-
- // mod by anchore 16/11/16
- UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color"));
- //UIButton customButton = new UIButton(Inter.getLocText(new String[]{"More", "Color"}) + "...");
-
- customButton.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent e) {
- customButtonPressed();
- }
- });
- customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
- JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
- centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8));
- centerPane1.add(customButton, BorderLayout.NORTH);
- centerPane.add(centerPane1);
- }
-
-
-
- /**
- * 添加监听
- * @param 监听列表
- * Add change listener.
- */
- public void addChangeListener(ChangeListener changeListener) {
- this.colorChangeListenerList.add(changeListener);
- }
-
- @Override
- protected String title4PopupWindow() {
- return "Color";
- }
-
- /**
- * 获取颜色
- * @return 颜色
- * Return the color.
- */
- public Color getColor() {
- return color;
- }
-
- /**
- * 获取颜色
- *
- * @return 颜色
- */
- public Color getNotNoneColor() {
- if (color == null) {
- setColor(Color.WHITE);
- return Color.WHITE;
- }
- return color;
- }
-
- /**
- * Set the color.
- *
- * @param color
- * the new color.
- */
- @Override
- public void setColor(Color color) {
- this.color = color;
-
- // fire color change.
- if (!colorChangeListenerList.isEmpty()) {
- ChangeEvent evt = new ChangeEvent(this);
-
- for (int i = 0; i < colorChangeListenerList.size(); i++) {
- this.colorChangeListenerList.get(i).stateChanged(evt);
- }
- }
- ColorSelectConfigManager.getInstance().addToColorQueue(color);
- this.repaint();
- }
-
- /**
- * 设置颜色
- * @param 颜色位置
- */
- @Override
- public void colorSetted(ColorCell colorCell) {
- colorCell.repaint();
- }
-
- protected void doTransparent() {
- setColor(null);
- }
- protected void customButtonPressed() {
- pane = new ColorSelectDetailPane(Color.WHITE);
- ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
- }
-
- @Override
- public Dimension getPreferredSize() {
- if(isSupportTransparent){
- return new Dimension(super.getPreferredSize().width, TRANSPANENT_WINDOW_HEIGHT);
- }
- return new Dimension(super.getPreferredSize().width, WINDWO_HEIGHT);
- }
-
- /**
- * 更新最近使用颜色
- *
- */
- public void updateUsedColor(){
- usedColorPane.updateUsedColor();
- }
-
+ private static final long serialVersionUID = -8634152305687249392L;
+
+ private Color color = null; // color
+ // color setting action.
+ private ArrayList colorChangeListenerList = new ArrayList();
+
+ // 颜色选择器
+ private ColorSelectDetailPane pane;
+ // 是否支持透明
+ private boolean isSupportTransparent;
+
+ private final static int TRANSPANENT_WINDOW_HEIGHT = 165;
+ private final static int WINDWO_HEIGHT = 150;
+
+ // 最近使用颜色
+ private UsedColorPane usedColorPane;
+
+ /**
+ * Constructor.
+ */
+ public NewColorSelectPane() {
+ this(false);
+ }
+
+ /**
+ * Constructor.
+ */
+ public NewColorSelectPane(boolean isSupportTransparent) {
+ this.isSupportTransparent = isSupportTransparent;
+ this.setLayout(FRGUIPaneFactory.createBorderLayout());
+ this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
+ if (isSupportTransparent) {
+ UIButton transpanrentButton = new UIButton(Inter.getLocText("FR-Designer_ChartF-Transparency"));
+ this.add(transpanrentButton, BorderLayout.NORTH);
+ transpanrentButton.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ doTransparent();
+ }
+ });
+ }
+
+ // center
+ JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
+ this.add(centerPane, BorderLayout.CENTER);
+
+ // 第一行
+ JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
+ row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
+ row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7
+ centerPane.add(row1Pane);
+ // 最近使用
+ usedColorPane = new UsedColorPane(1, 8, 1, this, true, false);
+ usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
+ row1Pane.add(usedColorPane.getPane());
+
+ JPanel menuColorPane1 = new JPanel();
+ centerPane.add(menuColorPane1);
+
+ menuColorPane1.setLayout(new GridLayout(5, 8, 1, 1));
+ menuColorPane1.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
+ for (int i = 0; i < ColorFactory.MenuColors.length; i++) {
+ menuColorPane1.add(new ColorCell(ColorFactory.MenuColors[i], this));
+ }
+
+ centerPane.add(Box.createVerticalStrut(1));
+
+ // mod by anchore 16/11/16
+ UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color"));
+
+ customButton.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mousePressed(MouseEvent e) {
+ customButtonPressed();
+ }
+ });
+ customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
+ JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
+ centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8));
+ centerPane1.add(customButton, BorderLayout.NORTH);
+ centerPane.add(centerPane1);
+ }
+
+
+ /**
+ * 添加监听
+ *
+ * @param 监听列表 Add change listener.
+ */
+ public void addChangeListener(ChangeListener changeListener) {
+ this.colorChangeListenerList.add(changeListener);
+ }
+
+ @Override
+ protected String title4PopupWindow() {
+ return "Color";
+ }
+
+ /**
+ * 获取颜色
+ *
+ * @return 颜色
+ * Return the color.
+ */
+ public Color getColor() {
+ return color;
+ }
+
+ /**
+ * 获取颜色
+ *
+ * @return 颜色
+ */
+ public Color getNotNoneColor() {
+ if (color == null) {
+ setColor(Color.WHITE);
+ return Color.WHITE;
+ }
+ return color;
+ }
+
+ /**
+ * Set the color.
+ *
+ * @param color the new color.
+ */
+ @Override
+ public void setColor(Color color) {
+ this.color = color;
+
+ // fire color change.
+ if (!colorChangeListenerList.isEmpty()) {
+ ChangeEvent evt = new ChangeEvent(this);
+
+ for (int i = 0; i < colorChangeListenerList.size(); i++) {
+ this.colorChangeListenerList.get(i).stateChanged(evt);
+ }
+ }
+ ColorSelectConfigManager.getInstance().addToColorQueue(color);
+ this.repaint();
+ }
+
+ /**
+ * 设置颜色
+ *
+ * @param 颜色位置
+ */
+ @Override
+ public void colorSetted(ColorCell colorCell) {
+ colorCell.repaint();
+ }
+
+ protected void doTransparent() {
+ setColor(null);
+ }
+
+ protected void customButtonPressed() {
+ pane = new ColorSelectDetailPane(Color.WHITE);
+ ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
+ }
+
+ @Override
+ public Dimension getPreferredSize() {
+ if (isSupportTransparent) {
+ return new Dimension(super.getPreferredSize().width, TRANSPANENT_WINDOW_HEIGHT);
+ }
+ return new Dimension(super.getPreferredSize().width, WINDWO_HEIGHT);
+ }
+
+ /**
+ * 更新最近使用颜色
+ */
+ public void updateUsedColor() {
+ usedColorPane.updateUsedColor();
+ }
}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/style/color/RecentUseColorPane.java b/designer_base/src/com/fr/design/style/color/RecentUseColorPane.java
index 914436d0f..c85ff6be8 100644
--- a/designer_base/src/com/fr/design/style/color/RecentUseColorPane.java
+++ b/designer_base/src/com/fr/design/style/color/RecentUseColorPane.java
@@ -1,55 +1,48 @@
package com.fr.design.style.color;
-import java.awt.BorderLayout;
-import java.awt.Color;
-
-import javax.swing.JColorChooser;
-import javax.swing.JPanel;
-
import com.fr.design.dialog.BasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
-public class RecentUseColorPane extends BasicPane implements ColorSelectable{
-
- JColorChooser chooser;
-
- @Override
- protected String title4PopupWindow() {
- return null;
- }
-
- public RecentUseColorPane() {
- }
-
- public RecentUseColorPane(JColorChooser chooser) {
- this.chooser = chooser;
-
- // center
- JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
- this.add(centerPane, BorderLayout.CENTER);
- // 最近使用
- UsedColorPane pane = new UsedColorPane(2, 10, ColorSelectConfigManager.getInstance().getColors(),this);
- centerPane.add(pane.getPane());
- }
-
- /**
- * 选中颜色
- *
- * @param 颜色
- */
- @Override
- public void colorSetted(ColorCell color) {
-
- }
-
- @Override
- public Color getColor() {
- return null;
- }
-
- @Override
- public void setColor(Color color) {
- chooser.getSelectionModel().setSelectedColor(color);
- }
-
+import javax.swing.*;
+import java.awt.*;
+
+public class RecentUseColorPane extends BasicPane implements ColorSelectable {
+
+ private JColorChooser chooser;
+
+ @Override
+ protected String title4PopupWindow() {
+ return null;
+ }
+
+
+ public RecentUseColorPane(JColorChooser chooser) {
+ this.chooser = chooser;
+
+ // center
+ JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
+ this.add(centerPane, BorderLayout.CENTER);
+ // 最近使用
+ UsedColorPane pane = new UsedColorPane(2, 10, this);
+ centerPane.add(pane.getPane());
+ }
+
+ /**
+ * 选中颜色
+ */
+ @Override
+ public void colorSetted(ColorCell color) {
+
+ }
+
+ @Override
+ public Color getColor() {
+ return null;
+ }
+
+ @Override
+ public void setColor(Color color) {
+ chooser.getSelectionModel().setSelectedColor(color);
+ }
+
}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/style/color/UsedColorPane.java b/designer_base/src/com/fr/design/style/color/UsedColorPane.java
index c8dfdcaec..5594254c3 100644
--- a/designer_base/src/com/fr/design/style/color/UsedColorPane.java
+++ b/designer_base/src/com/fr/design/style/color/UsedColorPane.java
@@ -1,119 +1,112 @@
package com.fr.design.style.color;
-import java.awt.Color;
-import java.awt.GridLayout;
-
-import javax.swing.BorderFactory;
-import javax.swing.JPanel;
-
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.SpecialUIButton;
-public class UsedColorPane extends BasicPane{
-
- public static final Color DEFAULT_COLOR = new Color(222,222,222);
-
- // 最近使用面板列数
- private int columns;
- // 最近使用面板行数
- private int rows;
- // 留白的单元格数量
- private int reserveCells;
- // 是否需要取色器按钮
- private boolean needPickColorButton;
- // 是否在取色时实时设定颜色
- private boolean setColorRealTime;
- // 最近使用颜色
- private Object[] colors;
- // 最近使用面板
- private JPanel pane;
-
- private ColorSelectable selectable;
-
- public JPanel getPane() {
- return pane;
- }
-
- public void setPane(JPanel pane) {
- this.pane = pane;
- }
-
- public UsedColorPane(){
-
- }
-
- /**
- * 构造函数
- *
- * @param rows 行
- * @param columns 列
- * @param reserveCells 留白的单元格个数
- * @param colors 最近使用的颜色
- * @param needPickColorButton 是否需要加上取色器按钮
- * @param setColorRealTime 取色器是否实时设定颜色
- */
- public UsedColorPane(int rows,int columns,int reserveCells, Object[] colors, ColorSelectable selectable, boolean needPickColorButton, boolean setColorRealTime){
- this.columns = columns;
- this.rows = rows;
- this.reserveCells = reserveCells;
- this.colors = colors;
- this.selectable = selectable;
- this.needPickColorButton = needPickColorButton;
- this.setColorRealTime = setColorRealTime;
- initialComponents();
- }
-
- public UsedColorPane(int rows,int columns, Object[] colors,ColorSelectable selectable){
- this(rows, columns, 0, colors, selectable, false, false);
- }
-
- private void initialComponents(){
- int total = columns * rows;
- JPanel panel = new JPanel();
- panel.setLayout(new GridLayout(rows,columns, 1, 1));
- panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
- Color[] colors = ColorSelectConfigManager.getInstance().getColors();
- int size = colors.length;
-
- int i = 0;
- if (needPickColorButton) {
- // 取色按钮
- SpecialUIButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, setColorRealTime);
- panel.add(pickColorButton);
- i++;
- this.reserveCells += 1;
- }
- while (i < this.reserveCells) {
- ColorCell cc = new ColorCell(DEFAULT_COLOR, selectable);
- cc.setVisible(false);
- panel.add(cc);
- i++;
- }
- while (i < total) {
- Color color = i < size ? colors[size-1-i]: DEFAULT_COLOR;
- panel.add(new ColorCell(color == null ? DEFAULT_COLOR : color, selectable));
- i++;
- }
- this.pane = panel;
- }
-
- /**
- * 更新最近使用颜色
- *
- */
- public void updateUsedColor(){
- int total = columns * rows;
- Color[] colors = ColorSelectConfigManager.getInstance().getColors();
- int size = colors.length;
- for(int i=this.reserveCells; i dbcomponents) {
- for (JComponent jcomponent : dbcomponents) {
- jcomponent.setDoubleBuffered(true);
- }
- }
-
- /**
- * 禁止双缓冲状态,并将初始状态为启动双缓冲的组件保存到dbcomponents中
- */
- public static void disableBuffer(Component comp, ArrayList dbcomponents) {
- if ((comp instanceof JComponent) && comp.isDoubleBuffered()) {
- JComponent jcomponent = (JComponent) comp;
-
- dbcomponents.add(jcomponent);
- jcomponent.setDoubleBuffered(false);
- }
-
- if (comp instanceof Container) {
- Container container = (Container) comp;
- int count = container.getComponentCount();
-
- if (count > 0) {
- for (int i = 0; i < count; i++) {
- Component component = container.getComponent(i);
-
- disableBuffer(component, dbcomponents);
- }
- }
- }
- }
-
- public static int indexOfComponent(Container container, Component target) {
- int count = container.getComponentCount();
-
- for (int i = 0; i < count; i++) {
- Component child = container.getComponent(i);
-
- if (child == target) {
- return i;
- }
- }
-
- return -1;
- }
-
- /**
- * 计算组件root相对于其顶层容器的可见区域
- */
- public static Rectangle computeVisibleRectRel2Root(Component root) {
- Container container = findAncestorScrollPane(root);
-
- if (container == null) {
- return getRelativeBounds(root);
- } else {
- // 如果是JScrollPane的子组件,需要计算其viewport与改组件的交叉的可见区域
- return getBoundsRel2Parent(root, container);
- }
- }
-
- /**
- * 计算组件root相对于其顶层容器的可见区域
- */
- public static Rectangle computeVisibleRect(JComponent root) {
- Rectangle root_bounds = ComponentUtils.getRelativeBounds(root);
- Rectangle rect = computeVisibleRectRel2Root(root);
- rect.x -= root_bounds.x;
- rect.y -= root_bounds.y;
-
- return rect;
- }
-
- private static Rectangle getBoundsRel2Parent(Component child, Container parent) {
- Rectangle cRect = getRelativeBounds(child);
- Rectangle pRect = getRelativeBounds(parent);
- Rectangle bounds = new Rectangle();
- Rectangle2D.intersect(cRect, pRect, bounds);
-
- return bounds;
- }
-
- public static Container findAncestorScrollPane(Component p) {
- if ((p == null) || !(p instanceof Container)) {
- return null;
- }
-
- Container c = p.getParent();
-
- return findAncestorScrollPane(c);
- }
-
- public static boolean isRootComponent(Component root) {
- Container parent = root.getParent();
- return parent == null;
- }
-
- public static boolean isChildOf(Component component, Class parent) {
- Container container = component.getParent();
- if (container != null) {
- if (ComparatorUtils.equals(container.getClass(), parent)) {
- return true;
- } else {
- return isChildOf(container, parent);
- }
- }
- return false;
- }
+package com.fr.design.utils;
+
+import com.fr.general.ComparatorUtils;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+
+/**
+ * 工具类,提供常用的工具方法
+ */
+public class ComponentUtils {
+
+ private ComponentUtils() {
+ }
+
+ public static boolean isComponentVisible(Component comp) {
+ if (!comp.isVisible() && !isRootComponent(comp)) {
+ return false;
+ }
+ Component parent = comp.getParent();
+
+ return parent == null || isComponentVisible(parent);
+
+ }
+
+ /**
+ * 获取component所在的容器的绝对位置
+ */
+ public static Rectangle getRelativeBounds(Component component) {
+ Rectangle bounds = new Rectangle(0, 0, component.getWidth(), component.getHeight());
+ Container parent = component.getParent();
+
+ while (parent != null) {
+ bounds.x += component.getX();
+ bounds.y += component.getY();
+ component = parent;
+ parent = component.getParent();
+ }
+
+ return bounds;
+ }
+
+ /**
+ * 恢复双缓冲状态,dbcomponents保存着初始状态为启动双缓冲的组件
+ */
+ public static void resetBuffer(ArrayList dbcomponents) {
+ for (JComponent jcomponent : dbcomponents) {
+ jcomponent.setDoubleBuffered(true);
+ }
+ }
+
+ /**
+ * 禁止双缓冲状态,并将初始状态为启动双缓冲的组件保存到dbcomponents中
+ */
+ public static void disableBuffer(Component comp, ArrayList dbcomponents) {
+ if ((comp instanceof JComponent) && comp.isDoubleBuffered()) {
+ JComponent jcomponent = (JComponent) comp;
+
+ dbcomponents.add(jcomponent);
+ jcomponent.setDoubleBuffered(false);
+ }
+
+ if (comp instanceof Container) {
+ Container container = (Container) comp;
+ int count = container.getComponentCount();
+
+ if (count > 0) {
+ for (int i = 0; i < count; i++) {
+ Component component = container.getComponent(i);
+
+ disableBuffer(component, dbcomponents);
+ }
+ }
+ }
+ }
+
+ public static int indexOfComponent(Container container, Component target) {
+ int count = container.getComponentCount();
+
+ for (int i = 0; i < count; i++) {
+ Component child = container.getComponent(i);
+
+ if (child.equals(target)) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * 计算组件root相对于其顶层容器的可见区域
+ */
+ public static Rectangle computeVisibleRectRel2Root(Component root) {
+ Container container = findAncestorScrollPane(root);
+
+ if (container == null) {
+ return getRelativeBounds(root);
+ } else {
+ // 如果是JScrollPane的子组件,需要计算其viewport与改组件的交叉的可见区域
+ return getBoundsRel2Parent(root, container);
+ }
+ }
+
+ /**
+ * 计算组件root相对于其顶层容器的可见区域
+ */
+ public static Rectangle computeVisibleRect(JComponent root) {
+ Rectangle rootBounds = ComponentUtils.getRelativeBounds(root);
+ Rectangle rect = computeVisibleRectRel2Root(root);
+ rect.x -= rootBounds.x;
+ rect.y -= rootBounds.y;
+
+ return rect;
+ }
+
+ private static Rectangle getBoundsRel2Parent(Component child, Container parent) {
+ Rectangle cRect = getRelativeBounds(child);
+ Rectangle pRect = getRelativeBounds(parent);
+ Rectangle bounds = new Rectangle();
+ Rectangle2D.intersect(cRect, pRect, bounds);
+
+ return bounds;
+ }
+
+ public static Container findAncestorScrollPane(Component p) {
+ if ((p == null) || !(p instanceof Container)) {
+ return null;
+ }
+
+ Container c = p.getParent();
+
+ return findAncestorScrollPane(c);
+ }
+
+ public static boolean isRootComponent(Component root) {
+ Container parent = root.getParent();
+ return parent == null;
+ }
+
+ public static boolean isChildOf(Component component, Class parent) {
+ Container container = component.getParent();
+ if (container != null) {
+ if (ComparatorUtils.equals(container.getClass(), parent)) {
+ return true;
+ } else {
+ return isChildOf(container, parent);
+ }
+ }
+ return false;
+ }
}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/env/RemoteEnv.java b/designer_base/src/com/fr/env/RemoteEnv.java
index a0bdc0e13..ac5732e73 100644
--- a/designer_base/src/com/fr/env/RemoteEnv.java
+++ b/designer_base/src/com/fr/env/RemoteEnv.java
@@ -55,7 +55,7 @@ import java.util.Timer;
import java.util.logging.Level;
import java.util.regex.Pattern;
-public class RemoteEnv implements Env {
+public class RemoteEnv extends AbstractEnv {
private static final int TIME_OUT = 30 * 1000;
private static final int PLAIN_SOCKET_PORT = 80;
private static final int SSL_PORT = 443;
@@ -1483,6 +1483,8 @@ public class RemoteEnv implements Env {
* @throws Exception 异常
*/
public boolean writeSvgFile(SvgProvider svgFile) throws Exception {
+ testServerConnection();
+
HashMap para = new HashMap();
para.put("op", "fr_remote_design");
para.put("cmd", "design_save_svg");
@@ -1534,6 +1536,8 @@ public class RemoteEnv implements Env {
*/
@Override
public boolean writeResource(XMLFileManagerProvider mgr) throws Exception {
+ testServerConnection();
+
HashMap para = new HashMap();
para.put("op", "fr_remote_design");
para.put("cmd", "design_save_resource");
diff --git a/designer_base/src/com/fr/start/BaseDesigner.java b/designer_base/src/com/fr/start/BaseDesigner.java
index 016ad604d..301a9191f 100644
--- a/designer_base/src/com/fr/start/BaseDesigner.java
+++ b/designer_base/src/com/fr/start/BaseDesigner.java
@@ -7,7 +7,7 @@ import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.RestartHelper;
-import com.fr.design.extra.WebDialog;
+import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.TemplateTreePane;
@@ -124,10 +124,10 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
public void actionPerformed(ActionEvent e) {
String[] plugins = PluginCollector.getCollector().getErrorPlugins();
if (ArrayUtils.isNotEmpty(plugins)) {
- String text = StableUtils.join(plugins, ",") + Inter.getLocText("FR-Designer_Plugin_Should_Update");
+ String text = StableUtils.join(plugins, ",") + ": " + Inter.getLocText("FR-Designer_Plugin_Should_Update_Please_Contact_Developer");
int r = JOptionPane.showConfirmDialog(null, text, Inter.getLocText("FR-Designer_Plugin_Should_Update_Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if (r == JOptionPane.OK_OPTION) {
- WebDialog.createPluginDialog();
+ WebViewDlgHelper.createPluginDialog();
}
}
timer.stop();
diff --git a/designer_chart/build.dev.gradle b/designer_chart/build.dev.gradle
index ba6df992b..db1478361 100644
--- a/designer_chart/build.dev.gradle
+++ b/designer_chart/build.dev.gradle
@@ -1,8 +1,26 @@
-apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
+
+buildscript {
+ repositories {
+ maven {
+ url "http://www.eveoh.nl/files/maven2"
+ }
+ }
+
+ dependencies {
+ classpath "nl.eveoh:gradle-aspectj:1.2"
+ }
+}
+
+ext.aspectjVersion = '1.7.4'
+apply plugin: 'aspectj'
+
+repositories {
+ mavenCentral()
+}
//指定构建的jdk版本
sourceCompatibility=1.7
//指定生成jar包的版本
diff --git a/designer_chart/build.dev.gradle.bak b/designer_chart/build.dev.gradle.bak
new file mode 100644
index 000000000..7566bcc82
--- /dev/null
+++ b/designer_chart/build.dev.gradle.bak
@@ -0,0 +1,85 @@
+
+apply plugin: 'java'
+tasks.withType(JavaCompile){
+ options.encoding = 'UTF-8'
+}
+
+buildscript {
+ repositories {
+ maven {
+ url "http://www.eveoh.nl/files/maven2"
+ }
+ }
+
+ dependencies {
+ classpath "nl.eveoh:gradle-aspectj:1.2"
+ }
+}
+
+ext.aspectjVersion = '1.7.4'
+apply plugin: 'aspectj'
+
+repositories {
+ mavenCentral()
+}
+//指定构建的jdk版本
+sourceCompatibility=1.7
+//指定生成jar包的版本
+version='8.0'
+
+def srcDir="."
+
+//对生成的jar包进行重命名
+
+jar{
+ baseName='fr-designer-chart'
+}
+
+sourceSets{
+ main{
+ java{
+ srcDirs=["${srcDir}/src"]
+ }
+ }
+}
+FileTree files =fileTree(dir:'./',include:'build.*.gradle')
+def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\'))
+buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\'))
+def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1)
+
+//指定外部依赖
+dependencies{
+compile fileTree(dir:"../../../finereport-lib-stable/${branchName}",include:'**/*.jar')
+compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar")
+
+ testCompile 'junit:junit:4.12'
+}
+//将非.java 文件复制到classes文件夹下参与打包
+task copyFile(type:Copy,dependsOn:compileJava){
+ copy{
+ from ("${srcDir}/src"){
+ exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html'
+
+ }
+ into 'build/classes/main'
+ }
+
+}
+
+//压缩项目中的js文件
+task compressJS{
+ ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){
+ classpath {
+ fileset(dir:'../../../finereport-lib4build-stable',includes:'**/*.jar')
+ }
+ }
+ ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){
+ fileset (dir:"${srcDir}/src"){
+ include (name:'**/*.js')
+ include (name:'**/*.css')
+ }
+
+ }
+}
+jar.dependsOn compressJS
+
diff --git a/designer_chart/build.master.gradle b/designer_chart/build.master.gradle
index ba6df992b..6730fd1ee 100644
--- a/designer_chart/build.master.gradle
+++ b/designer_chart/build.master.gradle
@@ -1,8 +1,26 @@
-apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
+buildscript {
+ repositories {
+ maven {
+ url "http://www.eveoh.nl/files/maven2"
+ }
+ }
+
+ dependencies {
+ classpath "nl.eveoh:gradle-aspectj:1.2"
+ }
+}
+
+ext.aspectjVersion = '1.7.4'
+apply plugin: 'aspectj'
+
+repositories {
+ mavenCentral()
+}
+
//指定构建的jdk版本
sourceCompatibility=1.7
//指定生成jar包的版本
diff --git a/designer_chart/build.master.gradle.bak b/designer_chart/build.master.gradle.bak
new file mode 100644
index 000000000..c0f28d1f8
--- /dev/null
+++ b/designer_chart/build.master.gradle.bak
@@ -0,0 +1,85 @@
+
+apply plugin: 'java'
+tasks.withType(JavaCompile){
+ options.encoding = 'UTF-8'
+}
+buildscript {
+ repositories {
+ maven {
+ url "http://www.eveoh.nl/files/maven2"
+ }
+ }
+
+ dependencies {
+ classpath "nl.eveoh:gradle-aspectj:1.2"
+ }
+}
+
+ext.aspectjVersion = '1.7.4'
+apply plugin: 'aspectj'
+
+repositories {
+ mavenCentral()
+}
+
+//指定构建的jdk版本
+sourceCompatibility=1.7
+//指定生成jar包的版本
+version='8.0'
+
+def srcDir="."
+
+//对生成的jar包进行重命名
+
+jar{
+ baseName='fr-designer-chart'
+}
+
+sourceSets{
+ main{
+ java{
+ srcDirs=["${srcDir}/src"]
+ }
+ }
+}
+FileTree files =fileTree(dir:'./',include:'build.*.gradle')
+def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\'))
+buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\'))
+def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1)
+
+//指定外部依赖
+dependencies{
+compile fileTree(dir:"../../../finereport-lib-stable/${branchName}",include:'**/*.jar')
+compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar")
+
+ testCompile 'junit:junit:4.12'
+}
+//将非.java 文件复制到classes文件夹下参与打包
+task copyFile(type:Copy,dependsOn:compileJava){
+ copy{
+ from ("${srcDir}/src"){
+ exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html'
+
+ }
+ into 'build/classes/main'
+ }
+
+}
+
+//压缩项目中的js文件
+task compressJS{
+ ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){
+ classpath {
+ fileset(dir:'../../../finereport-lib4build-stable',includes:'**/*.jar')
+ }
+ }
+ ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){
+ fileset (dir:"${srcDir}/src"){
+ include (name:'**/*.js')
+ include (name:'**/*.css')
+ }
+
+ }
+}
+jar.dependsOn compressJS
+
diff --git a/designer_chart/build.release.gradle b/designer_chart/build.release.gradle
index e97176e24..b897c71de 100644
--- a/designer_chart/build.release.gradle
+++ b/designer_chart/build.release.gradle
@@ -1,8 +1,26 @@
-apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
+buildscript {
+ repositories {
+ maven {
+ url "http://www.eveoh.nl/files/maven2"
+ }
+ }
+
+ dependencies {
+ classpath "nl.eveoh:gradle-aspectj:1.2"
+ }
+}
+
+ext.aspectjVersion = '1.7.4'
+apply plugin: 'aspectj'
+
+repositories {
+ mavenCentral()
+}
+
//指定构建的jdk版本
sourceCompatibility=1.8
//指定生成jar包的版本
diff --git a/designer_chart/src/com/fr/aspectj/designerchart/TemplateProcessTracker.aj b/designer_chart/src/com/fr/aspectj/designerchart/TemplateProcessTracker.aj
new file mode 100644
index 000000000..51e86fd15
--- /dev/null
+++ b/designer_chart/src/com/fr/aspectj/designerchart/TemplateProcessTracker.aj
@@ -0,0 +1,59 @@
+package com.fr.aspectj.designerchart;
+
+/**
+ * Created by plough on 2017/3/3.
+ */
+import com.fr.chart.chartattr.Chart;
+import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
+import org.aspectj.lang.reflect.SourceLocation;
+
+import javax.swing.event.ListSelectionEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.util.Date;
+
+public aspect TemplateProcessTracker {
+ //声明一个pointcut,匹配你需要的方法
+ pointcut onMouseClicked(MouseEvent e) :
+ execution(* mouseClicked(MouseEvent)) && args(e);
+ pointcut onMousePressed(MouseEvent e) :
+ execution(* mousePressed(MouseEvent)) && args(e);
+ pointcut onMouseReleased(MouseEvent e) :
+ execution(* mouseReleased(MouseEvent)) && args(e);
+ pointcut onActionPerformed(ActionEvent e) :
+ execution(* actionPerformed(ActionEvent)) && args(e);
+ pointcut onChartUpdate(Chart c) :
+ execution(* update(Chart)) && args(c);
+
+ //before表示之前的意思
+ //这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码
+ before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) {
+ SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置
+
+ //String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource());
+ String log = "";
+ TemplateInfoCollector.appendProcess(log);
+ }
+ //同上
+ before(ActionEvent e) : onActionPerformed(e) {
+ SourceLocation sl = thisJoinPoint.getSourceLocation();
+ // !within(LogHandlerBar) 没用, 手动过滤
+ if (e.getSource().toString().contains("javax.swing.Timer")) {
+ return;
+ }
+
+ //String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource());
+ String log = "";
+ TemplateInfoCollector.appendProcess(log);
+
+ }
+ //同上
+ before(Chart c) : onChartUpdate(c) {
+ SourceLocation sl = thisJoinPoint.getSourceLocation();
+ //String log = String.format("%s:\n%s\n插入新图表:%s\n\n", new Date(), sl, c.getChartName());
+ String log = "";
+ TemplateInfoCollector.appendProcess(log);
+
+ }
+
+}
diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
index c091c54b9..c67a6aea5 100644
--- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
+++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
@@ -75,7 +75,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
static {
GeneralContext.addPluginReadListener(new PluginReadListener() {
@Override
- public void success() {
+ public void success(Status status) {
//重新注册designModuleFactory
DesignModuleFactory.registerExtraWidgetOptions(initWidgetOption());
}
diff --git a/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java b/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java
index d717d31a8..8a157f084 100644
--- a/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java
+++ b/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java
@@ -31,44 +31,55 @@ public class MinMaxValuePane extends JPanel {
protected UITextField secUnitField;
public MinMaxValuePane() {
- minCheckBox = new UICheckBox(Inter.getLocText(new String[]{"Custom", "Min_Value"}));
- minValueField = new UITextField(6);
- maxCheckBox = new UICheckBox(Inter.getLocText(new String[]{"Custom", "Max_Value"}));
- maxValueField = new UITextField(6);
- isCustomMainUnitBox = new UICheckBox(Inter.getLocText("FR-Chart_MainGraduationUnit"));
- mainUnitField = new UITextField(6);
- isCustomSecUnitBox = new UICheckBox(Inter.getLocText("FR-Chart_SecondGraduationUnit"));
- secUnitField = new UITextField(6);
+ minCheckBox = new UICheckBox(Inter.getLocText(new String[]{"Custom", "Min_Value"}));
+ minValueField = new UITextField(6);
+ maxCheckBox = new UICheckBox(Inter.getLocText(new String[]{"Custom", "Max_Value"}));
+ maxValueField = new UITextField(6);
+ isCustomMainUnitBox = new UICheckBox(Inter.getLocText("FR-Chart_MainGraduationUnit"));
+ mainUnitField = new UITextField(6);
+ isCustomSecUnitBox = new UICheckBox(Inter.getLocText("FR-Chart_SecondGraduationUnit"));
+ secUnitField = new UITextField(6);
+
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
- double[] columnSize = { p, f };
- double[] rowSize = { p, p, p, p};
+ double[] columnSize = {p, f};
- Component[][] components = getPanelComponents();
- JPanel panel = TableLayoutHelper.createTableLayoutPane(components ,rowSize,columnSize);
+ Component[][] components = getPanelComponents();
+ JPanel panel = TableLayoutHelper.createTableLayoutPane(components, getRowSize(p), columnSize);
this.setLayout(new BorderLayout());
- this.add(panel,BorderLayout.CENTER);
+ this.add(panel, BorderLayout.CENTER);
+ addComponentListener(components);
+ }
- for(int i = 0; i < components.length; i++) {
- ((UICheckBox)components[i][0]).addActionListener(new ActionListener() {
+ protected double[] getRowSize(double p) {
+ return new double[]{p, p, p, p};
+ }
- @Override
- public void actionPerformed(ActionEvent e) {
- checkBoxUse();
- }
- });
- ChartSwingUtils.addListener((UICheckBox)components[i][0], (UITextField)components[i][1]);
+ protected void addComponentListener(Component[][] components) {
+ for (int i = 0; i < components.length; i++) {
+ addListener((UICheckBox) components[i][0]);
+ ChartSwingUtils.addListener((UICheckBox) components[i][0], (UITextField) components[i][1]);
}
}
- protected Component[][] getPanelComponents() {
- return new Component[][]{
- new Component[]{minCheckBox, minValueField},
- new Component[]{maxCheckBox, maxValueField},
- new Component[]{isCustomMainUnitBox, mainUnitField},
- new Component[]{isCustomSecUnitBox, secUnitField},
- };
- }
+ protected void addListener(UICheckBox checkBox) {
+ checkBox.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ checkBoxUse();
+ }
+ });
+ }
+
+ protected Component[][] getPanelComponents() {
+ return new Component[][]{
+ new Component[]{minCheckBox, minValueField},
+ new Component[]{maxCheckBox, maxValueField},
+ new Component[]{isCustomMainUnitBox, mainUnitField},
+ new Component[]{isCustomSecUnitBox, secUnitField},
+ };
+ }
private void checkBoxUse() {
minValueField.setEnabled(minCheckBox.isSelected());
@@ -101,7 +112,7 @@ public class MinMaxValuePane extends JPanel {
if(axis.getMinValue() != null) {
minValueField.setText(axis.getMinValue().toString());
}
- }
+ }
// 最大值
if (axis.isCustomMaxValue()) {
@@ -109,7 +120,7 @@ public class MinMaxValuePane extends JPanel {
if(axis.getMaxValue() != null) {
maxValueField.setText(axis.getMaxValue().toString());
}
- }
+ }
// 主次刻度单位
if (axis.isCustomMainUnit()) {
@@ -117,7 +128,7 @@ public class MinMaxValuePane extends JPanel {
if(axis.getMainUnit() != null) {
mainUnitField.setText(axis.getMainUnit().toString());
}
- }
+ }
if(axis.isCustomSecUnit()) {
isCustomSecUnitBox.setSelected(true);
diff --git a/designer_chart/src/com/fr/design/chart/report/GisMapTableDataContentPane.java b/designer_chart/src/com/fr/design/chart/report/GisMapTableDataContentPane.java
index 4e0443c9f..5a2f3a4b9 100644
--- a/designer_chart/src/com/fr/design/chart/report/GisMapTableDataContentPane.java
+++ b/designer_chart/src/com/fr/design/chart/report/GisMapTableDataContentPane.java
@@ -245,7 +245,7 @@ public class GisMapTableDataContentPane extends FurtherBasicBeanPane{
while(names.hasNext()) {
Object name = names.next();
String layName = editingAttr.getLayerTo(Utils.objectToString(name));
- if(ArrayUtils.contains(ChartConstants.NONE_KEYS, layName)) {// kunsnat: 考虑切换设计器语言.
+ if(ArrayUtils.contains(ChartConstants.getNoneKeys(), layName)) {// kunsnat: 考虑切换设计器语言.
layName = StringUtils.EMPTY;
}
list.add(new Object[]{name, layName});
@@ -230,7 +230,7 @@ public class MapCubeLayerPane extends BasicBeanPane{
while(names.hasNext()) {
Object name = names.next();
String layName = editingAttr.getLayerTo(Utils.objectToString(name));
- if(ArrayUtils.contains(ChartConstants.NONE_KEYS, layName)) {// kunsnat: 考虑切换设计器语言.
+ if(ArrayUtils.contains(ChartConstants.getNoneKeys(), layName)) {// kunsnat: 考虑切换设计器语言.
layName = StringUtils.EMPTY;
}
list.add(new Object[]{name, layName});
diff --git a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java
index 94836c7a3..1a68ad5e5 100644
--- a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java
+++ b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java
@@ -45,7 +45,7 @@ public class ChartHyperPoplinkPane extends BasicBeanPane {
ChartCollection cc = createChartCollection();
chartComponent = new ChartComponent();
- chartComponent.setPreferredSize(new Dimension(220, 170));// 在单元格弹出时 需要调整保证属性表的大小.
+ chartComponent.setPreferredSize(new Dimension(200, 170));// 在单元格弹出时 需要调整保证属性表的大小.
chartComponent.setSupportEdit(false);
chartComponent.populate(cc);
diff --git a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/FormHyperlinkPane.java b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/FormHyperlinkPane.java
index 52607e72e..01754ce2a 100644
--- a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/FormHyperlinkPane.java
+++ b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/FormHyperlinkPane.java
@@ -95,6 +95,8 @@ public class FormHyperlinkPane extends BasicBeanPane {
parameterList.toArray(parameters);
formHyperlink.setParameters(parameters);
+ } else {
+ formHyperlink.setParameters(null);
}
}
diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
index 91b6bba3c..3710dcd52 100644
--- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
+++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
@@ -79,7 +79,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen
eastPane.setLayout(new BorderLayout());
- eastPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 15));
+ eastPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 5));
JPanel button = new JPanel();
button.setPreferredSize(new Dimension(45, 20));
button.setLayout(new GridLayout(1, 2, 5, 0));
@@ -425,6 +425,8 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen
private void deleteAButton() {
//先重构属性,在重构面板,否则面板在重构过程中,会重新将属性中的切换图表加到indexList中,导致面板无法删除
+ //记录改变前的plotID
+ String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChart().getPlot().getPlotID();
if (editingCollection != null) {
int count = editingCollection.getChartCount();
for (int i = 0; i < count; i++) {
@@ -447,6 +449,11 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen
checkoutChange();
relayoutPane();
+
+ //重构面板
+ if (parent != null ){
+ parent.reLayoutEditPane(lastPlotID, editingCollection);
+ }
}
private void relayoutPane() {
diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java
index a3a028ef8..0b5cfe6c9 100644
--- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java
+++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java
@@ -33,7 +33,7 @@ import java.util.List;
* @version 创建时间:2012-12-26 上午10:56:51
*/
public class ChartTypePane extends AbstractChartAttrPane{
- private ComboBoxPane chartTypePane;
+ private ComboBoxPane chartTypeComBox;
private ChartTypeButtonPane buttonPane;
private ChartEditPane editPane;
private ChartCollection editingCollection;
@@ -72,13 +72,13 @@ public class ChartTypePane extends AbstractChartAttrPane{
if (editingCollection != null) {
relayoutChartTypePane(editingCollection);
}else {
- chartTypePane = new ComboBoxPane();
+ chartTypeComBox = new ComboBoxPane();
}
BasicScrollPane scrollPane = new BasicScrollPane() {
@Override
protected JPanel createContentPane() {
- return chartTypePane;
+ return chartTypeComBox;
}
@Override
@@ -99,7 +99,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
};
content.add(scrollPane, BorderLayout.CENTER);
- buttonPane.setEditingChartPane(chartTypePane);
+ buttonPane.setEditingChartPane(chartTypeComBox);
return content;
}
@@ -206,6 +206,8 @@ public class ChartTypePane extends AbstractChartAttrPane{
}
//第一步就是重构cardNames
cardNames = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(chartID);
+ //下拉框重构开始。为了防止重构是触发update
+ ((FlexibleComboBox)jcb).setItemEvenType(ItemEventType.REACTOR);
//重构下拉框选项
reactorComboBox();
//重新选择选中的下拉项
@@ -213,6 +215,8 @@ public class ChartTypePane extends AbstractChartAttrPane{
String plotID = chart.getPlot().getPlotID();
Object item = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(chartID, plotID);
jcb.setSelectedItem(item);
+ //下拉框重构结束
+ ((FlexibleComboBox)jcb).setItemEvenType(ItemEventType.DEFAULT);
//重新选中
checkPlotPane();
}
@@ -223,13 +227,10 @@ public class ChartTypePane extends AbstractChartAttrPane{
}
private void reactorComboBox() {
- FlexibleComboBox fcb = (FlexibleComboBox)jcb;
- fcb.setItemEvenType(ItemEventType.REACTOR);
- fcb.removeAllItems();
+ jcb.removeAllItems();
for (int i = 0; i < this.cardNames.length; i++) {
- fcb.addItem(cardNames[i]);
+ jcb.addItem(cardNames[i]);
}
- fcb.setItemEvenType(ItemEventType.DEFAULT);
}
@Override
@@ -285,7 +286,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
public void relayoutChartTypePane(ChartCollection collection){
if (needRelayout(collection)) {
- chartTypePane.relayout(collection);
+ chartTypeComBox.relayout(collection);
//设置面板切换状态
updatePaneState(collection);
}
@@ -313,7 +314,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
initContentPane();
buttonPane.populateBean(collection);
- chartTypePane.populateBean(chart);
+ chartTypeComBox.populateBean(chart);
this.initAllListeners();
}
@@ -325,7 +326,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
editingCollection = collection;
buttonPane.update(collection);// 内部操作时 已经做过处理.
Chart chart = collection.getSelectedChart();
- chartTypePane.updateBean(chart);
+ chartTypeComBox.updateBean(chart);
}
/**
@@ -333,7 +334,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
* @return 类型界面
*/
public FurtherBasicBeanPane[] getPaneList(){
- return chartTypePane.getCards().toArray(new FurtherBasicBeanPane[0]);
+ return chartTypeComBox.getCards().toArray(new FurtherBasicBeanPane[0]);
}
/**
@@ -341,7 +342,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
* @return 当前选中的图表的index
*/
public int getSelectedIndex(){
- return chartTypePane.getSelectedIndex();
+ return chartTypeComBox.getSelectedIndex();
}
/**
@@ -349,7 +350,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
* @return 选中的图标的序号
*/
public int getSelectedChartIndex(){
- return chartTypePane.getSelectedIndex();
+ return chartTypeComBox.getSelectedIndex();
}
/**
diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/UIEditLabel.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/UIEditLabel.java
index ceca4f9dc..c7c3c51c7 100644
--- a/designer_chart/src/com/fr/design/mainframe/chart/gui/UIEditLabel.java
+++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/UIEditLabel.java
@@ -161,35 +161,47 @@ public class UIEditLabel extends JPanel implements UIObserver{
return text;
}
+ protected boolean appendOriginalLabel() {
+ return true;
+ }
+
private void stopEditing(){
isEditingStopped = true;
this.removeAll();
- String text =this.showLabel.getText();
- text = StringUtils.cutStringEndWith(text,":");
- text = !ComparatorUtils.equals(text, this.originalLabel) ?
- StringUtils.perfectEnd(text, "(" + this.originalLabel + ")"): this.originalLabel;
- showLabel.setText(StringUtils.perfectEnd(text,":"));
+ if(appendOriginalLabel()) {
+ String text = this.showLabel.getText();
+ text = StringUtils.cutStringEndWith(text, ":");
+ text = !ComparatorUtils.equals(text, this.originalLabel) ?
+ StringUtils.perfectEnd(text, "(" + this.originalLabel + ")") : this.originalLabel;
+ showLabel.setText(StringUtils.perfectEnd(text, ":"));
+ }
this.add(showLabel, BorderLayout.CENTER);
this.revalidate();
this.repaint();
}
public String getText(){
- String text =this.showLabel.getText();
- text = StringUtils.cutStringEndWith(text,":");
- return StringUtils.cutStringEndWith(text,"("+this.originalLabel+")");
+ if(appendOriginalLabel()) {
+ String text = this.showLabel.getText();
+ text = StringUtils.cutStringEndWith(text, ":");
+ return StringUtils.cutStringEndWith(text, "(" + this.originalLabel + ")");
+ } else {
+ return this.showLabel.getText();
+ }
}
public void setText(String text){
- if(text == null || StringUtils.isEmpty(text)){
- this.showLabel.setText(this.originalLabel);
- return;
- }
- if(!ComparatorUtils.equals(text,originalLabel)){
- text = StringUtils.cutStringEndWith(text, ":");
- text = StringUtils.perfectEnd(text,"("+originalLabel+")");
+ if(appendOriginalLabel()) {
+ if (text == null || StringUtils.isEmpty(text)) {
+ this.showLabel.setText(this.originalLabel);
+ return;
+ }
+ if (!ComparatorUtils.equals(text, originalLabel)) {
+ text = StringUtils.cutStringEndWith(text, ":");
+ text = StringUtils.perfectEnd(text, "(" + originalLabel + ")");
+ }
+ text = StringUtils.perfectEnd(text, ":");
}
- text = StringUtils.perfectEnd(text,":");
this.showLabel.setText(text);
}
diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/TableDataPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/TableDataPane.java
index a6bea6b0c..721e7432a 100644
--- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/TableDataPane.java
+++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/TableDataPane.java
@@ -25,6 +25,10 @@ public class TableDataPane extends FurtherBasicBeanPane{
private ChartDataPane parent;
+ protected AbstractTableDataContentPane getDataContentPane() {
+ return dataContentPane;
+ }
+
public TableDataPane(ChartDataPane parent) {
this.parent = parent;
initDataPane();
@@ -103,34 +107,41 @@ public class TableDataPane extends FurtherBasicBeanPane{
* @param collection 图表属性的集合
*/
public void refreshContentPane(ChartCollection collection) {
+ refreshContentPane(getContentPane(collection.getSelectedChart().getPlot()));
+ }
+
+ protected void refreshContentPane(AbstractTableDataContentPane contentPane) {
if(dataContentPane != null) {
remove(dataContentPane);
}
- dataContentPane = getContentPane(collection.getSelectedChart().getPlot());
+ dataContentPane = contentPane;
if(dataContentPane != null) {
add(dataContentPane, BorderLayout.CENTER);
}
}
-
/**
- * 更新界面属性
+ * 更新界面属性
*/
public void populateBean(ChartCollection collection) {
if(collection == null) {
return;
}
TableDataDefinition data = (TableDataDefinition)collection.getSelectedChart().getFilterDefinition();
+ populateDSName(data);
+ if(dataContentPane != null) {
+ dataContentPane.populateBean(collection);
+ }
+ }
+ protected void populateDSName(TableDataDefinition dataDefinition){
+
TableData tableData = null;
- if(data != null) {
- tableData = data.getTableData();
+ if(dataDefinition != null) {
+ tableData = dataDefinition.getTableData();
}
onSelectTableData();
checkBoxUse();
tableDataPane.populateBean(tableData);
- if(dataContentPane != null) {
- dataContentPane.populateBean(collection);
- }
}
/**
@@ -141,6 +152,10 @@ public class TableDataPane extends FurtherBasicBeanPane{
dataContentPane.updateBean(collection);
}
TopDefinition dataDefinition = (TopDefinition)collection.getSelectedChart().getFilterDefinition();
+ updateDSName(dataDefinition);
+ }
+
+ protected void updateDSName(TopDefinition dataDefinition) {
if(dataDefinition instanceof TableDataDefinition) {
TableDataWrapper tableDataWrapper = tableDataPane.getTableDataWrapper();
if (dataDefinition != null && tableDataWrapper != null){
diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/AbstractReportDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/AbstractReportDataContentPane.java
index 4ff643522..768ecb7e8 100644
--- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/AbstractReportDataContentPane.java
+++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/AbstractReportDataContentPane.java
@@ -3,6 +3,8 @@ package com.fr.design.mainframe.chart.gui.data.report;
import com.fr.base.Formula;
import com.fr.base.Utils;
import com.fr.chart.chartattr.ChartCollection;
+import com.fr.chart.chartdata.NormalReportDataDefinition;
+import com.fr.chart.chartdata.SeriesDefinition;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.UIObserverListener;
@@ -16,6 +18,7 @@ import com.fr.stable.StableUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import java.awt.*;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -95,6 +98,20 @@ public abstract class AbstractReportDataContentPane extends BasicBeanPane{
axisLineStylePane = new ChartAxisLineStylePane();
zeroPane = aliagnZero4Second();
- axisReversed = new UICheckBox(Inter.getLocText("AxisReversed"));
+ axisReversed = new UICheckBox(Inter.getLocText("FR-Designer_AxisReversed"));
unitCombox = new UIComboBox(ChartConstants.UNIT_I18N_VALUES);
formatPane = new FormatPane();
axisLabelPane = new ChartAxisLabelPane();
@@ -151,7 +151,7 @@ public class ChartValuePane extends ChartAxisUsePane{
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = { LayoutConstants.CHART_ATTR_TOMARGIN,p,f};
- double[] rowSize = { p, p,};
+ double[] rowSize = { p, p};
Component[][] component = new Component[][]{
new Component[]{null,initMinMaxValue(),null},
new Component[]{null, addLogarithmicPane2ValuePane(), addLogText()},
@@ -171,12 +171,12 @@ public class ChartValuePane extends ChartAxisUsePane{
// 返回对数相关界面. 百分比 没有此界面.
protected JPanel addLogarithmicPane2ValuePane() {
JPanel labelLogPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
- labelLogPane.add(logBox = new UICheckBox(Inter.getLocText("Logarithmic")+":"));
- labelLogPane.add(new UILabel(Inter.getLocText("Chart_Log_Base")));
-
+ labelLogPane.add(logBox = new UICheckBox(Inter.getLocText("FR-Designer_Logarithmic")+":"));
+ labelLogPane.add(new UILabel(Inter.getLocText("FR-Designer_Chart_Log_Base")));
+
logBaseField = new UITextField(4);
logBaseField.setText("10");
- logBaseField.setPreferredSize(new Dimension(20, 20));
+ logBaseField.setPreferredSize(new Dimension(55, 20));
logBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -185,7 +185,7 @@ public class ChartValuePane extends ChartAxisUsePane{
});
ChartSwingUtils.addListener(logBox, logBaseField);
-
+
return labelLogPane;
}
@@ -221,7 +221,7 @@ public class ChartValuePane extends ChartAxisUsePane{
* @return 返回标题.
*/
public String title4PopupWindow() {
- return Inter.getLocText("Chart_F_Radar_Axis");
+ return Inter.getLocText("FR-Designer_Chart_F_Radar_Axis");
}
@Override
diff --git a/designer_form/build.dev.gradle b/designer_form/build.dev.gradle
index 20dc49a33..4b71fed5f 100644
--- a/designer_form/build.dev.gradle
+++ b/designer_form/build.dev.gradle
@@ -1,10 +1,27 @@
-apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
+buildscript {
+ repositories {
+ maven {
+ url "http://www.eveoh.nl/files/maven2"
+ }
+ }
+
+ dependencies {
+ classpath "nl.eveoh:gradle-aspectj:1.2"
+ }
+}
+
+ext.aspectjVersion = '1.7.4'
+apply plugin: 'aspectj'
+
+repositories {
+ mavenCentral()
+}
//指定构建的jdk版本
-sourceCompatibility=1.8
+sourceCompatibility=1.7
//指定生成的jar包版本
version='8.0'
diff --git a/designer_form/build.dev.gradle.bak b/designer_form/build.dev.gradle.bak
index 2b727caac..ae16b033e 100644
--- a/designer_form/build.dev.gradle.bak
+++ b/designer_form/build.dev.gradle.bak
@@ -4,7 +4,7 @@ tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
//指定构建的jdk版本
-sourceCompatibility=1.8
+sourceCompatibility=1.7
//指定生成的jar包版本
version='8.0'
@@ -20,7 +20,7 @@ sourceSets{
main{
java{
srcDirs=["${srcDir}/src",
-"${srcDir}/../designer/src"]
+ "${srcDir}/../designer/src"]
}
}
}
diff --git a/designer_form/build.master.gradle b/designer_form/build.master.gradle
index 324f408bf..45d1d86f1 100644
--- a/designer_form/build.master.gradle
+++ b/designer_form/build.master.gradle
@@ -1,8 +1,27 @@
-apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
+
+buildscript {
+ repositories {
+ maven {
+ url "http://www.eveoh.nl/files/maven2"
+ }
+ }
+
+ dependencies {
+ classpath "nl.eveoh:gradle-aspectj:1.2"
+ }
+}
+
+ext.aspectjVersion = '1.7.4'
+apply plugin: 'aspectj'
+
+repositories {
+ mavenCentral()
+}
+
//指定构建的jdk版本
sourceCompatibility=1.7
//指定生成的jar包版本
diff --git a/designer_form/build.master.gradle.bak b/designer_form/build.master.gradle.bak
index b6fdde506..348ba4875 100644
--- a/designer_form/build.master.gradle.bak
+++ b/designer_form/build.master.gradle.bak
@@ -3,6 +3,26 @@ apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
+
+buildscript {
+ repositories {
+ maven {
+ url "http://www.eveoh.nl/files/maven2"
+ }
+ }
+
+ dependencies {
+ classpath "nl.eveoh:gradle-aspectj:1.2"
+ }
+}
+
+ext.aspectjVersion = '1.7.4'
+apply plugin: 'aspectj'
+
+repositories {
+ mavenCentral()
+}
+
//指定构建的jdk版本
sourceCompatibility=1.7
//指定生成的jar包版本
@@ -47,7 +67,7 @@ def dataContent ={def dir ->
}
}
}
-FileTree f1=fileTree(dir:'../../../'include:"finereport-*-stable/${branchName}/build/libs/*.jar")
+FileTree f1=fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/build/libs/*.jar")
f1.each{File file->
println "----------${file.path}"
}
diff --git a/designer_form/build.release.gradle b/designer_form/build.release.gradle
index 90abcb81e..793f6a0b1 100644
--- a/designer_form/build.release.gradle
+++ b/designer_form/build.release.gradle
@@ -1,10 +1,27 @@
-apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
+buildscript {
+ repositories {
+ maven {
+ url "http://www.eveoh.nl/files/maven2"
+ }
+ }
+
+ dependencies {
+ classpath "nl.eveoh:gradle-aspectj:1.2"
+ }
+}
+
+ext.aspectjVersion = '1.7.4'
+apply plugin: 'aspectj'
+
+repositories {
+ mavenCentral()
+}
//指定构建的jdk版本
-sourceCompatibility=1.8
+sourceCompatibility=1.7
//指定生成的jar包版本
version='8.0'
diff --git a/designer_form/src/com/fr/aspectj/designerform/TemplateProcessTracker.aj b/designer_form/src/com/fr/aspectj/designerform/TemplateProcessTracker.aj
new file mode 100644
index 000000000..0aabeb362
--- /dev/null
+++ b/designer_form/src/com/fr/aspectj/designerform/TemplateProcessTracker.aj
@@ -0,0 +1,59 @@
+package com.fr.aspectj.designerform;
+
+/**
+ * Created by plough on 2017/3/3.
+ */
+import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
+import org.aspectj.lang.reflect.SourceLocation;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.util.Date;
+
+public aspect TemplateProcessTracker {
+ //声明一个pointcut,匹配你需要的方法
+ pointcut onMouseClicked(MouseEvent e) :
+ execution(* mouseClicked(MouseEvent)) && args(e);
+ pointcut onMousePressed(MouseEvent e) :
+ execution(* mousePressed(MouseEvent)) && args(e);
+ pointcut onMouseReleased(MouseEvent e) :
+ execution(* mouseReleased(MouseEvent)) && args(e);
+ pointcut onActionPerformed(ActionEvent e) :
+ execution(* actionPerformed(ActionEvent)) && args(e);
+ pointcut onSetValueAt(Object v, int r, int c) :
+ execution(* setValueAt(java.lang.Object, int, int)) && args(v, r, c);
+
+ //before表示之前的意思
+ //这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码
+ before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) {
+ SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置
+
+ //String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource());
+ String log = "";
+ TemplateInfoCollector.appendProcess(log);
+ }
+ //同上
+ before(ActionEvent e) : onActionPerformed(e) {
+ SourceLocation sl = thisJoinPoint.getSourceLocation();
+ // !within(LogHandlerBar) 没用, 手动过滤
+ if (e.getSource().toString().contains("javax.swing.Timer")) {
+ return;
+ }
+
+ //String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource());
+ String log = "";
+ TemplateInfoCollector.appendProcess(log);
+
+ }
+ //同上
+ before(Object v, int r, int c) : onSetValueAt(v, r, c) {
+ SourceLocation sl = thisJoinPoint.getSourceLocation();
+
+ //String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c);
+ String log = "";
+ TemplateInfoCollector.appendProcess(log);
+
+ }
+
+
+}
diff --git a/designer_form/src/com/fr/design/designer/beans/ConnectorCreator.java b/designer_form/src/com/fr/design/designer/beans/ConnectorCreator.java
index 2bfc0bf3f..ca9934416 100644
--- a/designer_form/src/com/fr/design/designer/beans/ConnectorCreator.java
+++ b/designer_form/src/com/fr/design/designer/beans/ConnectorCreator.java
@@ -8,13 +8,12 @@ import java.util.PriorityQueue;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
-
public class ConnectorCreator {
public static final int UNIT = 10;
public static final int SIDE = 2;
public static final int CORNER_LOSS = 20;
- public static final int vector[][] = { { UNIT, 0 }, { -UNIT, 0 }, { 0, UNIT }, { 0, -UNIT } };
+ public static final int VECTOR[][] = { { UNIT, 0 }, { -UNIT, 0 }, { 0, UNIT }, { 0, -UNIT } };
private long timeOut = 200;
private boolean beyond;
@@ -179,8 +178,8 @@ public class ConnectorCreator {
}
void pushInto() {
- for (int i = 0; i < vector.length; i++) {
- Point temp = new Point(p.x + vector[i][0], p.y + vector[i][1]);
+ for (int i = 0; i < VECTOR.length; i++) {
+ Point temp = new Point(p.x + VECTOR[i][0], p.y + VECTOR[i][1]);
if (parent != null && parent.x == temp.x && parent.y == temp.y) {
continue;
}
@@ -192,8 +191,8 @@ public class ConnectorCreator {
}
boolean reCheck() {
- for (int i = 0; i < vector.length; i++) {
- Point temp = new Point(p.x + SIDE * vector[i][0], p.y + SIDE * vector[i][1]);
+ for (int i = 0; i < VECTOR.length; i++) {
+ Point temp = new Point(p.x + SIDE * VECTOR[i][0], p.y + SIDE * VECTOR[i][1]);
AssessedPoint ap = new AssessedPoint(temp, this, loss(temp));
if (check(temp)) {
open.add(ap);
diff --git a/designer_form/src/com/fr/design/designer/beans/LayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/LayoutAdapter.java
index fffc1c587..c087d78fe 100644
--- a/designer_form/src/com/fr/design/designer/beans/LayoutAdapter.java
+++ b/designer_form/src/com/fr/design/designer/beans/LayoutAdapter.java
@@ -1,85 +1,94 @@
-package com.fr.design.designer.beans;
-
-import com.fr.design.beans.GroupModel;
-import com.fr.design.designer.creator.XCreator;
-
-/**
- * 该接口是LayoutManager的BeanInfo类。标准Java平台没有提供布局管理器的BeanInfo类,
- * 对于界面设计工具来说还需一些特殊的行为。
- * @since 6.5.3
- */
-public interface LayoutAdapter {
-
- /**
- * 在添加组件状态时,当鼠标移动到某个容器上方时,如果该容器有布局管理器,则会调用该布局
- * 管理适配器的accept来决定当前位置是否可以放置,并提供特殊的标识,比如红色区域标识。比
- * 如在BorderLayout中,如果某个方位已经放置了组件,则此时应该返回false标识该区域不可以
- * 放置。
- *@param creator 组件
- *@param x 添加的位置x,该位置是相对于container的
- *@param y 添加的位置y,该位置是相对于container的
- *@return 是否可以放置
- */
- boolean accept(XCreator creator, int x, int y);
-
- /**
- * 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适,如果不合适,就需要重新fix一下
- * @param creator 组件
- */
- void fix(XCreator creator);
-
- /**
- * 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的
- * addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。
- * @param creator 被添加的新组件
- * @param x 添加的位置x,该位置是相对于container的
- * @param y 添加的位置y,该位置是相对于container的
- * @return 是否添加成功,成功返回true,否则false
- */
- boolean addBean(XCreator creator, int x, int y);
-
- /**
- * 返回该布局管理适配器的Painter,为容器提供放置位置的标识。
- */
- HoverPainter getPainter();
-
- /**
- * 显示parent的字组件child,解决CardLayout中显示某个非显示组件的特殊情况
- * @param child 组件
- */
- void showComponent(XCreator child);
-
- void addNextComponent(XCreator dragged);
-
- /**
- * 组件叠放顺序前插入
- * @param target 目标组件
- * @param added 插入组件
- */
- void addBefore(XCreator target, XCreator added);
-
- /**
- * 组件叠放顺序后插入
- * @param target 目标组件
- * @param added 放置组件
- */
- void addAfter(XCreator target, XCreator added);
-
- /**
- * 能否放置更多组件
- * @return 能则返回true
- */
- boolean canAcceptMoreComponent();
-
- ConstraintsGroupModel getLayoutConstraints(XCreator creator);
-
- GroupModel getLayoutProperties();
-
- /**
- * 删除组件
- * @param creator 组件
- * @param initWidth 组件之前宽度
- * @param initHeight 组件之前高度
- */
- void removeBean(XCreator creator, int initWidth, int initHeight);
+package com.fr.design.designer.beans;
+
+import com.fr.design.beans.GroupModel;
+import com.fr.design.designer.creator.XCreator;
+
+/**
+ * 该接口是LayoutManager的BeanInfo类。标准Java平台没有提供布局管理器的BeanInfo类,
+ * 对于界面设计工具来说还需一些特殊的行为。
+ *
+ * @since 6.5.3
+ */
+public interface LayoutAdapter {
+
+ /**
+ * 在添加组件状态时,当鼠标移动到某个容器上方时,如果该容器有布局管理器,则会调用该布局
+ * 管理适配器的accept来决定当前位置是否可以放置,并提供特殊的标识,比如红色区域标识。比
+ * 如在BorderLayout中,如果某个方位已经放置了组件,则此时应该返回false标识该区域不可以
+ * 放置。
+ *
+ * @param creator 组件
+ * @param x 添加的位置x,该位置是相对于container的
+ * @param y 添加的位置y,该位置是相对于container的
+ * @return 是否可以放置
+ */
+ boolean accept(XCreator creator, int x, int y);
+
+ /**
+ * 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适,如果不合适,就需要重新fix一下
+ *
+ * @param creator 组件
+ */
+ void fix(XCreator creator);
+
+ /**
+ * 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的
+ * addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。
+ *
+ * @param creator 被添加的新组件
+ * @param x 添加的位置x,该位置是相对于container的
+ * @param y 添加的位置y,该位置是相对于container的
+ * @return 是否添加成功,成功返回true,否则false
+ */
+ boolean addBean(XCreator creator, int x, int y);
+
+ /**
+ * 返回该布局管理适配器的Painter,为容器提供放置位置的标识。
+ */
+ HoverPainter getPainter();
+
+ /**
+ * 显示parent的字组件child,解决CardLayout中显示某个非显示组件的特殊情况
+ *
+ * @param child 组件
+ */
+ void showComponent(XCreator child);
+
+ void addNextComponent(XCreator dragged);
+
+ /**
+ * 组件叠放顺序前插入
+ *
+ * @param target 目标组件
+ * @param added 插入组件
+ */
+ void addBefore(XCreator target, XCreator added);
+
+ /**
+ * 组件叠放顺序后插入
+ *
+ * @param target 目标组件
+ * @param added 放置组件
+ */
+ void addAfter(XCreator target, XCreator added);
+
+ /**
+ * 能否放置更多组件
+ *
+ * @return 能则返回true
+ */
+ boolean canAcceptMoreComponent();
+
+ ConstraintsGroupModel getLayoutConstraints(XCreator creator);
+
+ GroupModel getLayoutProperties();
+
+ /**
+ * 删除组件
+ *
+ * @param creator 组件
+ * @param initWidth 组件之前宽度
+ * @param initHeight 组件之前高度
+ */
+ void removeBean(XCreator creator, int initWidth, int initHeight);
}
\ No newline at end of file
diff --git a/designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java b/designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java
index e32ece18e..23686f651 100644
--- a/designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java
+++ b/designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java
@@ -1,31 +1,30 @@
-package com.fr.design.designer.beans.actions;
-
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-
-import javax.swing.KeyStroke;
-
-import com.fr.base.BaseUtils;
-import com.fr.general.Inter;
-import com.fr.design.mainframe.FormDesigner;
-
-public class CopyAction extends FormEditAction {
-
- public CopyAction(FormDesigner t) {
- super(t);
- this.setName(Inter.getLocText("M_Edit-Copy"));
- this.setMnemonic('C');
- this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png"));
- this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));
- }
-
- @Override
- public boolean executeActionReturnUndoRecordNeeded() {
- FormDesigner tc = getEditingComponent();
- if (tc != null) {
- tc.copy();
- }
- return false;
- }
-
+package com.fr.design.designer.beans.actions;
+
+import com.fr.base.BaseUtils;
+import com.fr.design.mainframe.FormDesigner;
+import com.fr.general.Inter;
+
+import javax.swing.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+public class CopyAction extends FormEditAction {
+
+ public CopyAction(FormDesigner t) {
+ super(t);
+ this.setName(Inter.getLocText("M_Edit-Copy"));
+ this.setMnemonic('C');
+ this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png"));
+ this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));
+ }
+
+ @Override
+ public boolean executeActionReturnUndoRecordNeeded() {
+ FormDesigner tc = getEditingComponent();
+ if (tc != null) {
+ tc.copy();
+ }
+ return false;
+ }
+
}
\ No newline at end of file
diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java
index d5232d26a..493dd02aa 100644
--- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java
+++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java
@@ -1,174 +1,189 @@
-package com.fr.design.designer.beans.adapters.layout;
-
-import java.awt.LayoutManager;
-
-import com.fr.general.ComparatorUtils;
-import com.fr.design.beans.GroupModel;
-import com.fr.design.designer.beans.ConstraintsGroupModel;
-import com.fr.design.designer.beans.HoverPainter;
-import com.fr.design.designer.beans.LayoutAdapter;
-import com.fr.design.designer.beans.painters.NullPainter;
-import com.fr.design.designer.creator.XCreator;
-import com.fr.design.designer.creator.XLayoutContainer;
-import com.fr.design.designer.creator.XWidgetCreator;
-import com.fr.design.utils.ComponentUtils;
-import com.fr.design.utils.gui.LayoutUtils;
-
-public abstract class AbstractLayoutAdapter implements LayoutAdapter {
-
- protected XLayoutContainer container;
- protected LayoutManager layout;
-
- public AbstractLayoutAdapter(XLayoutContainer container) {
- this.container = container;
- this.layout = container.getLayout();
- }
-
- /**
- * 是否使用控件备份大小
- * @param xCreator 控件
- * @return 所在容器相同,且支持备份的话返回true
- */
- public boolean whetherUseBackupSize(XCreator xCreator) {
- Class clazz = container.getClass();
- Class bkClazz = null;
- if(xCreator.getBackupParent() != null) {
- bkClazz = xCreator.getBackupParent().getClass();
- }
- return ComparatorUtils.equals(bkClazz, clazz)
- && supportBackupSize();
- }
-
- /**
- * 是否支持用备份大小
- * @return 否
- */
- public boolean supportBackupSize() {
- return false;
- }
-
- /**
- * 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适,如果不合适,就需要重新fix一下
- * @param creator 组件
- */
- public void fix(XCreator creator) {
- }
-
- /**
- * 显示parent的字组件child,解决CardLayout中显示某个非显示组件的特殊情况
- * @param child 组件
- */
- @Override
- public void showComponent(XCreator child) {
- child.setVisible(true);
- }
-
- /**
- * 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的
- * addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。
- * @param creator 被添加的新组件
- * @param x 添加的位置x,该位置是相对于container的
- * @param y 添加的位置y,该位置是相对于container的
- * @return 是否添加成功,成功返回true,否则false
- */
- @Override
- public boolean addBean(XCreator creator, int x, int y) {
- if (!accept(creator, x, y)) {
- return false;
- }
- addComp(creator, x, y);
- ((XWidgetCreator) creator).recalculateChildrenSize();
- return true;
- }
-
- /**
- * 删除组件
- * @param creator 组件
- * @param initWidth 组件之前宽度
- * @param initHeight 组件之前高度
- */
- public void removeBean(XCreator creator, int creatorWidth, int creatorHeight) {
- delete(creator, creatorWidth, creatorHeight);
- }
-
- protected void delete(XCreator creator, int creatorWidth, int creatorHeight) {
- }
-
- protected abstract void addComp(XCreator creator, int x, int y);
-
- /**
- * 增加下一个组件
- * @param dragged 组件
- */
- @Override
- public void addNextComponent(XCreator dragged) {
- container.add(dragged);
- LayoutUtils.layoutRootContainer(container);
- }
-
- /**
- * 目标控件位置插入组件
- * @param target 目标
- * @param added 增加组件
- */
- @Override
- public void addBefore(XCreator target, XCreator added) {
- int index = ComponentUtils.indexOfComponent(container, target);
-
- if (index == -1) {
- container.add(added, 0);
- } else {
- container.add(added, index);
- }
-
- LayoutUtils.layoutRootContainer(container);
- }
-
- /**
- * 插在目标组件后面
- * @param target 目标
- * @param added 增加组件
- */
- @Override
- public void addAfter(XCreator target, XCreator added) {
- int index = ComponentUtils.indexOfComponent(container, target);
-
- if (index == -1) {
- container.add(added);
- } else {
- index++;
-
- if (index >= container.getComponentCount()) {
- container.add(added);
- } else {
- container.add(added, index);
- }
- }
-
- LayoutUtils.layoutRootContainer(container);
- }
-
- @Override
- public HoverPainter getPainter() {
- return new NullPainter(container);
- }
-
- /**
- * 是否能接收更多的组件
- * @return 能则返回true
- */
- @Override
- public boolean canAcceptMoreComponent() {
- return true;
- }
-
- @Override
- public ConstraintsGroupModel getLayoutConstraints(XCreator creator) {
- return null;
- }
-
- @Override
- public GroupModel getLayoutProperties() {
- return null;
- }
+package com.fr.design.designer.beans.adapters.layout;
+
+import com.fr.design.beans.GroupModel;
+import com.fr.design.designer.beans.ConstraintsGroupModel;
+import com.fr.design.designer.beans.HoverPainter;
+import com.fr.design.designer.beans.LayoutAdapter;
+import com.fr.design.designer.beans.painters.NullPainter;
+import com.fr.design.designer.creator.XCreator;
+import com.fr.design.designer.creator.XLayoutContainer;
+import com.fr.design.designer.creator.XWidgetCreator;
+import com.fr.design.utils.ComponentUtils;
+import com.fr.design.utils.gui.LayoutUtils;
+import com.fr.general.ComparatorUtils;
+
+import java.awt.*;
+
+public abstract class AbstractLayoutAdapter implements LayoutAdapter {
+
+ protected XLayoutContainer container;
+ protected LayoutManager layout;
+
+ public AbstractLayoutAdapter(XLayoutContainer container) {
+ this.container = container;
+ this.layout = container.getLayout();
+ }
+
+ /**
+ * 是否使用控件备份大小
+ *
+ * @param xCreator 控件
+ * @return 所在容器相同,且支持备份的话返回true
+ */
+ public boolean whetherUseBackupSize(XCreator xCreator) {
+ Class clazz = container.getClass();
+ Class bkClazz = null;
+ if (xCreator.getBackupParent() != null) {
+ bkClazz = xCreator.getBackupParent().getClass();
+ }
+ return ComparatorUtils.equals(bkClazz, clazz)
+ && supportBackupSize();
+ }
+
+ /**
+ * 是否支持用备份大小
+ *
+ * @return 否
+ */
+ public boolean supportBackupSize() {
+ return false;
+ }
+
+ /**
+ * 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适,如果不合适,就需要重新fix一下
+ *
+ * @param creator 组件
+ */
+ public void fix(XCreator creator) {
+ }
+
+ /**
+ * 显示parent的字组件child,解决CardLayout中显示某个非显示组件的特殊情况
+ *
+ * @param child 组件
+ */
+ @Override
+ public void showComponent(XCreator child) {
+ child.setVisible(true);
+ }
+
+ /**
+ * 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的
+ * addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。
+ *
+ * @param creator 被添加的新组件
+ * @param x 添加的位置x,该位置是相对于container的
+ * @param y 添加的位置y,该位置是相对于container的
+ * @return 是否添加成功,成功返回true,否则false
+ */
+ @Override
+ public boolean addBean(XCreator creator, int x, int y) {
+ if (!accept(creator, x, y)) {
+ return false;
+ }
+ addComp(creator, x, y);
+ ((XWidgetCreator) creator).recalculateChildrenSize();
+ return true;
+ }
+
+ /**
+ * 删除组件
+ *
+ * @param creator 组件
+ * @param creatorWidth
+ * @param creatorHeight
+ */
+ public void removeBean(XCreator creator, int creatorWidth, int creatorHeight) {
+ delete(creator, creatorWidth, creatorHeight);
+ }
+
+ protected void delete(XCreator creator, int creatorWidth, int creatorHeight) {
+ }
+
+ protected abstract void addComp(XCreator creator, int x, int y);
+
+ /**
+ * 增加下一个组件
+ *
+ * @param dragged 组件
+ */
+ @Override
+ public void addNextComponent(XCreator dragged) {
+ container.add(dragged);
+ LayoutUtils.layoutRootContainer(container);
+ }
+
+ /**
+ * 目标控件位置插入组件
+ *
+ * @param target 目标
+ * @param added 增加组件
+ */
+ @Override
+ public void addBefore(XCreator target, XCreator added) {
+ int index = ComponentUtils.indexOfComponent(container, target);
+
+ if (index == -1) {
+ container.add(added, 0);
+ } else {
+ container.add(added, index);
+ }
+
+ LayoutUtils.layoutRootContainer(container);
+ }
+
+ /**
+ * 插在目标组件后面
+ *
+ * @param target 目标
+ * @param added 增加组件
+ */
+ @Override
+ public void addAfter(XCreator target, XCreator added) {
+ int index = ComponentUtils.indexOfComponent(container, target);
+
+ if (index == -1) {
+ container.add(added);
+ } else {
+ index++;
+
+ if (index >= container.getComponentCount()) {
+ container.add(added);
+ } else {
+ container.add(added, index);
+ }
+ }
+
+ LayoutUtils.layoutRootContainer(container);
+ }
+
+ @Override
+ public HoverPainter getPainter() {
+ return new NullPainter(container);
+ }
+
+ /**
+ * 是否能接收更多的组件
+ *
+ * @return 能则返回true
+ */
+ @Override
+ public boolean canAcceptMoreComponent() {
+ return true;
+ }
+
+ @Override
+ public ConstraintsGroupModel getLayoutConstraints(XCreator creator) {
+ return null;
+ }
+
+ @Override
+ public GroupModel getLayoutProperties() {
+ return null;
+ }
+
+
+ public XLayoutContainer getContainer() {
+ return this.container;
+ }
}
\ No newline at end of file
diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
index 3d53eab01..539e60450 100644
--- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
+++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
@@ -1,7 +1,5 @@
package com.fr.design.designer.beans.adapters.layout;
-import java.awt.*;
-
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter;
@@ -9,13 +7,14 @@ import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.properties.BoundsGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
-import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
-import com.fr.form.ui.container.WBodyLayoutType;
+import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
+import java.awt.*;
+
public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
//是不是添加到父容器上
private boolean isAdd2ParentLayout = false;
@@ -74,48 +73,39 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout();
if(topLayout != null){
if (topLayout.isEditable()){
- return topLayoutAccept(creator, x, y, topLayout);
+ return topLayoutAccept(creator, x, y);
}
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) {
return false;
+ } else {
+ return acceptWidget(x, y);
}
- else {
- return acceptWidget(creator, x, y);
- }
- }
- else{
+ } else {
FRLogger.getLogger().error("top layout is null!");
}
return false;
}
- //toplayout假如可以编辑的话就往里面添加组件
- private boolean topLayoutAccept(XCreator creator, int x, int y, XLayoutContainer topLayout) {
- //判断有没有和当前控件重叠
- //先计算当前控件的位置
- int creatorX, creatorY;
- if (XCreatorUtils.getParentXLayoutContainer(creator) != null) {
-
+ //topLayout假如可以编辑的话就往里面添加组件
+ private boolean topLayoutAccept(XCreator creator, int x, int y) {
+ //允许组件重叠,可以不判断有没有和当前控件重叠
+ //先计算当前控件的位置
+ int creatorX, creatorY;
+ if (XCreatorUtils.getParentXLayoutContainer(creator) != null) {
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator);
creatorX = creatorRectangle.x;
creatorY = creatorRectangle.y;
} else {
+ //这边计算得到的组件其实位置是正确的,
+ //因为传入的x和y已经加上了宽度或者高度的一半,再减去相同的宽度和高度的一半是没区别的,
+ // 例如高度为21,那么就是+10-10;
+ // 高度为20,那么就是+10-10; 没区别
int w = creator.getWidth() / 2;
int h = creator.getHeight() / 2;
creatorX = x - w;
creatorY = y - h;
- }
- //再判断和布局中其他控件重叠
- Rectangle curRec = new Rectangle(creatorX, creatorY, creator.getWidth(), creator.getHeight());
- WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout)topLayout.toData();
- for (int i = 0, count = wAbsoluteLayout.getWidgetCount(); i < count; i++) {
- WAbsoluteLayout.BoundsWidget temp = (WAbsoluteLayout.BoundsWidget) wAbsoluteLayout.getWidget(i);
- Rectangle rectangle = temp.getBounds();
- if (curRec.intersects(rectangle)){
- return false;
- }
}
if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) {
return false;
@@ -168,16 +158,15 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
return !ComparatorUtils.equals(trisectAreaDirect, 0);
}
- //当前绝对布局不可编辑,就当成一个控件,组件添加在周围
- private boolean acceptWidget(XCreator creator, int x, int y){
- isFindRelatedComps = false;
- //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
- Component comp = container.getComponentAt(x, y);
- boolean isMatchEdge = false;
- //如果当前处于边缘地带, 那么就把他贴到父容器上
- XLayoutContainer parent = container.findNearestFit();
- container = parent != null ? parent : container;
- isAdd2ParentLayout = true;
+ //当前绝对布局不可编辑,就当成一个控件,组件添加在周围
+ private boolean acceptWidget(int x, int y) {
+ isFindRelatedComps = false;
+ //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
+ Component comp = container.getComponentAt(x, y);
+ //如果当前处于边缘地带, 那么就把他贴到父容器上
+ XLayoutContainer parent = container.findNearestFit();
+ container = parent != null ? parent : container;
+ isAdd2ParentLayout = true;
int componentHeight = comp.getHeight();
int componentWidth = comp.getWidth();
@@ -244,7 +233,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
if (creator.hasTitleStyle()) {
addParentCreator(creator);
} else {
- container.add(creator, creator.toData().getWidgetName());
+ container.add(creator, creator.toData().getWidgetName(),0);
}
XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
layout.updateBoundsWidget(creator);
@@ -255,7 +244,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) {
addParentCreator(creator);
} else {
- container.add(creator, creator.toData().getWidgetName());
+ container.add(creator, creator.toData().getWidgetName(),0);
}
XWFitLayout layout = (XWFitLayout) container;
// 更新对应的BoundsWidget
@@ -274,7 +263,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
private void addParentCreator(XCreator child) {
XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight());
- container.add(parentPanel, child.toData().getWidgetName());
+ container.add(parentPanel, child.toData().getWidgetName(),0);
}
/**
@@ -325,17 +314,15 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
int height = creator.getHeight();
int width = creator.getWidth();
if (x < 0) {
- width += x;
- x = 0;
+ x = container.getX();
} else if (x + creator.getWidth() > container.getWidth()) {
- width = container.getWidth() - x;
+ x = container.getWidth() - width;
}
if (y < 0) {
- height += y;
- y = 0;
+ y = container.getY();
} else if (y + creator.getHeight() > container.getHeight()) {
- height = container.getHeight() - y;
+ y = container.getHeight() - height;
}
creator.setBounds(x, y, width, height);
diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java
index 313c08b02..75190ba3b 100644
--- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java
+++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java
@@ -2,9 +2,11 @@ package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
+import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.PaddingMargin;
+import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.ComparatorUtils;
@@ -17,7 +19,7 @@ import java.util.*;
* 所以把公共的方法挪动这边父类里来
* Created by zhouping on 2016/8/18.
*/
-public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
+public class FRBodyLayoutAdapter extends AbstractLayoutAdapter {
protected static final int COMP_TOP = 1;
protected static final int COMP_BOTTOM = 2;
protected static final int COMP_LEFT = 3;
@@ -34,7 +36,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
protected static final int BORDER_PROPORTION = 10; //边界三等分或交叉区域大小取组件1/10和默认大小
protected int trisectAreaDirect = 0;
- protected int crossPointAreaDirect = 0;
+ private int crossPointAreaDirect = 0;
// 增加删除拉伸控件用的临时list
protected java.util.List rightComps;
protected java.util.List leftComps;
@@ -49,6 +51,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
protected int minHeight = 0;
protected int actualVal = 0; // 存在间隔时,add move drag 判断对齐等都要考虑
protected PaddingMargin margin; // 布局容器边距
+
/**
* 在添加组件状态时,当鼠标移动到某个容器上方时,如果该容器有布局管理器,则会调用该布局
* 管理适配器的accept来决定当前位置是否可以放置,并提供特殊的标识,比如红色区域标识。比
@@ -76,9 +79,10 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
/**
* 交叉点区域时,能否对应位置放入组件
+ *
* @param comp 待放置组件
- * @param x x
- * @param y y
+ * @param x x
+ * @param y y
* @return 能否放入
*/
protected boolean canAcceptWhileCrossPoint(Component comp, int x, int y) {
@@ -95,7 +99,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
min = isNotDefaultArea ? min : minWidth * 2;
} else if (ComparatorUtils.equals(crossPointAreaDirect, COMP_RIGHT_BOTTOM)) {
bottomComp = container.getRightBottomComp(cX, cY, cH, cW);
- isNotDefaultArea = (bottomComp == null) || (bottomComp.getX()+bottomComp.getWidth() != cX + cW) ;
+ isNotDefaultArea = (bottomComp == null) || (bottomComp.getX() + bottomComp.getWidth() != cX + cW);
rightComp = container.getBottomRightComp(cX, cY, cH, cW);
minLength = isNotDefaultArea ? Math.min(cH, rightComp.getHeight()) : Math.min(cW, bottomComp.getWidth());
min = isNotDefaultArea ? min : minWidth * 2;
@@ -105,12 +109,12 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
minLength = isNotDefaultArea ? Math.min(cW, bottomComp.getWidth()) : Math.min(cH, leftComp.getHeight());
min = isNotDefaultArea ? minWidth * 2 : min;
} else if (ComparatorUtils.equals(crossPointAreaDirect, COMP_RIGHT_TOP)) {
- isNotDefaultArea = (rightComp == null) || (rightComp.getY() != cY) ;
+ isNotDefaultArea = (rightComp == null) || (rightComp.getY() != cY);
topComp = container.getRightTopComp(cX, cY, cW);
minLength = isNotDefaultArea ? Math.min(cW, topComp.getWidth()) : Math.min(cH, rightComp.getWidth());
- min = isNotDefaultArea ? minWidth * 2 : min ;
+ min = isNotDefaultArea ? minWidth * 2 : min;
} else if (ComparatorUtils.equals(crossPointAreaDirect, COMP_TOP)) {
- minLength= Math.min(rightComp.getHeight(), Math.min(cH, leftComp.getHeight()));
+ minLength = Math.min(rightComp.getHeight(), Math.min(cH, leftComp.getHeight()));
} else if (ComparatorUtils.equals(crossPointAreaDirect, COMP_BOTTOM)) {
leftComp = container.getBottomLeftComp(cX, cY, cH);
rightComp = container.getBottomRightComp(cX, cY, cH, cW);
@@ -129,9 +133,10 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
/**
* 三等分区域时,能否对应位置放入组件
+ *
* @param comp 待放置组件
- * @param x x
- * @param y y
+ * @param x x
+ * @param y y
* @return 能否放入
*/
protected boolean canAcceptWhileTrisection(Component comp, int x, int y) {
@@ -142,28 +147,28 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
upMinHeight = getUpMinHeightComp(cY, x);
downMinHeight = getDownMinHeightComp(comp, y);
return upMinHeight == 0 ? downMinHeight >= minHeight * 2 + actualVal : (upMinHeight + downMinHeight) >= minHeight * 3 + actualVal;
- } else if(ComparatorUtils.equals(trisectAreaDirect, COMP_BOTTOM)) {
+ } else if (ComparatorUtils.equals(trisectAreaDirect, COMP_BOTTOM)) {
upMinHeight = getUpMinHeightComp(cY + cH + actualVal, x);
- if (cY + cH + DEFAULT_AREA_LENGTH>container.getHeight() - margin.getBottom()){
+ if (cY + cH + DEFAULT_AREA_LENGTH > container.getHeight() - margin.getBottom()) {
downMinHeight = 0;
} else {
Component targetComp = container.getBottomComp(x, cY, cH);
downMinHeight = getDownMinHeightComp(targetComp, cY + cH + DEFAULT_AREA_LENGTH + actualVal);
}
- return downMinHeight == 0 ? (upMinHeight >= minHeight * 2 + actualVal) : ((upMinHeight+downMinHeight) >= minHeight * 3 + actualVal);
- } else if(ComparatorUtils.equals(trisectAreaDirect, COMP_LEFT)) {
- rightMinWidth = getMinRightWidth(cX, 0, y);
- if(cX - DEFAULT_AREA_LENGTH < margin.getLeft()) {
+ return downMinHeight == 0 ? (upMinHeight >= minHeight * 2 + actualVal) : ((upMinHeight + downMinHeight) >= minHeight * 3 + actualVal);
+ } else if (ComparatorUtils.equals(trisectAreaDirect, COMP_LEFT)) {
+ rightMinWidth = getMinRightWidth(cX, 0, y);
+ if (cX - DEFAULT_AREA_LENGTH < margin.getLeft()) {
leftMinWidth = 0;
} else {
Component targetRightComp = container.getLeftComp(cX, y);
leftMinWidth = getMinLeftWidth(targetRightComp, cX - DEFAULT_AREA_LENGTH - actualVal);
}
- return leftMinWidth == 0 ? (rightMinWidth >= minWidth * 2 + actualVal) : ((leftMinWidth+rightMinWidth) >= minWidth * 3 + actualVal);
- } else if(ComparatorUtils.equals(trisectAreaDirect, COMP_RIGHT)) {
+ return leftMinWidth == 0 ? (rightMinWidth >= minWidth * 2 + actualVal) : ((leftMinWidth + rightMinWidth) >= minWidth * 3 + actualVal);
+ } else if (ComparatorUtils.equals(trisectAreaDirect, COMP_RIGHT)) {
leftMinWidth = getMinLeftWidth(comp, x);
rightMinWidth = getMinRightWidth(cX, cW, y);
- return rightMinWidth == 0 ? (leftMinWidth >= minWidth * 2 + actualVal) : ((leftMinWidth+rightMinWidth) >= minWidth * 3 + actualVal);
+ return rightMinWidth == 0 ? (leftMinWidth >= minWidth * 2 + actualVal) : ((leftMinWidth + rightMinWidth) >= minWidth * 3 + actualVal);
}
return false;
}
@@ -176,16 +181,16 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
if (cY == margin.getTop()) {
return 0;
}
- int max=container.getWidth() - margin.getRight();
+ int max = container.getWidth() - margin.getRight();
int mouseX = x;
int minHeight = cY;
int bott = 0;
if (isFindRelatedComps) {
upComps = new ArrayList();
}
- for(; mouseX margin.getLeft()) {
+ while (mouseX > margin.getLeft()) {
Component comp = container.getTopComp(mouseX, cY);
- bott = comp.getHeight() + comp.getY()+actualVal;
+ bott = comp.getHeight() + comp.getY() + actualVal;
if (bott == cY) {
if (comp.getHeight() < minHeight) {
minHeight = comp.getHeight();
}
- mouseX = comp.getX()-DEFAULT_AREA_LENGTH-actualVal;
+ mouseX = comp.getX() - DEFAULT_AREA_LENGTH - actualVal;
if (isFindRelatedComps) {
upComps.add(comp);
}
- } else{
+ } else {
break;
}
}
@@ -231,13 +236,13 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
int cX = currentcomp.getX();
int cY = currentcomp.getY();
int minHeight = currentcomp.getHeight();
- int max=container.getWidth() - margin.getRight();
+ int max = container.getWidth() - margin.getRight();
if (isFindRelatedComps) {
downComps = new ArrayList();
}
int mouseX = cX + DEFAULT_AREA_LENGTH;
while (mouseX < max) {
- Component comp = container.getComponentAt(mouseX, y);
+ Component comp = container.getComponentAt(mouseX, y);
if (comp.getY() == cY) {
if (comp.getHeight() < minHeight) {
minHeight = comp.getHeight();
@@ -246,12 +251,12 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
if (isFindRelatedComps) {
downComps.add(comp);
}
- }else{
+ } else {
break;
}
}
mouseX = cX - DEFAULT_AREA_LENGTH - actualVal;
- while(mouseX > margin.getLeft()) {
+ while (mouseX > margin.getLeft()) {
Component comp = container.getComponentAt(mouseX, y);
if (comp.getY() == cY) {
if (comp.getHeight() < minHeight) {
@@ -261,7 +266,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
if (isFindRelatedComps) {
downComps.add(comp);
}
- }else{
+ } else {
break;
}
}
@@ -273,9 +278,9 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
* 判断对齐时考虑间隔
*/
private int getMinRightWidth(int cX, int cW, int y) {
- int xL = cX + DEFAULT_AREA_LENGTH ;
+ int xL = cX + DEFAULT_AREA_LENGTH;
xL = cW == 0 ? xL : (xL + cW + actualVal);
- if (xL > container.getWidth() - margin.getRight()){
+ if (xL > container.getWidth() - margin.getRight()) {
return 0;
}
// 以当前组件紧挨着右侧的组件为基准,在y轴方向查找符合条件的组件
@@ -286,7 +291,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
rightComps = new ArrayList();
}
int mouseY = targetComp.getY() + DEFAULT_AREA_LENGTH;
- while (mouseY margin.getTop()) {
+ while (mouseY > margin.getTop()) {
Component comp = container.getComponentAt(xL, mouseY);
if (comp.getX() == targetComp.getX()) {
if (comp.getWidth() < minWidth) {
@@ -311,7 +316,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
if (isFindRelatedComps) {
rightComps.add(comp);
}
- }else{
+ } else {
break;
}
}
@@ -329,9 +334,9 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
if (isFindRelatedComps) {
leftComps = new ArrayList();
}
- int rightx = 0;
+ int rightx = 0;
int mouseY = currentComp.getY() + DEFAULT_AREA_LENGTH;
- while(mouseYmargin.getTop()) {
+ while (mouseY > margin.getTop()) {
Component comp = container.getComponentAt(x, mouseY);
- rightx = comp.getX()+comp.getWidth();
+ rightx = comp.getX() + comp.getWidth();
if (rightx == compRightLength) {
if (comp.getWidth() < minWidth) {
minWidth = comp.getWidth();
@@ -358,7 +363,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
if (isFindRelatedComps) {
leftComps.add(comp);
}
- }else{
+ } else {
break;
}
}
@@ -367,13 +372,14 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
/**
* 判断是否鼠标在组件的三等分区域,如果组件在布局管理器中间,上下左右都可能会三等分
+ *
* @param parentComp 鼠标所在区域的组件
- * @param x 坐标x
- * @param y 坐标y
+ * @param x 坐标x
+ * @param y 坐标y
* @return 是则返回true
*/
public boolean isTrisectionArea(Component parentComp, int x, int y) {
- XCreator creator = (XCreator)parentComp;
+ XCreator creator = (XCreator) parentComp;
if (container.getComponentCount() <= 1) {
return false;
}
@@ -382,23 +388,23 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
int xL = parentComp.getX();
int yL = parentComp.getY();
// 组件宽高的十分之一和默认值取大
- int minRangeWidth = Math.max(maxWidth/BORDER_PROPORTION, DEFAULT_AREA_LENGTH);
- int minRangeHeight = Math.max(maxHeight/BORDER_PROPORTION, DEFAULT_AREA_LENGTH);
- if(y < yL+minRangeHeight ) {
+ int minRangeWidth = Math.max(maxWidth / BORDER_PROPORTION, DEFAULT_AREA_LENGTH);
+ int minRangeHeight = Math.max(maxHeight / BORDER_PROPORTION, DEFAULT_AREA_LENGTH);
+ if (y < yL + minRangeHeight) {
// 在组件上侧三等分
trisectAreaDirect = COMP_TOP;
- } else if(y > yL + maxHeight - minRangeHeight) {
+ } else if (y > yL + maxHeight - minRangeHeight) {
// 在组件下侧三等分
trisectAreaDirect = COMP_BOTTOM;
} else if (x < xL + minRangeWidth) {
// 在组件左侧三等分
trisectAreaDirect = COMP_LEFT;
- } else if(x > xL + maxWidth - minRangeWidth) {
+ } else if (x > xL + maxWidth - minRangeWidth) {
// 在组件右侧三等分
trisectAreaDirect = COMP_RIGHT;
}
// tab布局的边界特殊处理,不进行三等分
- if(!creator.getTargetChildrenList().isEmpty()){
+ if (!creator.getTargetChildrenList().isEmpty()) {
return false;
}
@@ -407,21 +413,22 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
/**
* 是否为组件交叉点区域 或者是相邻三组建中间点
+ *
* @param currentComp 当前组件
- * @param x 坐标x
- * @param y 坐标y
+ * @param x 坐标x
+ * @param y 坐标y
* @return 是则返回true
*/
public boolean isCrossPointArea(Component currentComp, int x, int y) {
// 3个及以上都会出现交叉点区域(包括边界处的)
- if(currentComp == null || container.getComponentCount() <= 2){
+ if (currentComp == null || container.getComponentCount() <= 2) {
return false;
}
int cX = currentComp.getX();
int cY = currentComp.getY();
int cW = currentComp.getWidth();
int cH = currentComp.getHeight();
- int areaWidth = Math.max(cW / BORDER_PROPORTION ,DEFAULT_AREA_LENGTH);
+ int areaWidth = Math.max(cW / BORDER_PROPORTION, DEFAULT_AREA_LENGTH);
int areaHeight = Math.max(cH / BORDER_PROPORTION, DEFAULT_AREA_LENGTH);
int rx = cX + cW;
int by = cY + cH;
@@ -432,27 +439,27 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
if (x < objX && y < objY) {
//左上角区域
crossPointAreaDirect = cY > margin.getTop() || cX > margin.getLeft() ? COMP_LEFT_TOP : 0;
- } else if (y < objY && x > rx - areaWidth){
+ } else if (y < objY && x > rx - areaWidth) {
//右上角
crossPointAreaDirect = cY > margin.getTop() || rx < containerW ? COMP_RIGHT_TOP : 0;
} else if (x < objX && y > by - areaHeight) {
//左下角
crossPointAreaDirect = cX > margin.getLeft() || by < containerH ? COMP_LEFT_BOTTOM : 0;
- } else if (x > rx-areaWidth && y > by - areaHeight) {
+ } else if (x > rx - areaWidth && y > by - areaHeight) {
//右下角
crossPointAreaDirect = by < containerH || rx < containerW ? COMP_RIGHT_BOTTOM : 0;
} else {
isMiddlePosition(currentComp, x, y, areaWidth, areaHeight);
}
// tab布局的边界特殊处理
- XCreator creator = (XCreator)currentComp;
- if(!creator.getTargetChildrenList().isEmpty()){
+ XCreator creator = (XCreator) currentComp;
+ if (!creator.getTargetChildrenList().isEmpty()) {
return false;
}
return crossPointAreaDirect != 0;
}
- private void isMiddlePosition(Component comp, int x, int y, int areaWidth , int areaHeight) {
+ private void isMiddlePosition(Component comp, int x, int y, int areaWidth, int areaHeight) {
int cX = comp.getX();
int cY = comp.getY();
int cW = comp.getWidth();
@@ -479,14 +486,14 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
Component bottomComp = container.getBottomComp(cX, cY, cH);
if (x < (cX + areaWidth)) {
isCrosspoint = topComp != null && bottomComp != null && topComp.getX() == cX && bottomComp.getX() == cX;
- crossPointAreaDirect = isCrosspoint ? COMP_LEFT : 0;
+ crossPointAreaDirect = isCrosspoint ? COMP_LEFT : 0;
} else if (x > (cX + cW - areaWidth)) {
topComp = container.getRightTopComp(cX, cY, cW);
bottomComp = container.getRightBottomComp(cX, cY, cH, cW);
if (topComp != null && bottomComp != null) {
- isCrosspoint = topComp.getX() + topComp.getWidth() == cX + cW && bottomComp.getX() + bottomComp.getWidth() == cX+cW;
+ isCrosspoint = topComp.getX() + topComp.getWidth() == cX + cW && bottomComp.getX() + bottomComp.getWidth() == cX + cW;
}
- crossPointAreaDirect = isCrosspoint ? COMP_RIGHT : 0;
+ crossPointAreaDirect = isCrosspoint ? COMP_RIGHT : 0;
}
}
}
@@ -513,15 +520,16 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
/**
* 平分,正常情况拖入组件时,按照上1/4区域、下1/4区域为上下平分,中左侧1/2区域、中右侧1/2区域为左右平分
+ *
* @param currentComp 当前位置组件
- * @param child 待放置组件
- * @param x x
- * @param y y
+ * @param child 待放置组件
+ * @param x x
+ * @param y y
*/
protected void fixHalve(Component currentComp, XCreator child, int x, int y) {
- XCreator creator = (XCreator)currentComp;
- if(!creator.getTargetChildrenList().isEmpty()){
- fixHalveOfTab(creator,child,x,y);
+ XCreator creator = (XCreator) currentComp;
+ if (!creator.getTargetChildrenList().isEmpty()) {
+ fixHalveOfTab(creator, child, x, y);
return;
}
int maxWidth = currentComp.getWidth();
@@ -536,18 +544,18 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
int finalY = yL;
int finalW = maxWidth;
int finalH = maxHeight;
- if (isDividUp){
+ if (isDividUp) {
dim.width = maxWidth;
dim.height = maxHeight / 2 - actualVal / 2;
finalY = yL + dim.height + actualVal;
finalH = maxHeight - dim.height - actualVal;
- } else if(isDividDown){
+ } else if (isDividDown) {
// 若当前区域高度非偶数,那么和isDividUp时计算一致,否则永远都是上半部分小1px
dim.height = maxHeight / 2 - actualVal / 2;
dim.width = maxWidth;
finalH = maxHeight - dim.height - actualVal;
yL = yL + finalH + actualVal;
- } else if(isDividLeft){
+ } else if (isDividLeft) {
dim.width = maxWidth / 2 - actualVal / 2;
dim.height = maxHeight;
finalX = xL + dim.width + actualVal;
@@ -571,7 +579,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
// 边界判断抄得原来的逻辑
// tab布局的边界拖入新组件,和当前tab布局平分,这时候的actualVal组建间隔是tab里面的组建间隔
// 不应该在外层自适应布局添加
- private void fixHalveOfTab(XCreator currentCreator, XCreator child, int x, int y){
+ private void fixHalveOfTab(XCreator currentCreator, XCreator child, int x, int y) {
int maxWidth = currentCreator.getWidth();
int maxHeight = currentCreator.getHeight();
int xL = currentCreator.getX();
@@ -582,7 +590,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
int finalY = yL;
int finalW = maxWidth;
int finalH = maxHeight;
- switch(position){
+ switch (position) {
case COMP_TOP:
dim.width = maxWidth;
dim.height = maxHeight / 2;
@@ -592,7 +600,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
case COMP_BOTTOM:
dim.height = maxHeight / 2;
dim.width = maxWidth;
- finalH = maxHeight-dim.height;
+ finalH = maxHeight - dim.height;
yL = yL + finalH;
break;
case COMP_LEFT:
@@ -619,13 +627,22 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
}
}
- private int getPositionOfFix(XCreator currentCreator,int x,int y){
+ private int getPositionOfFix(XCreator currentCreator, int x, int y) {
int position = 0;
XLayoutContainer cardLayout = ((XWCardMainBorderLayout) currentCreator).getCardPart();
XLayoutContainer container = (XLayoutContainer) cardLayout.getComponent(0);
Rectangle rect = ComponentUtils.getRelativeBounds(container);
+ /*
+ * 为了获取到鼠标drop位置的控件,
+ * 我们之前已经将y值变为相对坐标值;
+ * 由于在x轴上没有偏移,所以x值一直等于相对坐标值,最多差一个边界值1。
+ * 在进行新添加的控件位置计算时,
+ * 又通过ComponentUtils.getRelativeBounds()方法获取到了绝对坐标,
+ * 再次计算相对坐标,所以将y值重新变成绝对坐标。
+ * */
+ y = y + WCardMainBorderLayout.TAB_HEIGHT + this.getParaEditorYOffset();
int tempX = x - rect.x;
- int tempY = y - rect.y + WCardMainBorderLayout.TAB_HEIGHT;
+ int tempY = y - rect.y;
int containerX = container.getX();
int containerY = container.getY();
int containerWidth = container.getWidth();
@@ -634,13 +651,13 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
Rectangle currentXY = new Rectangle(tempX, tempY, 1, 1);
// 上边缘
Rectangle upEdge = new Rectangle(containerX, containerY, containerWidth, BORDER_PROPORTION);
- if(upEdge.intersects(currentXY)){
+ if (upEdge.intersects(currentXY)) {
position = COMP_TOP;
}
int bottomY = containerY + containerHeight - BORDER_PROPORTION;
// 下边缘
Rectangle bottomEdge = new Rectangle(containerX, bottomY, containerWidth, BORDER_PROPORTION);
- if(bottomEdge.intersects(currentXY)){
+ if (bottomEdge.intersects(currentXY)) {
position = COMP_BOTTOM;
}
//左右边缘的高度 -10*2 是为了不和上下边缘重合
@@ -648,47 +665,68 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
int leftY = containerY + BORDER_PROPORTION;
// 左边缘
Rectangle leftEdge = new Rectangle(containerX, leftY, BORDER_PROPORTION, verticalHeight);
- if(leftEdge.intersects(currentXY)){
+ if (leftEdge.intersects(currentXY)) {
position = COMP_LEFT;
}
return position;
}
+ /**
+ * 获取因为参数面板导致的Y坐标偏移
+ *
+ * @return 参数面板导致的Y坐标偏移
+ */
+ protected int getParaEditorYOffset() {
+ int offset = 0;
+ if (container.getParent() != null) {
+ Component components[] = container.getParent().getComponents();
+ for (Component component : components) {
+ if (component instanceof XWParameterLayout) {
+ offset = component.getY() + component.getHeight();
+ break;
+ }
+ }
+ }
+ return offset;
+ }
+
+
/**
* 组件交叉区域进行插入时,调整受到变动的其他组件,之前是交叉区域插入也按照三等分逻辑,后面测试中发现有bug,改为和bi一样的鼠标所在侧平分
* 默认左上角、右下角区域是垂直方向插入组件
* 右上角和左下角是水平方向插入组件,这样避免田字块时重复
+ *
* @param currentComp 当前位置组件
- * @param child 待放置组件
- * @param x x
- * @param y y
+ * @param child 待放置组件
+ * @param x x
+ * @param y y
*/
protected void fixCrossPointArea(Component currentComp, XCreator child, int x, int y) {
//计算前先全部初始化待调整控件所在的list
initCompsList();
- switch(crossPointAreaDirect) {
- case COMP_LEFT_TOP :
+ switch (crossPointAreaDirect) {
+ case COMP_LEFT_TOP:
dealCrossPointAtLeftTop(currentComp, child);
break;
- case COMP_RIGHT_BOTTOM :
+ case COMP_RIGHT_BOTTOM:
dealCrossPointAtRightBottom(currentComp, child);
break;
- case COMP_LEFT_BOTTOM :
+ case COMP_LEFT_BOTTOM:
dealCrossPointAtLeftBottom(currentComp, child);
break;
- case COMP_RIGHT_TOP :
+ case COMP_RIGHT_TOP:
dealCrossPointAtRightTop(currentComp, child);
break;
- case COMP_TOP :
+ case COMP_TOP:
dealCrossPointAtTop(currentComp, child);
break;
- case COMP_BOTTOM :
+ case COMP_BOTTOM:
dealCrossPointAtBottom(currentComp, child);
break;
- case COMP_LEFT :
+ case COMP_LEFT:
dealCrossPointAtLeft(currentComp, child);
break;
- case COMP_RIGHT :
+ case COMP_RIGHT:
dealCrossPointAtRight(currentComp, child);
break;
}
@@ -708,16 +746,16 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
Component topComp = container.getTopComp(cX, cY);
Component leftComp = container.getLeftComp(cX, cY);
//上方没有组件或者有一个x坐标不相同的组件
- if (topComp==null || topComp.getX()!=cX) {
+ if (topComp == null || topComp.getX() != cX) {
minDH = cH < leftComp.getHeight() ? cH : leftComp.getHeight();
downComps.add(leftComp);
downComps.add(currentComp);
int dLength = minDH / 2;
- childw = leftComp.getWidth()+cW+actualVal;
- childh = dLength-actualVal / 2;
+ childw = leftComp.getWidth() + cW + actualVal;
+ childh = dLength - actualVal / 2;
if (isCalculateChildPos) {
childPosition = new int[]{leftComp.getX(), leftComp.getY(), childw, childh};
- } else{
+ } else {
//先设置child位置,不然leftComp坐标调整后就不对了
child.setLocation(leftComp.getX(), leftComp.getY());
child.setSize(childw, childh);
@@ -726,7 +764,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
} else {
rightComps.add(currentComp);
rightComps.add(topComp);
- minRW = cW= minDH) {
minDH -= actualVal / 2;
if ((minDH * 2 / 3) < minHeight) {
dLength = minDH - minHeight;
- }else {
+ } else {
dLength = minDH / 3;
}
uLength = averageH - dLength;
- } else{
+ } else {
minUH -= actualVal / 2;
if ((minUH * 2 / 3) < minHeight) {
uLength = minUH - minHeight;
- }else {
+ } else {
uLength = minUH / 3;
}
dLength = averageH - uLength;
@@ -999,16 +1038,16 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
child.setLocation(margin.getLeft(), margin.getRight());
child.setSize(rightLength - actualVal / 2, height);
} else {
- childPosition = new int[] {margin.getLeft(), margin.getRight(), rightLength - actualVal / 2, height};
+ childPosition = new int[]{margin.getLeft(), margin.getRight(), rightLength - actualVal / 2, height};
}
return;
- } else if(minRW == 0){
+ } else if (minRW == 0) {
leftLength = minLW / 2;
calculateLeftComps(leftLength, child, leftLength);
return;
} else if (minRW >= minLW) {
minLW -= actualVal / 2;
- if(minLW * 2 / 3 < minWidth) {
+ if (minLW * 2 / 3 < minWidth) {
leftLength = minLW - minWidth;
} else {
leftLength = minLW / 3;
@@ -1016,7 +1055,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
rightLength = averageW - leftLength;
} else {
minRW -= actualVal / 2;
- if(minRW * 2 / 3 < minWidth) {
+ if (minRW * 2 / 3 < minWidth) {
rightLength = minRW - minWidth;
} else {
rightLength = minRW / 3;
@@ -1033,12 +1072,12 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
private void calculateBottomComps(int length) {
length += actualVal / 2;
- for (int i = 0,num = downComps.size(); i < num; i++){
+ for (int i = 0, num = downComps.size(); i < num; i++) {
Component comp = downComps.get(i);
comp.setLocation(comp.getX(), comp.getY() + length);
int offset = comp.getHeight() - length;
comp.setSize(comp.getWidth(), offset);
- XCreator creator = (XCreator)comp;
+ XCreator creator = (XCreator) comp;
creator.recalculateChildHeight(offset);
}
}
@@ -1048,24 +1087,24 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
int childWidth = (upComps.size() - 1) * actualVal;
int childX = container.getWidth() - margin.getLeft() - margin.getRight();
int childY = 0;
- if(upComps.size() > INDEX_ZERO){
+ if (upComps.size() > INDEX_ZERO) {
childY = upComps.get(INDEX_ZERO).getY() + upComps.get(INDEX_ZERO).getHeight() - length;
}
- for (int i = 0,num = upComps.size(); i < num; i++){
+ for (int i = 0, num = upComps.size(); i < num; i++) {
Component comp = upComps.get(i);
childWidth += comp.getWidth();
- if (comp.getX() < childX){
+ if (comp.getX() < childX) {
childX = comp.getX();
}
if (!isCalculateChildPos) {
int offset = comp.getHeight() - length;
comp.setSize(comp.getWidth(), offset);
- XCreator creator = (XCreator)comp;
+ XCreator creator = (XCreator) comp;
creator.recalculateChildHeight(offset);
}
}
childY += actualVal;
- averageH -= actualVal/2;
+ averageH -= actualVal / 2;
if (isCalculateChildPos) {
childPosition = new int[]{childX, childY, childWidth, averageH};
} else {
@@ -1081,25 +1120,25 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
}
int childH = (leftComps.size() - 1) * actualVal;
int childX = 0;
- if(leftComps.size() > INDEX_ZERO){
+ if (leftComps.size() > INDEX_ZERO) {
childX = leftComps.get(INDEX_ZERO).getX() + leftComps.get(INDEX_ZERO).getWidth() - length;
}
int childY = container.getHeight() - margin.getBottom();
- for (int i = 0,num = leftComps.size(); i < num; i++){
+ for (int i = 0, num = leftComps.size(); i < num; i++) {
Component comp = leftComps.get(i);
childH += comp.getHeight();
- if (comp.getY() < childY){
+ if (comp.getY() < childY) {
childY = comp.getY();
}
if (!isCalculateChildPos) {
int offset = comp.getWidth() - length;
comp.setSize(offset, comp.getHeight());
- XCreator creator = (XCreator)comp;
+ XCreator creator = (XCreator) comp;
creator.recalculateChildWidth(offset);
}
}
childX += actualVal;
- averageW -= actualVal/2;
+ averageW -= actualVal / 2;
if (isCalculateChildPos) {
childPosition = new int[]{childX, childY, averageW, childH};
} else {
@@ -1110,33 +1149,34 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter{
private void calculateRightComps(int length) {
length += actualVal / 2;
- for (int i=0,num=rightComps.size(); i coordinates[i] - DEPENDING_SCOPE && coordinate + diff < coordinates[i] + DEPENDING_SCOPE) {
diff = coordinates[i] - coordinate;
@@ -554,8 +544,8 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
difference = Math.max(difference, minWidth - getMinWidth(leftComps));
}
//重新计算左右两侧组件size、point
- if (CalculateLefttRelatComponent(difference)) {
- CalculateRightRelatComponent(objx + difference, -difference);
+ if (calculateLefttRelatComponent(difference)) {
+ calculateRightRelatComponent(objx + difference, -difference);
}
}
@@ -670,10 +660,9 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
difference = Math.max(difference, minHeight - getMinHeight(upComps));
}
//重新计算上下两侧组件size、point
- if (CalculateUpRelatComponent(difference)) {
- CalculateDownRelatComponent(objY + difference, -difference);
+ if (calculateUpRelatComponent(difference)) {
+ calculateDownRelatComponent(objY + difference, -difference);
}
- ;
}
/**
@@ -753,13 +742,13 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
int height = creatorHeight;
calculateRelatedComponent(x, y, width, height);
if (!rightComps.isEmpty() && getAllHeight(rightComps) == height) {
- CalculateRightRelatComponent(x, width + actualVal);
+ calculateRightRelatComponent(x, width + actualVal);
} else if (!leftComps.isEmpty() && getAllHeight(leftComps) == height) {
- CalculateLefttRelatComponent(width + actualVal);
+ calculateLefttRelatComponent(width + actualVal);
} else if (!downComps.isEmpty() && getAllWidth(downComps) == width) {
- CalculateDownRelatComponent(y, height + actualVal);
+ calculateDownRelatComponent(y, height + actualVal);
} else if (!upComps.isEmpty() && getAllWidth(upComps) == width) {
- CalculateUpRelatComponent(height + actualVal);
+ calculateUpRelatComponent(height + actualVal);
} else {
// 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理
calculateNoRelatedComponent(x, y, width, height);
@@ -1022,7 +1011,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
setAdjustedSize(tabLayout, offset, isHor);
for (int m = 0; m < tabLayout.getComponentCount(); m++) {
XCreator childCreator = tabLayout.getXCreator(m);
- BoundsWidget wgt = tabLayout.toData().getBoundsWidget(childCreator.toData());
+ WAbsoluteLayout.BoundsWidget wgt = (WAbsoluteLayout.BoundsWidget) tabLayout.toData().getBoundsWidget(childCreator.toData());
wgt.setBounds(tabLayout.getComponent(m).getBounds());
}
adjustCreatorsSize(percent, tabLayout, isHor);
@@ -1065,7 +1054,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
* @param objX 调整后的坐标x
* @param objWidth 调整后的宽度
*/
- protected void CalculateRightRelatComponent(int objX, int objWidth) {
+ protected void calculateRightRelatComponent(int objX, int objWidth) {
int count = rightComps.size();
for (int i = 0; i < count; i++) {
XCreator creator = (XCreator) rightComps.get(i);
@@ -1105,7 +1094,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 删除或拉伸控件左边框时 调整左侧的组件位置大小;
*/
- protected boolean CalculateLefttRelatComponent(int objWidth) {
+ protected boolean calculateLefttRelatComponent(int objWidth) {
if (isBeyondAdjustWidthScope(objWidth)) {
return false;
}
@@ -1123,7 +1112,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 删除或拉伸下边框 调整下方的组件位置大小
*/
- protected void CalculateDownRelatComponent(int objY, int objHeight) {
+ protected void calculateDownRelatComponent(int objY, int objHeight) {
int count = downComps.size();
for (int i = 0; i < count; i++) {
XCreator creator = (XCreator) downComps.get(i);
@@ -1163,7 +1152,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 删除或拉伸上边框 调整上方的组件位置大小
*/
- protected boolean CalculateUpRelatComponent(int objHeight) {
+ protected boolean calculateUpRelatComponent(int objHeight) {
if (isBeyondAdjustHeightScope(objHeight)) {
return false;
}
diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java
index 8c67a44ab..b1ca803c6 100644
--- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java
+++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java
@@ -1,94 +1,105 @@
-/**
- *
- */
-package com.fr.design.designer.beans.adapters.layout;
-
-
-import java.awt.Rectangle;
-
-import com.fr.design.beans.GroupModel;
-import com.fr.design.designer.creator.XCreator;
-import com.fr.design.designer.creator.XLayoutContainer;
-import com.fr.design.designer.creator.XWidgetCreator;
-import com.fr.design.designer.creator.cardlayout.XWCardLayout;
-import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
-import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel;
-import com.fr.design.utils.ComponentUtils;
-import com.fr.form.ui.LayoutBorderStyle;
-import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
-import com.fr.general.ComparatorUtils;
-
-/**
- * tab布局tabFit适配器
- *
- * @author focus
- * @date 2014-6-24
- */
-public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter {
- //标题栏高度对tab布局内部组件的y坐标造成了偏移
- private static int TAB_HEIGHT = 40;
-
- /**
- * 构造函数
- * @param container XWTabFitLayout容器
- */
- public FRTabFitLayoutAdapter(XLayoutContainer container) {
- super(container);
- }
-
- /**
- * 返回布局自身属性,方便一些特有设置在layout刷新时处理
- */
- @Override
- public GroupModel getLayoutProperties() {
- XWTabFitLayout xfl = (XWTabFitLayout) container;
- return new FRTabFitLayoutPropertiesGroupModel(xfl);
- }
-
- /**
- * 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的
- * addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。
- * @param creator 被添加的新组件
- * @param x 添加的位置x,该位置是相对于container的
- * @param y 添加的位置y,该位置是相对于container的
- * @return 是否添加成功,成功返回true,否则false
- */
- @Override
- public boolean addBean(XCreator creator, int x, int y) {
- // 经过accept判断后,container会被改变,先备份
- XLayoutContainer backUpContainer = container;
- Rectangle rect = ComponentUtils.getRelativeBounds(container);
-
- int posX = x - rect.x;
- int posY = y - rect.y;
- if (!accept(creator, posX, posY)) {
- return false;
- }
- // posX,posY是新拖入组件相对于容器的位置,若在tab布局的边缘,则需要把新组件添加到
- // 父层自适应布局中,这时候的添加位置就是tab布局所在的位置
- if(this.intersectsEdge(posX, posY, backUpContainer)){
- if(!ComparatorUtils.equals(backUpContainer.getOuterLayout(), backUpContainer.getBackupParent())){
- XWTabFitLayout tabLayout = (XWTabFitLayout)backUpContainer;
- y = adjustY(y,tabLayout);
- }
- addComp(creator, x, y);
- ((XWidgetCreator) creator).recalculateChildrenSize();
- return true;
- }
- // 如果不在边缘,容器为本自适应布局,增加组件的位置就是相对于容器的位置
- addComp(creator, posX, posY);
- ((XWidgetCreator) creator).recalculateChildrenSize();
- return true;
- }
-
- // tab布局的纵坐标受到tab高度的影响,判断的上边界取得是里面XWTabFitLayout的上边界,
- // 实际计算的时候的纵坐标用了外层的CardMainBorerLayout,需要将tab高度减掉
- private int adjustY(int y,XWTabFitLayout tabLayout){
- XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent();
- LayoutBorderStyle style = cardLayout.toData().getBorderStyle();
- if(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)){
- y -= WCardMainBorderLayout.TAB_HEIGHT;
- }
- return y;
- }
+/**
+ *
+ */
+package com.fr.design.designer.beans.adapters.layout;
+
+
+import com.fr.design.beans.GroupModel;
+import com.fr.design.designer.creator.XCreator;
+import com.fr.design.designer.creator.XLayoutContainer;
+import com.fr.design.designer.creator.XWParameterLayout;
+import com.fr.design.designer.creator.XWidgetCreator;
+import com.fr.design.designer.creator.cardlayout.XWCardLayout;
+import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
+import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
+import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel;
+import com.fr.design.mainframe.widget.editors.ParameterEditor;
+import com.fr.design.utils.ComponentUtils;
+import com.fr.form.ui.LayoutBorderStyle;
+import com.fr.form.ui.container.WBorderLayout;
+import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
+import com.fr.general.ComparatorUtils;
+
+import java.awt.*;
+
+/**
+ * tab布局tabFit适配器
+ *
+ * @author focus
+ * @date 2014-6-24
+ */
+public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter {
+
+ /**
+ * 构造函数
+ *
+ * @param container XWTabFitLayout容器
+ */
+ public FRTabFitLayoutAdapter(XLayoutContainer container) {
+ super(container);
+ }
+
+ /**
+ * 返回布局自身属性,方便一些特有设置在layout刷新时处理
+ */
+ @Override
+ public GroupModel getLayoutProperties() {
+ XWTabFitLayout xfl = (XWTabFitLayout) container;
+ return new FRTabFitLayoutPropertiesGroupModel(xfl);
+ }
+
+ /**
+ * 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的
+ * addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。
+ *
+ * @param creator 被添加的新组件
+ * @param x 添加的位置x,该位置是相对于container的
+ * @param y 添加的位置y,该位置是相对于container的
+ * @return 是否添加成功,成功返回true,否则false
+ */
+ @Override
+ public boolean addBean(XCreator creator, int x, int y) {
+ // 经过accept判断后,container会被改变,先备份
+ XLayoutContainer backUpContainer = container;
+ Rectangle rect = ComponentUtils.getRelativeBounds(container);
+ int posX = x - rect.x;
+ int posY = y - rect.y;
+ if (!accept(creator, posX, posY)) {
+ return false;
+ }
+ // posX,posY是新拖入组件相对于容器的位置,若在tab布局的边缘,则需要把新组件添加到l
+ // 父层自适应布局中,这时候的添加位置就是tab布局所在的位置
+ if (this.intersectsEdge(posX, posY, backUpContainer)) {
+ if (!ComparatorUtils.equals(backUpContainer.getOuterLayout(), backUpContainer.getBackupParent())) {
+ XWTabFitLayout tabLayout = (XWTabFitLayout) backUpContainer;
+ y = adjustY(y, tabLayout);
+ }
+ addComp(creator, x, y);
+ ((XWidgetCreator) creator).recalculateChildrenSize();
+ return true;
+ }
+ // 如果不在边缘,容器为本自适应布局,增加组件的位置就是相对于容器的位置
+ addComp(creator, posX, posY);
+ ((XWidgetCreator) creator).recalculateChildrenSize();
+ return true;
+ }
+
+ // tab布局的纵坐标受到tab高度以及参数面板高度的影响,判断的上边界取得是里面XWTabFitLayout的上边界,
+ // 实际计算的时候的纵坐标用了外层的CardMainBorerLayout,需要将tab高度和参数面板高度减掉
+ // 将y值变为相对坐标以实现获取到鼠标drop位置的控件
+ // TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了
+ private int adjustY(int y, XWTabFitLayout tabLayout) {
+ XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent();
+ LayoutBorderStyle style = cardLayout.toData().getBorderStyle();
+ y = y - this.getParaEditorYOffset();
+ if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
+ y = y - WCardMainBorderLayout.TAB_HEIGHT;
+ }
+ return y;
+ }
+
+ protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) {
+ return ComponentUtils.getRelativeBounds(mainLayout);
+ }
+
}
\ No newline at end of file
diff --git a/designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java b/designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java
index a9d700770..3538d2fd9 100644
--- a/designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java
+++ b/designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java
@@ -3,8 +3,6 @@
*/
package com.fr.design.designer.beans.location;
-import java.awt.*;
-
import com.fr.design.beans.location.Absorptionline;
import com.fr.design.beans.location.MoveUtils;
import com.fr.design.designer.creator.*;
@@ -15,6 +13,8 @@ import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WParameterLayout;
+import java.awt.*;
+
/**
* @author richer
* @since 6.5.3
@@ -27,32 +27,30 @@ public abstract class AccessDirection implements Direction {
abstract int getCursor();
- protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle current_bounds, FormDesigner designer,
- Rectangle oldbounds);
-
- protected int[] sorption(int x, int y,Rectangle current_bounds, FormDesigner designer) {
- // 自适应布局不需要吸附线,但需要对齐线,对齐线后面处理
- if (!designer.hasWAbsoluteLayout()) {
- designer.getStateModel().setEquidistantLine(null);
- designer.getStateModel().setXAbsorptionline(null);
- designer.getStateModel().setYAbsorptionline(null);
- return new int[] { x, y };
- } else {
- int posy = current_bounds.y;
-
- Point relativePoint = getRelativePoint(x, y, current_bounds,designer);
- sorptionPoint(relativePoint,current_bounds, designer);
- return new int[] { relativePoint.x, relativePoint.y };
- }
+ protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle currentBounds, FormDesigner designer,
+ Rectangle oldBounds);
+
+ protected int[] sorption(int x, int y, Rectangle currentBounds, FormDesigner designer) {
+ // 自适应布局不需要吸附线,但需要对齐线,对齐线后面处理
+ if (!designer.hasWAbsoluteLayout()) {
+ designer.getStateModel().setEquidistantLine(null);
+ designer.getStateModel().setXAbsorptionline(null);
+ designer.getStateModel().setYAbsorptionline(null);
+ return new int[]{x, y};
+ } else {
+ Point relativePoint = getRelativePoint(x, y, currentBounds, designer);
+ sorptionPoint(relativePoint, currentBounds, designer);
+ return new int[]{relativePoint.x, relativePoint.y};
+ }
- }
+ }
- protected Point getRelativePoint(int x, int y, Rectangle current_bounds,FormDesigner designer) {
- if (x < 0) {
- x = 0;
- } else if (x > designer.getRootComponent().getWidth() && designer.getSelectionModel().hasSelectionComponent()) {
- x = designer.getRootComponent().getWidth();
- }
+ protected Point getRelativePoint(int x, int y, Rectangle currentBounds, FormDesigner designer) {
+ if (x < 0) {
+ x = 0;
+ } else if (x > designer.getRootComponent().getWidth() && designer.getSelectionModel().hasSelectionComponent()) {
+ x = designer.getRootComponent().getWidth();
+ }
//参数面板可以无下限拉长
if (y < 0) {
y = 0;
@@ -63,111 +61,101 @@ public abstract class AccessDirection implements Direction {
return new Point(x, y);
}
- protected void sorptionPoint(Point point, Rectangle current_bounds,FormDesigner designer) {
- boolean findInX = current_bounds.getWidth() <= MoveUtils.SORPTION_UNIT ? true : false;
- boolean findInY = current_bounds.getHeight() <= MoveUtils.SORPTION_UNIT ? true : false;
-
- WAbsoluteLayout layout =getLayout(designer);
- FormSelection selection = designer.getSelectionModel().getSelection();
-
- boolean isWidgetsIntersect = false;
- for (int i = 0, count = layout.getWidgetCount(); i < count; i++) {
- BoundsWidget temp = (BoundsWidget) layout.getWidget(i);
- if (!temp.isVisible() || selection.contains(temp.getWidget())) {
- continue;
- }
- Rectangle bounds = getWidgetRelativeBounds(temp.getBounds(), selection);
- if (!findInX) {
- int x1 = bounds.x;
- if (Math.abs(x1 - point.x) <= MoveUtils.SORPTION_UNIT) {
- point.x = x1;
- findInX = true;
- }
- int x2 = bounds.x + bounds.width;
- if (Math.abs(x2 - point.x) <= MoveUtils.SORPTION_UNIT) {
- point.x = x2;
- findInX = true;
- }
- }
- if (!findInY) {
- int y1 = bounds.y;
- if (Math.abs(y1 - point.y) <= MoveUtils.SORPTION_UNIT) {
- point.y = y1;
- findInY = true;
- }
- int y2 = bounds.y + bounds.height;
- if (Math.abs(y2 - point.y) <= MoveUtils.SORPTION_UNIT) {
- point.y = y2;
- findInY = true;
- }
+ protected void sorptionPoint(Point point, Rectangle currentBounds, FormDesigner designer) {
+ boolean findInX = currentBounds.getWidth() <= MoveUtils.SORPTION_UNIT;
+ boolean findInY = currentBounds.getHeight() <= MoveUtils.SORPTION_UNIT;
+ WAbsoluteLayout layout = getLayout(designer);
+ FormSelection selection = designer.getSelectionModel().getSelection();
+ for (int i = 0, count = layout.getWidgetCount(); i < count; i++) {
+ BoundsWidget temp = (BoundsWidget) layout.getWidget(i);
+ if (!temp.isVisible() || selection.contains(temp.getWidget())) {
+ continue;
+ }
+ Rectangle bounds = getWidgetRelativeBounds(temp.getBounds(), selection);
+ if (!findInX) {
+ int x1 = bounds.x;
+ if (Math.abs(x1 - point.x) <= MoveUtils.SORPTION_UNIT) {
+ point.x = x1;
+ findInX = true;
+ }
+ int x2 = bounds.x + bounds.width;
+ if (Math.abs(x2 - point.x) <= MoveUtils.SORPTION_UNIT) {
+ point.x = x2;
+ findInX = true;
+ }
+ }
+ if (!findInY) {
+ int y1 = bounds.y;
+ if (Math.abs(y1 - point.y) <= MoveUtils.SORPTION_UNIT) {
+ point.y = y1;
+ findInY = true;
+ }
+ int y2 = bounds.y + bounds.height;
+ if (Math.abs(y2 - point.y) <= MoveUtils.SORPTION_UNIT) {
+ point.y = y2;
+ findInY = true;
+ }
}
if (findInX && findInY) {
break;
}
- if (current_bounds.intersects(bounds) && !(layout instanceof WParameterLayout)){
- isWidgetsIntersect = true;
- }
- }
- processRectangleIntersects(designer, point.x, point.y, isWidgetsIntersect);
+ }
+ setDesignerStateModelProperties(designer, findInX, findInY, currentBounds, point);
+ }
- designer.getStateModel().setXAbsorptionline(findInX && current_bounds.getWidth() > MoveUtils.SORPTION_UNIT ? Absorptionline.createXAbsorptionline(point.x) : null);
- designer.getStateModel().setYAbsorptionline(findInY && current_bounds.getHeight() > MoveUtils.SORPTION_UNIT ? Absorptionline.createYAbsorptionline(point.y) : null);
- designer.getStateModel().setEquidistantLine(null);
- }
+ private void setDesignerStateModelProperties(FormDesigner designer, boolean findInX, boolean findInY, Rectangle
+ currentBounds, Point point) {
+ designer.getStateModel().setXAbsorptionline(findInX && currentBounds.getWidth() > MoveUtils.SORPTION_UNIT ? Absorptionline.createXAbsorptionline(point.x) : null);
+ designer.getStateModel().setYAbsorptionline(findInY && currentBounds.getHeight() > MoveUtils.SORPTION_UNIT ? Absorptionline.createYAbsorptionline(point.y) : null);
+ designer.getStateModel().setEquidistantLine(null);
+ }
- private Rectangle getWidgetRelativeBounds(Rectangle bounds, FormSelection selection){
- Rectangle relativeRec = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
- XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
- if (parent == null) {
- return relativeRec;
- }
- Rectangle rec = ComponentUtils.getRelativeBounds(parent);
- relativeRec.x += rec.x;
- relativeRec.y += rec.y;
- return relativeRec;
- }
+ private Rectangle getWidgetRelativeBounds(Rectangle bounds, FormSelection selection) {
+ Rectangle relativeRec = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
+ XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
+ if (parent == null) {
+ return relativeRec;
+ }
+ Rectangle rec = ComponentUtils.getRelativeBounds(parent);
+ relativeRec.x += rec.x;
+ relativeRec.y += rec.y;
+ return relativeRec;
+ }
- private void processRectangleIntersects(FormDesigner designer, int x, int y, boolean isIntersects){
- if(isIntersects){
- if(designer.getLocationOnScreen() != null) {
- MoveUtils.displayForbidWindow(x + designer.getLocationOnScreen().x, y + designer.getLocationOnScreen().y);
- }
- designer.setWidgetsIntersect(true);
- }
- else{
- MoveUtils.hideForbidWindow();
- designer.setWidgetsIntersect(false);
- }
- }
private WAbsoluteLayout getLayout(final FormDesigner designer){
XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator(
designer.getTarget().getContainer());
WAbsoluteLayout layout;
- if (formLayoutContainer.acceptType(XWBorderLayout.class)){//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面
- Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent();
- if(container instanceof XWAbsoluteLayout){
- layout = ((XWAbsoluteLayout)container).toData();
- }
- else {
- layout = (WAbsoluteLayout) designer.getParaComponent().toData();
- }
- } else{
+ if (formLayoutContainer.acceptType(XWBorderLayout.class)) {//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面
+ Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent();
+ if (container instanceof XWAbsoluteLayout) {
+ layout = ((XWAbsoluteLayout) container).toData();
+ } else {
+ layout = (WAbsoluteLayout) designer.getParaComponent().toData();
+ }
+ } else {
layout = (WAbsoluteLayout) designer.getTarget().getContainer();
}
- return layout;
+ return layout;
}
- /**
- * 拖拽
- * @param dx 坐标x
- * @param dy 坐标y
- * @param designer 设计界面
- */
- public void drag(int dx, int dy, FormDesigner designer) {
- Rectangle rec = getDraggedBounds(dx, dy, designer.getSelectionModel().getSelection().getRelativeBounds(), designer, designer.getSelectionModel().getSelection().getBackupBounds());
+ /**
+ * 拖拽
+ *
+ * @param dx 坐标x
+ * @param dy 坐标y
+ * @param designer 设计界面
+ */
+ public void drag(int dx, int dy, FormDesigner designer) {
+ Rectangle rec = getDraggedBounds(dx, dy, designer.getSelectionModel().getSelection().getRelativeBounds(), designer, designer.getSelectionModel().getSelection().getBackupBounds());
+ if (rec != null) {
+ designer.getSelectionModel().getSelection().setSelectionBounds(rec, designer);
+ } else {
+ return;
+ }
//设定控件最小高度21,因每次拖曳至少移动1,防止控件高度等于21时,拖曳导致rec.y的变化使得控件不停的向上或向下移动。
if(rec.height == MINHEIGHT){
ymin = rec.y;
@@ -190,10 +178,8 @@ public abstract class AccessDirection implements Direction {
rec.width = MINWIDTH;
rec.x = xmin;
}
- if(rec != null) {
- designer.getSelectionModel().getSelection().setSelectionBounds(rec, designer);
- }
- }
+
+ }
/**
* 更新鼠标指针形状
diff --git a/designer_form/src/com/fr/design/designer/beans/location/Inner.java b/designer_form/src/com/fr/design/designer/beans/location/Inner.java
index c54796a0a..b07b18b4a 100644
--- a/designer_form/src/com/fr/design/designer/beans/location/Inner.java
+++ b/designer_form/src/com/fr/design/designer/beans/location/Inner.java
@@ -9,9 +9,8 @@ import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.container.WAbsoluteLayout;
-import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.stable.ArrayUtils;
-import com.fr.third.com.lowagie.text.*;
+import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import java.awt.*;
import java.awt.Rectangle;
@@ -47,89 +46,97 @@ public class Inner extends AccessDirection {
return new Point(x, y);
}
- @Override
- protected void sorptionPoint(Point point, Rectangle current_bounds, final FormDesigner designer) {
- RectangleDesigner rd = new RectangleDesigner() {
- public void setXAbsorptionline(Absorptionline line) {
- designer.getStateModel().setXAbsorptionline(line);
- }
- public void setYAbsorptionline(Absorptionline line) {
- designer.getStateModel().setYAbsorptionline(line);
- }
-
- /**
- * 获取当前选中块的水平线数组
- *
- * @return 块的水平线数组
- *
- */
- public int[] getHorizontalLine(){
- return ArrayUtils.EMPTY_INT_ARRAY;
- }
-
- /**
- * 获取当前选中块的垂直线数组
- *
- * @return 块的垂直线数组
- *
- */
- public int[] getVerticalLine(){
- return ArrayUtils.EMPTY_INT_ARRAY;
- }
- public RectangleIterator createRectangleIterator() {
- return getRectangleIterator(designer);
- }
+ private class RectDesigner implements RectangleDesigner {
+ private FormDesigner designer = null;
- /**
- * 设置designer内部组件是否重叠的标志位
- *
- * @param isIntersects 是否重叠
- */
- @Override
- public void setWidgetsIntersects(boolean isIntersects) {
- designer.setWidgetsIntersect(isIntersects);
- }
+ public RectDesigner(FormDesigner designer) {
+ this.designer = designer;
+ }
- /**
- * 获取designer内部组件是否重叠的标志位
- *
- * @return 重叠
- */
- @Override
- public boolean getWidgetsIntersects() {
- return designer.isWidgetsIntersect();
- }
+ public void setXAbsorptionline(Absorptionline line) {
+ designer.getStateModel().setXAbsorptionline(line);
+ }
+ public void setYAbsorptionline(Absorptionline line) {
+ designer.getStateModel().setYAbsorptionline(line);
+ }
- /**
- * 获取designer相对屏幕的位置
- *
- * @return 位置
- */
- @Override
- public Point getDesignerLocationOnScreen() {
- return designer.getLocationOnScreen();
- }
+ /**
+ * 获取当前选中块的水平线数组
+ *
+ * @return 块的水平线数组
+ *
+ */
+ public int[] getHorizontalLine(){
+ return ArrayUtils.EMPTY_INT_ARRAY;
+ }
- /**
- * 设置等距线
- *
- * @param line 吸附线
- */
- @Override
- public void setEquidistantLine(Absorptionline line) {
- designer.getStateModel().setEquidistantLine(line);
- }
+ /**
+ * 获取当前选中块的垂直线数组
+ *
+ * @return 块的垂直线数组
+ *
+ */
+ public int[] getVerticalLine(){
+ return ArrayUtils.EMPTY_INT_ARRAY;
+ }
+ public RectangleIterator createRectangleIterator() {
+ return getRectangleIterator(designer);
+ }
- @Override
- public int getDesignerScrollHorizontalValue() {
- return designer.getArea().getHorizontalValue();
- }
+ /**
+ * 设置designer内部组件是否重叠的标志位
+ *
+ * @param isIntersects 是否重叠
+ */
+ @Override
+ public void setWidgetsIntersected(boolean isIntersects) {
+ designer.setWidgetsIntersect(isIntersects);
+ }
- @Override
- public int getDesignerScrollVerticalValue() {
- return designer.getArea().getVerticalValue();
- }
- };
+ /**
+ * 获取designer内部组件是否重叠的标志位
+ *
+ * @return 重叠
+ */
+ @Override
+ public boolean isWidgetsIntersected() {
+ return designer.isWidgetsIntersect();
+ }
+
+ /**
+ * 获取designer相对屏幕的位置
+ *
+ * @return 位置
+ */
+ @Override
+ public Point getDesignerLocationOnScreen() {
+ return designer.getLocationOnScreen();
+ }
+
+ /**
+ * 设置等距线
+ *
+ * @param line 吸附线
+ */
+ @Override
+ public void setEquidistantLine(Absorptionline line) {
+ designer.getStateModel().setEquidistantLine(line);
+ }
+
+ @Override
+ public int getDesignerScrollHorizontalValue() {
+ return designer.getArea().getHorizontalValue();
+ }
+
+ @Override
+ public int getDesignerScrollVerticalValue() {
+ return designer.getArea().getVerticalValue();
+ }
+ }
+
+ @Override
+ protected void sorptionPoint(Point point, Rectangle current_bounds, final FormDesigner designer) {
+ RectDesigner rd = new RectDesigner(designer);
//判断当前操作的是不是参数面板,要特殊处理
boolean isParameterLayout = ((XCreator)(designer.getSelectionModel().getSelection().getSelectedCreator().getParent())).acceptType(XWParameterLayout.class);
point.setLocation(MoveUtils.sorption(point.x, point.y, current_bounds.width, current_bounds.height, rd, isParameterLayout));
diff --git a/designer_form/src/com/fr/design/designer/beans/models/AddingModel.java b/designer_form/src/com/fr/design/designer/beans/models/AddingModel.java
index 46798f4d9..9d308b9d4 100644
--- a/designer_form/src/com/fr/design/designer/beans/models/AddingModel.java
+++ b/designer_form/src/com/fr/design/designer/beans/models/AddingModel.java
@@ -1,133 +1,141 @@
-package com.fr.design.designer.beans.models;
-
-import java.awt.Rectangle;
-
-import com.fr.design.designer.creator.XWAbsoluteLayout;
-import com.fr.design.mainframe.FormDesigner;
-import com.fr.design.designer.beans.AdapterBus;
-import com.fr.design.designer.beans.ComponentAdapter;
-import com.fr.design.designer.beans.adapters.component.CompositeComponentAdapter;
-import com.fr.design.designer.creator.XCreator;
-import com.fr.design.designer.creator.XLayoutContainer;
-import com.fr.design.designer.creator.XWParameterLayout;
-import com.fr.design.utils.ComponentUtils;
-import com.fr.general.ComparatorUtils;
-
-/**
- * 添加状态下的model
- */
-public class AddingModel {
-
- // 当前要添加的组件
- private XCreator creator;
- // 记录当前鼠标的位置信息
- private int current_x;
- private int current_y;
- private boolean added;
-
- public AddingModel(FormDesigner designer, XCreator xCreator) {
- String creatorName = getXCreatorName(designer, xCreator);
- this.creator = xCreator;
- instantiateCreator(designer, creatorName);
- // 初始的时候隐藏该组件的图标
- current_x = -this.creator.getWidth();
- current_y = -this.creator.getHeight();
- }
-
- /**
- * 待说明
- * @param designer 设计器
- * @param creatorName 组件名
- */
- public void instantiateCreator(FormDesigner designer, String creatorName) {
- creator.toData().setWidgetName(creatorName);
- ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator);
- adapter.initialize();
- creator.addNotify();
- creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter);
- }
-
- public AddingModel(XCreator xCreator, int x, int y) {
- this.creator = xCreator;
- this.creator.backupCurrentSize();
- this.creator.backupParent();
- this.creator.setSize(xCreator.initEditorSize());
- current_x = x - (xCreator.getWidth() / 2);
- current_y = y - (xCreator.getHeight() / 2);
- }
-
- /**
- * 隐藏当前组件的图标
- */
- public void reset() {
- current_x = -this.creator.getWidth();
- current_y = -this.creator.getHeight();
- }
-
- public String getXCreatorName(FormDesigner designer,XCreator x){
- String def= x.createDefaultName();
- if (x.acceptType(XWParameterLayout.class)) {
- return def;
- }
- int i = 0;
- while (designer.getTarget().isNameExist(def + i)) {
- i++;
- }
- return def+i;
- }
-
- public int getCurrentX() {
- return current_x;
- }
-
- public int getCurrentY() {
- return current_y;
- }
-
-
- /**
- * 移动组件图标到鼠标事件发生的位置
- * @param x 坐标
- * @param y 坐标
- */
- public void moveTo(int x, int y) {
- current_x = x - (this.creator.getWidth() / 2);
- current_y = y - (this.creator.getHeight() / 2);
- }
-
- public XCreator getXCreator() {
- return this.creator;
- }
-
- /**
- * 当前组件是否已经添加到某个容器中
- * @return 是返回true
- */
- public boolean isCreatorAdded() {
- return added;
- }
-
- /**
- * 加入容器
- * @param designer 设计器
- * @param container 容器
- * @param x 坐标
- * @param y 坐标
- * @return 成功返回true
- */
- public boolean add2Container(FormDesigner designer, XLayoutContainer container, int x, int y) {
- //考虑不同布局嵌套的情况,获取顶层容器
- XLayoutContainer xLayoutContainer = container.getTopLayout();
- if(xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class)){
- container = xLayoutContainer;
- }
-
- Rectangle rect = ComponentUtils.getRelativeBounds(container);
- if(!ComparatorUtils.equals(container.getOuterLayout(), container.getBackupParent())){
- return added = container.getLayoutAdapter().addBean(creator, x + designer.getArea().getHorizontalValue(), y + designer.getArea().getVerticalValue());
- }
- return added = container.getLayoutAdapter().addBean(creator,
- x + designer.getArea().getHorizontalValue() - rect.x,
- y + designer.getArea().getVerticalValue() - rect.y);
- }
+package com.fr.design.designer.beans.models;
+
+import java.awt.Rectangle;
+
+import com.fr.design.designer.creator.XWAbsoluteLayout;
+import com.fr.design.mainframe.FormDesigner;
+import com.fr.design.designer.beans.AdapterBus;
+import com.fr.design.designer.beans.ComponentAdapter;
+import com.fr.design.designer.beans.adapters.component.CompositeComponentAdapter;
+import com.fr.design.designer.creator.XCreator;
+import com.fr.design.designer.creator.XLayoutContainer;
+import com.fr.design.designer.creator.XWParameterLayout;
+import com.fr.design.utils.ComponentUtils;
+import com.fr.general.ComparatorUtils;
+
+/**
+ * 添加状态下的model
+ */
+public class AddingModel {
+
+ // 当前要添加的组件
+ private XCreator creator;
+ // 记录当前鼠标的位置信息
+ private int currentX;
+ private int currentY;
+ private boolean added;
+
+ public AddingModel(FormDesigner designer, XCreator xCreator) {
+ String creatorName = getXCreatorName(designer, xCreator);
+ this.creator = xCreator;
+ instantiateCreator(designer, creatorName);
+ // 初始的时候隐藏该组件的图标
+ currentY = -this.creator.getWidth();
+ currentX = -this.creator.getHeight();
+ }
+
+ /**
+ * 待说明
+ *
+ * @param designer 设计器
+ * @param creatorName 组件名
+ */
+ public void instantiateCreator(FormDesigner designer, String creatorName) {
+ creator.toData().setWidgetName(creatorName);
+ ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator);
+ adapter.initialize();
+ creator.addNotify();
+ creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter);
+ }
+
+ public AddingModel(XCreator xCreator, int x, int y) {
+ this.creator = xCreator;
+ this.creator.backupCurrentSize();
+ this.creator.backupParent();
+ this.creator.setSize(xCreator.initEditorSize());
+ currentX = x - (xCreator.getWidth() / 2);
+ currentY = y - (xCreator.getHeight() / 2);
+ }
+
+ /**
+ * 隐藏当前组件的图标
+ */
+ public void reset() {
+ currentX = -this.creator.getWidth();
+ currentY = -this.creator.getHeight();
+ }
+
+ public String getXCreatorName(FormDesigner designer, XCreator x) {
+ String def = x.createDefaultName();
+ if (x.acceptType(XWParameterLayout.class)) {
+ return def;
+ }
+ int i = 0;
+ while (designer.getTarget().isNameExist(def + i)) {
+ i++;
+ }
+ return def + i;
+ }
+
+ public int getCurrentX() {
+ return currentX;
+ }
+
+ public int getCurrentY() {
+ return currentY;
+ }
+
+
+ /**
+ * 移动组件图标到鼠标事件发生的位置
+ *
+ * @param x 坐标
+ * @param y 坐标
+ */
+ public void moveTo(int x, int y) {
+ currentX = x - (this.creator.getWidth() / 2);
+ currentY = y - (this.creator.getHeight() / 2);
+ }
+
+ public XCreator getXCreator() {
+ return this.creator;
+ }
+
+ /**
+ * 当前组件是否已经添加到某个容器中
+ *
+ * @return 是返回true
+ */
+ public boolean isCreatorAdded() {
+ return added;
+ }
+
+ /**
+ * 加入容器
+ *
+ * @param designer 设计器
+ * @param container 容器
+ * @param x 坐标
+ * @param y 坐标
+ * @return 成功返回true
+ */
+ public boolean add2Container(FormDesigner designer, XLayoutContainer container, int x, int y) {
+ //考虑不同布局嵌套的情况,获取顶层容器
+ XLayoutContainer xLayoutContainer = container.getTopLayout();
+ if (xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class)) {
+ container = xLayoutContainer;
+ }
+
+ Rectangle rect = ComponentUtils.getRelativeBounds(container);
+ if (!ComparatorUtils.equals(container.getOuterLayout(), container.getBackupParent())) {
+ added = container.getLayoutAdapter().addBean(creator,
+ x + designer.getArea().getHorizontalValue(),
+ y + designer.getArea().getVerticalValue());
+ return added;
+ }
+ added = container.getLayoutAdapter().addBean(creator,
+ x + designer.getArea().getHorizontalValue() - rect.x,
+ y + designer.getArea().getVerticalValue() - rect.y);
+ return added;
+ }
}
\ No newline at end of file
diff --git a/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java b/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
index 834b28d74..13eaa18ac 100644
--- a/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
+++ b/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
@@ -1,328 +1,461 @@
-package com.fr.design.designer.beans.models;
-
-import java.awt.LayoutManager;
-import java.awt.Rectangle;
-import java.awt.Toolkit;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-
-import com.fr.design.designer.beans.AdapterBus;
-import com.fr.design.designer.beans.LayoutAdapter;
-import com.fr.design.designer.beans.events.DesignerEvent;
-import com.fr.design.designer.beans.location.Direction;
-import com.fr.design.designer.beans.location.Location;
-import com.fr.design.designer.creator.XCreator;
-import com.fr.design.designer.creator.XCreatorUtils;
-import com.fr.design.designer.creator.XLayoutContainer;
-import com.fr.design.designer.creator.XWFitLayout;
-import com.fr.design.designer.creator.XWParameterLayout;
-import com.fr.design.form.util.XCreatorConstants;
-import com.fr.design.mainframe.FormDesigner;
-import com.fr.design.mainframe.FormSelection;
-import com.fr.design.mainframe.FormSelectionUtils;
-import com.fr.design.utils.gui.LayoutUtils;
-import com.fr.stable.ArrayUtils;
-
-/**
- * 该model保存当前选择的组件和剪切版信息
- */
-public class SelectionModel {
- private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
- private static FormSelection CLIP_BOARD = new FormSelection();
- private FormDesigner designer;
- private FormSelection selection;
- private Rectangle hotspot_bounds;
-
- public SelectionModel(FormDesigner designer) {
- this.designer = designer;
- selection = new FormSelection();
- }
-
- /**
- * 重置。清空formSelction以及选择区域
- */
- public void reset() {
- selection.reset();
- hotspot_bounds = null;
- }
-
- /**
- * formSelction是否为空
- * @return 是否为空
- */
- public static boolean isEmpty(){
- return CLIP_BOARD.isEmpty();
- }
-
- /**
- * 鼠标点击一下,所选中的单个组件。按下Ctrl或者shift键时鼠标可以进行多选
- * @param e 鼠标事件
- */
- public void selectACreatorAtMouseEvent(MouseEvent e) {
- if (!e.isControlDown() && !e.isShiftDown()) {
- // 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件
- selection.reset();
- }
-
- // 获取e所在的组件
- XCreator comp = designer.getComponentAt(e);
-
- //布局组件的顶层布局如不可编辑,要获取其顶层布局
- XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout();
- if(topLayout != null && !topLayout.isEditable()){
- comp = topLayout;
- }
-
- // 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的
- if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) {
- XCreator parentContainer = (XCreator) comp.getParent();
- comp = parentContainer.isDedicateContainer() ? parentContainer : comp;
- }
- if (selection.removeSelectedCreator(comp) || selection.addSelectedCreator(comp)) {
- designer.getEditListenerTable().fireCreatorModified(comp, DesignerEvent.CREATOR_SELECTED);
- designer.repaint();
- }
- }
-
- /**
- * 将所选组件剪切到剪切板上
- */
- public void cutSelectedCreator2ClipBoard() {
- if (hasSelectionComponent()) {
- selection.cut2ClipBoard(CLIP_BOARD);
- designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED);
- designer.repaint();
- }
- }
-
- /**
- * 复制当前选中的组件到剪切板
- */
- public void copySelectedCreator2ClipBoard() {
- if (!selection.isEmpty()) {
- selection.copy2ClipBoard(CLIP_BOARD);
- }
- }
-
- /**
- * 从剪切板粘帖组件
- * @return 否
- */
- public boolean pasteFromClipBoard() {
- if (!CLIP_BOARD.isEmpty()) {
- XLayoutContainer parent = null;
- if (!hasSelectionComponent()) {
- FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),CLIP_BOARD, DELTA_X_Y, DELTA_X_Y);
- } else {
- parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
- if (parent != null) {
- Rectangle rec = selection.getSelctionBounds();
- FormSelectionUtils.paste2Container(designer, parent,CLIP_BOARD, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y);
- }
- }
- } else {
- Toolkit.getDefaultToolkit().beep();
- }
- return false;
- }
-
- public FormSelection getSelection() {
- return selection;
- }
-
- /**
- * 删除当前所有选择的组件
- */
- public void deleteSelection() {
- XCreator[] roots = selection.getSelectedCreators();
-
- if (roots.length > 0) {
- for (XCreator creator : roots) {
- if(creator.acceptType(XWParameterLayout.class)){
- designer.removeParaComponent();
- }
-
- removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight());
- creator.removeAll();
- // 清除被选中的组件
- selection.reset();
- }
- setSelectedCreator(designer.getRootComponent());
- // 触发事件
- designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED);
- designer.repaint();
- }
- }
-
- /**
- * 从选择组件中删除某组件
- *
- * @param creator 组件
- * @param creatorWidth 组件之前宽度
- * @param creatorHeight 组件之前高度
- */
- public void removeCreator(XCreator creator, int creatorWidth, int creatorHeight) {
- selection.removeCreator(creator);
- removeCreatorFromContainer(creator, creatorWidth, creatorHeight);
- designer.repaint();
- }
-
- /**
- * 设置选择区域
- */
- public void setHotspotBounds(Rectangle rect) {
- hotspot_bounds = rect;
- }
-
- /**
- * 获得当前选择区域
- */
- public Rectangle getHotspotBounds() {
- return hotspot_bounds;
- }
-
- private void removeCreatorFromContainer(XCreator creator, int creatorWidth, int creatorHeight) {
- XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(creator);
- if (parent == null) {
- return;
- }
- boolean changeCreator = creator.shouldScaleCreator() || creator.hasTitleStyle();
- if (parent.acceptType(XWFitLayout.class) && changeCreator) {
- creator = (XCreator) creator.getParent();
- }
- parent.getLayoutAdapter().removeBean(creator, creatorWidth, creatorHeight);
- // 删除其根组件,同时就删除了同时被选择的叶子组件
- parent.remove(creator);
- LayoutManager layout = parent.getLayout();
-
- if (layout != null) {
- // 刷新组件容器的布局
- LayoutUtils.layoutContainer(parent);
- }
- }
-
- /**
- * 是否有组件被选择。如果所选组件是最底层容器,也视为无选择
- * @return 是则返回true
- */
- public boolean hasSelectionComponent() {
- return !selection.isEmpty() && selection.getSelectedCreator().getParent() != null;
- }
-
- /**
- * 移动组件至指定位置
- * @param x 坐标x
- * @param y 坐标y
- */
- public void move(int x, int y) {
- for (XCreator creator : selection.getSelectedCreators()) {
- creator.setLocation(creator.getX() + x, creator.getY() + y);
- LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator);
- if (layoutAdapter != null) {
- layoutAdapter.fix(creator);
- }
- }
- designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(),
- DesignerEvent.CREATOR_SELECTED);
- }
-
- /**
- * 释放捕获
- */
- public void releaseDragging() {
- designer.setPainter(null);
- selection.fixCreator(designer);
- designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(),
- DesignerEvent.CREATOR_RESIZED);
- }
-
- public Direction getDirectionAt(MouseEvent e) {
- Direction dir;
- if (e.isControlDown() || e.isShiftDown()) {
- XCreator creator = designer.getComponentAt(e.getX(), e.getY(), selection.getSelectedCreators());
- if (creator != designer.getRootComponent() && selection.addedable(creator)) {
- return Location.add;
- }
- }
- if (hasSelectionComponent()) {
- int x = e.getX() + designer.getArea().getHorizontalValue();
- int y = e.getY() + designer.getArea().getVerticalValue();
- dir = getDirection(selection.getRelativeBounds(), x, y);
- if (selection.size() == 1) {
- if (!ArrayUtils.contains(selection.getSelectedCreator().getDirections(), dir.getActual())) {
- dir = Location.outer;
- }
- }
- } else {
- dir = Location.outer;
- }
-
- if (designer.getDesignerMode().isFormParameterEditor() && dir == Location.outer) {
- dir = designer.getLoc2Root(e);
- }
- return dir;
- }
-
- private Direction getDirection(Rectangle bounds, int x, int y) {
- if (x < (bounds.x - XCreatorConstants.RESIZE_BOX_SIZ)) {
- return Location.outer;
- } else if ((x >= (bounds.x - XCreatorConstants.RESIZE_BOX_SIZ)) && (x <= bounds.x)) {
- if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) {
- return Location.outer;
- } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) {
- return Location.left_top;
- } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) {
- return Location.left;
- } else if ((y >= (bounds.y + bounds.height))
- && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) {
- return Location.left_bottom;
- } else {
- return Location.outer;
- }
- } else if ((x > bounds.x) && (x < (bounds.x + bounds.width))) {
- if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) {
- return Location.outer;
- } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) {
- return Location.top;
- } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) {
- return Location.inner;
- } else if ((y >= (bounds.y + bounds.height))
- && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) {
- return Location.bottom;
- } else {
- return Location.outer;
- }
- } else if ((x >= (bounds.x + bounds.width))
- && (x <= (bounds.x + bounds.width + XCreatorConstants.RESIZE_BOX_SIZ))) {
- if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) {
- return Location.outer;
- } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) {
- return Location.right_top;
- } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) {
- return Location.right;
- } else if ((y >= (bounds.y + bounds.height))
- && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) {
- return Location.right_bottom;
- } else {
- return Location.outer;
- }
- } else {
- return Location.outer;
- }
- }
-
- private void fireCreatorSelected() {
- designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(),
- DesignerEvent.CREATOR_SELECTED);
- }
-
- public void setSelectedCreator(XCreator rootComponent) {
- selection.setSelectedCreator(rootComponent);
- fireCreatorSelected();
- }
-
- public void setSelectedCreators(ArrayList rebuildSelection) {
- selection.setSelectedCreators(rebuildSelection);
- fireCreatorSelected();
- }
+package com.fr.design.designer.beans.models;
+
+import com.fr.design.designer.beans.AdapterBus;
+import com.fr.design.designer.beans.LayoutAdapter;
+import com.fr.design.designer.beans.events.DesignerEvent;
+import com.fr.design.designer.beans.location.Direction;
+import com.fr.design.designer.beans.location.Location;
+import com.fr.design.designer.creator.*;
+import com.fr.design.designer.creator.cardlayout.XWCardLayout;
+import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
+import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
+import com.fr.design.form.util.XCreatorConstants;
+import com.fr.design.mainframe.FormDesigner;
+import com.fr.design.mainframe.FormSelection;
+import com.fr.design.mainframe.FormSelectionUtils;
+import com.fr.design.utils.ComponentUtils;
+import com.fr.design.utils.gui.LayoutUtils;
+import com.fr.stable.ArrayUtils;
+
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+
+/**
+ * 该model保存当前选择的组件和剪切版信息
+ */
+public class SelectionModel {
+ //被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。
+ private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
+ private static final double OFFSET_RELATIVE = 0.80;
+ private static FormSelection clipboard = new FormSelection();
+ private FormDesigner designer;
+ private FormSelection selection;
+ private Rectangle hotspotBounds;
+
+ public SelectionModel(FormDesigner designer) {
+ this.designer = designer;
+ selection = new FormSelection();
+ }
+
+ /**
+ * 重置。清空formSelction以及选择区域
+ */
+ public void reset() {
+ selection.reset();
+ hotspotBounds = null;
+ }
+
+ /**
+ * formSelction是否为空
+ *
+ * @return 是否为空
+ */
+ public static boolean isEmpty() {
+ return clipboard.isEmpty();
+ }
+
+ /**
+ * 鼠标点击一下,所选中的单个组件。按下Ctrl或者shift键时鼠标可以进行多选
+ *
+ * @param e 鼠标事件
+ */
+ public void selectACreatorAtMouseEvent(MouseEvent e) {
+ if (!e.isControlDown() && !e.isShiftDown()) {
+ // 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件
+ selection.reset();
+ }
+ // 获取e所在的组件
+ XCreator comp = designer.getComponentAt(e);
+
+ //布局组件的顶层布局如不可编辑,要获取其顶层布局
+ XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout();
+ if (topLayout != null && !topLayout.isEditable()) {
+ comp = topLayout;
+ }
+
+ // 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的
+ if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) {
+ XCreator parentContainer = (XCreator) comp.getParent();
+ comp = parentContainer.isDedicateContainer() ? parentContainer : comp;
+ }
+ if (selection.removeSelectedCreator(comp) || selection.addSelectedCreator(comp)) {
+ designer.getEditListenerTable().fireCreatorModified(comp, DesignerEvent.CREATOR_SELECTED);
+ designer.repaint();
+ }
+ }
+
+ /**
+ * 将所选组件剪切到剪切板上
+ */
+ public void cutSelectedCreator2ClipBoard() {
+ if (hasSelectionComponent()) {
+ selection.cut2ClipBoard(clipboard);
+ designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED);
+ designer.repaint();
+ }
+ }
+
+ /**
+ * 复制当前选中的组件到剪切板
+ */
+ public void copySelectedCreator2ClipBoard() {
+ if (!selection.isEmpty()) {
+ selection.copy2ClipBoard(clipboard);
+ }
+ }
+
+ /**
+ * 从剪切板粘帖组件
+ *
+ * @return 否
+ */
+ public boolean pasteFromClipBoard() {
+ if (!clipboard.isEmpty()) {
+ if (!hasSelectedPasteSource()) {
+ //未选
+ unselectedPaste();
+ } else {
+ //已选
+ selectedPaste();
+ }
+ } else {
+ Toolkit.getDefaultToolkit().beep();
+ }
+ return false;
+ }
+
+ public FormSelection getSelection() {
+ return selection;
+ }
+
+ /**
+ * 粘贴时未选择组件
+ */
+ private void unselectedPaste() {
+ if (designer.getClass().equals(FormDesigner.class)) {
+ if (selection.getSelectedCreator() instanceof XWFitLayout) {
+ if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) {
+ XLayoutContainer container = (XLayoutContainer) selection.getSelectedCreator();
+ //tab布局编辑器内部左上角第一个坐标点
+ int leftUpX = container.toData().getMargin().getLeft() + 1;
+ int leftUpY = container.toData().getMargin().getTop() + 1;
+ //选中第一个坐标点坐在的组件
+ selection.setSelectedCreator((XCreator) container.getComponentAt(leftUpX, leftUpY));
+ Rectangle rectangle = selection.getRelativeBounds();
+ if (hasSelectedPasteSource()) {
+ selectedPaste();
+ } else {
+ FormSelectionUtils.paste2Container(designer, container, clipboard,
+ rectangle.x + rectangle.width / 2,
+ rectangle.y + DELTA_X_Y);
+ }
+ } else {
+ //自适应布局编辑器内部左上角第一个坐标点
+ int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1;
+ int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1;
+ //选中第一个坐标点坐在的组件
+ selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY));
+ Rectangle rectangle = selection.getRelativeBounds();
+ if (hasSelectedPasteSource()) {
+ selectedPaste();
+ } else {
+ FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),
+ clipboard,
+ rectangle.x + rectangle.width / 2,
+ rectangle.y + DELTA_X_Y);
+ }
+ }
+ } else {
+ //绝对布局
+ //编辑器外面还有两层容器,使用designer.getRootComponent()获取到的是编辑器中层的容器,不是编辑器表层
+ //当前选择的就是编辑器表层
+ FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(),
+ clipboard,
+ DELTA_X_Y,
+ DELTA_X_Y);
+ }
+ } else {
+ //cpt本地组件复用,编辑器就一层,是最底层,使用designer.getRootComponent()就可以获取到
+ //使用selection.getSelectedCreator()也应该是可以获取到的。
+ FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),
+ clipboard,
+ DELTA_X_Y,
+ DELTA_X_Y);
+ }
+ }
+
+ /**
+ * 粘贴时选择组件
+ */
+ private void selectedPaste() {
+ XLayoutContainer container = null;
+ //获取到编辑器的表层容器(已选的组件的父容器就是表层容器)
+ container = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
+ if (container != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) {
+ //自适应布局
+
+ Rectangle selectionRec = selection.getRelativeBounds();
+ //获取父容器位置,补充因参数面板高度导致的位置坐标计算偏移
+ Rectangle containerRec = ComponentUtils.getRelativeBounds(container);
+ int positionX, positionY;
+
+ if (container.getClass().equals(XWTabFitLayout.class)) {
+ //tab内部粘贴不补充高度偏移
+ //且不计算参数面板造成的影响,因为在
+ //@see com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter#addBean中做了
+ positionX = selectionRec.x + selectionRec.width / 2;
+ positionY = (int) (selectionRec.y + selectionRec.height * OFFSET_RELATIVE);
+ } else {
+ //计算自适应布局位置
+ positionX = selectionRec.x - containerRec.x + selectionRec.width / 2;
+ positionY = (int) (selectionRec.y - containerRec.y + selectionRec.height * OFFSET_RELATIVE);
+ }
+ FormSelectionUtils.paste2Container(designer, container, clipboard, positionX, positionY);
+ } else if (container != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) {
+ //绝对布局
+ Rectangle rec = selection.getSelctionBounds();
+ FormSelectionUtils.paste2Container(designer, container, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y);
+ }
+ }
+
+ /**
+ * 删除当前所有选择的组件
+ */
+ public void deleteSelection() {
+ XCreator[] roots = selection.getSelectedCreators();
+
+ if (roots.length > 0) {
+ for (XCreator creator : roots) {
+ if (creator.acceptType(XWParameterLayout.class)) {
+ designer.removeParaComponent();
+ }
+ removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight());
+ creator.removeAll();
+ // 清除被选中的组件
+ selection.reset();
+ }
+ setSelectedCreator(designer.getRootComponent());
+ FormSelectionUtils.rebuildSelection(designer);
+ // 触发事件
+ designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED);
+ designer.repaint();
+ }
+ }
+
+ /**
+ * 从选择组件中删除某组件
+ *
+ * @param creator 组件
+ * @param creatorWidth 组件之前宽度
+ * @param creatorHeight 组件之前高度
+ */
+ public void removeCreator(XCreator creator, int creatorWidth, int creatorHeight) {
+ selection.removeCreator(creator);
+ removeCreatorFromContainer(creator, creatorWidth, creatorHeight);
+ designer.repaint();
+ }
+
+ /**
+ * 设置选择区域
+ */
+ public void setHotspotBounds(Rectangle rect) {
+ hotspotBounds = rect;
+ }
+
+ /**
+ * 获得当前选择区域
+ */
+ public Rectangle getHotspotBounds() {
+ return hotspotBounds;
+ }
+
+ private void removeCreatorFromContainer(XCreator creator, int creatorWidth, int creatorHeight) {
+ XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(creator);
+ if (parent == null) {
+ return;
+ }
+ boolean changeCreator = creator.shouldScaleCreator() || creator.hasTitleStyle();
+ if (parent.acceptType(XWFitLayout.class) && changeCreator) {
+ creator = (XCreator) creator.getParent();
+ }
+ parent.getLayoutAdapter().removeBean(creator, creatorWidth, creatorHeight);
+ // 删除其根组件,同时就删除了同时被选择的叶子组件
+ parent.remove(creator);
+ LayoutManager layout = parent.getLayout();
+
+ if (layout != null) {
+ // 刷新组件容器的布局
+ LayoutUtils.layoutContainer(parent);
+ }
+ }
+
+ /**
+ * 是否有组件被选择。如果所选组件是最底层容器,也视为无选择
+ *
+ * @return 是则返回true
+ * yaoh.wu 不应该通过判断是否是最底层容器来判断是否选择了组件
+ * 而是应该判断选择的容器是否是编辑器的最表层容器,也就是点击空白地方选择的容器
+ * 但是直接判断选择的容器是否是编辑器最表层类型又会引发拖动时选不上的情况,
+ * 因此通过判断父容器来实现
+ *
+ * 举例:frm组件复用 绝对布局情况下,不选择时有三层容器:
+ * 底层@see {@link com.fr.design.designer.creator.XWBorderLayout}
+ * 中层@see {@link XWFitLayout}
+ * 表层@see {@link com.fr.design.designer.creator.XWAbsoluteBodyLayout}
+ *
+ * 但是编辑窗口的最外层其实是表层@see {@link com.fr.design.designer.creator.XWAbsoluteBodyLayout},
+ * 其他两层不是靠添加组件就可以编辑的。
+ */
+ public boolean hasSelectedPasteSource() {
+ XCreator selectionXCreator = selection.getSelectedCreator();
+ if (designer.getClass().equals(FormDesigner.class)) {
+ //frm本地组件复用
+ if (selectionXCreator != null) {
+ //选中的是否是tab布局编辑器本身
+ boolean tabEditor = selectionXCreator.getClass().equals(XWCardMainBorderLayout.class)
+ || selectionXCreator.getClass().equals(XWCardLayout.class)
+ || selectionXCreator.getClass().equals(XWTabFitLayout.class);
+ //选中的是否是frm绝对布局编辑器本身
+ boolean absoluteEditor = selectionXCreator.getClass().equals(XWAbsoluteBodyLayout.class);
+ //选中是否是frm绝对画布块编辑器本身
+ boolean absoluteCanvas = selectionXCreator.getClass().equals(XWAbsoluteLayout.class);
+ //选中的是否是相对布局编辑器本身
+ boolean relativeEditor = selectionXCreator.getClass().equals(XWFitLayout.class);
+
+ return !(tabEditor || absoluteEditor || absoluteCanvas || relativeEditor);
+ } else {
+ return false;
+ }
+ } else {
+ //cpt本地组件复用,selection.getSelectedCreator().getParent()=@XWParameterLayout instanceof @XWAbsoluteLayout
+ return selectionXCreator != null && selectionXCreator.getParent() != null;
+ }
+ }
+
+ /**
+ * 是否有组件被选择。如果所选组件是最底层容器,也视为无选择
+ *
+ * @return 是则返回true
+ */
+ public boolean hasSelectionComponent() {
+ return !selection.isEmpty() && selection.getSelectedCreator().getParent() != null;
+ }
+
+ /**
+ * 移动组件至指定位置
+ *
+ * @param x 坐标x
+ * @param y 坐标y
+ */
+ public void move(int x, int y) {
+ for (XCreator creator : selection.getSelectedCreators()) {
+ creator.setLocation(creator.getX() + x, creator.getY() + y);
+ LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator);
+ if (layoutAdapter != null) {
+ layoutAdapter.fix(creator);
+ }
+ }
+ designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(),
+ DesignerEvent.CREATOR_SELECTED);
+ }
+
+ /**
+ * 释放捕获
+ */
+ public void releaseDragging() {
+ designer.setPainter(null);
+ selection.fixCreator(designer);
+ designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(),
+ DesignerEvent.CREATOR_RESIZED);
+ }
+
+ public Direction getDirectionAt(MouseEvent e) {
+ Direction dir;
+ if (e.isControlDown() || e.isShiftDown()) {
+ XCreator creator = designer.getComponentAt(e.getX(), e.getY(), selection.getSelectedCreators());
+ if (creator != designer.getRootComponent() && selection.addedable(creator)) {
+ return Location.add;
+ }
+ }
+ if (hasSelectionComponent()) {
+ int x = e.getX() + designer.getArea().getHorizontalValue();
+ int y = e.getY() + designer.getArea().getVerticalValue();
+ dir = getDirection(selection.getRelativeBounds(), x, y);
+ if (selection.size() == 1 && !ArrayUtils.contains(selection.getSelectedCreator().getDirections(), dir
+ .getActual())) {
+ dir = Location.outer;
+ }
+ } else {
+ dir = Location.outer;
+ }
+
+ if (designer.getDesignerMode().isFormParameterEditor() && dir == Location.outer) {
+ dir = designer.getLoc2Root(e);
+ }
+ return dir;
+ }
+
+ private Direction getDirection(Rectangle bounds, int x, int y) {
+ if (x < (bounds.x - XCreatorConstants.RESIZE_BOX_SIZ)) {
+ return Location.outer;
+ } else if ((x >= (bounds.x - XCreatorConstants.RESIZE_BOX_SIZ)) && (x <= bounds.x)) {
+ if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) {
+ return Location.outer;
+ } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) {
+ return Location.left_top;
+ } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) {
+ return Location.left;
+ } else if ((y >= (bounds.y + bounds.height))
+ && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) {
+ return Location.left_bottom;
+ } else {
+ return Location.outer;
+ }
+ } else if ((x > bounds.x) && (x < (bounds.x + bounds.width))) {
+ if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) {
+ return Location.outer;
+ } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) {
+ return Location.top;
+ } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) {
+ return Location.inner;
+ } else if ((y >= (bounds.y + bounds.height))
+ && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) {
+ return Location.bottom;
+ } else {
+ return Location.outer;
+ }
+ } else if ((x >= (bounds.x + bounds.width))
+ && (x <= (bounds.x + bounds.width + XCreatorConstants.RESIZE_BOX_SIZ))) {
+ if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) {
+ return Location.outer;
+ } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) {
+ return Location.right_top;
+ } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) {
+ return Location.right;
+ } else if ((y >= (bounds.y + bounds.height))
+ && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) {
+ return Location.right_bottom;
+ } else {
+ return Location.outer;
+ }
+ } else {
+ return Location.outer;
+ }
+ }
+
+ private void fireCreatorSelected() {
+ designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(),
+ DesignerEvent.CREATOR_SELECTED);
+ }
+
+ public void setSelectedCreator(XCreator rootComponent) {
+ selection.setSelectedCreator(rootComponent);
+ fireCreatorSelected();
+ }
+
+ public void setSelectedCreators(ArrayList rebuildSelection) {
+ selection.setSelectedCreators(rebuildSelection);
+ fireCreatorSelected();
+ }
}
\ No newline at end of file
diff --git a/designer_form/src/com/fr/design/designer/beans/models/StateModel.java b/designer_form/src/com/fr/design/designer/beans/models/StateModel.java
index a623caddc..ff3fcbedc 100644
--- a/designer_form/src/com/fr/design/designer/beans/models/StateModel.java
+++ b/designer_form/src/com/fr/design/designer/beans/models/StateModel.java
@@ -1,446 +1,476 @@
-package com.fr.design.designer.beans.models;
-
-import java.awt.Component;
-import java.awt.Cursor;
-import java.awt.Graphics;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Toolkit;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-
-import com.fr.design.beans.location.Absorptionline;
-import com.fr.design.mainframe.FormDesigner;
-import com.fr.design.mainframe.FormSelectionUtils;
-import com.fr.design.designer.beans.AdapterBus;
-import com.fr.design.designer.beans.HoverPainter;
-import com.fr.design.designer.beans.LayoutAdapter;
-import com.fr.design.designer.beans.events.DesignerEvent;
-import com.fr.design.designer.beans.location.Direction;
-import com.fr.design.designer.beans.location.Location;
-import com.fr.design.designer.creator.XConnector;
-import com.fr.design.designer.creator.XCreator;
-import com.fr.design.designer.creator.XCreatorUtils;
-import com.fr.design.designer.creator.XLayoutContainer;
-import com.fr.design.designer.creator.XWAbsoluteLayout;
-import com.fr.design.utils.ComponentUtils;
-
-/**
- * 普通模式下的状态model
- */
-public class StateModel {
- // 对应的selection model
-
- private SelectionModel selectionModel;
- // 当前鼠标进入拖拽区域的位置类型
- private Direction driection;
-
- // 当前拖拽的起始位置
- private int current_x;
- private int current_y;
-
- private Point startPoint = new Point();
- private Point currentPoint = new Point();
-
- private Absorptionline lineInX;
- private Absorptionline lineInY;
- //等距线
- private Absorptionline lineEquidistant;
-
- // 当前是否处于拖拽选择状态
- private boolean selecting;
- private boolean dragging;
-
- private boolean addable;
-
- private FormDesigner designer;
-
- public StateModel(FormDesigner designer) {
- this.designer = designer;
- selectionModel = designer.getSelectionModel();
- }
-
- /**
- * 返回direction
- * @return direction方向
- */
- public Direction getDirection() {
- return driection;
- }
-
- /**
- * 是否有组件正被选中
- *
- * @return true 如果至少一个组件被选中
- */
- public boolean isSelecting() {
- return selecting;
- }
-
- /**
- *是否能拖拽
- * @return 非outer且选中为空
- */
- public boolean dragable() {
- return ((driection != Location.outer) && !selecting);
- }
-
- /**
- * 拖拽中是否可以转换为添加模式:
- * 如果拖拽组件只有一个,鼠标当前所在位置的最底层表单容器与这个组件的容器不同;
- * 如果拖拽组件为多个,鼠标当前所在位置的最底层表单容器除了要求要跟这些组件的容器不同外,还必须是绝对定位布局
- */
- private void checkAddable(MouseEvent e) {
- addable = false;
- designer.setPainter(null);
-
- if (driection != Location.inner) {
- return;
- }
-
- XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
- XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
- XCreator creator = selectionModel.getSelection().getSelectedCreator();
- Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator);
- if (creatorContainer != null && creatorContainer != container
- && (selectionModel.getSelection().size() == 1 || container instanceof XWAbsoluteLayout)) {
- HoverPainter painter = AdapterBus.getContainerPainter(designer, container);
- designer.setPainter(painter);
- if (painter != null) {
- Rectangle rect = ComponentUtils.getRelativeBounds(container);
- rect.x -= designer.getArea().getHorizontalValue();
- rect.y -= designer.getArea().getVerticalValue();
- painter.setRenderingBounds(rect);
- painter.setHotspot(new Point(e.getX(), e.getY()));
- painter.setCreator(creator);
- }
- addable = true;
- }
- }
-
- private boolean addBean(XLayoutContainer container, int x, int y) {
- LayoutAdapter adapter = container.getLayoutAdapter();
- Rectangle r = ComponentUtils.getRelativeBounds(container);
- if (selectionModel.getSelection().size() == 1) {
- return adapter.addBean(selectionModel.getSelection().getSelectedCreator(), x
- + designer.getArea().getHorizontalValue() - r.x, y + designer.getArea().getVerticalValue() - r.y);
- }
- for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) {
- adapter.addBean(creator, x + designer.getArea().getHorizontalValue() - r.x, y + designer.getArea().getVerticalValue()- r.y);
- }
- return true;
- }
-
- private void adding(int x, int y) {
- // 当前鼠标所在的组件
- XCreator hoveredComponent = designer.getComponentAt(x, y, selectionModel.getSelection().getSelectedCreators());
-
- // 获取该组件所在的焦点容器
- XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
-
- boolean success = false;
-
- if (container != null) {
- // 如果是容器,则调用其acceptComponent接受组件
- success = addBean(container, x, y);
- }
-
- if (success) {
- FormSelectionUtils.rebuildSelection(designer);
- designer.getEditListenerTable().fireCreatorModified(
- selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED);
- } else {
- Toolkit.getDefaultToolkit().beep();
- }
-
- // 取消提示
- designer.setPainter(null);
- }
-
- /**
- *是否拖拽
- * @return dragging状态
- */
- public boolean isDragging() {
- return dragging;
- }
-
- /**
- *是否可以开始画线
- * @return startPoint不为空返回true
- */
- public boolean prepareForDrawLining() {
- return startPoint != null;
- }
-
- /**
- *设置开始位置
- * @param p point位置
- */
- public void setStartPoint(Point p) {
- this.startPoint = p;
- }
-
- /**
- *返回开始位置
- * @return 点位置
- */
- public Point getStartPoint() {
- return startPoint;
- }
-
- /**
- *返回当前点位置
- * @return 点位置
- */
- public Point getEndPoint() {
- return currentPoint;
- }
-
- /**
- *当前选中组件
- * @param e 鼠标事件
- */
- public void startSelecting(MouseEvent e) {
- selecting = true;
- selectionModel.setHotspotBounds(new Rectangle());
- current_x = getMouseXY(e).x;
- current_y = getMouseXY(e).y;
- }
-
- /**
- *当前鼠标的xy
- * @param e 鼠标事件
- */
- public void startResizing(MouseEvent e) {
- if (!selectionModel.getSelection().isEmpty()) {
- driection.backupBounds(designer);
- }
- current_x = getMouseXY(e).x;
- current_y = getMouseXY(e).y;
- }
-
- /**
- *起始点开始DrawLine
- * @param p 点位置
- */
- public void startDrawLine(Point p) {
- this.startPoint = p;
- if(p != null) {
- try {
- designer.setCursor(XConnector.connectorCursor);
- } catch (Exception e) {
- }
- } else {
- designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- /**
- *鼠标释放时所在的区域及圈中的组件
- * @param e 鼠标事件
- */
- public void selectCreators(MouseEvent e) {
- int x = getMouseXY(e).x;
- int y = getMouseXY(e).y;
-
- Rectangle bounds = createCurrentBounds(x, y);
-
- if ((x != current_x) || (y != current_y)) {
- selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent()));
- }
- selectionModel.setHotspotBounds(null);
- }
-
- /**
- *画所在区域线
- * @param e 鼠标事件
- */
- public void drawLine(MouseEvent e) {
- designer.getDrawLineHelper().setDrawLine(true);
- Point p = designer.getDrawLineHelper().getNearWidgetPoint(e);
- if (p != null) {
- currentPoint = p;
- } else {
- currentPoint.x = e.getX() + designer.getArea().getHorizontalValue();
- currentPoint.y = e.getY() + designer.getArea().getVerticalValue();
- }
- }
-
- private Rectangle createCurrentBounds(int x, int y) {
- Rectangle bounds = new Rectangle();
-
- bounds.x = Math.min(x, current_x);
- bounds.y = Math.min(y, current_y);
- bounds.width = Math.max(x, current_x) - bounds.x;
- bounds.height = Math.max(y, current_y) - bounds.y;
-
- return bounds;
- }
-
- private ArrayList getHotspotCreators(Rectangle selection, XCreator root) {
- ArrayList creators = new ArrayList();
-
- if (!root.isVisible() && !designer.isRoot(root)) {
- return creators;
- }
-
- if (root instanceof XLayoutContainer) {
- XLayoutContainer container = (XLayoutContainer) root;
- int count = container.getXCreatorCount();
- Rectangle clipped = new Rectangle(selection);
-
- for (int i = count - 1; i >= 0; i--) {
- XCreator child = container.getXCreator(i);
-
- if (selection.contains(child.getBounds())) {
- creators.add(child);
- } else {
- clipped.x = selection.x - child.getX();
- clipped.y = selection.y - child.getY();
- creators.addAll(getHotspotCreators(clipped, child));
- }
- }
- }
-
- return creators;
- }
-
-
- /**
- *重置model
- */
- public void resetModel() {
- dragging = false;
- selecting = false;
- }
-
- /**
- *重置
- */
- public void reset() {
- driection = Location.outer;
- dragging = false;
- selecting = false;
- }
-
- /**
- *取消拖拽
- */
- public void draggingCancel() {
- designer.repaint();
- reset();
- }
-
- /**
- *设置可拉伸方向
- * @param dir 拉伸方向
- */
- public void setDirection(Direction dir) {
- if(driection != dir) {
- this.driection = dir;
- driection.updateCursor(designer);
- }
- }
-
- /**
- *x吸附线赋值
- * @param line 线
- */
- public void setXAbsorptionline(Absorptionline line) {
- this.lineInX = line;
- }
-
- /**
- *y吸附线赋值
- * @param line 线
- */
- public void setYAbsorptionline(Absorptionline line) {
- this.lineInY = line;
- }
-
- /**
- * 等距线赋值
- * @param line 线
- */
- public void setEquidistantLine(Absorptionline line){
- this.lineEquidistant = line;
- }
-
- /**
- *画吸附线
- * @param g Graphics类
- */
- public void paintAbsorptionline(Graphics g) {
- if(lineInX != null) {
- lineInX.paint(g,designer.getArea());
- }
- if(lineInY != null) {
- lineInY.paint(g,designer.getArea());
- }
- if(lineEquidistant != null){
- lineEquidistant.paint(g,designer.getArea());
- }
- }
-
- /**
- *拖拽
- * @param e 鼠标事件
- */
- public void dragging(MouseEvent e) {
- checkAddable(e);
- setDependLinePainter(e);
- driection.drag(getMouseXY(e).x-current_x, getMouseXY(e).y-current_y, designer);
- this.dragging = true;
- }
-
- // 拖拽时画依附线用到的painter
- private void setDependLinePainter(MouseEvent e){
- XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
- XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
- XCreator creator = selectionModel.getSelection().getSelectedCreator();
- HoverPainter painter = AdapterBus.getContainerPainter(designer, container);
- designer.setPainter(painter);
- if (painter != null) {
- painter.setHotspot(new Point(e.getX(), e.getY()));
- painter.setCreator(creator);
- }
- }
-
- /**
- *释放捕获
- * @param e 鼠标事件
- */
- public void releaseDragging(MouseEvent e) {
- this.dragging = false;
- if (addable) {
- adding(e.getX(), e.getY());
- } else if (!selectionModel.getSelection().isEmpty()) {
- selectionModel.releaseDragging();
- }
- designer.repaint();
- }
-
- /**
- *改变选择区域
- *
- * @param e 鼠标事件
- */
- public void changeSelection(MouseEvent e) {
- Rectangle bounds = createCurrentBounds(getMouseXY(e).x, getMouseXY(e).y);
- selectionModel.setHotspotBounds(bounds);
- }
-
- /**
- *返回鼠标所在的x、y 考虑滚动条的值
- *
- * @param e 鼠标事件
- * @return xy值
- */
- public Point getMouseXY(MouseEvent e) {
- Point p1 = new Point(e.getX() + designer.getArea().getHorizontalValue(), e.getY()
- + designer.getArea().getVerticalValue());
- return p1;
- }
-
+package com.fr.design.designer.beans.models;
+
+import com.fr.design.beans.location.Absorptionline;
+import com.fr.design.designer.beans.AdapterBus;
+import com.fr.design.designer.beans.HoverPainter;
+import com.fr.design.designer.beans.LayoutAdapter;
+import com.fr.design.designer.beans.events.DesignerEvent;
+import com.fr.design.designer.beans.location.Direction;
+import com.fr.design.designer.beans.location.Location;
+import com.fr.design.designer.creator.*;
+import com.fr.design.mainframe.FormDesigner;
+import com.fr.design.mainframe.FormSelectionUtils;
+import com.fr.design.utils.ComponentUtils;
+
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+
+/**
+ * 普通模式下的状态model
+ */
+public class StateModel {
+ // 对应的selection model
+
+ private SelectionModel selectionModel;
+ // 当前鼠标进入拖拽区域的位置类型
+ private Direction driection;
+
+ // 当前拖拽的起始位置
+ private int currentX;
+ private int currentY;
+
+ //拖拽组件原始位置大小备份
+ private Rectangle selectedPositionBackup;
+
+ private Point startPoint = new Point();
+ private Point currentPoint = new Point();
+
+ private Absorptionline lineInX;
+ private Absorptionline lineInY;
+ //等距线
+ private Absorptionline lineEquidistant;
+
+ // 当前是否处于拖拽选择状态
+ private boolean selecting;
+ private boolean dragging;
+
+ private boolean addable;
+
+ private FormDesigner designer;
+
+ public StateModel(FormDesigner designer) {
+ this.designer = designer;
+ selectionModel = designer.getSelectionModel();
+ }
+
+ /**
+ * 返回direction
+ *
+ * @return direction方向
+ */
+ public Direction getDirection() {
+ return driection;
+ }
+
+ /**
+ * 是否有组件正被选中
+ *
+ * @return true 如果至少一个组件被选中
+ */
+ public boolean isSelecting() {
+ return selecting;
+ }
+
+ /**
+ * 是否能拖拽
+ *
+ * @return 非outer且选中为空
+ */
+ public boolean dragable() {
+ return ((driection != Location.outer) && !selecting);
+ }
+
+ /**
+ * 拖拽中是否可以转换为添加模式:
+ * 如果拖拽组件只有一个,鼠标当前所在位置的最底层表单容器与这个组件的容器不同;
+ * 如果拖拽组件为多个,鼠标当前所在位置的最底层表单容器除了要求要跟这些组件的容器不同外,还必须是绝对定位布局
+ */
+ private void checkAddable(MouseEvent e) {
+ addable = false;
+ designer.setPainter(null);
+
+ if (driection != Location.inner) {
+ return;
+ }
+
+ XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
+ XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
+ XCreator creator = selectionModel.getSelection().getSelectedCreator();
+ Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator);
+ if (creatorContainer != null && creatorContainer != container
+ && (selectionModel.getSelection().size() == 1 || container instanceof XWAbsoluteLayout)) {
+ HoverPainter painter = AdapterBus.getContainerPainter(designer, container);
+ designer.setPainter(painter);
+ if (painter != null) {
+ Rectangle rect = ComponentUtils.getRelativeBounds(container);
+ rect.x -= designer.getArea().getHorizontalValue();
+ rect.y -= designer.getArea().getVerticalValue();
+ painter.setRenderingBounds(rect);
+ painter.setHotspot(new Point(e.getX(), e.getY()));
+ painter.setCreator(creator);
+ }
+ addable = true;
+ }
+ }
+
+ /**
+ * @param container 容器
+ * @param mouseX 鼠标释放位置X
+ * @param mouseY 鼠标释放位置Y
+ * @return 是否成功
+ */
+ private boolean addBean(XLayoutContainer container, int mouseX, int mouseY) {
+ LayoutAdapter adapter = container.getLayoutAdapter();
+ Rectangle rectangleContainer = ComponentUtils.getRelativeBounds(container);
+ if (selectionModel.getSelection().size() == 1) {
+ return adapter.addBean(selectionModel.getSelection().getSelectedCreator(),
+ mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x,
+ mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y);
+ }
+ for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) {
+ adapter.addBean(creator,
+ mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x,
+ mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y);
+ }
+ return true;
+ }
+
+ /**
+ * @param mouseReleasedX 鼠标释放位置X
+ * @param mouseReleasedY 鼠标释放位置Y
+ */
+ private void adding(int mouseReleasedX, int mouseReleasedY) {
+ // 当前鼠标所在的组件
+ XCreator hoveredComponent = designer.getComponentAt(mouseReleasedX, mouseReleasedY, selectionModel.getSelection().getSelectedCreators());
+
+ // 获取该组件所在的焦点容器
+ XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
+
+ boolean success = false;
+
+ if (container != null) {
+ // 如果是容器,则调用其acceptComponent接受组件
+ success = addBean(container, mouseReleasedX, mouseReleasedY);
+ }
+
+ if (success) {
+ FormSelectionUtils.rebuildSelection(designer);
+ designer.getEditListenerTable().fireCreatorModified(
+ selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED);
+ } else {
+ selectionModel.getSelection().setSelectionBounds(selectedPositionBackup, designer);
+ Toolkit.getDefaultToolkit().beep();
+ }
+ // 取消提示
+ designer.setPainter(null);
+ }
+
+ /**
+ * 是否拖拽
+ *
+ * @return dragging状态
+ */
+ public boolean isDragging() {
+ return dragging;
+ }
+
+ /**
+ * 是否可以开始画线
+ *
+ * @return startPoint不为空返回true
+ */
+ public boolean prepareForDrawLining() {
+ return startPoint != null;
+ }
+
+ /**
+ * 设置开始位置
+ *
+ * @param p point位置
+ */
+ public void setStartPoint(Point p) {
+ this.startPoint = p;
+ }
+
+ /**
+ * 返回开始位置
+ *
+ * @return 点位置
+ */
+ public Point getStartPoint() {
+ return startPoint;
+ }
+
+ /**
+ * 返回当前点位置
+ *
+ * @return 点位置
+ */
+ public Point getEndPoint() {
+ return currentPoint;
+ }
+
+ /**
+ * 当前选中组件
+ *
+ * @param e 鼠标事件
+ */
+ public void startSelecting(MouseEvent e) {
+ selecting = true;
+ selectionModel.setHotspotBounds(new Rectangle());
+ currentX = getMouseXY(e).x;
+ currentY = getMouseXY(e).y;
+ }
+
+ /**
+ * 当前鼠标的xy
+ *
+ * @param e 鼠标事件
+ */
+ public void startResizing(MouseEvent e) {
+ if (!selectionModel.getSelection().isEmpty()) {
+ driection.backupBounds(designer);
+ }
+ currentX = getMouseXY(e).x;
+ currentY = getMouseXY(e).y;
+ }
+
+ /**
+ * 起始点开始DrawLine
+ *
+ * @param p 点位置
+ */
+ public void startDrawLine(Point p) {
+ this.startPoint = p;
+ if (p != null) {
+ try {
+ designer.setCursor(XConnector.connectorCursor);
+ } catch (Exception e) {
+ }
+ } else {
+ designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ /**
+ * 鼠标释放时所在的区域及圈中的组件
+ *
+ * @param e 鼠标事件
+ */
+ public void selectCreators(MouseEvent e) {
+ int x = getMouseXY(e).x;
+ int y = getMouseXY(e).y;
+
+ Rectangle bounds = createCurrentBounds(x, y);
+
+ if ((x != currentX) || (y != currentY)) {
+ selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent()));
+ }
+ selectionModel.setHotspotBounds(null);
+ }
+
+ /**
+ * 画所在区域线
+ *
+ * @param e 鼠标事件
+ */
+ public void drawLine(MouseEvent e) {
+ designer.getDrawLineHelper().setDrawLine(true);
+ Point p = designer.getDrawLineHelper().getNearWidgetPoint(e);
+ if (p != null) {
+ currentPoint = p;
+ } else {
+ currentPoint.x = e.getX() + designer.getArea().getHorizontalValue();
+ currentPoint.y = e.getY() + designer.getArea().getVerticalValue();
+ }
+ }
+
+ private Rectangle createCurrentBounds(int x, int y) {
+ Rectangle bounds = new Rectangle();
+
+ bounds.x = Math.min(x, currentX);
+ bounds.y = Math.min(y, currentY);
+ bounds.width = Math.max(x, currentX) - bounds.x;
+ bounds.height = Math.max(y, currentY) - bounds.y;
+
+ return bounds;
+ }
+
+ private ArrayList