Browse Source

Merge pull request #290 in DESIGN/design from release/10.0 to 10.0

* commit '20f439b7f27dbdc0924a723d2d071dacc2551c5b': (38 commits)
  REPORT-10202 没用的监听,删了
  CORE-116 继续改国际化规范
  无JIRA任务,表单添加参数面板后,水印错位
  REPORT-9652 优化一下,减少RPC和数据库访问次数 【10.0二轮回归】部署集成-集群-大数据量模板加载时文件夹显示异常
  REPORT-10160 10.0冒烟 Mac设计器启动, 字体糊了
  REPORT-10181【10.0插件】设计器插件管理这里插件的详细信息jar包显示不全
  无JIRA任务 打包
  CHART-2699 类型选择弹出框的图表 用图片
  CHART-2699 类型选择弹出框的图表 用图片
  REPORT-10159
  REPORT-10159
  REPORT-10185【10.0二轮回归】 远程设计特卡
  rt
  REPORT-9819 【10.0二轮回归】alphafine搜索模板打开后,再次搜索会增加多个重复模板的搜索结果
  REPORT-9511【设计器】表单从自适应布局切换到绝对布局,绝对画布块的宽度不能修改
  REPORT-10049【10.0二轮回归】设计器右上角登录后,重启仍然显示未登录,打开一下设计器插件管理才出来
  rt
  rt
  REPORT-9819 【10.0二轮回归】alphafine搜索模板打开后,再次搜索会增加多个重复模板的搜索结果
  代码质量
  ...
master
neil 7 years ago
parent
commit
bfa179753d
  1. 143
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 4
      designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java
  3. 84
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  4. 15
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  5. 30
      designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java
  6. 3
      designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java
  7. 2
      designer-base/src/main/java/com/fr/design/actions/help/WebDemoAction.java
  8. 2
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  9. 8
      designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java
  10. 2
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  11. 2
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java
  12. 3
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  13. 48
      designer-base/src/main/java/com/fr/design/formula/FunctionNAD.java
  14. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/ObjectJControlPane.java
  15. 13
      designer-base/src/main/java/com/fr/design/gui/frpane/LoadingBasicPane.java
  16. 25
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  17. 46
      designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java
  18. 20
      designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java
  19. 7
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  20. 70
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  21. 47
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  22. 30
      designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java
  23. 2
      designer-base/src/main/java/com/fr/file/FileNodeFILE.java
  24. 23
      designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java
  25. 11
      designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java
  26. 82
      designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java
  27. 9
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  28. 5
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  29. 418
      designer-form/src/main/java/com/fr/design/mainframe/MobileParaWidgetTable.java
  30. 353
      designer-form/src/main/java/com/fr/design/mainframe/MobileWidgetTable.java
  31. 3
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java
  32. 11
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  33. 18
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteLayoutDefinePane.java
  34. 24
      designer-realize/src/main/java/com/fr/design/condition/PaddingPane.java
  35. 41
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  36. 186
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  37. 31
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java
  38. 30
      designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java
  39. 14
      designer-realize/src/main/java/com/fr/design/webattr/ReportWriteAttrPane.java
  40. 15
      designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java
  41. 5
      designer-realize/src/main/java/com/fr/start/Designer.java
  42. 5
      designer-realize/src/main/java/com/fr/start/SplashContext.java
  43. 2
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java
  44. 2
      designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

143
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -8,21 +8,23 @@ import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.style.color.ColorSelectConfigManager;
import com.fr.design.utils.DesignUtils;
import com.fr.file.FILEFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
import com.fr.stable.Constants;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.ListMap;
@ -37,12 +39,12 @@ import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.connect.AuthException;
import javax.swing.SwingWorker;
import javax.swing.*;
import javax.swing.SwingWorker.StateValue;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
@ -107,7 +109,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private Color paginationLineColor = Color.black; // line color of paper
private boolean supportCellEditorDef = false;
private boolean isDragPermited = false;
private int language;
private Locale language = Locale.SIMPLIFIED_CHINESE;
//2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容
private boolean useOracleSystemSpace = true;
private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT;
@ -549,7 +551,18 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
return;
}
try {
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(getDefaultConfig()));
final String envName = getDefaultEnvName();
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(getDefaultConfig()), new WorkContextCallback() {
@Override
public void done() {
DesignerEnvManager.getEnvManager().setCurEnvName(envName);
DesignUtils.refreshDesignerFrame();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea();
DesignTableDataManager.fireDSChanged(new HashMap<String, String>());
}
});
} catch (AuthException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
@ -698,37 +711,15 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/**
* 返回语言类型
*/
public int getLanguage() {
return this.language;
}
/**
* 返回语言类型
*/
public Locale getLocale() {
// 性能
if (language <= 1) {
return Locale.CHINA;
}
Locale[] locales = supportLocale();
if (language <= locales.length) {
return locales[language - 1];
}
return Locale.CHINA;
}
// 当前系统支持的语言
protected Locale[] supportLocale() {
Inter.getInstance();
Map<Locale, String> languageMap = InterProviderFactory.getProvider().getSupportLocaleMap();
return languageMap.keySet().toArray(new Locale[languageMap.size()]);
public Locale getLanguage() {
return language;
}
/**
* 设置语言参数
*/
public void setLanguage(int i) {
this.language = i;
public void setLanguage(Locale locale) {
this.language = locale;
}
/**
@ -1295,7 +1286,34 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void readLanguage(XMLableReader reader) {
String tmpVal;
if ((tmpVal = reader.getElementValue()) != null) {
this.setLanguage(Integer.parseInt(tmpVal));
if (!CommonUtils.isNumber(tmpVal)) {
setLanguage(CommonUtils.stringToLocale(tmpVal));
} else {
// 用于兼容10.0之前的版本
int value = Integer.parseInt(tmpVal);
switch (value) {
case 0:
setLanguage(Locale.SIMPLIFIED_CHINESE);
break;
case 1:
setLanguage(Locale.US);
break;
case 2:
setLanguage(Locale.JAPAN);
break;
case 3:
setLanguage(Locale.TRADITIONAL_CHINESE);
break;
case 4:
setLanguage(Locale.KOREA);
break;
case 5:
setLanguage(new Locale("pt", "PT"));
break;
default:
setLanguage(Locale.SIMPLIFIED_CHINESE);
}
}
}
}
@ -1353,6 +1371,34 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
reader.readXMLObject(this.configManager);
}
public String getUUID() {
return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid;
}
public int getActiveKeyStatus() {
return activeKeyStatus;
}
public void setActiveKeyStatus(int activeKeyStatus) {
this.activeKeyStatus = activeKeyStatus;
}
public AlphaFineConfigManager getAlphaFineConfigManager() {
return alphaFineConfigManager;
}
public void setAlphaFineConfigManager(AlphaFineConfigManager alphaFineConfigManager) {
this.alphaFineConfigManager = alphaFineConfigManager;
}
public boolean isImageCompress() {
return imageCompress;
}
public void setImageCompress(boolean imageCompress) {
this.imageCompress = imageCompress;
}
/**
* Read XML.<br>
* The method will be invoked when read data from XML file.<br>
@ -1625,17 +1671,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
}
public String getUUID() {
return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid;
}
public int getActiveKeyStatus() {
return activeKeyStatus;
}
public void setActiveKeyStatus(int activeKeyStatus) {
this.activeKeyStatus = activeKeyStatus;
}
//写入uuid
private void writeUUID(XMLPrintWriter writer) {
@ -1799,7 +1834,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writer.textNode("" + this.lastOpenFilePath);
writer.end();
writer.startTAG("Language").textNode(String.valueOf(this.language)).end()
writer.startTAG("Language").textNode(CommonUtils.localeToString(language)).end()
.startTAG("JettyServerPort").textNode(String.valueOf(this.jettyServerPort)).end();
}
@ -1852,20 +1887,4 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
.end();
}
public AlphaFineConfigManager getAlphaFineConfigManager() {
return alphaFineConfigManager;
}
public void setAlphaFineConfigManager(AlphaFineConfigManager alphaFineConfigManager) {
this.alphaFineConfigManager = alphaFineConfigManager;
}
public boolean isImageCompress() {
return imageCompress;
}
public void setImageCompress(boolean imageCompress) {
this.imageCompress = imageCompress;
}
}

4
designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java

@ -4,8 +4,8 @@ import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
@ -33,7 +33,7 @@ public class VideoAction extends UpdateAction
public void actionPerformed(ActionEvent arg0)
{
String url;
if (FRContext.getLocale().equals(Locale.US)) {
if (GeneralContext.getLocale().equals(Locale.US)) {
url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en");
} else {
url = CloudCenter.getInstance().acquireUrlByKind("bbs.video");

84
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -12,6 +12,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIDictionaryComboBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
@ -23,7 +24,6 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.log.Log4jConfig;
import com.fr.locale.InterProviderFactory;
import com.fr.third.apache.log4j.Level;
@ -32,14 +32,11 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Map;
@ -87,9 +84,7 @@ public class PreferencePane extends BasicPane {
private static final String DISPLAY_MINUS = "-";
private static final Level[] LOG = {Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG};
private static java.util.List<String> LANGUAGE = new ArrayList<>();
private static int designerEnvLanguageIndex; // 打开设置对话框时,设计器使用的语言
private boolean languageChanged; // 是否修改了设计器语言设置
//设置是否支持undo
private UICheckBox supportUndoCheckBox;
@ -114,7 +109,8 @@ public class PreferencePane extends BasicPane {
private UITextField logExportDirectoryField;
private UIComboBox logLevelComboBox, languageComboBox, pageLengthComboBox, reportLengthComboBox;
private UIComboBox logLevelComboBox, pageLengthComboBox, reportLengthComboBox;
private UIDictionaryComboBox<Locale> languageComboBox;
private IntegerEditor portEditor;
private UITextField jdkHomeTextField;
private UICheckBox oracleSpace;
@ -123,18 +119,8 @@ public class PreferencePane extends BasicPane {
public PreferencePane() {
this.initComponents();
this.initLanguageItems();
}
// 语言选项
private void initLanguageItems() {
LANGUAGE.clear();
Map<Locale, String> map = InterProviderFactory.getProvider().getSupportLocaleMap();
LANGUAGE.add(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Language_Default"));
for (Locale locale : map.keySet()) {
LANGUAGE.add(getLocaledLanguage(map.get(locale), locale));
}
}
protected void initComponents() {
JPanel contentPane = this;
@ -182,13 +168,6 @@ public class PreferencePane extends BasicPane {
advancePane.add(spaceUpPane);
}
private static String getLocaledLanguage(String key, Locale locale) {
StringBuilder sb = new StringBuilder();
sb.append(com.fr.design.i18n.Toolkit.i18nText(key)).append("(");
sb.append(com.fr.design.i18n.Toolkit.i18nText(key)).append(")");
return sb.toString();
}
private void createFunctionPane(JPanel generalPane) {
JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference-Function"));
generalPane.add(functionPane);
@ -379,8 +358,9 @@ public class PreferencePane extends BasicPane {
JPanel LanguagePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Choose_Language"));
generalPane.add(languageAndDashBoard_pane);
languageAndDashBoard_pane.add(LanguagePane);
languageComboBox = new UIComboBox(LANGUAGE.toArray());
languageComboBox.setFont(FRFont.getInstance("Dialog", Font.PLAIN, 12));//为了在中文系统中显示韩文
languageComboBox = createLanguageComboBox();
ActionLabel languageLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Designer_Language"));
languageLabel.addActionListener(new ActionListener() {
@Override
@ -402,16 +382,26 @@ public class PreferencePane extends BasicPane {
Component[][] components = {
{languageLabel, languageComboBox, noticeLabel},
};
languageComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
//Inter.fr = ResourceBundle.getBundle("com/fr/general/locale/fr", Locale.US);
}
});
JPanel choosePane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
LanguagePane.add(choosePane);
}
private UIDictionaryComboBox<Locale> createLanguageComboBox() {
Map<Locale, String> map = InterProviderFactory.getProvider().getSupportLocaleMap();
int size = map.size();
Locale[] keys = new Locale[size];
String[] values = new String[size];
int i = 0;
for (Map.Entry<Locale, String> entry : map.entrySet()) {
keys[i] = entry.getKey();
values[i] = com.fr.design.i18n.Toolkit.i18nText(entry.getValue());
i++;
}
UIDictionaryComboBox<Locale> languageComboBox = new UIDictionaryComboBox<>(keys, values);
languageComboBox.setFont(FRFont.getInstance("Dialog", Font.PLAIN, 12));//为了在中文系统中显示韩文
return languageComboBox;
}
private String getDisplayShortCut(String shotrCut) {
return shotrCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH)
.replace(CONTROL, DISPLAY_CONTROL).replace(OPEN_BRACKET, DISPLAY_OPEN_BRACKET).replace(CLOSE_BRACKET, DISPLAY_CLOSE_BRACKET)
@ -506,7 +496,7 @@ public class PreferencePane extends BasicPane {
JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference_CachingTemplate"));
UILabel memoryLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference_MaxCachingTemplate"));
UILabel memoryTipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Preference_CachingTemplateTip"));
memoryTipLabel.setBorder(BorderFactory.createEmptyBorder( 0, CACHING_GAP, 0, 0));
memoryTipLabel.setBorder(BorderFactory.createEmptyBorder(0, CACHING_GAP, 0, 0));
cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT);
JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
memorySpace.add(memoryLabel);
@ -564,8 +554,8 @@ public class PreferencePane extends BasicPane {
this.logLevelComboBox.setSelectedItem(Log4jConfig.getInstance().getRootLevel());
this.languageComboBox.setSelectedItem(LANGUAGE.get(designerEnvManager.getLanguage()));
designerEnvLanguageIndex = designerEnvManager.getLanguage();
this.languageComboBox.setSelectedItem(designerEnvManager.getLanguage());
this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit());
this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit());
@ -625,7 +615,7 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setPaginationLineColor(paginationLineColorTBButton.getColor());
designerEnvManager.setLanguage(getLanguageInt());
designerEnvManager.setLanguage(languageComboBox.getSelectedItem());
designerEnvManager.setPageLengthUnit((short) pageLengthComboBox.getSelectedIndex());
designerEnvManager.setReportLengthUnit((short) reportLengthComboBox.getSelectedIndex());
@ -637,7 +627,6 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected());
// designerEnvManager.setAutoBackUp(this.autoBackUp.isSelected());
designerEnvManager.setUndoLimit(maxUndoLimit.getSelectedIndex() * SELECTED_INDEX_5);
if (maxUndoLimit.getSelectedIndex() == SELECTED_INDEX_5) {
@ -648,21 +637,6 @@ public class PreferencePane extends BasicPane {
}
/*
* 得到所选语言的int值
*/
private int getLanguageInt() {
int l = 0;
String lang = (String) this.languageComboBox.getSelectedItem();
for (int i = 0; i < LANGUAGE.size(); i++) {
if (ComparatorUtils.equals(lang, LANGUAGE.get(i))) {
l = i;
break;
}
}
return l;
}
// 如果语言设置改变了,则显示重启对话框
public void showRestartDialog() {
@ -689,11 +663,7 @@ public class PreferencePane extends BasicPane {
return showWindow(window, new DialogActionAdapter() {
@Override
public void doOk() {
if (languageComboBox.getSelectedIndex() != designerEnvLanguageIndex) {
languageChanged = true;
} else {
languageChanged = false;
}
languageChanged = !ComparatorUtils.equals(languageComboBox.getSelectedItem(), DesignerEnvManager.getEnvManager(false).getLanguage());
}
});
}

15
designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java

@ -9,14 +9,10 @@ import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.utils.DesignUtils;
import com.fr.general.GeneralContext;
import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
@ -36,17 +32,6 @@ public class SwitchExistEnv extends MenuDef {
this.setName(getMenuKeySet().getMenuName());
this.setHasScrollSubMenu(true);
initMenuDef();
JTemplate<?, ?> t = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (t != null) {
GeneralContext.addEnvWillChangedListener(
t.getPath(),
new EnvChangedListener() {
public void envChanged() {
SwitchExistEnv.this.clearShortCuts();
initMenuDef();
}
});
}
}
private void initMenuDef() {

30
designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java

@ -10,8 +10,8 @@ import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.GeneralUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
@ -72,18 +72,18 @@ public class AboutPane extends JPanel {
addPhoneAndQQPane(contentPane);
// 官网
JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Official_Website"), CloudCenter.getInstance().acquireUrlByKind("website." + FRContext.getLocale(), ProductConstants.WEBSITE_URL));
JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Official_Website"), CloudCenter.getInstance().acquireUrlByKind("website." + GeneralContext.getLocale(), ProductConstants.WEBSITE_URL));
// 支持邮箱
String defaultEmail = CloudCenter.getInstance().acquireUrlByKind("support.email", ProductConstants.SUPPORT_EMAIL);
JPanel emailPane = getEmailActionPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Support_Email"), CloudCenter.getInstance().acquireUrlByKind("support.email." + FRContext.getLocale(), defaultEmail));
JPanel emailPane = getEmailActionPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Support_Email"), CloudCenter.getInstance().acquireUrlByKind("support.email." + GeneralContext.getLocale(), defaultEmail));
contentPane.add(urlActionPane);
contentPane.add(emailPane);
if (FRContext.getLocale().equals(Locale.CHINA) || FRContext.getLocale().equals(Locale.TAIWAN)){
if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)) {
contentPane.add(getRemarkPane());
}
}
if (shouldShowThanks()) {
addThankPane(contentPane);
@ -93,13 +93,13 @@ public class AboutPane extends JPanel {
private void addPhoneAndQQPane(JPanel contentPane) {
BoxCenterAligmentPane boxCenterAlignmentPane;
// 英文版不显示服务电话和QQ
if (FRContext.getLocale().equals(Locale.US)) {
if (GeneralContext.getLocale().equals(Locale.US)) {
return;
}
boxCenterAlignmentPane = new BoxCenterAligmentPane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Service_Phone") + CloudCenter.getInstance().acquireUrlByKind("service.phone." + FRContext.getLocale(), COMPANY_TELEPHONE));
contentPane.add(boxCenterAlignmentPane);
// 繁体版不显示QQ
if (FRContext.getLocale().equals(Locale.TAIWAN)) {
if (GeneralContext.getLocale().equals(Locale.TAIWAN)) {
return;
}
boxCenterAlignmentPane = new BoxCenterAligmentPane("QQ: " + CloudCenter.getInstance().acquireUrlByKind("help.qq"));
@ -110,17 +110,17 @@ public class AboutPane extends JPanel {
private boolean shouldShowThanks() {
Locale[] hideLocales = {Locale.US, Locale.KOREA, Locale.JAPAN};
for (Locale loc : hideLocales) {
if (FRContext.getLocale().equals(loc)) {
if (GeneralContext.getLocale().equals(loc)) {
return false;
}
}
return true;
}
private JPanel getRemarkPane(){
String remark = com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_About_Remark_Info",PRESIDENT_PHONE);
private JPanel getRemarkPane() {
String remark = com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_About_Remark_Info", PRESIDENT_PHONE);
UILabel label = new UILabel();
label.setSize(new Dimension(580,30));
label.setSize(new Dimension(580, 30));
//用THML标签进行拼接,以实现自动换行
StringBuilder builder = new StringBuilder("<html>");
@ -139,12 +139,12 @@ public class AboutPane extends JPanel {
break;
}
}
builder.append(chars, start, len-1).append("<br/>");
builder.append(chars, start, len - 1).append("<br/>");
start = start + len - 1;
len = 0;
}
//拼接剩余部分
builder.append(chars, start, remark.length()-start);
builder.append(chars, start, remark.length() - start);
builder.append("</html>");
JPanel jPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
@ -184,7 +184,7 @@ public class AboutPane extends JPanel {
StringUtils.BLANK, ProductConstants.RELEASE_VERSION, BUILD_PREFIX);
}
private JPanel getEmailActionPane(final String desc, final String mailTo){
private JPanel getEmailActionPane(final String desc, final String mailTo) {
ActionLabel emailLabel = new ActionLabel(mailTo);
emailLabel.addActionListener(new ActionListener() {
@ -204,7 +204,7 @@ public class AboutPane extends JPanel {
return panel;
}
private JPanel getURLActionPane(final String desc, final String url){
private JPanel getURLActionPane(final String desc, final String url) {
ActionLabel actionLabel = new ActionLabel(url);
actionLabel.addActionListener(new ActionListener() {
@Override

3
designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java

@ -6,6 +6,7 @@ import com.fr.base.Utils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.http.HttpToolbox;
import com.fr.stable.CommonUtils;
import com.fr.stable.ProductConstants;
@ -78,7 +79,7 @@ public class TutorialAction extends UpdateAction {
// 生成帮助文档 sitecenter key, help.zh_CN.10
protected String createDocKey() {
String locale = FRContext.getLocale().toString();
String locale = GeneralContext.getLocale().toString();
return CommonUtils.join(new String[]{ "help", locale, ProductConstants.MAIN_VERSION }, ".");
}

2
designer-base/src/main/java/com/fr/design/actions/help/WebDemoAction.java

@ -1,6 +1,7 @@
package com.fr.design.actions.help;
import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
@ -23,6 +24,7 @@ public class WebDemoAction extends UpdateAction {
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
ServerStarter.browserDemoURL();
}

2
designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java

@ -103,7 +103,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
}
private boolean isIncludeUnderline(String name) {
return ComparatorUtils.equals(name.indexOf(StoreProcedureAssist.GROUP_MARKER), -1) ? false : true;
return name.contains(StoreProcedureAssist.GROUP_MARKER);
}
/**

8
designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java

@ -6,9 +6,9 @@ package com.fr.design.editor.editor;
import com.fr.base.FRContext;
import com.fr.design.gui.date.UIDatePicker;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.GeneralContext;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
@ -60,9 +60,9 @@ public class DateEditor extends Editor<Date> {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
uiDatePicker = new UIDatePicker();
if (format) {
int dateStyle = (FRContext.getLocale() == Locale.ENGLISH
|| FRContext.getLocale() == Locale.US
|| FRContext.getLocale() == Locale.UK) ? uiDatePicker.STYLE_EN_DATE : uiDatePicker.STYLE_CN_DATE;
int dateStyle = (GeneralContext.getLocale() == Locale.ENGLISH
|| GeneralContext.getLocale() == Locale.US
|| GeneralContext.getLocale() == Locale.UK) ? uiDatePicker.STYLE_EN_DATE : uiDatePicker.STYLE_CN_DATE;
uiDatePicker.setStyle(dateStyle);
uiDatePicker.setEditable(false);
}

2
designer-base/src/main/java/com/fr/design/extra/PluginUtils.java

@ -229,7 +229,7 @@ public class PluginUtils {
jo.put("free", pluginContext.isFree());
jo.put("licDamaged", pluginContext.isLicDamaged());
jo.put("available", pluginContext.isAvailable());
jo.put("leftDays", String.valueOf(pluginContext.getLeftDays()));
jo.put("leftDays", pluginContext.getLeftDays());
jo.put("trial", pluginContext.isOnTrial());
jo.put("deadline", getDeadline(pluginContext));
jo.put("registerFailed", pluginContext.isRegisterFailed());

2
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java

@ -114,7 +114,6 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
GeneralContext.removeEnvWillChangedListener(selected.getPath());
if (contains(selected) == -1) {
return;
}
@ -139,7 +138,6 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
public void closeVirtualSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
GeneralContext.removeEnvWillChangedListener(selected.getPath());
if (contains(selected) == -1) {
return;
}

3
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -20,6 +20,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.parser.FRLexer;
import com.fr.parser.FRParser;
import com.fr.stable.EncodeConstants;
@ -774,7 +775,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
desBuf = getText((TextUserObject) selectedValue, path);
}
} catch (IOException exp) {
FRContext.getLogger().error(exp.getMessage(), exp);
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
}
descriptionTextArea.setText(desBuf.toString());
descriptionTextArea.moveCaretPosition(0);

48
designer-base/src/main/java/com/fr/design/formula/FunctionNAD.java

@ -1,6 +1,6 @@
package com.fr.design.formula;
import com.fr.base.FRContext;
import com.fr.general.GeneralContext;
import com.fr.script.CalculatorEmbeddedFunction;
import com.fr.stable.StringUtils;
import com.fr.stable.script.Function;
@ -10,29 +10,29 @@ import java.util.Locale;
public class FunctionNAD extends AbstractNameAndDescription {
private Function fn;
FunctionNAD(Function fn) {
this.fn = fn;
}
public String getName() {
return fn == null ? StringUtils.EMPTY : fn.getClass().getSimpleName();
}
public String getDesc() {
if (fn == null) {
return StringUtils.EMPTY;
}
Locale locale = FRContext.getLocale();
String describtion = fn.getDescription(locale);
if (describtion.startsWith(CalculatorEmbeddedFunction.LOCALE_PREFIX)) {
// 老的自定义函数兼容, 没有重写getDescription
return Locale.CHINA.equals(locale) ? fn.getCN() : fn.getEN();
}
return describtion;
}
private Function fn;
FunctionNAD(Function fn) {
this.fn = fn;
}
public String getName() {
return fn == null ? StringUtils.EMPTY : fn.getClass().getSimpleName();
}
public String getDesc() {
if (fn == null) {
return StringUtils.EMPTY;
}
Locale locale = GeneralContext.getLocale();
String describtion = fn.getDescription(locale);
if (describtion.startsWith(CalculatorEmbeddedFunction.LOCALE_PREFIX)) {
// 老的自定义函数兼容, 没有重写getDescription
return Locale.CHINA.equals(locale) ? fn.getCN() : fn.getEN();
}
return describtion;
}
@Override
public String searchResult(String keyWord, boolean findDescription) {

7
designer-base/src/main/java/com/fr/design/gui/controlpane/ObjectJControlPane.java

@ -23,7 +23,10 @@ public abstract class ObjectJControlPane extends JListControlPane {
@Override
protected BasicBeanPane createPaneByCreators(NameableCreator creator) {
return Reflect.on(creator.getUpdatePane()).create(object).get();
try {
return Reflect.on(creator.getUpdatePane()).create(object).get();
} catch (Exception e) {
return super.createPaneByCreators(creator);
}
}
}

13
designer-base/src/main/java/com/fr/design/gui/frpane/LoadingBasicPane.java

@ -8,9 +8,13 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.LayoutUtils;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import javax.swing.*;
import java.awt.*;
/**
* @author richer
@ -23,6 +27,10 @@ public abstract class LoadingBasicPane extends BasicPane {
private JProgressBar progressBar;
public LoadingBasicPane() {
initCards();
initPane();
}
protected void initPane(){
new SwingWorker<Integer, Void>() {
@Override
@ -42,6 +50,7 @@ public abstract class LoadingBasicPane extends BasicPane {
}
private void initCards() {
card = new CardLayout();
setLayout(card);

25
designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -179,8 +179,9 @@ public class TemplateFileTree extends EnvFileTree {
@Override
protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) {
FileNode[] fnArray = listFileNodes(treeNode);
return fileNodeArray2TreeNodeArray(fnArray);
}
@ -189,13 +190,14 @@ public class TemplateFileTree extends EnvFileTree {
*/
private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length];
for (int i = 0; i < res.length; i++) {
FileNode fn = fileNodes[i];
res[i] = new ExpandMutableTreeNode(fn);
if (fn.isDirectory()) {
res[i].add(new ExpandMutableTreeNode());
if (isLocal || WorkContext.getCurrent().isRoot()) {
if (isLocal || isRoot) {
res[i].setFullAuthority(true);
} else {
boolean hasFullAuthority = isContained(fn);
@ -203,7 +205,6 @@ public class TemplateFileTree extends EnvFileTree {
}
}
}
return res;
}
@ -222,22 +223,18 @@ public class TemplateFileTree extends EnvFileTree {
String fileName = fileNode.getEnvPath();
String[] auPaths = auPath.split(CoreConstants.SEPARATOR);
String[] nodePaths = fileName.split(CoreConstants.SEPARATOR);
if (auPaths.length == nodePaths.length) {
// 待判断目录是有权限目录或者有权限目录的子目录,全部权限
if (auPaths.length <= nodePaths.length) {
for (int i = 0; i < auPaths.length; i++) {
if (!auPaths[i].equals(nodePaths[i])) {
return false;
}
}
return fileNode.isDirectory();
} else {
int len = Math.min(auPaths.length, nodePaths.length);
for (int i = 0; i < len; i++) {
if (!auPaths[i].equals(nodePaths[i])) {
return false;
}
}
return true;
}
// 其他情况半权限
else {
return false;
}
}
@ -273,6 +270,7 @@ public class TemplateFileTree extends EnvFileTree {
* 求当前TreeNode下所有的FileNode.
*/
private FileNode[] listFileNodes(ExpandMutableTreeNode currentTreeNode) {
if (currentTreeNode == null) {
return new FileNode[0];
}
@ -280,6 +278,7 @@ public class TemplateFileTree extends EnvFileTree {
Object object = currentTreeNode.getUserObject();
if (object instanceof FileNode) {
return this.listFileNodes(((FileNode) object).getEnvPath());
}

46
designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java

@ -20,15 +20,27 @@ import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.event.EventDispatcher;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.ExtraClassManager;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType;
import com.fr.report.fun.VerticalTextProcessor;
import com.fr.report.fun.impl.DefaultVerticalTextProcessor;
import com.fr.stable.Constants;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
@ -103,12 +115,32 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
initOtherComponent();
initAllNames();
indentationUnitProcessor = ExtraDesignClassManager.getInstance().getSingle(IndentationUnitProcessor.MARK_STRING);
if (null == indentationUnitProcessor) {
indentationUnitProcessor = new DefaultIndentationUnitProcessor();
}
addPluginListeners(PluginEventType.AfterRun);
addPluginListeners(PluginEventType.AfterStop);
refreshIndentationUnit();
}
private void addPluginListeners(PluginEventType type) {
EventDispatcher.listen(type, new PluginEventListener() {
@Override
public void on(PluginEvent event) {
refreshIndentationUnit();
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(IndentationUnitProcessor.MARK_STRING);
}
});
}
private void refreshIndentationUnit() {
this.indentationUnitProcessor = ExtraDesignClassManager.getInstance().getSingle(IndentationUnitProcessor.MARK_STRING);
if (null == this.indentationUnitProcessor) {
this.indentationUnitProcessor = new DefaultIndentationUnitProcessor();
}
}
private void initOtherComponent() {
hPaneContainer.add(hAlignmentPane);

20
designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java

@ -13,17 +13,30 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.DesignUtils;
import com.fr.env.EnvListPane;
import com.fr.event.EventDispatcher;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import com.fr.workspace.connect.AuthException;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
@ -132,7 +145,6 @@ public class TemplatePane extends JPanel implements MouseListener {
final String selectedName = envListPane.updateEnvManager();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName);
GeneralContext.fireEnvWillChangeListener();
try {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
if (workspace == null) {

7
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -50,7 +50,6 @@ import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction;
import com.fr.design.utils.ThemeUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime;
import com.fr.plugin.manage.PluginFilter;
@ -224,7 +223,7 @@ public abstract class ToolBarMenuDock {
// 添加帮助菜单
menuList.add(createHelpMenuDef());
if (FRContext.getLocale() == Locale.CHINA || FRContext.getLocale() == Locale.TAIWAN) {
if (GeneralContext.getLocale() == Locale.CHINA || GeneralContext.getLocale() == Locale.TAIWAN) {
// 添加社区菜单
addCommunityMenuDef(menuList);
}
@ -272,7 +271,7 @@ public abstract class ToolBarMenuDock {
}
public void addCommunityMenuDef(java.util.List<MenuDef> menuList) {
Locale locale = FRContext.getLocale();
Locale locale = GeneralContext.getLocale();
Locale[] locales = supportCommunityLocales();
for (int i = 0; i < locales.length; i++) {
if (locale.equals(locales[i])) {
@ -451,7 +450,7 @@ public abstract class ToolBarMenuDock {
java.util.List<ShortCut> shortCuts = new ArrayList<ShortCut>();
shortCuts.add(new WebDemoAction());
// 英文,把 video 和帮助文档放到 Help 下面
if (FRContext.getLocale().equals(Locale.US)) {
if (GeneralContext.getLocale().equals(Locale.US)) {
shortCuts.add(new VideoAction());
shortCuts.add(new TutorialAction());
}

70
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -1,13 +1,9 @@
package com.fr.design.utils;
import com.fr.base.BaseUtils;
import com.fr.base.EnvException;
import com.fr.base.FRContext;
import com.fr.base.FeedBackInfo;
import com.fr.base.ServerConfig;
import com.fr.base.Utils;
import com.fr.base.remote.RemoteDeziConstants;
import com.fr.dav.DavXMLUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.DesignerEnvProcessor;
@ -17,8 +13,6 @@ import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.GeneralContext;
import com.fr.general.http.HttpClient;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CodeUtils;
@ -32,16 +26,12 @@ import javax.swing.*;
import java.awt.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URI;
@ -138,6 +128,7 @@ public class DesignUtils {
String line = null;
while ((line = reader.readLine()) != null) {
if (line.startsWith("demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
ServerStarter.browserDemoURL();
} else if (StringUtils.isNotEmpty(line)) {
File f = new File(line);
@ -235,7 +226,7 @@ public class DesignUtils {
}
//先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整.
Locale designerLocale = FRContext.getLocale();
Locale designerLocale = GeneralContext.getLocale();
String file = com.fr.design.i18n.Toolkit.i18nText("FR-Designer_File");
char displayChar = file.charAt(0);
if (!guiFRFont.canDisplay(displayChar)) {
@ -417,61 +408,6 @@ public class DesignUtils {
* @throws Exception 异常
*/
public static boolean sendFeedBack(FeedBackInfo feedBackInfo) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
// 把tableData写成xml文件到out
DavXMLUtils.writeXMLFeedBackInfo(feedBackInfo, out);
InputStream input = postBytes2ServerB(out.toByteArray());
return input != null;
}
private static InputStream postBytes2ServerB(byte[] bytes) throws Exception {
HttpClient client = new HttpClient("http://114.215.175.35:8080/WebReport/product_advice.jsp");
client.asGet();
client.setContent(bytes);
return execute4InputStream(client);
}
/**
* execute method之后,取返回的inputstream
*/
private static ByteArrayInputStream execute4InputStream(HttpClient client) throws Exception {
int statusCode = client.getResponseCode();
if (statusCode != HttpURLConnection.HTTP_OK) {
throw new EnvException("Method failed: " + statusCode);
}
InputStream in = client.getResponseStream();
if (in == null) {
return null;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
Utils.copyBinaryTo(in, out);
// 看一下传过来的byte[]是不是DesignProcessor.INVALID,如果是的话,就抛Exception
byte[] bytes = out.toByteArray();
// carl:格式一致传中文
String message = new String(bytes, EncodeConstants.ENCODING_UTF_8);
if (ComparatorUtils.equals(message, RemoteDeziConstants.NO_SUCH_RESOURCE)) {
return null;
} else if (ComparatorUtils.equals(message, RemoteDeziConstants.INVALID_USER)) {
throw new EnvException(RemoteDeziConstants.INVALID_USER);
} else if (ComparatorUtils.equals(message, RemoteDeziConstants.FILE_LOCKED)) {
JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("FR-Designer_file-is-locked"));
return null;
} else if (message.startsWith(RemoteDeziConstants.RUNTIME_ERROR_PREFIX)) {
}
return new ByteArrayInputStream(bytes);
} finally {
in.close();
out.close();
client.release();
}
return true;
}
}

47
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -23,7 +23,6 @@ import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;
@ -115,7 +114,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
/**
* 主机位置
*/
private RemoteEnvURL remoteEnvURL = new RemoteEnvURL("");
private RemoteWorkspaceURL remoteWorkspaceURL = new RemoteWorkspaceURL("");
/**
* https 配置面板
*/
@ -189,7 +188,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
fileChooserButton.setEnabled(isHttps);
updateHttpsConfigPanel();
remoteEnvURL.setHttps(isHttps);
remoteWorkspaceURL.setHttps(isHttps);
fillRemoteEnvURLField();
fillIndividualField();
}
@ -267,9 +266,9 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
public void populateBean(RemoteDesignerWorkspaceInfo ob) {
WorkspaceConnection connection = ob.getConnection();
if (connection != null) {
this.remoteEnvURL = Strings.isNullOrEmpty(connection.getUrl())
? RemoteEnvURL.createDefaultURL()
: new RemoteEnvURL(connection.getUrl());
this.remoteWorkspaceURL = Strings.isNullOrEmpty(connection.getUrl())
? RemoteWorkspaceURL.createDefaultURL()
: new RemoteWorkspaceURL(connection.getUrl());
String username = fromNullable(connection.getUserName()).or(StringUtils.EMPTY);
String pwd = fromNullable(connection.getPassword()).or(StringUtils.EMPTY);
String certPath = fromNullable(connection.getCertPath()).or(StringUtils.EMPTY);
@ -280,17 +279,17 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
this.certSecretKeyInput.setText(certSecretKey);
} else {
this.remoteEnvURL = RemoteEnvURL.createDefaultURL();
this.remoteWorkspaceURL = RemoteWorkspaceURL.createDefaultURL();
this.usernameInput.setText(StringUtils.EMPTY);
this.passwordInput.setText(StringUtils.EMPTY);
}
fillRemoteEnvURLField();
fillIndividualField();
httpsCheckbox.setSelected(this.remoteEnvURL.getHttps());
httpsCheckbox.setSelected(this.remoteWorkspaceURL.getHttps());
DesignerEnvManager.getEnvManager().setHttps(this.remoteEnvURL.getHttps());
fileChooserButton.setEnabled(this.remoteEnvURL.getHttps());
DesignerEnvManager.getEnvManager().setHttps(this.remoteWorkspaceURL.getHttps());
fileChooserButton.setEnabled(this.remoteWorkspaceURL.getHttps());
updateHttpsConfigPanel();
@ -299,7 +298,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
@Override
public RemoteDesignerWorkspaceInfo updateBean() {
WorkspaceConnection connection = new WorkspaceConnection(
this.remoteEnvURL.getURL(),
this.remoteWorkspaceURL.getURL(),
this.usernameInput.getText(),
new String(this.passwordInput.getPassword()),
this.certPathInput.getText(),
@ -576,7 +575,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
*/
private void fillRemoteEnvURLField() {
remoteEnvURLInput.getDocument().removeDocumentListener(overallDocListener);
remoteEnvURLInput.setText(remoteEnvURL.getURL());
remoteEnvURLInput.setText(remoteWorkspaceURL.getURL());
remoteEnvURLInput.getDocument().addDocumentListener(overallDocListener);
}
@ -584,14 +583,14 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
* 自动填充子条目输入框
*/
private void fillIndividualField() {
if (remoteEnvURL == null) {
if (remoteWorkspaceURL == null) {
return;
}
disableSubDocListener();
hostNameInput.setText(remoteEnvURL.hasDefaultHostName() ? StringUtils.EMPTY : remoteEnvURL.getHost());
portInput.setText(remoteEnvURL.getPort());
webAppNameInput.setText(remoteEnvURL.getWeb());
servletNameInput.setText(remoteEnvURL.getServlet());
hostNameInput.setText(remoteWorkspaceURL.hasDefaultHostName() ? StringUtils.EMPTY : remoteWorkspaceURL.getHost());
portInput.setText(remoteWorkspaceURL.getPort());
webAppNameInput.setText(remoteWorkspaceURL.getWeb());
servletNameInput.setText(remoteWorkspaceURL.getServlet());
enableSubDocListener();
}
@ -601,11 +600,11 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
String port = portInput.getText();
String web = webAppNameInput.getText();
String servlet = servletNameInput.getText();
remoteEnvURL.setHttps(isHttps);
remoteEnvURL.setHost(host);
remoteEnvURL.setPort(port);
remoteEnvURL.setWeb(web);
remoteEnvURL.setServlet(servlet);
remoteWorkspaceURL.setHttps(isHttps);
remoteWorkspaceURL.setHost(host);
remoteWorkspaceURL.setPort(port);
remoteWorkspaceURL.setWeb(web);
remoteWorkspaceURL.setServlet(servlet);
}
@ -617,10 +616,10 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
}
private void actionURLInputChange() {
remoteEnvURL = new RemoteEnvURL(remoteEnvURLInput.getText());
remoteWorkspaceURL = new RemoteWorkspaceURL(remoteEnvURLInput.getText());
fillIndividualField();
httpsCheckbox.setSelected(remoteEnvURL.getHttps());
httpsCheckbox.setSelected(remoteWorkspaceURL.getHttps());
boolean isHttps = httpsCheckbox.isSelected();
DesignerEnvManager.getEnvManager().setHttps(isHttps);
fileChooserButton.setEnabled(isHttps);

30
designer-base/src/main/java/com/fr/env/RemoteEnvURL.java → designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java vendored

@ -8,7 +8,7 @@ import java.util.Objects;
/**
* @author yaohwu
*/
public class RemoteEnvURL implements FCloneable {
public class RemoteWorkspaceURL implements FCloneable {
/**
* 默认 hostname
@ -17,20 +17,20 @@ public class RemoteEnvURL implements FCloneable {
/**
* 默认 web app name
*/
private static final String DEFAULT_WEB_APP_NAME = "WebReport";
private static final String DEFAULT_WEB_APP_NAME = "webroot";
/**
* 默认 servlet name
*/
private static final String DEFAULT_SERVLET_NAME = "ReportServer";
private static final String DEFAULT_SERVLET_NAME = "decision";
/**
* 默认端口
*/
private static final String DEFAULT_PORT = "8080";
private static final String DEFAULT_PORT = "8075";
private static final String HTTPS = "https://";
private static final String HTTP = "http://";
public static final RemoteEnvURL DEFAULT_URL =
new RemoteEnvURL(
public static final RemoteWorkspaceURL DEFAULT_URL =
new RemoteWorkspaceURL(
false,
DEFAULT_HOST_NAME,
DEFAULT_PORT,
@ -45,12 +45,12 @@ public class RemoteEnvURL implements FCloneable {
/**
* 解析 url 字符串 生成 RemoteEnvURL 对象
* 解析 url 字符串 生成 RemoteWorkspaceURL 对象
* url 字符串格式 (http(s)://)host(:port)/+web/+servlet/+(others)
*
* @param url x:x/x/x/x
*/
public RemoteEnvURL(String url) {
public RemoteWorkspaceURL(String url) {
// 没有写协议名称 默认 使用 http 协议
if (!url.startsWith(HTTPS) && !url.startsWith(HTTP)) {
@ -102,12 +102,12 @@ public class RemoteEnvURL implements FCloneable {
return DEFAULT_HOST_NAME.equals(host);
}
public static RemoteEnvURL createDefaultURL() {
public static RemoteWorkspaceURL createDefaultURL() {
return DEFAULT_URL.clone();
}
public RemoteEnvURL(boolean isHttps, String host, String port, String web, String servlet) {
public RemoteWorkspaceURL(boolean isHttps, String host, String port, String web, String servlet) {
this.isHttps = isHttps;
this.host = host != null ? host.trim() : StringUtils.EMPTY;
this.port = port != null ? port.trim() : StringUtils.EMPTY;
@ -172,7 +172,7 @@ public class RemoteEnvURL implements FCloneable {
if (o == null || getClass() != o.getClass()) {
return false;
}
RemoteEnvURL that = (RemoteEnvURL) o;
RemoteWorkspaceURL that = (RemoteWorkspaceURL) o;
return isHttps == that.isHttps &&
Objects.equals(host, that.host) &&
Objects.equals(port, that.port) &&
@ -188,7 +188,7 @@ public class RemoteEnvURL implements FCloneable {
@Override
public String toString() {
return "RemoteEnvURL{" +
return "RemoteWorkspaceURL{" +
"isHttps=" + isHttps +
", host='" + host + '\'' +
", port='" + port + '\'' +
@ -198,10 +198,10 @@ public class RemoteEnvURL implements FCloneable {
}
@Override
public RemoteEnvURL clone() {
RemoteEnvURL cloned;
public RemoteWorkspaceURL clone() {
RemoteWorkspaceURL cloned;
try {
cloned = (RemoteEnvURL) super.clone();
cloned = (RemoteWorkspaceURL) super.clone();
return cloned;
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable

2
designer-base/src/main/java/com/fr/file/FileNodeFILE.java

@ -219,7 +219,7 @@ public class FileNodeFILE implements FILE {
}
try {
return WorkContext.getWorkResource().createFile(StableUtils.pathJoin(node.getEnvPath(), name));
return WorkContext.getWorkResource().createDirectory(StableUtils.pathJoin(node.getEnvPath(), name));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;

23
designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java

@ -1,33 +1,20 @@
package com.fr.design;
import com.fr.locale.InterProviderFactory;
import junit.framework.TestCase;
import java.util.HashSet;
import java.util.Locale;
public class DesignerEnvManagerTest extends TestCase{
public void testGetLocale() {
DesignerEnvManager envManager = new DesignerEnvManager();
assertEquals("默认值", envManager.getLocale(), Locale.CHINA);
assertEquals("默认值", envManager.getLanguage(), Locale.SIMPLIFIED_CHINESE);
HashSet<Locale> result = new HashSet<>();
Locale[] locales = envManager.supportLocale();
int len = locales.length;
assertEquals(len, InterProviderFactory.getProvider().getSupportLocaleMap().size());
for (int i = 0; i < len; i++) {
envManager.setLanguage(i + 1);
Locale locale = envManager.getLocale();
result.add(locale);
}
assertEquals("每个int都有对应的locale", result.size(), len);
envManager.setLanguage(Locale.US);
assertEquals("上边界", envManager.getLanguage(), Locale.US);
envManager.setLanguage(998);
assertEquals("上边界", envManager.getLocale(), Locale.CHINA);
envManager.setLanguage(-998);
assertEquals("下边界", envManager.getLocale(), Locale.CHINA);
envManager.setLanguage(Locale.SIMPLIFIED_CHINESE);
assertEquals("下边界", envManager.getLanguage(), Locale.SIMPLIFIED_CHINESE);
}
}

11
designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java

@ -13,20 +13,17 @@ public class TutorialActionTest extends TestCase{
TutorialAction action = new TutorialAction();
GeneralContext.setLocale(Locale.US);
String enKey = action.createDocKey();
assertTrue(enKey.indexOf(Locale.US.toString()) != -1);
assertTrue(enKey.indexOf(ProductConstants.MAIN_VERSION) != -1);
assertTrue(enKey.contains(Locale.US.toString()));
assertTrue(enKey.contains(ProductConstants.MAIN_VERSION));
GeneralContext.setLocale(Locale.CHINA);
String zhKey = action.createDocKey();
assertTrue(zhKey.indexOf(Locale.CHINA.toString()) != -1);
assertTrue(zhKey.contains(Locale.CHINA.toString()));
Locale pt = new Locale("pt", "PT");
GeneralContext.setLocale(pt);
String ptKey = action.createDocKey();
assertTrue(ptKey.indexOf(pt.toString()) != -1);
GeneralContext.setLanguage(998);
assertTrue(action.createDocKey().indexOf(Locale.CHINA.toString()) != -1);
assertTrue(ptKey.contains(pt.toString()));
}
public void testServerOnline() {

82
designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java vendored

@ -14,71 +14,71 @@ public class RemoteEnvURLTest {
public void testURLParser() {
String a;
RemoteEnvURL b;
RemoteWorkspaceURL b;
// https or http begin
a = "www.baidu.com:9090/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
Assert.assertFalse(b.getHttps());
a = "http://www.baidu.com:9090/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
Assert.assertFalse(b.getHttps());
a = "https://www.baidu.com:9090/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
Assert.assertTrue(b.getHttps());
// https or http end
// host begin
a = "https://www.baidu.com/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("www.baidu.com", b.getHost());
a = "https://baidu.com/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("baidu.com", b.getHost());
a = "https://192.168.1/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("192.168.1", b.getHost());
a = "https://中文·o((⊙﹏⊙))o囖/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getHost());
a = "https://a.b.c.d.e.f/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a.b.c.d.e.f", b.getHost());
// host end
//port begin
a = "https://www.baidu.com:9090/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("9090", b.getPort());
a = "https://www.baidu.com:/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getPort());
a = "https://www.baidu.com/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getPort());
a = "https://www.baidu.com:kk/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("kk", b.getPort());
a = "https://www.baidu.com:中文·o((⊙﹏⊙))o囖/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getPort());
a = "https://www.baidu.com:中文·o((⊙﹏⊙))o囖";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getPort());
a = "https://www.baidu.com:中文·o((⊙﹏⊙))o囖///////";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getPort());
//port end
@ -86,109 +86,109 @@ public class RemoteEnvURLTest {
//web begin
a = "https://www.baidu.com:9090///";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getWeb());
a = "https://www.baidu.com:9090";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getWeb());
a = "https://www.baidu.com:9090/";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getWeb());
a = "https://www.baidu.com:9090///web///servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("web", b.getWeb());
a = "https://www.baidu.com:9090/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("web", b.getWeb());
a = "https://www.baidu.com:9090/中文·o((⊙﹏⊙))o囖/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getWeb());
a = "https://www.baidu.com:9090/web///servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("web", b.getWeb());
a = "https://www.baidu.com:9090///web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("web", b.getWeb());
//web end
//servlet begin
a = "https://www.baidu.com:9090///web////servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("servlet", b.getServlet());
a = "https://www.baidu.com:9090";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090/";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//web";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//web//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//web/";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//web//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//web/a/";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
a = "https://www.baidu.com:9090//web/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
a = "https://www.baidu.com:9090//web/a//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
a = "https://www.baidu.com:9090//web/中文·o((⊙﹏⊙))o囖//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getServlet());
a = "https://www.baidu.com//web//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com//web/a/";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
a = "https://www.baidu.com//web/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
a = "https://www.baidu.com//web/a//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
// servlet end
//others begin
a = "https://www.baidu.com/web/servlet/ahttps://www.baidu.com/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
Assert.assertTrue(b.getHttps());
assertEquals("www.baidu.com", b.getHost());
assertEquals("", b.getPort());

9
designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java

@ -136,15 +136,6 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
allCharts[i] = rowChart;
}
//异步加载图片
new Thread(new Runnable() {
@Override
public void run() {
initAllChartsDemoImage(allCharts);
}
}).start();
return child;
}

5
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -109,15 +109,13 @@ public class FormDesignerUI extends ComponentUI {
// 当前正在添加的组件
paintAddingBean(g, addingModel);
}
paintWatermark((Graphics2D) g);
}
// 绘制水印
private void paintWatermark(Graphics2D g) {
WatermarkAttr watermark = ReportUtils.getWatermarkFromAttrMarkFile(designer.getTarget());
WatermarkPainter painter = WatermarkPainter.createPainter(watermark, designer.getResolution());
painter.paint(g, 0, designer.getParaHeight(), designer.getArea().getBounds());
painter.paint(g, 0, 0, designer.getArea().getBounds());
}
private int[] getActualLine(int i) {
@ -400,6 +398,7 @@ public class FormDesignerUI extends ComponentUI {
// g.drawImage(img,-designer.getArea().getHorizontalValue(),-designer.getArea().getVerticalValue() + designer.getParaHeight(), (int) (parent.getSize().width*time + designer.getArea().getHorizontalValue()), (int) (parent.getSize().height*time + designer.getArea().getVerticalValue()),null);
designer.paintContent(clipg);
paintWatermark((Graphics2D) clipg);
clipg.dispose();
// 恢复双缓冲

418
designer-form/src/main/java/com/fr/design/mainframe/MobileParaWidgetTable.java

@ -1,418 +0,0 @@
package com.fr.design.mainframe;
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.gui.ilable.UILabel;
import com.fr.design.gui.itable.HeaderRenderer;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.form.ui.Label;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.RoundRectangle2D;
import java.util.EventObject;
/**
* MobileParaWidgetTable主要显示参数面板容器的控件列表与MobileWidgetTable的区别就是该表多了UITextField这一列
* Created with IntelliJ IDEA.
* User: zx
* Date: 14-7-9
* Time: 上午11:26
* Modified by fanglei during 2017/1/22 - 2017/2/
*/
class MobileParaWidgetTable extends JTable {
private FormDesigner designer;
private String[][] cellData;
private String[] headers = {com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Label"), com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Widgetname")};
private static final int WIDGET_TABLE_ROW_HEIGHT = 22;
private static final int UITEXTFIELD_WIDTH = 0;
private static final int GAP = 11;
private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件
private int selectedRow = -1;
private int selectedColumn = -1;
private boolean draging = false;
private void init(FormDesigner designer) {
this.designer = designer;
this.cellData = getData();
this.setTableProperties();
this.setDefaultEditor(Object.class, new MobileCellEditor());
this.setModel(new BeanTableModel());
this.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
TableColumn tc = this.getColumn(this.getColumnName(0));
tc.setMinWidth(UITEXTFIELD_WIDTH);
tc.setMaxWidth(UITEXTFIELD_WIDTH);
tc.setPreferredWidth(UITEXTFIELD_WIDTH);
this.repaint();
this.setDefaultRenderer(Object.class, new MobileWidgetTableCellRenderer());
refreshData();
this.addMouseListener(mouseAdapter);
this.addMouseMotionListener(mouseAdapter);
}
MobileParaWidgetTable(FormDesigner designer) {
init(designer);
add(moveComponent);
}
private void setTableProperties() {
JTableHeader header = getTableHeader();
header.setReorderingAllowed(false);
header.setPreferredSize(new Dimension(0, WIDGET_TABLE_ROW_HEIGHT));
header.setDefaultRenderer(new HeaderRenderer());
this.setRowHeight(WIDGET_TABLE_ROW_HEIGHT);
this.setGridColor(new Color(212, 208, 200));
this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.setColumnSelectionAllowed(false);
this.setRowSelectionAllowed(false);
this.setFillsViewportHeight(true);
}
private MouseAdapter mouseAdapter = new MouseAdapter() {
/**
* 鼠标按下时处理的事件设置当前选中的行列
* @param e
*/
@Override
public void mousePressed(MouseEvent e) {
getInstance().setCellSelected();
}
/**
* 鼠标放开时处理的事件如果是正在拖动则执行换位操作重新绘制属性表如果不是则什么也不做
* @param e
*/
@Override
public void mouseReleased(MouseEvent e) {
if (!draging) {
return;
}
draging = false;
moveComponent.setVisible(false);
int toIndex = e.getY() < GAP ? 0 : (int) Math.rint((e.getY() - GAP) / WIDGET_TABLE_ROW_HEIGHT) + 1;
//当鼠标放开时,将选中的容器调整至新的顺序
((WParameterLayout) designer.getParaComponent().toData()).adjustOrder(selectedRow, toIndex);
//拿取排序后表格数据,然后重绘表格
getInstance().refreshData();
getInstance().repaint();
designer.fireTargetModified();
getInstance().setCellSelected();
}
/**
* 设置鼠标在属性表区域移动时候的事件
* @param e
*/
@Override
public void mouseMoved(MouseEvent e) {
int overColumn = e.getX() < getColumnModel().getColumn(0).getWidth() ? 0 : 1; // 判断当前鼠标在哪一列
int overRow = -1;
for (int i = 0; i < getRowCount(); i++) {
if (e.getY() > i * WIDGET_TABLE_ROW_HEIGHT && e.getY() <= (i + 1) * WIDGET_TABLE_ROW_HEIGHT) {
overRow = i; //判断当前鼠标在哪一行
}
}
//如果鼠标移动到当前选中的行列上面的时候,并且不能在第一列
if (overRow == selectedRow && overColumn == selectedColumn && overColumn != 0) {
//把当前选中的那一列行的光标改成(除了第一列)移动样式MOVE_CURSOR
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
} else {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
/**
* 鼠标拖动事件如果鼠标当前是<code>MOVE_CURSOR</code>状态则执行开始拖动的代码
* 绘制一个<code>moveComponent</code>来跟随鼠标移动
* @param e
*/
@Override
public void mouseDragged(MouseEvent e) {
int width = getColumnModel().getColumn(1).getWidth();
//如果点击选中的是第二列,就可以拖动
if (selectedColumn == 1) {
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
draging = true;
moveComponent.setText(getValueAt(selectedRow, selectedColumn).toString());
moveComponent.setLocation(getColumnModel().getColumn(0).getWidth(), e.getY() - GAP);
moveComponent.setSize(new Dimension(width, WIDGET_TABLE_ROW_HEIGHT));
moveComponent.setVisible(true);
moveComponent.setForeground(Color.lightGray);
moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray));
}
}
/**
* 设置鼠标单击时处理的事件单击第二列的控件列表进入控件属性表
* @param e
*/
@Override
public void mouseClicked(MouseEvent e) {
if (getSelectedRow() != -1 && getSelectedColumn() == 1) {
String widgetName = cellData[getSelectedRow()][getSelectedColumn()];
if (StringUtils.isNotEmpty(widgetName)) {
int count = getEditingDesigner().getParaComponent().getComponentCount();
for (int i = 0; i < count; i++) {
XCreator xCreator = (XCreator) getEditingDesigner().getParaComponent().getComponent(i);
Widget widget = xCreator.toData();
if (!widget.acceptType(Label.class) && ComparatorUtils.equals(widgetName, widget.getWidgetName())) {
//设置选中的component,这句代码控制点击之后跳转到相应component属性表
getEditingDesigner().getSelectionModel().setSelectedCreator(xCreator);
}
}
}
}
}
/**
* 鼠标离开属性表区域事件
* @param e
*/
@Override
public void mouseExited(MouseEvent e) {
draging = false;
moveComponent.setVisible(false);
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
};
public MobileParaWidgetTable getInstance() {
return this;
}
private FormDesigner getEditingDesigner() {
return designer;
}
/**
* 设置当前get到的行列的单元格为选中状态
*/
private void setCellSelected() {
selectedRow = getSelectedRow();
selectedColumn = getSelectedColumn();
if (selectedRow != -1) {
this.setRowSelectionInterval(selectedRow, selectedRow);
}
if (selectedColumn != -1) {
this.setColumnSelectionInterval(selectedColumn, selectedColumn);
}
}
/**
* 重新get排序后的数据
*/
public void refreshData() {
cellData = getData();
}
/**
* 获取参数面板的控件列表
*
* @return String[][] 二维数组[0][0]widgetTag, [0][1]widgetName
*/
private String[][] getData() {
XLayoutContainer paraContainer = designer.getParaComponent();
if (paraContainer == null || !paraContainer.acceptType(XWParameterLayout.class)) {
return new String[0][0];
}
WParameterLayout para = (WParameterLayout) (paraContainer.toData());
return para.getWidgetNameTag();
}
/**
* 自定义的tableRender类
*/
private class MobileWidgetTableCellRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (column == 0) {
UITextField uiTableTextField;
if (getSelectedColumn() == column && getSelectedRow() == row) {
uiTableTextField = new UITableTextField(value.toString());
} else {
uiTableTextField = new UITextField(value.toString());
}
return uiTableTextField;
}
return this;
}
}
/**
* 自定义的tableEditor类
*/
private class MobileCellEditor extends AbstractCellEditor implements TableCellEditor {
UITableTextField uiTableTextField;
MobileCellEditor() {
uiTableTextField = new UITableTextField();
uiTableTextField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent evt) {
stopCellEditing();
designer.fireTargetModified();
}
});
uiTableTextField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
firePropertyChange();
}
@Override
public void removeUpdate(DocumentEvent e) {
firePropertyChange();
}
@Override
public void changedUpdate(DocumentEvent e) {
firePropertyChange();
}
});
}
/**
* cell改变相应的nametag改变
*/
private void firePropertyChange() {
((WParameterLayout) designer.getParaComponent().toData()).add2NameTagMap(uiTableTextField.getText(),
cellData[getSelectedRow()][1]);
((WParameterLayout) designer.getParaComponent().toData()).setNameTagModified(cellData[getSelectedRow()][1],
true);
}
@Override
public Object getCellEditorValue() {
return uiTableTextField.getText();
}
/**
* 双击以编辑, 表示只有双击的情况下才可以编辑
*/
@Override
public boolean isCellEditable(EventObject anEvent) {
return !(anEvent instanceof MouseEvent) || ((MouseEvent) anEvent).getClickCount() >= 2;
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {
uiTableTextField.setText(value.toString());
return uiTableTextField;
}
}
/**
* BeanTableModel类继承DefaultTableModel类指定了表格的表头和内容
*/
private class BeanTableModel extends DefaultTableModel {
BeanTableModel() {
super(cellData, headers);
}
@Override
public int getRowCount() {
return cellData.length;
}
@Override
public int getColumnCount() {
return headers.length;
}
@Override
public Object getValueAt(int row, int column) {
if (row >= getRowCount() || column >= getColumnCount()) {
return null;
}
Object[] rowValue = cellData[row];
if (column > -1 && column < rowValue.length) {
return cellData[row][column];
}
return null;
}
@Override
public String getColumnName(int column) {
if (column == 0) {
return headers[0];
} else {
return headers[1];
}
}
@Override
public void setValueAt(Object aValue, int row, int column) {
if (row >= getRowCount() || column >= getColumnCount()) {
return;
}
if (aValue == null) {
cellData[row][column] = null;
return;
}
cellData[row][column] = aValue.toString();
}
/**
* 是否可编辑 控件标签列可以编辑控件名不可编辑
*
* @param row 行号
* @param column 列号
* @return 是否可编辑
*/
public boolean isCellEditable(int row, int column) {
return column != 1;
}
}
/**
* 继承自JTextField类重写了编辑框的样式
*/
private class UITableTextField extends UITextField {
public UITableTextField() {
super();
}
public UITableTextField(String string) {
super(string);
}
protected void paintBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (this.isFocusOwner()) {
g2d.setStroke(new BasicStroke(1.5f));
} else {
g2d.setStroke(new BasicStroke(1f));
}
RoundRectangle2D.Double rect = new RoundRectangle2D.Double(0, 0, this.getWidth() - 2, this.getHeight() - 2, 4, 4);
g2d.setColor(Color.orange);
g2d.draw(rect);
}
}
}

353
designer-form/src/main/java/com/fr/design/mainframe/MobileWidgetTable.java

@ -1,353 +0,0 @@
package com.fr.design.mainframe;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.*;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.GroupRenderer;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.*;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
/**
* MobileWidgetTable类主要显示各种容器的控件列表bodytab绝对布局快不包括参数面板
* Created with IntelliJ IDEA.
* User: zx
* Date: 14-9-15
* Time: 下午4:52
* Modified by fanglei at 2017/01/23
*/
public class MobileWidgetTable extends JTable {
private FormDesigner designer;
private String[][] cellData;
private String[] headers = {com.fr.design.i18n.Toolkit.i18nText("Form-Widget_Name")};
private static final int WIDGET_TABLE_ROW_HEIGHT = 22;
private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件
private int selectedRow = -1;
private static final int GAP = 11;
private boolean draging = false;
private boolean collapsed = false; // 控件列表是否折叠
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
//第一行渲染成为标题的样子
if (row == 0) {
return new GroupRenderer();
}
return super.getCellRenderer(row, column);
}
public MobileWidgetTable(FormDesigner designer) {
this.designer = designer;
cellData = getData();
this.setTableProperties();
TableModel defaultModel = new BeanTableModel();
this.setModel(defaultModel);
this.repaint();
this.setDefaultRenderer(Object.class, new DefaultTableCellRenderer());
refreshData();
this.addMouseListener(mouseAdapter);
this.addMouseMotionListener(mouseAdapter);
add(moveComponent);
}
private void setTableProperties() {
JTableHeader header = getTableHeader();
header.setReorderingAllowed(false);
header.setPreferredSize(new Dimension(0, 0)); // 隐藏表头
GroupRenderer headerRenderer = new GroupRenderer();
headerRenderer.setPreferredSize(new Dimension(0, 0)); //这行代码隐藏表头。因为要实现折叠效果,表头不好监听事件
headerRenderer.setHorizontalAlignment(JLabel.LEFT);
header.setDefaultRenderer(headerRenderer);
this.setRowHeight(WIDGET_TABLE_ROW_HEIGHT);
this.setGridColor(new Color(212, 208, 200));
this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.setColumnSelectionAllowed(false);
this.setRowSelectionAllowed(false);
this.setFillsViewportHeight(false);
this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
}
private MouseAdapter mouseAdapter = new MouseAdapter() {
/**
* 鼠标按下时处理的事件设置当前选中的行列
* @param e
*/
@Override
public void mousePressed(MouseEvent e) {
getInstance().setCellSelected();
if (selectedRow == 0 && !e.isPopupTrigger() && e.getClickCount() == 1 && e.getX() < WIDGET_TABLE_ROW_HEIGHT / 2) { // 如果是点击在第一行
toggleCollapse();
}
}
/**
* 鼠标放开时处理的事件如果是正在拖动则执行换位操作重新绘制属性表如果不是则什么也不做
* 所谓的换行就是简单的重新拿到一次表格数据然后重新绘制表格
* @param e
*/
@Override
public void mouseReleased(MouseEvent e) {
if (!draging) {
return;
}
draging = false;
moveComponent.setVisible(false);
int toIndex = e.getY() < GAP ? 0 : (int) Math.rint((e.getY() - GAP) / WIDGET_TABLE_ROW_HEIGHT) + 1;
//当鼠标放开时,将选中的容器调整至新的顺序
((WSortLayout) designer.getSelectionModel().getSelection().getSelectedCreator().toData()).adjustOrder(selectedRow - 1, toIndex - 1);
//拿取排序后表格数据,然后重绘表格
getInstance().refreshData();
getInstance().repaint();
designer.fireTargetModified();
getInstance().setCellSelected();
}
/**
* 设置鼠标在属性表区域移动时候的事件
* @param e
*/
@Override
public void mouseMoved(MouseEvent e) {
int overRow = 0;
for (int i = 0; i < getRowCount(); i++) {
if (e.getY() > i * WIDGET_TABLE_ROW_HEIGHT && e.getY() <= (i + 1) * WIDGET_TABLE_ROW_HEIGHT) {
overRow = i; //判断鼠标在哪一行
}
}
//如果鼠标移动到当前选中的行上面的时候
if (overRow == selectedRow && selectedRow > 0) {
//把当前选中的那一行的光标改成(除了第一列)移动样式MOVE_CURSOR
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
} else {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
/**
* 鼠标拖动事件如果鼠标当前是<code>MOVE_CURSOR</code>状态则执行开始拖动的代码
* 绘制一个<code>moveComponent</code>来跟随鼠标移动
* @param e
*/
@Override
public void mouseDragged(MouseEvent e) {
int width = getColumnModel().getColumn(0).getWidth();
//如果当前选中的行的范围是合理的话,就可以拖动
if (selectedRow < getRowCount() && selectedRow > 0) {
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
draging = true;
moveComponent.setText(getValueAt(selectedRow, 0).toString());
moveComponent.setLocation(0, e.getY() - GAP);
moveComponent.setSize(new Dimension(width, WIDGET_TABLE_ROW_HEIGHT));
moveComponent.setVisible(true);
moveComponent.setForeground(Color.lightGray);
moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray));
}
}
/**
* 设置鼠标单击时处理的事件单击控件列表进入控件属性表
* @param e
*/
@Override
public void mouseClicked(MouseEvent e) {
if (selectedRow > 0) {
//当前点击的控件的名字
String widgetName = cellData[selectedRow][0];
if (StringUtils.isNotEmpty(widgetName)) {
//当前选择的容器
XCreator selectedContainer = designer.getSelectionModel().getSelection().getSelectedCreator();
WLayout selectedWidget = (WLayout) selectedContainer.toData();
//当前选择的容器中的控件数量
int count = selectedWidget.getWidgetCount();
for (int i = 0; i < count; i++) {
XCreator xCreator = (XCreator) selectedContainer.getComponent(i);
Widget widget = xCreator.toData();
if (ComparatorUtils.equals(widgetName, widget.getWidgetName())) {
getEditingDesigner().getSelectionModel().setSelectedCreator(xCreator);
}
}
}
} else if (selectedRow == 0) { // 如果是点击在第一行
if (!e.isPopupTrigger() && e.getClickCount() > 1) {
toggleCollapse();
}
}
}
/**
* 鼠标离开属性表区域事件
* @param e
*/
public void mouseExited(MouseEvent e) {
draging = false;
moveComponent.setVisible(false);
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
};
public MobileWidgetTable getInstance() {
return this;
}
public FormDesigner getEditingDesigner() {
return designer;
}
/**
* 设置当前get到的行列的单元格为选中状态
*/
private void setCellSelected() {
selectedRow = getSelectedRow();
if (selectedRow != -1) {
this.setRowSelectionInterval(selectedRow, selectedRow);
this.setColumnSelectionInterval(0, 0);
}
}
/**
* 切换属性组折叠属性true/false
*/
private void toggleCollapse() {
this.setCollapsed(!this.isCollapsed());
//这里获取表格的父控件是为了当表格被折叠了后,装表格的父控件也要相应的重新布局一下
//比如折叠之后表格行数应该比原来的少,占用父容器空间应该小点,不重新布局父容器,表格大小不会改变
Container parent = MobileWidgetTable.this.getParent();
if (parent != null) {
parent.revalidate();
}
repaint();
}
/**
* 重新get排序后的数据
*/
public void refreshData() {
cellData = getData();
}
/**
* 获取选中控件的控件列表
*
* @return String[][] 二维数组[0][0]widgetName
*/
private String[][] getData() {
List<String> mobileWidgetList = new ArrayList<String>();
if (designer.isFormParaDesigner()) {
return new String[0][0];
}
WSortLayout body = (WSortLayout) designer.getRootComponent().toData();
if (body == null) {
return new String[0][0];
}
body.setSorted(false);
if (body.getWidgetCount() > 0 && body.getWidget(0).acceptType(WAbsoluteBodyLayout.class)) {
WAbsoluteBodyLayout absoluteBodyLayout = (WAbsoluteBodyLayout) ((WAbsoluteLayout.BoundsWidget) body.getWidget(0)).getWidget();
mobileWidgetList = absoluteBodyLayout.getOrderedMobileWidgetList();
} else {
mobileWidgetList = body.getOrderedMobileWidgetList();
}
String[][] widgetName = new String[mobileWidgetList.size() + 1][1];
widgetName[0][0] = com.fr.design.i18n.Toolkit.i18nText("FR-Designer_WidgetOrder");
for (int i = 0; i < mobileWidgetList.size(); i++) {
widgetName[i + 1][0] = mobileWidgetList.get(i);
}
body.setSorted(true);
return widgetName;
}
public boolean isCollapsed() {
return collapsed;
}
public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
}
/**
* 自定义的tableEditor类
*/
public class BeanTableModel extends DefaultTableModel {
public BeanTableModel() {
super(cellData, headers);
}
@Override
public int getRowCount() {
if (isCollapsed()) {
return 1;
}
return cellData.length;
}
@Override
public int getColumnCount() {
return 1;
}
@Override
public Object getValueAt(int row, int column) {
if (row >= getRowCount() || column >= getColumnCount()) {
return null;
}
if (row == 0) {
return (isCollapsed() ? "+" : "-") + cellData[row][0];
}
return cellData[row][0];
}
@Override
public String getColumnName(int column) {
return headers[0];
}
@Override
public void setValueAt(Object aValue, int row, int column) {
if (row >= getRowCount() || column >= getColumnCount()) {
return;
}
if (aValue == null) {
cellData[row] = null;
return;
}
cellData[row][0] = aValue.toString();
}
/**
* 是否可编辑
*
* @param row 行号
* @param column 列号
* @return 是否可编辑
*/
public boolean isCellEditable(int row, int column) {
return false;
}
}
}

3
designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java

@ -6,6 +6,7 @@ import com.fr.design.designer.beans.events.DesignerEvent;
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.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
@ -79,7 +80,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane {
public WidgetBoundPane createWidgetBoundPane(XCreator xCreator) {
XLayoutContainer xLayoutContainer = getParent(xCreator);
if (xLayoutContainer == null || xCreator.acceptType(XWParameterLayout.class) || xCreator.acceptType(XWAbsoluteLayout.class)) {
if (xLayoutContainer == null || xCreator.acceptType(XWParameterLayout.class) || xCreator.acceptType(XWAbsoluteBodyLayout.class)) {
return null;
} else if (xLayoutContainer.acceptType(XWAbsoluteLayout.class)) {
return new WidgetAbsoluteBoundPane(xCreator);

11
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java

@ -19,6 +19,7 @@ import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.widget.ui.designer.component.WidgetBoundPane;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
@ -43,6 +44,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
private AccessibleWLayoutBorderStyleEditor borderStyleEditor;
private AccessibleBodyWatermarkEditor watermarkEditor;
private WidgetBoundPane boundPane;
private UIComboBox layoutCombox;
private WBodyLayoutType layoutType = WBodyLayoutType.ABSOLUTE;
@ -54,6 +56,9 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
public void initComponent() {
super.initComponent();
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
boundPane = new WidgetBoundPane(creator);
centerPane.add(boundPane, BorderLayout.CENTER);
borderStyleEditor = new AccessibleWLayoutBorderStyleEditor();
watermarkEditor = new AccessibleBodyWatermarkEditor();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
@ -65,7 +70,8 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
borderPane.add(jPanel, BorderLayout.CENTER);
UIExpandablePane advancedPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Advanced"), 280, 20, borderPane );
this.add(advancedPane, BorderLayout.NORTH);
centerPane.add(advancedPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.NORTH);
}
public JPanel createThirdPane() {
@ -77,7 +83,6 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer-Widget_Scaling_Mode")), comboBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
jPanel.add(northPane, BorderLayout.NORTH);
jPanel.add(centerPane, BorderLayout.CENTER);
// northPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0));
centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 0, 0));
return jPanel;
@ -101,12 +106,14 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
public void populateSubPane(WAbsoluteLayout ob) {
layoutCombox.setSelectedIndex(1);
borderStyleEditor.setValue(ob.getBorderStyle());
boundPane.populate();
watermarkEditor.setValue(ReportUtils.getWatermarkFromAttrMarkFile(getCurrentIOFile()));
}
public WAbsoluteBodyLayout updateSubPane() {
WAbsoluteBodyLayout layout = (WAbsoluteBodyLayout) creator.toData();
boundPane.update();
Item item = (Item) layoutCombox.getSelectedItem();
Object value = item.getValue();
int state = 0;

18
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteLayoutDefinePane.java

@ -12,19 +12,19 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.design.widget.ui.designer.component.WidgetBoundPane;
import com.fr.form.ui.container.WAbsoluteLayout;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* Created by ibm on 2017/8/2.
*/
public class FRAbsoluteLayoutDefinePane extends AbstractDataModify<WAbsoluteLayout> {
protected UIComboBox comboBox;
private WidgetBoundPane boundPane;
public FRAbsoluteLayoutDefinePane(XCreator xCreator) {
super(xCreator);
@ -34,17 +34,13 @@ public class FRAbsoluteLayoutDefinePane extends AbstractDataModify<WAbsoluteLayo
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
boundPane = new WidgetBoundPane(creator);
centerPane.add(boundPane, BorderLayout.NORTH);
initUIComboBox();
JPanel thirdPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel jPanel = createThirdPane();
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
thirdPane.add(jPanel, BorderLayout.CENTER);
UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("FR-Designer-Widget_Area_Scaling"), 280, 20, thirdPane);
centerPane.add(layoutExpandablePane, BorderLayout.CENTER);
this.add(centerPane, BorderLayout.CENTER);
this.add(layoutExpandablePane, BorderLayout.CENTER);
}
public JPanel createThirdPane() {
@ -80,7 +76,6 @@ public class FRAbsoluteLayoutDefinePane extends AbstractDataModify<WAbsoluteLayo
public void populateBean(WAbsoluteLayout ob) {
populateSubPane(ob);
comboBox.setSelectedIndex(ob.getCompState());
boundPane.populate();
}
@ -88,7 +83,6 @@ public class FRAbsoluteLayoutDefinePane extends AbstractDataModify<WAbsoluteLayo
public WAbsoluteLayout updateBean() {
WAbsoluteLayout wAbsoluteLayout = updateSubPane();
wAbsoluteLayout.setCompState(comboBox.getSelectedIndex());
boundPane.update();
return wAbsoluteLayout;
}

24
designer-realize/src/main/java/com/fr/design/condition/PaddingPane.java

@ -7,11 +7,15 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.style.DefaultIndentationUnitProcessor;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.report.cell.cellattr.highlight.HighlightAction;
import com.fr.report.cell.cellattr.highlight.PaddingHighlightAction;
import javax.swing.*;
import javax.swing.SpinnerNumberModel;
/**
* @author richie
@ -45,7 +49,23 @@ public class PaddingPane extends ConditionAttrSingleConditionPane<HighlightActio
this.add(this.paddingScopeComboBox);
this.paddingLeftSpinner.setValue(new Integer(0));
this.paddingRightSpinner.setValue(new Integer(0));
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
refreshIndentationUnit();
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(IndentationUnitProcessor.MARK_STRING);
}
});
refreshIndentationUnit();
}
private void refreshIndentationUnit() {
this.indentationUnitProcessor = ExtraDesignClassManager.getInstance().getSingle(IndentationUnitProcessor.MARK_STRING);
if (null == this.indentationUnitProcessor) {
this.indentationUnitProcessor = new DefaultIndentationUnitProcessor();

41
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -28,10 +28,11 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.design.mainframe.errorinfo.ErrorInfoUploader;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import com.fr.form.main.Form;
import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient;
import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.ImageExporter;
@ -44,11 +45,28 @@ import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.event.DocumentEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.AWTEventListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -761,11 +779,18 @@ public class AlphaFineDialog extends UIDialog {
*
* @param cellModel
*/
private void saveLocalHistory(AlphaCellModel cellModel) {
RecentSearchManager searchManager = RecentSearchManager.getInstance();
searchManager.addModel(storeText, cellModel, cellModel.getSearchCount() + 1);
sendDataToServer(storeText, cellModel);
private void saveLocalHistory(final AlphaCellModel cellModel) {
Thread sendThread = new Thread(new Runnable() {
@Override
public void run() {
RecentSearchManager searchManager = RecentSearchManager.getInstance();
searchManager.addModel(storeText, cellModel);
sendDataToServer(storeText, cellModel);
TemplateInfoCollector.getInstance().sendTemplateInfo();
ErrorInfoUploader.getInstance().sendErrorInfo();
}
});
sendThread.start();
}
/**

186
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
@ -11,21 +12,10 @@ import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
* Created by XiaXiang on 2017/3/27.
@ -40,9 +30,9 @@ public class FileSearchManager implements AlphaFineSearchProvider {
private SearchResult lessModelList;
private SearchResult moreModelList;
private String searchText;
private List<FileNode> fileNodes = null;
private FileNode[] fileNodes = null;
//停止搜索
private boolean stopSearch = false;
//隐藏的搜索功能,可根据特殊的字符标记判断搜索分类
private boolean isContainCpt = true;
private boolean isContainFrm = true;
@ -58,9 +48,6 @@ public class FileSearchManager implements AlphaFineSearchProvider {
return instance;
}
public synchronized static void init() {
}
/**
* 根据文件路径获取文件模型
@ -84,52 +71,52 @@ public class FileSearchManager implements AlphaFineSearchProvider {
lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Templates")));
return lessModelList;
}
fileNodes = new ArrayList<>();
fileNodes = listTpl(ProjectConstants.REPORTLETS_NAME, true);
AlphaFineHelper.checkCancel();
fileNodes = FRContext.getFileNodes().list(ProjectConstants.REPORTLETS_NAME, new FileExtension[]{FileExtension.CPT, FileExtension.FRM}, true);
isContainCpt = true;
isContainFrm = true;
doSearch(this.searchText, true);
if (stopSearch) {
lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Templates"), com.fr.design.i18n.Toolkit.i18nText("FR-Designer_AlphaFine_ShowAll"), true, CellType.FILE));
lessModelList.addAll(filterModelList.subList(0, AlphaFineConstants.SHOW_SIZE));
stopSearch = false;
return this.lessModelList;
}
doSearch(this.searchText);
if (filterModelList.isEmpty()) {
return new SearchResult();
} else if (filterModelList.size() < AlphaFineConstants.SHOW_SIZE + 1) {
lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Templates")));
lessModelList.addAll(filterModelList);
} else {
lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Templates"), com.fr.design.i18n.Toolkit.i18nText("FR-Designer_AlphaFine_ShowAll"), true, CellType.FILE));
lessModelList.addAll(filterModelList.subList(0, AlphaFineConstants.SHOW_SIZE));
moreModelList.addAll(filterModelList.subList(AlphaFineConstants.SHOW_SIZE, filterModelList.size()));
}
lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Templates"), com.fr.design.i18n.Toolkit.i18nText("FR-Designer_AlphaFine_ShowAll"), false, CellType.FILE));
lessModelList.addAll(filterModelList);
return lessModelList;
}
@Override
public SearchResult getMoreSearchResult(String searchText) {
if (moreModelList != null && !moreModelList.isEmpty()) {
return moreModelList;
}
this.filterModelList = new SearchResult();
this.moreModelList = new SearchResult();
AlphaFineHelper.checkCancel();
isContainCpt = true;
isContainFrm = true;
doSearch(this.searchText, false);
moreModelList.addAll(filterModelList.subList(AlphaFineConstants.SHOW_SIZE, filterModelList.size()));
return moreModelList;
}
private void doSearch(String searchText, boolean needMore) {
for (FileNode node : fileNodes) {
boolean isAlreadyContain = false;
isAlreadyContain = searchFile(searchText, node, isAlreadyContain, needMore);
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainFileContent() && node.getLock() == null) {
searchFileContent(searchText, node, isAlreadyContain, needMore);
private void doSearch(String searchText) {
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) {
for (FileNode node : fileNodes) {
if (node.getName().toLowerCase().contains(searchText)) {
FileModel model = new FileModel(node.getName(), node.getEnvPath());
if (!AlphaFineHelper.getFilterResult().contains(model)) {
AlphaFineHelper.checkCancel();
filterModelList.add(model);
}
}
}
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE && stopSearch) {
return;
}
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainFileContent()) {
FileNode[] fileNodes = FRContext.getFileNodes().filterFiles(searchText, ProjectConstants.REPORTLETS_NAME, new FileExtension[]{FileExtension.CPT, FileExtension.FRM}, true);
for (FileNode node : fileNodes) {
FileModel model = new FileModel(node.getName(), node.getEnvPath());
if (!AlphaFineHelper.getFilterResult().contains(model) && !filterModelList.contains(model)) {
AlphaFineHelper.checkCancel();
filterModelList.add(model);
}
}
}
}
@ -144,113 +131,6 @@ public class FileSearchManager implements AlphaFineSearchProvider {
return searchText;
}
/**
* 搜索文件内容
*
* @param searchText
* @param node
* @param isAlreadyContain
*/
private void searchFileContent(String searchText, FileNode node, boolean isAlreadyContain, boolean needMore) {
try {
InputStream inputStream = new ByteArrayInputStream(WorkContext.getWorkResource().readFully(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1))));
InputStreamReader isr = new InputStreamReader(inputStream, "UTF-8");
BufferedReader reader = new BufferedReader(isr);
String line;
int columnNumber;
boolean isFoundInContent = false;
while ((line = reader.readLine()) != null) {
columnNumber = line.toLowerCase().indexOf(searchText);
if (columnNumber != -1) {
isFoundInContent = true;
break;
}
}
if (isFoundInContent && !isAlreadyContain) {
FileModel model = new FileModel(node.getName(), node.getEnvPath());
if (!AlphaFineHelper.getFilterResult().contains(model)) {
AlphaFineHelper.checkCancel();
filterModelList.add(model);
}
if (this.filterModelList.size() > AlphaFineConstants.SHOW_SIZE && needMore) {
stopSearch = true;
}
}
isr.close();
reader.close();
} catch (Exception e) {
FineLoggerFactory.getLogger().error("file read error: " + e.getMessage());
}
}
/**
* 搜索模板
*
* @param searchText
* @param node
* @param isAlreadyContain
* @return
*/
private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain, boolean needMore) {
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) {
if (node.getName().toLowerCase().contains(searchText)) {
FileModel model = new FileModel(node.getName(), node.getEnvPath());
if (!AlphaFineHelper.getFilterResult().contains(model)) {
AlphaFineHelper.checkCancel();
filterModelList.add(model);
}
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE && needMore) {
stopSearch = true;
}
isAlreadyContain = true;
}
}
return isAlreadyContain;
}
/**
* 获取工作目录下所有符合要求的模板
*
* @param rootFilePath
* @param recurse
* @return
*/
private List<FileNode> listTpl(String rootFilePath, boolean recurse) {
List<FileNode> fileNodeList = new ArrayList<FileNode>();
try {
listAll(rootFilePath, fileNodeList, recurse);
} catch (Exception e) {
FRContext.getLogger().error("file search error: " + e.getMessage(), e);
}
return fileNodeList;
}
/**
* 获取当前工作目录下所有模板
*
* @param rootFilePath
* @param nodeList
* @param recurse
* @throws Exception
*/
private void listAll(String rootFilePath, List<FileNode> nodeList, boolean recurse) throws Exception {
FileNode[] fns = FRContext.getFileNodes().list(rootFilePath);
for (int i = 0; i < fns.length; i++) {
FileNode fileNode = fns[i];
if (fileNode.isDirectory()) {
if (recurse) {
listAll(rootFilePath + File.separator + fns[i].getName(), nodeList, true);
} else {
nodeList.add(fns[i]);
}
} else if (isContainCpt && fileNode.isFileType("cpt")) {
nodeList.add(fileNode);
} else if (isContainFrm && fileNode.isFileType("frm")) {
nodeList.add(fileNode);
}
}
}
/**
* 是否包含cpt

31
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.CellModelHelper;
import com.fr.design.mainframe.alphafine.cell.model.ActionModel;
@ -9,7 +10,6 @@ import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.design.mainframe.toolbar.UpdateActionManager;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
@ -18,7 +18,7 @@ import com.fr.third.org.apache.lucene.analysis.Analyzer;
import com.fr.third.org.apache.lucene.analysis.standard.StandardAnalyzer;
import com.fr.third.org.apache.lucene.document.Document;
import com.fr.third.org.apache.lucene.document.Field;
import com.fr.third.org.apache.lucene.document.IntField;
import com.fr.third.org.apache.lucene.document.LongField;
import com.fr.third.org.apache.lucene.document.StringField;
import com.fr.third.org.apache.lucene.index.DirectoryReader;
import com.fr.third.org.apache.lucene.index.IndexReader;
@ -44,7 +44,7 @@ import java.util.List;
* Created by XiaXiang on 2018/1/22.
*/
public class RecentSearchManager implements AlphaFineSearchProvider {
private static final int MAX_SIZE = 3;
private static final int MAX_SIZE = 100;
private static RecentSearchManager instance;
IndexReader indexReader = null;
IndexSearcher indexSearcher = null;
@ -77,8 +77,12 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
recentModelList = getRecentModelList(searchText);
if (recentModelList != null && recentModelList.size() > 0) {
modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_AlphaFine_Latest")));
if (recentModelList.size() > AlphaFineConstants.LATEST_SHOW_SIZE) {
modelList.addAll(recentModelList.subList(0, AlphaFineConstants.LATEST_SHOW_SIZE));
} else {
modelList.addAll(recentModelList);
}
}
modelList.addAll(recentModelList);
return modelList;
}
@ -126,15 +130,14 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
*
* @param searchKey
* @param cellModel
* @param searchCount
*/
public void addModel(String searchKey, AlphaCellModel cellModel, int searchCount) {
public void addModel(String searchKey, AlphaCellModel cellModel) {
try {
initWriter();
Document doc = new Document();
doc.add(new StringField("searchKey", searchKey, Field.Store.YES));
doc.add(new StringField("cellModel", cellModel.ModelToJson().toString(), Field.Store.YES));
doc.add(new IntField("searchCount", searchCount, Field.Store.YES));
doc.add(new LongField("time", System.currentTimeMillis(), Field.Store.YES));
writeDoc(doc);
} catch (JSONException e) {
FineLoggerFactory.getLogger().error("add document error: " + e.getMessage());
@ -170,7 +173,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
IndexSearcher searcher = new IndexSearcher(indexReader);
//构建排序字段
SortField[] sortField = new SortField[1];
sortField[0] = new SortField("searchCount", SortField.Type.INT, true);
sortField[0] = new SortField("time", SortField.Type.LONG, true);
Sort sortKey = new Sort(sortField);
String searchField = "searchKey";
Term term = new Term(searchField, key);
@ -186,13 +189,11 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
UpdateAction action = UpdateActionManager.getUpdateActionManager().getActionByName(model.getName());
if (action != null) {
((ActionModel) model).setAction(action);
recentModelList.add(model);
addModel(model);
}
} else {
recentModelList.add(model);
addModel(model);
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error("local search error: " + e.getMessage());
@ -201,5 +202,11 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
return recentModelList;
}
private void addModel(AlphaCellModel model) {
if (!recentModelList.contains(model)) {
recentModelList.add(model);
}
}
}

30
designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java

@ -4,18 +4,14 @@
package com.fr.design.mainframe.bbs;
import com.fr.base.FRContext;
import com.fr.config.BaseDBEnv;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.DateUtils;
import com.fr.general.GeneralContext;
import com.fr.stable.EnvChangedListener;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
@ -73,7 +69,6 @@ public class UserInfoPane extends BasicPane {
this.userInfoLabel = new UserInfoLabel(this);
this.markUnSignIn();
addEnvChangedListener();
autoPushLoginDialog();
this.add(userInfoLabel, BorderLayout.CENTER);
@ -115,20 +110,13 @@ public class UserInfoPane extends BasicPane {
return StringUtils.EMPTY;
}
private void addEnvChangedListener() {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override
public void envChanged() {
if (BaseDBEnv.isDBEnvAvailable()) {
String username = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isEmpty(username)) {
markUnSignIn();
} else {
markSignIn(username);
}
}
}
});
public void updateBBSUserInfo(){
String username = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isEmpty(username)) {
markUnSignIn();
} else {
markSignIn(username);
}
}
@ -154,7 +142,7 @@ public class UserInfoPane extends BasicPane {
return dayNew - dayOld;
}
} catch (ParseException e) {
FRContext.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage());
}
return 1;
}

14
designer-realize/src/main/java/com/fr/design/webattr/ReportWriteAttrPane.java

@ -11,8 +11,11 @@ import com.fr.design.write.submit.SubmitVisitorListPane;
import com.fr.report.worksheet.WorkSheet;
import com.fr.report.write.ReportWriteAttr;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
public class ReportWriteAttrPane extends LoadingBasicPane {
private SubmitVisitorListPane submiterListPane;
@ -25,6 +28,13 @@ public class ReportWriteAttrPane extends LoadingBasicPane {
}
public ReportWriteAttrPane(ElementCasePane ePane){
this.ePane = ePane;
//REPORT-9958 这边需要赋值后再初始化面板
super.initPane();
}
@Override
protected void initPane(){
}
@Override

15
designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java

@ -1,6 +1,5 @@
package com.fr.start;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ibutton.UIButton;
@ -14,18 +13,12 @@ import com.fr.design.mainframe.ActiveKeyGenerator;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.stable.OperatingSystem;
import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
@ -147,7 +140,7 @@ public class CollectUserInformationDialog extends UIDialog {
private void getKeyAction() {
Locale locale = FRContext.getLocale();
Locale locale = GeneralContext.getLocale();
String url = EN_LOGIN_HTML;
if (ComparatorUtils.equals(locale, Locale.TAIWAN)) {
url = TW_LOGIN_HTML;

5
designer-realize/src/main/java/com/fr/start/Designer.java

@ -150,11 +150,6 @@ public class Designer extends BaseDesigner {
private static SplashStrategy createSplash() {
// 这里可以开接口加载自定义启动画面
if (OperatingSystem.isWindows()) {
return new SplashFx();
} else if (OperatingSystem.isMacOS()) {
return new SplashMac();
}
return new SplashFx();
}

5
designer-realize/src/main/java/com/fr/start/SplashContext.java

@ -1,11 +1,10 @@
package com.fr.start;
import com.fr.base.FRContext;
import com.fr.design.mainframe.bbs.BBSConstants;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.GeneralContext;
import com.fr.module.ModuleEvent;
import com.fr.stable.StringUtils;
@ -135,7 +134,7 @@ public class SplashContext {
private boolean shouldShowThanks() {
Locale[] hideLocales = {Locale.CHINA, Locale.TAIWAN};
for (Locale loc : hideLocales) {
if (FRContext.getLocale().equals(loc)) {
if (GeneralContext.getLocale().equals(loc)) {
return true;
}
}

2
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -43,6 +43,7 @@ import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.actions.NewFormAction;
import com.fr.design.mainframe.bbs.BBSGuestPane;
import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider;
import com.fr.design.mainframe.form.FormElementCaseDesigner;
@ -123,6 +124,7 @@ public class DesignerActivator extends Activator implements Prepare {
preLoadPane();
loadLogAppender();
DesignerSocketIO.update();
UserInfoPane.getInstance().updateBBSUserInfo();
}
private void loadLogAppender() {

2
designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

@ -64,7 +64,7 @@ public class PreStartActivator extends Activator {
private void initLanguage() {
//这两句的位置不能随便调换,因为会影响语言切换的问题
GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLocale());
GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLanguage());
}
@Override

Loading…
Cancel
Save