diff --git a/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java b/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java index 69a68f451..27e7e22ce 100644 --- a/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java +++ b/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java @@ -12,14 +12,22 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import com.fr.base.BaseUtils; +import com.fr.design.fun.CellAttributeProvider; +import com.fr.design.fun.PresentKindProvider; import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.mainframe.cell.CellElementEditPane; +import com.fr.general.GeneralContext; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.Elem; import com.fr.report.elementcase.TemplateElementCase; @@ -34,7 +42,29 @@ import com.fr.report.elementcase.TemplateElementCase; * @since 2012-5-24下午1:50:21 */ public class CellElementPropertyPane extends DockingView { - + + static { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + synchronized (CellElementPropertyPane.class) { + singleton = new CellElementPropertyPane(); + } + } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign, PresentKindProvider.MARK_STRING) || + context.contain(PluginModule.ExtraDesign, CellAttributeProvider.MARK_STRING); + } + }); + } + + public synchronized static CellElementPropertyPane getInstance() { if (singleton == null) { singleton = new CellElementPropertyPane(); diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java b/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java index 98dd3abb4..b6b8e738e 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java @@ -5,6 +5,7 @@ import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.general.IOUtils; import com.fr.stable.StringUtils; import javax.swing.*; @@ -36,6 +37,7 @@ public class ContentCellRender implements ListCellRenderer { AlphaCellModel model = (AlphaCellModel) value; name.setText(model.getName()); String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png"; + name.setIcon(IOUtils.readIcon(iconUrl)); if (model.getType() == CellType.NO_RESULT) { name.setIcon(null); name.setForeground(AlphaFineConstants.MEDIUM_GRAY); diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java b/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java index a03b68a6e..54e9ed15c 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.alphafine.cell.render; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.general.IOUtils; import javax.swing.*; import java.awt.*; @@ -37,8 +38,8 @@ public class TitleCellRender implements ListCellRenderer { panel.add(this.more, BorderLayout.EAST); } if (moreModel.isLoading()) { - ImageIcon imageIcon = new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/loading.gif")); - + ImageIcon imageIcon = (ImageIcon) IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/loading.gif"); + //设置cell的加载动画 imageIcon.setImageObserver(list); UILabel loadingLabel = new UILabel(imageIcon); diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index aebcf227b..18df7363c 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -27,6 +27,7 @@ import com.fr.form.main.Form; import com.fr.form.main.FormIO; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; +import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.general.http.HttpClient; import com.fr.io.TemplateWorkBookIO; @@ -59,17 +60,29 @@ import java.util.concurrent.ExecutionException; * Created by XiaXiang on 2017/3/21. */ public class AlphaFineDialog extends UIDialog { + private static final String ACTION_MARK_SHORT = "k:1 "; + private static final String ACTION_MARK = "k:setting "; + private static final String DOCUMENT_MARK_SHORT = "k:2 "; + private static final String DOCUMENT_MARK = "k:help "; + private static final String FILE_MARK_SHORT = "k:3 "; + private static final String FILE_MARK = "k:reportlets "; + private static final String CPT_MARK = "k:cpt "; + private static final String FRM_MARK = "k:frm "; + private static final String DS_MARK = "k:ds "; + private static final String DS_NAME = "dsname=\""; + private static final String PLUGIN_MARK_SHORT = "k:4 "; + private static final String PLUGIN_MARK = "k:shop "; private AlphaFineTextField searchTextField; @@ -83,8 +96,8 @@ public class AlphaFineDialog extends UIDialog { private SwingWorker searchWorker; //是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下 private boolean forceOpen; - - + + public AlphaFineDialog(Frame parent, boolean forceOpen) { super(parent); this.forceOpen = forceOpen; @@ -92,17 +105,19 @@ public class AlphaFineDialog extends UIDialog { initListener(); initComponents(); } - + /** * 全局快捷键 * * @return */ public static AWTEventListener listener() { + return new AWTEventListener() { - + @Override public void eventDispatched(AWTEvent event) { + if (event instanceof KeyEvent) { KeyEvent e = (KeyEvent) event; KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e); @@ -110,35 +125,39 @@ public class AlphaFineDialog extends UIDialog { if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFinePane.getAlphaFinePane().isVisible()) { doClickAction(); } - + } } }; } - + private static void doClickAction() { + AlphaFineHelper.showAlphaFineDialog(false); } - + /** * 初始化全部组件 */ private void initComponents() { + searchTextField = new AlphaFineTextField("AlphaFine"); searchTextField.setFont(AlphaFineConstants.GREATER_FONT); searchTextField.setBackground(Color.white); searchTextField.setBorderPainted(false); searchTextField.initKeyListener(this); JPanel topPane = new JPanel(new BorderLayout()); - UILabel iconLabel = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigsearch.png"))); + UILabel iconLabel = new UILabel(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/bigsearch.png")); iconLabel.setPreferredSize(AlphaFineConstants.ICON_LABEL_SIZE); iconLabel.setOpaque(true); iconLabel.setBackground(Color.white); topPane.add(iconLabel, BorderLayout.WEST); topPane.add(searchTextField, BorderLayout.CENTER); closeButton = new UIButton() { + @Override public void paintComponent(Graphics g) { + g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); super.paintComponent(g); @@ -146,11 +165,13 @@ public class AlphaFineDialog extends UIDialog { }; closeButton.setContentAreaFilled(false); closeButton.setPreferredSize(AlphaFineConstants.CLOSE_BUTTON_SIZE); - closeButton.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/alphafine_close.png"))); + closeButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/alphafine_close.png")); closeButton.set4ToolbarButton(); closeButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { + dispose(); } }); @@ -161,34 +182,38 @@ public class AlphaFineDialog extends UIDialog { topPane.add(borderLabel, BorderLayout.SOUTH); add(topPane, BorderLayout.CENTER); searchTextField.getDocument().addDocumentListener(new DocumentAdapter() { + @Override protected void textChanged(DocumentEvent e) { + doSearch(searchTextField.getText()); } }); } - + /** * */ private void initProperties() { + setUndecorated(true); addComponentListener(new ComponentHandler()); setSize(AlphaFineConstants.FIELD_SIZE); centerWindow(this); - + } - + /** * 设置面板位置 * * @param win */ private void centerWindow(Window win) { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - + Dimension winSize = win.getSize(); - + if (winSize.height > screenSize.height) { winSize.height = screenSize.height; } @@ -198,7 +223,7 @@ public class AlphaFineDialog extends UIDialog { //这里设置位置:水平居中,竖直偏上 win.setLocation((screenSize.width - winSize.width) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE); } - + // TODO: 2017/5/8 xiaxiang: 窗体圆角setShape()有毛边,重写paint方法可以解决毛边问题,但带来了别的问题,处理比较麻烦,暂用setShape(); // public void paint(Graphics g){ // @@ -210,14 +235,14 @@ public class AlphaFineDialog extends UIDialog { // g2.fillRoundRect(0, 0, getWidth(), getHeight(), 25, 25); // g2.dispose(); // } - + /** * 执行搜索 * * @param text */ private void doSearch(String text) { - + if (StringUtils.isBlank(text) || text.equals("AlphaFine")) { removeSearchResult(); } else if (text.contains("'")) { @@ -225,13 +250,14 @@ public class AlphaFineDialog extends UIDialog { } else { showSearchResult(); } - + } - + /** * 移除搜索结果 */ private void removeSearchResult() { + if (searchResultPane != null) { remove(searchResultPane); searchResultPane = null; @@ -239,7 +265,7 @@ public class AlphaFineDialog extends UIDialog { setSize(AlphaFineConstants.FIELD_SIZE); repaint(); } - + /** * 展示搜索结果 */ @@ -250,11 +276,12 @@ public class AlphaFineDialog extends UIDialog { } initSearchWorker(); } - + /** * 初始化搜索面板 */ private void initSearchResultComponents() { + searchResultList = new JList(); searchListModel = new SearchListModel(new SearchResult()); searchResultList.setModel(searchListModel); @@ -263,7 +290,7 @@ public class AlphaFineDialog extends UIDialog { searchResultPane.setLayout(new BorderLayout()); searchResultList.setCellRenderer(new ContentCellRender()); searchResultList.setFixedCellHeight(AlphaFineConstants.CELL_HEIGHT); - + leftSearchResultPane = new UIScrollPane(searchResultList); leftSearchResultPane.setBackground(Color.white); leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); @@ -276,7 +303,7 @@ public class AlphaFineDialog extends UIDialog { add(searchResultPane, BorderLayout.SOUTH); setSize(AlphaFineConstants.FULL_SIZE); } - + /** * 异步加载搜索结果 */ @@ -288,12 +315,14 @@ public class AlphaFineDialog extends UIDialog { this.searchWorker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { + rebuildList(searchTextField.getText().toLowerCase()); return null; } @Override protected void done() { + if (!isCancelled() && searchListModel.getSize() > 0) { searchResultList.setSelectedIndex(1); showResult(searchResultList.getSelectedIndex(), searchResultList.getSelectedValue()); @@ -302,7 +331,7 @@ public class AlphaFineDialog extends UIDialog { }; this.searchWorker.execute(); } - + /** * 重新构建搜索结果列表 * 先根据输入判断是不是隐藏的搜索功能 @@ -310,6 +339,7 @@ public class AlphaFineDialog extends UIDialog { * @param searchText */ private void rebuildList(String searchText) { + searchListModel.removeAllElements(); if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) { getActionList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); @@ -332,13 +362,14 @@ public class AlphaFineDialog extends UIDialog { } doNormalSearch(searchText.trim()); } - + /** * 普通搜索 * * @param searchText */ private void doNormalSearch(String searchText) { + getRecentList(searchText); getRecommendList(searchText); getActionList(searchText); @@ -346,57 +377,63 @@ public class AlphaFineDialog extends UIDialog { getDocumentList(searchText); getPluginList(searchText); } - + private synchronized void getDocumentList(final String searchText) { + SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); for (Object object : documentModelList) { AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } - + } - + private synchronized void getFileList(final String searchText) { + SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText); for (Object object : fileModelList) { AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } } - + private synchronized void getActionList(final String searchText) { + SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText); for (Object object : actionModelList) { AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } } - + private synchronized void getPluginList(final String searchText) { + SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText); for (Object object : pluginModelList) { AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } } - + private synchronized void getRecommendList(final String searchText) { + SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText); for (Object object : recommendModelList) { AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } } - + private synchronized void getRecentList(final String searchText) { + SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText); for (Object object : recentModelList) { AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } - + } - + /** * 初始化监听器 */ @@ -421,7 +458,7 @@ public class AlphaFineDialog extends UIDialog { } } }); - + /** *单击时触发右侧面板展示搜索结果 */ @@ -434,7 +471,7 @@ public class AlphaFineDialog extends UIDialog { } } }); - + /** * 键盘监听器 */ @@ -539,11 +576,7 @@ public class AlphaFineDialog extends UIDialog { try { bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl())); } catch (IOException e) { - try { - bufferedImage = ImageIO.read(getClass().getResource("/com/fr/design/mainframe/alphafine/images/default_product.png")); - } catch (IOException e1) { - FRLogger.getLogger().error(e.getMessage()); - } + bufferedImage = IOUtils.readImage("/com/fr/design/mainframe/alphafine/images/default_product.png"); } return bufferedImage; } @@ -589,8 +622,8 @@ public class AlphaFineDialog extends UIDialog { private void showDefaultPreviewPane() { rightSearchResultPane.removeAll(); - UILabel label = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/opening.gif"))); - label.setBorder(BorderFactory.createEmptyBorder(120, 0, 0, 0)); + UILabel label = new UILabel(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/opening.gif")); + label.setBorder(BorderFactory.createEmptyBorder(120,0,0,0)); rightSearchResultPane.add(label, BorderLayout.CENTER); validate(); repaint(); @@ -602,23 +635,28 @@ public class AlphaFineDialog extends UIDialog { initMouseListener(); } - + /** * 窗口拖拽 */ private void initMouseListener() { + addMouseMotionListener(new MouseMotionAdapter() { + @Override public void mouseDragged(MouseEvent e) { + doMouseDragged(e); } }); - + addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + doMousePressed(e); } - + }); } @@ -749,7 +787,7 @@ public class AlphaFineDialog extends UIDialog { } } - + /** * 点击显示更多时,添加对应的model到list;点击收起是移除model * @@ -757,6 +795,7 @@ public class AlphaFineDialog extends UIDialog { * @param selectedValue */ private void rebuildShowMoreList(int index, MoreModel selectedValue) { + SearchResult moreResult = getMoreResult(selectedValue); if ((selectedValue).getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"))) { for (int i = 0; i < moreResult.size(); i++) { @@ -765,14 +804,14 @@ public class AlphaFineDialog extends UIDialog { } else { for (int i = 0; i < moreResult.size(); i++) { this.searchListModel.remove(index + AlphaFineConstants.SHOW_SIZE + 1); - + } } this.searchResultList.validate(); this.searchResultList.repaint(); validate(); repaint(); - + } private void rebuildList() { @@ -819,14 +858,16 @@ public class AlphaFineDialog extends UIDialog { public void setSearchWorker(SwingWorker searchWorker) { this.searchWorker = searchWorker; } - - + + public boolean isForceOpen() { + return forceOpen; } - + public void setForceOpen(boolean forceOpen) { + this.forceOpen = forceOpen; } - + } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java b/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java index 121929e09..21d815727 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java @@ -3,6 +3,7 @@ */ package com.fr.design.mainframe.bbs; +import com.fr.general.IOUtils; import com.fr.stable.StringUtils; import java.util.Properties; @@ -43,7 +44,7 @@ public class BBSConstants { if (PROP == null) { PROP = new Properties(); try { - PROP.load(BBSConstants.class.getResourceAsStream("/com/fr/design/mainframe/bbs/bbs.properties")); + PROP.load(IOUtils.getResourceAsStream("/com/fr/design/mainframe/bbs/bbs.properties", BBSConstants.class)); } catch (Exception e) { } } diff --git a/designer/src/com/fr/design/module/DesignerModule.java b/designer/src/com/fr/design/module/DesignerModule.java index 9e0837ac0..12ada2f02 100644 --- a/designer/src/com/fr/design/module/DesignerModule.java +++ b/designer/src/com/fr/design/module/DesignerModule.java @@ -32,7 +32,6 @@ import com.fr.general.xml.GeneralXMLTools; import com.fr.io.importer.Excel2007ReportImporter; import com.fr.io.importer.ExcelReportImporter; import com.fr.main.impl.WorkBook; -import com.fr.plugin.ExtraClassManager; import com.fr.quickeditor.ChartQuickEditor; import com.fr.quickeditor.cellquick.*; import com.fr.quickeditor.floatquick.FloatImageQuickEditor; @@ -47,7 +46,6 @@ import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; import com.fr.stable.bridge.StableFactory; import com.fr.stable.fun.LogProvider; -import com.fr.stable.plugin.PluginSimplify; import com.fr.stable.script.CalculatorProviderContext; import com.fr.stable.script.ValueConverter; import com.fr.stable.web.ServletContext; @@ -99,7 +97,7 @@ public class DesignerModule extends DesignModule { InformationCollector.getInstance().collectStartTime(); ExtraDesignClassManager.getInstance().getFeedback().didFeedback(); - ExtraClassManager.getInstance().addMutable(LogProvider.MARK_STRING, DesignerLogImpl.getInstance(), PluginSimplify.NULL); + StableFactory.registerMarkedObject(LogProvider.MARK_STRING, DesignerLogImpl.getInstance()); } private void registerOtherPane() { @@ -214,7 +212,7 @@ public class DesignerModule extends DesignModule { } }); } - + private static abstract class AbstractWorkBookApp implements App { @Override @@ -236,6 +234,11 @@ public class DesignerModule extends DesignModule { public void process() { } + + @Override + public void undo() { + + } } @Override diff --git a/designer_base/src/com/fr/design/ExtraDesignClassManager.java b/designer_base/src/com/fr/design/ExtraDesignClassManager.java index 72c902821..ee86d8adf 100644 --- a/designer_base/src/com/fr/design/ExtraDesignClassManager.java +++ b/designer_base/src/com/fr/design/ExtraDesignClassManager.java @@ -9,18 +9,18 @@ import com.fr.design.data.datapane.TableDataNameObjectCreator; import com.fr.design.fun.*; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOptionFactory; +import com.fr.design.menu.ShortCut; import com.fr.design.widget.Appearance; import com.fr.form.ui.Widget; import com.fr.general.FRLogger; -import com.fr.general.GeneralContext; import com.fr.general.GeneralUtils; import com.fr.general.IOUtils; -import com.fr.plugin.ExtraXMLFileManager; -import com.fr.stable.EnvChangedListener; +import com.fr.plugin.AbstractExtraClassManager; +import com.fr.plugin.injectable.CompatibleInjectionContainer; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.injectable.PluginSingleInjection; +import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraDesignClassManagerProvider; -import com.fr.stable.plugin.PluginSimplify; -import com.fr.stable.xml.XMLPrintWriter; -import com.fr.stable.xml.XMLableReader; import java.util.*; @@ -29,42 +29,25 @@ import java.util.*; * @since : 8.0 * 用于设计器扩展的管理类 */ -public class ExtraDesignClassManager extends ExtraXMLFileManager implements ExtraDesignClassManagerProvider { - - private static final String XML_TAG = "ExtraDesignClassManager"; - - private static ExtraDesignClassManager classManager; - +public class ExtraDesignClassManager extends AbstractExtraClassManager implements ExtraDesignClassManagerProvider { + + private static ExtraDesignClassManager classManager = new ExtraDesignClassManager(); + + private CompatibleInjectionContainer shortCuts = new CompatibleInjectionContainer<>(); + public synchronized static ExtraDesignClassManager getInstance() { - if (classManager == null) { - classManager = new ExtraDesignClassManager(); - classManager.readXMLFile(); - } - return classManager; } - + static { - GeneralContext.addEnvChangedListener(new EnvChangedListener() { - public void envChanged() { - ExtraDesignClassManager.envChanged(); - } - }); + StableFactory.registerMarkedObject(PluginModule.ExtraDesign.getAgentName(), classManager); } - - - private synchronized static void envChanged() { - classManager = null; - } - - - - + public TableDataNameObjectCreator[] getReportTableDataCreators() { return getKindsOfTableDataCreators(TableDataDefineProvider.XML_TAG); } - - + + /** * 添加serverTDCreators * @@ -73,7 +56,7 @@ public class ExtraDesignClassManager extends ExtraXMLFileManager implements Extr public TableDataNameObjectCreator[] getServerTableDataCreators() { return getKindsOfTableDataCreators(ServerTableDataDefineProvider.XML_TAG); } - + private TableDataNameObjectCreator[] getKindsOfTableDataCreators(String tag) { Set set = getArray(tag); if (set.isEmpty()) { @@ -82,19 +65,19 @@ public class ExtraDesignClassManager extends ExtraXMLFileManager implements Extr List creators = new ArrayList<>(); for (TableDataDefineProvider provider : set) { TableDataNameObjectCreator creator = new TableDataNameObjectCreator( - provider.nameForTableData(), - provider.prefixForTableData(), - provider.iconPathForTableData(), - provider.classForTableData(), - provider.classForInitTableData(), - provider.appearanceForTableData() + provider.nameForTableData(), + provider.prefixForTableData(), + provider.iconPathForTableData(), + provider.classForTableData(), + provider.classForInitTableData(), + provider.appearanceForTableData() ); creators.add(creator); } return creators.toArray(new TableDataNameObjectCreator[creators.size()]); } - - + + public Map, Class> getParameterWidgetOptionsMap() { Map, Class> map = new HashMap<>(); Set set = getArray(ParameterWidgetOptionProvider.XML_TAG); @@ -103,7 +86,7 @@ public class ExtraDesignClassManager extends ExtraXMLFileManager implements Extr } return map; } - + public WidgetOption[] getParameterWidgetOptions() { Set set = getArray(ParameterWidgetOptionProvider.XML_TAG); if (set.isEmpty()) { @@ -112,16 +95,16 @@ public class ExtraDesignClassManager extends ExtraXMLFileManager implements Extr Set result = new HashSet<>(); for (ParameterWidgetOptionProvider provider : set) { WidgetOption option = WidgetOptionFactory.createByWidgetClass( - provider.nameForWidget(), - IOUtils.readIcon(provider.iconPathForWidget()), - provider.classForWidget() + provider.nameForWidget(), + IOUtils.readIcon(provider.iconPathForWidget()), + provider.classForWidget() ); result.add(option); } return result.toArray(new WidgetOption[result.size()]); } - - + + public WidgetOption[] getWebWidgetOptions() { Set set = getArray(ToolbarItemProvider.XML_TAG); if (set.isEmpty()) { @@ -130,17 +113,17 @@ public class ExtraDesignClassManager extends ExtraXMLFileManager implements Extr List list = new ArrayList<>(); for (ToolbarItemProvider provider : set) { WidgetOption option = WidgetOptionFactory.createByWidgetClass( - provider.nameForWidget(), - IOUtils.readIcon(provider.iconPathForWidget()), - provider.classForWidget() + provider.nameForWidget(), + IOUtils.readIcon(provider.iconPathForWidget()), + provider.classForWidget() ); list.add(option); } return list.toArray(new WidgetOption[list.size()]); } - - - + + + public Map, Class> getFormWidgetOptionsMap() { Set set = getArray(FormWidgetOptionProvider.XML_TAG); Map, Class> map = new HashMap<>(); @@ -149,15 +132,15 @@ public class ExtraDesignClassManager extends ExtraXMLFileManager implements Extr } return map; } - + public WidgetOption[] getFormWidgetOptions() { return getFormUnits(false); } - + public WidgetOption[] getFormWidgetContainerOptions() { return getFormUnits(true); } - + private WidgetOption[] getFormUnits(boolean isContainer) { Set set = getArray(FormWidgetOptionProvider.XML_TAG); if (set.isEmpty()) { @@ -167,18 +150,18 @@ public class ExtraDesignClassManager extends ExtraXMLFileManager implements Extr for (FormWidgetOptionProvider provider : set) { if (provider.isContainer() == isContainer) { WidgetOption option = WidgetOptionFactory.createByWidgetClass( - provider.nameForWidget(), - BaseUtils.readIcon(provider.iconPathForWidget()), - provider.classForWidget() + provider.nameForWidget(), + BaseUtils.readIcon(provider.iconPathForWidget()), + provider.classForWidget() ); result.add(option); } } return result.toArray(new WidgetOption[result.size()]); } - - - + + + public WidgetOption[] getCellWidgetOptions() { Set set = getArray(CellWidgetOptionProvider.XML_TAG); if (set.isEmpty()) { @@ -187,16 +170,16 @@ public class ExtraDesignClassManager extends ExtraXMLFileManager implements Extr Set result = new HashSet<>(); for (CellWidgetOptionProvider provider : set) { WidgetOption option = WidgetOptionFactory.createByWidgetClass( - provider.nameForWidget(), - IOUtils.readIcon(provider.iconPathForWidget()), - provider.classForWidget() + provider.nameForWidget(), + IOUtils.readIcon(provider.iconPathForWidget()), + provider.classForWidget() ); - result.add(option); + result.add(option); } return result.toArray(new WidgetOption[result.size()]); - + } - + public Map, Appearance> getCellWidgetOptionsMap() { Set set = getArray(CellWidgetOptionProvider.XML_TAG); Map, Appearance> map = new HashMap<>(); @@ -205,8 +188,8 @@ public class ExtraDesignClassManager extends ExtraXMLFileManager implements Extr } return map; } - - + + public Feedback getFeedback() { try { Class clazz = GeneralUtils.classForName("com.fr.design.feedback.CurrentFeedback"); @@ -218,34 +201,29 @@ public class ExtraDesignClassManager extends ExtraXMLFileManager implements Extr } return Feedback.EMPTY; } - - /** - * 文件名 - * - * @return 文件名 - */ + @Override - public String fileName() { - return "designer.xml"; + protected boolean demountSpecific(PluginSingleInjection injection) { + + if (ShortCut.TEMPLATE_TREE.equals(injection.getName()) && injection.getOriginalObject() instanceof ShortCut) { + shortCuts.remove(injection.getObject()); + return true; + } + return false; } - - /** - * 读xml - * - * @param reader xml对象 - */ - public void readXML(XMLableReader reader) { - readXML(reader, null, PluginSimplify.NULL); + + @Override + protected boolean mountSpecific(PluginSingleInjection injection) { + + if (ShortCut.TEMPLATE_TREE.equals(injection.getName()) && injection.getOriginalObject() instanceof ShortCut) { + shortCuts.put(injection.getObject(), (ShortCut) injection.getOriginalObject()); + return true; + } + return false; } - - - /** - * 写xml - * - * @param writer xml对象 - */ - public void writeXML(XMLPrintWriter writer) { - writer.startTAG(XML_TAG); - writer.end(); + + public Set getExtraShortCuts() { + + return shortCuts.getSet(); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/actions/UpdateAction.java b/designer_base/src/com/fr/design/actions/UpdateAction.java index 04e8b7fe4..b716da73b 100644 --- a/designer_base/src/com/fr/design/actions/UpdateAction.java +++ b/designer_base/src/com/fr/design/actions/UpdateAction.java @@ -13,6 +13,7 @@ import com.fr.design.gui.imenu.UICheckBoxMenuItem; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.menu.ShortCut; import com.fr.design.selection.SelectionListener; +import com.fr.general.ComparatorUtils; import com.fr.stable.StringUtils; import com.fr.stable.pinyin.PinyinFormat; import com.fr.stable.pinyin.PinyinHelper; @@ -300,8 +301,7 @@ public abstract class UpdateAction extends ShortCut implements Action { if (!(object instanceof UpdateAction)) { return false; } - - return ((UpdateAction) object).getName().equals(this.getName()); + return ComparatorUtils.equals(((UpdateAction) object).getName(), this.getName()); } @Override diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java index c8f5ba317..1507d77b5 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java @@ -14,6 +14,7 @@ import com.fr.design.data.tabledata.wrapper.AbstractTableDataWrapper; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.fun.TableDataDefineProvider; import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; @@ -29,8 +30,12 @@ import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; import com.fr.general.NameObject; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.core.PropertyChangeAdapter; -import com.fr.stable.plugin.PluginReadListener; import javax.swing.*; import java.awt.*; @@ -45,7 +50,8 @@ import java.util.Map; public class TableDataTreePane extends BasicTableDataTreePane { private static TableDataTreePane singleton = new TableDataTreePane(); - + + public static final int PLUGIN_LISTENER_PRIORITY = 1; public synchronized static BasicTableDataTreePane getInstance(DesignModelAdapter tc) { @@ -81,13 +87,22 @@ public class TableDataTreePane extends BasicTableDataTreePane { addMenuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH); createAddMenuDef(); - - GeneralContext.addPluginReadListener(new PluginReadListener() { + + GeneralContext.listenPluginRunningChanged(new PluginEventListener(PLUGIN_LISTENER_PRIORITY) { + @Override - public void success(Status status) { + public void on(PluginEvent event) { + addMenuDef.clearShortCuts(); createAddMenuDef(); } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign, TableDataDefineProvider.XML_TAG); + } }); editAction = new EditAction(); diff --git a/designer_base/src/com/fr/design/data/tabledata/wrapper/TableDataFactory.java b/designer_base/src/com/fr/design/data/tabledata/wrapper/TableDataFactory.java index bc414d1a9..ca118df76 100644 --- a/designer_base/src/com/fr/design/data/tabledata/wrapper/TableDataFactory.java +++ b/designer_base/src/com/fr/design/data/tabledata/wrapper/TableDataFactory.java @@ -5,20 +5,15 @@ import com.fr.base.TableData; import com.fr.data.TableDataSource; import com.fr.data.impl.*; import com.fr.data.impl.storeproc.StoreProcedure; -import com.fr.design.ExtraDesignClassManager; import com.fr.design.data.datapane.TableDataNameObjectCreator; import com.fr.design.data.tabledata.tabledatapane.*; -import com.fr.design.fun.TableDataCreatorProvider; import com.fr.file.DatasourceManagerProvider; import com.fr.general.ComparatorUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; /** @@ -32,6 +27,8 @@ public abstract class TableDataFactory { * 有顺序的,用来排序用 */ private static Map map = new java.util.LinkedHashMap(); + + private static Map extraMap = new LinkedHashMap<>(); /** * 同一类型的只能加一次,就加最上层的类,因为要排序。如果将所有的 FileTableData都加进来,那么FileTableData的排序就不正确了 @@ -54,11 +51,27 @@ public abstract class TableDataFactory { * @param clazz 数据集类 * @param creator 组件 */ - public static void register(Class clazz, TableDataNameObjectCreator creator) { - map.put(clazz.getName(), creator); + public static void registerExtra(Class clazz, TableDataNameObjectCreator creator) { + + extraMap.put(clazz.getName(), creator); } - + + public static void removeExtra(Class clazz) { + + extraMap.remove(clazz.getName()); + } + private static TableDataNameObjectCreator getTableDataNameObjectCreator(TableData tabledata) { + + TableDataNameObjectCreator creator = getFrom(tabledata, extraMap); + if (creator == null) { + creator = getFrom(tabledata, map); + } + return creator; + } + + private static TableDataNameObjectCreator getFrom(TableData tabledata, Map map) { + TableDataNameObjectCreator tableDataNameObjectCreator = map.get(tabledata.getClass().getName()); if (tableDataNameObjectCreator == null) { tableDataNameObjectCreator = map.get(tabledata.getClass().getSuperclass().getName()); @@ -69,7 +82,7 @@ public abstract class TableDataFactory { } return tableDataNameObjectCreator; } - + /** * 获取数据集所对应的编辑面板 * diff --git a/designer_base/src/com/fr/design/extra/LoginWebBridge.java b/designer_base/src/com/fr/design/extra/LoginWebBridge.java index 7db9fc5ac..2990ad133 100644 --- a/designer_base/src/com/fr/design/extra/LoginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/LoginWebBridge.java @@ -9,6 +9,8 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.json.JSONObject; +import com.fr.plugin.manage.bbs.BBSPluginLogin; +import com.fr.plugin.manage.bbs.BBSUserInfo; import com.fr.stable.EncodeConstants; import com.fr.stable.StringUtils; import javafx.scene.web.WebEngine; @@ -320,6 +322,7 @@ public class LoginWebBridge { DesignerEnvManager.getEnvManager().setBBSName(username); DesignerEnvManager.getEnvManager().setInShowBBsName(username); DesignerEnvManager.getEnvManager().setBBSPassword(password); + BBSPluginLogin.getInstance().login(new BBSUserInfo(username, password)); return LOGININ;//登录成功,0 } else if ($uid == -1) { return USERNAME_NOT_EXSIT;//用户名不存在,-1 diff --git a/designer_base/src/com/fr/design/extra/PluginConstants.java b/designer_base/src/com/fr/design/extra/PluginConstants.java new file mode 100644 index 000000000..ad560b458 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/PluginConstants.java @@ -0,0 +1,15 @@ +package com.fr.design.extra; + +/** + * Created by ibm on 2017/5/25. + */ +public class PluginConstants { + public static final int BYTES_NUM = 1024; + private static final String TEMP_PATH = System.getProperty("user.dir") + "/tmp"; + public static final String DOWNLOAD_PATH = System.getProperty("user.dir") + "/download"; + //插件依赖的下载位置 + public static final String DEPENDENCE_DOWNLOAD_PATH = System.getProperty("user.dir") + "/download/dependence"; + public static final String TEMP_FILE = "temp.zip"; + public static final String CONNECTION_404 = "404"; + +} diff --git a/designer_base/src/com/fr/design/extra/PluginControlPane.java b/designer_base/src/com/fr/design/extra/PluginControlPane.java index 82657904f..be3c8601d 100644 --- a/designer_base/src/com/fr/design/extra/PluginControlPane.java +++ b/designer_base/src/com/fr/design/extra/PluginControlPane.java @@ -8,10 +8,13 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.IOUtils; import com.fr.general.Inter; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginLicense; -import com.fr.plugin.PluginLicenseManager; -import com.fr.plugin.PluginLoader; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.license.Licensed; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTaskCallback; +import com.fr.plugin.manage.control.PluginTaskResult; +import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; import javax.swing.*; @@ -20,7 +23,8 @@ import javax.swing.event.DocumentListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; -import java.util.ArrayList; +import java.util.*; +import java.util.List; /** * @author richie @@ -32,7 +36,7 @@ public class PluginControlPane extends BasicPane { private DefaultListModel listModel; private PluginDetailPane detailPane; private java.util.List listeners = new ArrayList(); - private Plugin[] plugins; + private List plugins; private UITextField searchTextField; public PluginControlPane() { @@ -63,19 +67,22 @@ public class PluginControlPane extends BasicPane { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof Plugin) { - PluginLicense pluginLicense = PluginLicenseManager.getInstance().getPluginLicenseByID(((Plugin) value).getId()); + if (value instanceof PluginView) { + Licensed context = PluginManager.getContext(PluginMarker.read((PluginView) value)); + if (context == null) { + return this; + } String extraInfo = ""; - if (pluginLicense.isJarDamage()) { + if (context.isLicDamaged()) { extraInfo = "(" + Inter.getLocText("FR-Plugin-Plugin_Damaged") + ")"; - } else if (pluginLicense.getLeftTime() != -1) { - if (pluginLicense.isAvailable()) { - extraInfo = "(" + (pluginLicense.isTrial() ? Inter.getLocText("FR-Plugin-Designer_Trial") : Inter.getLocText("FR-Plugin-Designer_Authorized")) + pluginLicense.getLeftTime() + Inter.getLocText("FR-Plugin-Designer_Left") + ")"; + } else if (!context.isFree()) { + if (context.isAvailable()) { + extraInfo = "(" + (context.isOnTrial() ? Inter.getLocText("FR-Plugin-Designer_Trial") : Inter.getLocText("FR-Plugin-Designer_Authorized")) + context.getLeftDays() + Inter.getLocText("FR-Plugin-Designer_Left") + ")"; } else { - extraInfo = "(" + (pluginLicense.isTrial() ? Inter.getLocText("FR-Plugin-Designer_Trial") : Inter.getLocText("FR-Plugin-Designer_Authorized")) + Inter.getLocText("FR-Plugin-Designer_Expired") + ")"; + extraInfo = "(" + (context.isOnTrial() ? Inter.getLocText("FR-Plugin-Designer_Trial") : Inter.getLocText("FR-Plugin-Designer_Authorized")) + Inter.getLocText("FR-Plugin-Designer_Expired") + ")"; } } - setText(((Plugin) value).getName() + extraInfo); + setText(((PluginView) value).getName() + extraInfo); setIcon(IOUtils.readIcon("/com/fr/design/images/server/plugin.png")); } return this; @@ -101,7 +108,7 @@ public class PluginControlPane extends BasicPane { pluginList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { - Plugin plugin = (Plugin) pluginList.getSelectedValue(); + PluginView plugin = (PluginView) pluginList.getSelectedValue(); if (plugin != null) { detailPane.populate(plugin); for (PluginSelectListener l : listeners) { @@ -118,9 +125,9 @@ public class PluginControlPane extends BasicPane { listeners.add(l); } - public void loadPlugins(Plugin[] plugins) { + public void loadPlugins(java.util.List plugins) { this.plugins = plugins; - for (Plugin plugin : plugins) { + for (PluginView plugin : plugins) { listModel.addElement(plugin); } } @@ -128,21 +135,28 @@ public class PluginControlPane extends BasicPane { private void doSearch(String text) { if (StringUtils.isNotBlank(text)) { listModel.clear(); - for (Plugin plugin : plugins) { - if (plugin.match(text)) { + for (PluginView plugin : plugins) { + if (PluginUtils.isPluginMatch(plugin, text)) { listModel.addElement(plugin); } } } } - public Plugin getSelectedPlugin() { - return (Plugin) pluginList.getSelectedValue(); + public PluginView getSelectedPlugin() { + return (PluginView) pluginList.getSelectedValue(); } - public void deletePlugin(Plugin plugin) { + public void deletePlugin(PluginView plugin) { listModel.removeElement(plugin); - PluginLoader.getLoader().deletePlugin(plugin); + String id = plugin.getID(); + String version = plugin.getVersion(); + PluginManager.getController().uninstall(PluginMarker.create(id, version), true, new PluginTaskCallback() { + @Override + public void done(PluginTaskResult result) { + + } + }); } @Override diff --git a/designer_base/src/com/fr/design/extra/PluginDetailPane.java b/designer_base/src/com/fr/design/extra/PluginDetailPane.java index 4edfb934f..a5d44a614 100644 --- a/designer_base/src/com/fr/design/extra/PluginDetailPane.java +++ b/designer_base/src/com/fr/design/extra/PluginDetailPane.java @@ -3,7 +3,7 @@ package com.fr.design.extra; import com.fr.design.dialog.BasicPane; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.plugin.Plugin; +import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; import javax.swing.*; @@ -56,8 +56,8 @@ public class PluginDetailPane extends BasicPane { } - public void populate(Plugin plugin) { - textPane.setText(plugin.toHTML()); + public void populate(PluginView plugin) { + textPane.setText(PluginUtils.pluginToHtml(plugin)); } public void reset() { diff --git a/designer_base/src/com/fr/design/extra/PluginFromStorePane.java b/designer_base/src/com/fr/design/extra/PluginFromStorePane.java index e40f5a2bf..4de4b0d18 100644 --- a/designer_base/src/com/fr/design/extra/PluginFromStorePane.java +++ b/designer_base/src/com/fr/design/extra/PluginFromStorePane.java @@ -1,26 +1,30 @@ package com.fr.design.extra; import com.fr.base.FRContext; -import com.fr.design.DesignerEnvManager; -import com.fr.design.RestartHelper; +import com.fr.design.extra.tradition.callback.UpdateOnlineCallback; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.plugin.Plugin; -import com.fr.stable.StringUtils; +import com.fr.json.JSONObject; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.bbs.BBSPluginLogin; +import com.fr.plugin.manage.control.PluginTaskResult; +import com.fr.plugin.manage.control.ProgressCallback; +import com.fr.plugin.view.PluginView; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.File; import java.util.List; -import java.util.concurrent.ExecutionException; /** * @author richie * @date 2015-03-10 * @since 8.0 */ -public class PluginFromStorePane extends PluginAbstractLoadingViewPane { +public class PluginFromStorePane extends PluginAbstractLoadingViewPane, Void> { private UILabel errorMsgLabel; private UITabbedPane tabbedPane; private PluginControlPane controlPane; @@ -29,7 +33,6 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane loadData() throws Exception { //Thread.sleep(3000); return PluginsReaderFromStore.readPlugins(); } /** * 加载成功处理 + * * @param plugins 插件 */ - public void loadOnSuccess(Plugin[] plugins) { + public void loadOnSuccess(List plugins) { controlPane.loadPlugins(plugins); - tabbedPane.setTitleAt(2, Inter.getLocText("FR-Designer-Plugin_All_Plugins") + "(" + plugins.length + ")"); + tabbedPane.setTitleAt(2, Inter.getLocText("FR-Designer-Plugin_All_Plugins") + "(" + plugins.size() + ")"); } /** * 加载失败 + * * @param e 异常消息 */ public void loadOnFailed(Exception e) { @@ -159,85 +167,53 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane(){ - - @Override - protected Void doInBackground() throws Exception { - Plugin plugin = controlPane.getSelectedPlugin(); - String id = null; - if (plugin != null) { - id = plugin.getId(); - } - String username = DesignerEnvManager.getEnvManager().getBBSName(); - String password = DesignerEnvManager.getEnvManager().getBBSPassword(); - try { - PluginHelper.downloadPluginFile(id,username,password, new Process() { - @Override - public void process(Double integer) { - publish(integer); - } - }); - Thread.sleep(2000); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - return null; - } + if (BBSPluginLogin.getInstance().hasLogin()) { + PluginView plugin = controlPane.getSelectedPlugin(); + String id = null; + if (plugin != null) { + id = plugin.getID(); + } - public void process(List list) { - pane.setProgress(list.get(list.size() - LISTNUM1) * LISTNUM100); - } + try { + PluginMarker pluginMarker = PluginMarker.create(id, plugin.getVersion()); + JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(id); + String latestPluginVersion = (String)latestPluginInfo.get("version"); + PluginMarker toPluginMarker = PluginMarker.create(id, latestPluginVersion); + PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane)); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } - public void done() { - //下载完成,开始执行安装 - try { - get(); - pane.didTaskFinished(); - installFromDiskZipFile(PluginHelper.getDownloadTempFile()); - } catch (InterruptedException e) { - FRContext.getLogger().error(e.getMessage(), e); - } catch (ExecutionException e) { - FRContext.getLogger().error(e.getMessage(), e); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - } - }.execute(); } - } /** * 正在加载页的标题 + * * @return 标题字符串 */ public String textForLoadingLabel() { @@ -246,11 +222,12 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane p) throws Exception { - HttpClient httpClient = new HttpClient(getDownloadPath(id, username, password)); - if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { - int totalSize = httpClient.getContentLength(); - InputStream reader = httpClient.getResponseStream(); - String temp = StableUtils.pathJoin(DOWNLOAD_PATH, TEMP_FILE); - StableUtils.makesureFileExist(new File(temp)); - FileOutputStream writer = new FileOutputStream(temp); - byte[] buffer = new byte[PluginConstants.BYTES_NUM]; - int bytesRead = 0; - int totalBytesRead = 0; - - while ((bytesRead = reader.read(buffer)) > 0) { - writer.write(buffer, 0, bytesRead); - buffer = new byte[PluginConstants.BYTES_NUM]; - totalBytesRead += bytesRead; - p.process(totalBytesRead / (double) totalSize); - } - reader.close(); - writer.flush(); - writer.close(); - } else { - throw new com.fr.plugin.PluginVerifyException(Inter.getLocText("FR-Designer-Plugin_Connect_Server_Error")); - } - } - - private static boolean invalidUser(String id, String username, String password) { - if (StringUtils.isEmpty(id)) { - return false; - } else if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)){ - return false; - } else { - return true; - } - } - - private static String getDownloadPath(String id, String username, String password) throws Exception { - HashMap map = new HashMap(); - map.put("id", id); - map.put("username", username); - map.put("password", password); - HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.download"), map); - String resText = httpClient.getResponseText(); - String charSet = EncodeConstants.ENCODING_UTF_8; - resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet); - - return resText; - } - - public static File getDownloadTempFile() { - return new File(StableUtils.pathJoin(DOWNLOAD_PATH, TEMP_FILE)); - } - - /** - * 从压缩文件中读取插件信息 - * - * @param chosenFile 选择的压缩文件 - * @return 返回插件对象 - * @throws Exception 读取插件信息失败则抛出异常 - */ - public static Plugin readPlugin(File chosenFile) throws Exception { - // 需要先删除临时目录保证加压出来的文件不会和安装失败的文件混合到一起 - StableUtils.deleteFile(new File(TEMP_PATH)); - - IOUtils.unzip(chosenFile, TEMP_PATH); - File pluginFileDir = getTempPluginFileDirectory(); - if (pluginFileDir == null) { - return null; - } - Plugin plugin = null; - if (pluginFileDir.isDirectory()) { - File[] pluginFiles = pluginFileDir.listFiles(); - if (ArrayUtils.isNotEmpty(pluginFiles)) { - for (File f : pluginFiles) { - if (f.getName().equals("plugin.xml")) { - plugin = new Plugin(); - InputStream inputStream = plugin.readEncryptXml(new FileInputStream(f)); - XMLTools.readInputStreamXML(plugin, inputStream); - //检查是否需要准备插件依赖环境 - checkDependenceEnv(plugin); - if (!plugin.isValidate()) { - return null; - } - inputStream.close(); - break; - } - } - } - } - return plugin; - } - - //将所有未配置好的资源文件依赖准备好 - private static void checkDependenceEnv(Plugin plugin) throws PluginDependenceException { - PluginDependence dependence = plugin.getDependence(); - if (dependence == null) { - return; - } - - List needInstallDependence = new ArrayList(); - - String currentID = dependence.getCurrentPluginID(); - List list = dependence.getDependPlugins(); - for (int i = 0; list != null && i < list.size(); i++) { - PluginDependenceUnit dependenceUnit = list.get(i); - if (!dependenceUnit.checkFileEnv()) { - needInstallDependence.add(dependenceUnit); - } - } - - if (needInstallDependence.isEmpty()) { - return; - } - - //安装插件依赖 - installDependenceOnline(currentID, needInstallDependence); - } - - /** - * 构造一个下载UI - * - * @param currentID - * @param list - * @throws PluginDependenceException - */ - private static void installDependenceOnline(String currentID, List list) throws PluginDependenceException { - DownLoadDependenceUI ui = new DownLoadDependenceUI(currentID, list); - ui.installOnline(); - } - - /** - * 从选中的压缩文件中安装插件 - * - * @param chosenFile 选择的压缩文件 - * @param after 操作完成事件 - * @throws Exception 安装失败则抛出异常 - */ - public static void installPluginFromDisk(File chosenFile, After after) throws Exception { - Plugin plugin = readPlugin(chosenFile); - installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, after); - } - - /** - * 从压缩文件中复制Restart*.class和restart.exe到bin目录下 - * - * @param file 插件文件 - * @param plugin 插件 - * @throws Exception - */ - public static void copyFilesToBinFolder(File file, Plugin plugin) throws Exception { - File[] pluginFiles = file.listFiles(); - for (File restartFile : pluginFiles) { - if (restartFile.getAbsolutePath().endsWith(".class")) { - String installHome = StableUtils.getInstallHome(); - IOUtils.copy(restartFile, new File(StableUtils.pathJoin(new String[]{installHome, "bin"}))); - } - } - } - - /** - * 从插件压缩包解压到得临时文件中安装插件 - * - * @param env 报表运行环境 - * @param plugin 插件 - * @param after 操作完成事件 - * @throws Exception - */ - public static void installPluginFromUnzippedTempDir(Env env, final Plugin plugin, final After after) throws Exception { - validPlugin(plugin); - if (plugin.isValidate()) { - File file = getTempPluginFileDirectory(); - env.copyFilesToPluginAndLibFolder(file, plugin); - copyFilesToBinFolder(file, plugin); - env.movePluginEmbFile(file, plugin); - } - // 删除放解压文件的临时文件夹 - StableUtils.deleteFile(new File(TEMP_PATH)); - PluginConfigManager.getProviderInstance().pushNewPlugin(plugin); - PluginConfigManager.getProviderInstance().syncPluginConfig(); - new SwingWorker() { - - @Override - protected String doInBackground() throws Exception { - return sendInstalledPluginInfo(plugin); - } - - @Override - protected void done() { - try { - String text = get(); - FRLogger.getLogger().info("plugin install:" + text); - } catch (InterruptedException e) { - FRLogger.getLogger().error(e.getMessage(), e); - } catch (ExecutionException e) { - FRLogger.getLogger().error(e.getMessage(), e); - } - if (after != null) { - after.done(); - } - } - }.execute(); - } - - private static void validPlugin(Plugin plugin) throws Exception { - if (plugin == null) { - throw new com.fr.plugin.PluginVerifyException(Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip_Cannot_Be_Install")); - } - if (PluginLoader.getLoader().isInstalled(plugin)) { - throw new com.fr.plugin.PluginVerifyException(Inter.getLocText("FR-Designer-Plugin_Has_Been_Installed")); - } - if (plugin.checkIfJarExpired()) { - String jarExpiredInfo = Inter.getLocText(new String[]{"FR-Designer-Plugin_Jar_Expired", ",", "FR-Designer-Plugin_Install_Failed", ",", "FR-Designer-Plugin_Please_Update_Jar", plugin.getRequiredJarTime()}); - FRLogger.getLogger().error(jarExpiredInfo); - throw new com.fr.plugin.PluginVerifyException(jarExpiredInfo); - } - File fileToCheck = getTempPluginFileDirectory(); - File oldfile = new File(StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), ProjectConstants.PLUGINS_NAME, "plugin-" + plugin.getId())); - if (!PluginManagerHelper.checkLic(plugin, fileToCheck)) { - if (!PluginManagerHelper.checkLic(plugin, oldfile)) {//安装时,在安装目录下和压缩包里都没有才弹框 - String checkLicFail = Inter.getLocText("FR-Designer-PluginLicense_Check_Failed"); - FRLogger.getLogger().error(checkLicFail); - throw new com.fr.plugin.PluginVerifyException(checkLicFail); - } - } - } - - /** - * 获取插件解压的临时文件夹 - * - * @return 临时文件 - */ - public static File getTempPluginFileDirectory() { - File file = new File(TEMP_PATH); - if (file.isDirectory() && !file.getName().startsWith(".")) { - File[] files = file.listFiles(); - if (ArrayUtils.isNotEmpty(files)) { - for (File f : files) { - if (foundConfigFile(f)) { - return f; - } - } - } - } - return null; - } - - private static boolean foundConfigFile(File dir) { - if (!dir.isDirectory()) { - return false; - } - File[] files = dir.listFiles(); - if (ArrayUtils.isNotEmpty(files)) { - for (File f : files) { - if ("plugin.xml".equals(f.getName())) { - return true; - } - } - } - return false; - } - - /** - * 从运行环境中卸载插件 - * - * @param env 报表运行环境 - * @param plugin 插件 - * @return 返回没有删除掉的文件的集合 - * @throws Exception 卸载出错的时候抛出此异常 - */ - public static String[] uninstallPlugin(Env env, Plugin plugin) throws Exception { - if (plugin == null || env == null) { - return ArrayUtils.EMPTY_STRING_ARRAY; - } - //卸载前监听 - plugin.preUninstall(); - PluginLoader.getLoader().deletePlugin(plugin); - return env.deleteFileFromPluginAndLibFolder(plugin); - } - - /** - * 比较插件的版本,这里简单的比价字符串,不需要用数字作为标号 - * 版本号相同也认为是更新 - * - * @param plugin 当前的插件 - * @param oldPlugin 老的插件 - * @return 当前插件比老的插件版本高则返回true,否则返回false - */ - public static boolean isNewThan(Plugin plugin, Plugin oldPlugin) { - return ComparatorUtils.compare(plugin.getVersion(), oldPlugin.getVersion()) >= 0; - } - - private static String sendInstalledPluginInfo(final Plugin plugin) { - if (StableUtils.isDebug()) { - return "debug status"; - } - HashMap map = new HashMap(); - map.put("key", DesignerEnvManager.getEnvManager().getActivationKey()); - map.put("detail", plugin.toJSONObject().toString()); - map.put("build", GeneralUtils.readBuildNO()); - //第三个参数encode, nodejs服务器那边如果参数不encode, 带了空格会报错, 直接用urlconnection也是一样, jetty没能还原. - HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.install"), map, true); - httpClient.setTimeout(TIME_OUT); - httpClient.asGet(); - return httpClient.getResponseText(); - } - - private static final int TIME_OUT = 5000; -} diff --git a/designer_base/src/com/fr/design/extra/PluginInstalledPane.java b/designer_base/src/com/fr/design/extra/PluginInstalledPane.java index 9d4ecd6d3..0ad45bfde 100644 --- a/designer_base/src/com/fr/design/extra/PluginInstalledPane.java +++ b/designer_base/src/com/fr/design/extra/PluginInstalledPane.java @@ -1,16 +1,22 @@ package com.fr.design.extra; -import com.fr.base.FRContext; import com.fr.design.RestartHelper; import com.fr.design.gui.ibutton.UIButton; import com.fr.general.Inter; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginLoader; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTaskCallback; +import com.fr.plugin.manage.control.PluginTaskResult; +import com.fr.plugin.view.PluginView; + import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; /** * @author richie @@ -42,7 +48,7 @@ public class PluginInstalledPane extends PluginAbstractViewPane { panel.add(deleteButton); controlPane.addPluginSelectionListener(new PluginSelectListener() { @Override - public void valueChanged(Plugin plugin) { + public void valueChanged(PluginView plugin) { disableButton.setEnabled(true); deleteButton.setEnabled(true); changeTextForButton(plugin); @@ -51,28 +57,35 @@ public class PluginInstalledPane extends PluginAbstractViewPane { disableButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - Plugin plugin = controlPane.getSelectedPlugin(); + PluginView plugin = controlPane.getSelectedPlugin(); if (plugin != null) { - plugin.setActive(!plugin.isActive()); - changeTextForButton(plugin); - try { - FRContext.getCurrentEnv().writePlugin(plugin); - int rv = JOptionPane.showOptionDialog( - PluginInstalledPane.this, - plugin.isActive() ? Inter.getLocText("FR-Designer-Plugin_Has_Been_Actived") : Inter.getLocText("FR-Designer-Plugin_Has_Been_Disabled"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.YES_NO_OPTION, - JOptionPane.INFORMATION_MESSAGE, - null, - new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")}, - null - ); - if (rv == JOptionPane.OK_OPTION) { - RestartHelper.restart(); - } - } catch (Exception e1) { - FRContext.getLogger().error(e1.getMessage(), e1); + boolean isActive = plugin.isActive(); + PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion()); + String modifyMessage = isActive ? Inter.getLocText("FR-Designer-Plugin_Has_Been_Actived") : Inter.getLocText("FR-Designer-Plugin_Has_Been_Disabled"); + if (isActive) { + PluginManager.getController().forbid(pluginMarker, new PluginTaskCallback() { + @Override + public void done(PluginTaskResult result) { + if (result.isSuccess()) { + JOptionPane.showMessageDialog(null, modifyMessage); + } else { + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } + }); + } else { + PluginManager.getController().enable(pluginMarker, new PluginTaskCallback() { + @Override + public void done(PluginTaskResult result) { + if (result.isSuccess()) { + JOptionPane.showMessageDialog(null, modifyMessage); + } else { + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } + }); } + changeTextForButton(plugin); } } }); @@ -83,21 +96,25 @@ public class PluginInstalledPane extends PluginAbstractViewPane { } }); - PluginLoader loader = PluginLoader.getLoader(); - Plugin[] plugins = loader.getInstalled(); - controlPane.loadPlugins(plugins); - num = plugins.length; + List plugins = PluginManager.getContexts(); + List pluginViews = new ArrayList<>(); + for (PluginContext plugin : plugins) { + pluginViews.add((PluginView) plugin); + } + controlPane.loadPlugins(pluginViews); + num = plugins.size(); } /** * tab标题 + * * @return 同上 */ public String tabTitle() { return Inter.getLocText("FR-Designer-Plugin_Installed") + "(" + num + ")"; } - private void doDelete(Plugin plugin) { + private void doDelete(PluginView plugin) { int rv = JOptionPane.showOptionDialog( PluginInstalledPane.this, Inter.getLocText("FR-Designer-Plugin_Will_Be_Delete"), @@ -114,21 +131,19 @@ public class PluginInstalledPane extends PluginAbstractViewPane { if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { return; } - + try { - String[] filesToBeDelete = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), plugin); controlPane.deletePlugin(plugin); - RestartHelper.saveFilesWhichToDelete(filesToBeDelete); } catch (Exception e) { JOptionPane.showMessageDialog(PluginInstalledPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } - + if (rv == JOptionPane.OK_OPTION) { RestartHelper.restart(); } } - private void changeTextForButton(Plugin plugin) { + private void changeTextForButton(PluginView plugin) { if (plugin.isActive()) { disableButton.setText(Inter.getLocText("FR-Designer-Plugin_Disable")); } else { diff --git a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java new file mode 100644 index 000000000..6b6c0409a --- /dev/null +++ b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java @@ -0,0 +1,266 @@ +package com.fr.design.extra; + +import com.fr.base.FRContext; +import com.fr.design.DesignerEnvManager; +import com.fr.design.extra.exe.callback.*; +import com.fr.design.extra.exe.extratask.InstallPluginTask; +import com.fr.design.extra.exe.extratask.UpdatePluginTask; +import com.fr.general.FRLogger; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.bbs.BBSPluginLogin; +import com.fr.plugin.manage.bbs.BBSUserInfo; +import com.fr.plugin.manage.control.PluginTaskCallback; +import com.fr.plugin.view.PluginView; +import com.fr.stable.StringUtils; + +import java.io.File; +import java.util.List; + + +/** + * Created by ibm on 2017/5/26. + */ +public class PluginOperateUtils { + + public static void installPluginOnline(final String pluginInfo, JSCallback jsCallback) { + //下载插件 + if (!BBSPluginLogin.getInstance().hasLogin()) { + LoginCheckContext.fireLoginCheckListener(); + } + PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); + if (BBSPluginLogin.getInstance().hasLogin()) { + PluginManager.getController().download(pluginMarker, new DownloadCallback(new InstallPluginTask(pluginMarker, jsCallback), jsCallback)); + } + } + + public static void installPluginFromDisk(File zipFile, JSCallback jsCallback) { + PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback)); + } + + public static void updatePluginOnline(List pluginMarkerList, JSCallback jsCallback) { + if (!(BBSPluginLogin.getInstance().hasLogin())) { + LoginCheckContext.fireLoginCheckListener(); + } + if (BBSPluginLogin.getInstance().hasLogin()) { + for (int i = 0; i < pluginMarkerList.size(); i++) { + try { + JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarkerList.get(i).getPluginID()); + String latestPluginVersion = (String) latestPluginInfo.get("version"); + PluginMarker pluginMarker = pluginMarkerList.get(i); + PluginMarker toPluginMarker = PluginMarker.create(pluginMarkerList.get(i).getPluginID(), latestPluginVersion); + PluginManager.getController().download(pluginMarkerList.get(i), new DownloadCallback(new UpdatePluginTask(pluginMarker, toPluginMarker, jsCallback), jsCallback)); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } + } + } + } + + public static void updatePluginFromDisk(final String filePath, JSCallback jsCallback) { + PluginManager.getController().update(new File(filePath), new UpdateFromDiskCallback(new File(filePath), jsCallback)); + } + + public static void setPluginActive(String pluginInfo, JSCallback jsCallback) { + PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); + PluginContext plugin = PluginManager.getContext(pluginMarker); + boolean active = plugin.isActive(); + PluginTaskCallback modifyStatusCallback = new ModifyStatusCallback(active, jsCallback); + if (active) { + PluginManager.getController().forbid(pluginMarker, modifyStatusCallback); + } else { + PluginManager.getController().enable(pluginMarker, modifyStatusCallback); + } + } + + public static void uninstallPlugin(final String pluginInfo, final boolean isForce, JSCallback jsCallback) { + PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); + PluginManager.getController().uninstall(pluginMarker, isForce, new UninstallPluginCallback(pluginMarker, jsCallback)); + } + + public static void readUpdateOnline(JSCallback jsCallback) { + + new Thread(new Runnable() { + @Override + public void run() { + try { + List plugins = PluginsReaderFromStore.readPluginsForUpdate(); + JSONArray jsonArray = new JSONArray(); + for (PluginView plugin : plugins) { + org.json.JSONObject jsonObject = new org.json.JSONObject(); + jsonObject.put("pluginid", plugin.getID()); + jsonArray.put(jsonObject); + } + String result = jsonArray.toString(); + jsCallback.execute(result); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } + }).start(); + + + } + + public static void searchPlugin(String keyword, JSCallback jsCallback) { + new Thread(new Runnable() { + @Override + public void run() { + try { + if (StringUtils.isBlank(keyword)) { + getRecommendPlugins(jsCallback); + return; + } + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("shop.plugin.store") + "&keyword=" + keyword); + httpClient.asGet(); + String result = httpClient.getResponseText(); + JSONObject jsonObject = new JSONObject(result); + JSONArray jsonArray = jsonObject.getJSONArray("result"); + jsCallback.execute(jsonArray.toString()); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } + }).start(); + + } + + public static void getPluginFromStore(String category, String seller, String fee, JSCallback jsCallback) { + new Thread(new Runnable() { + @Override + public void run() { + String plistUrl = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.plist") + "?"; + boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee); + if (getRecommend) { + getRecommendPlugins(jsCallback); + return; + } + + if (StringUtils.isNotBlank(plistUrl)) { + StringBuilder url = new StringBuilder(); + url.append(plistUrl); + dealParams(url, category, seller, fee); + try { + HttpClient httpClient = new HttpClient(url.toString()); + httpClient.asGet(); + String result = httpClient.getResponseText(); + JSONObject resultJSONObject = new JSONObject(result); + JSONArray resultArr = resultJSONObject.getJSONArray("result"); + jsCallback.execute(resultArr.toString()); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } else { + String result = PluginConstants.CONNECTION_404; + jsCallback.execute(result); + } + } + + }).start(); + + } + + public static void getRecommendPlugins(JSCallback jsCallback) { + String plistUrl = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.feature"); + try { + HttpClient httpClient = new HttpClient(plistUrl.toString()); + String result = httpClient.getResponseText(); + jsCallback.execute(result); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + + } + + public static void dealParams(StringBuilder url, String category, String seller, String fee) { + if (StringUtils.isNotBlank(category)) { + url.append("cid=").append(category.split("-")[1]); + } else { + url.append("cid=").append(""); + } + if (StringUtils.isNotBlank(seller)) { + switch (seller.split("-")[1]) { + case "finereport": + url.append("&seller=").append(1); + break; + case "developer": + url.append("&seller=").append(2); + break; + default: + url.append("&seller=").append(""); + } + } + if (StringUtils.isNotBlank(fee)) { + switch (fee.split("-")[1]) { + case "free": + url.append("&fee=").append(1); + break; + case "charge": + url.append("&fee=").append(2); + break; + default: + url.append("&fee=").append(""); + } + } + } + + public static void getPluginCategories(JSCallback jsCallback) { + new Thread(new Runnable() { + @Override + public void run() { + String result; + String url = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.category"); + if (url != null) { + HttpClient httpClient = new HttpClient(url); + result = httpClient.getResponseText(); + } else { + result = PluginConstants.CONNECTION_404; + } + jsCallback.execute(result); + } + }).start(); + } + + public static void getPluginPrefix(JSCallback jsCallback) { + new Thread(new Runnable() { + @Override + public void run() { + String result = SiteCenter.getInstance().acquireUrlByKind("plugin.url.prefix"); + jsCallback.execute(result); + } + }).start(); + } + + public static void getLoginInfo(JSCallback jsCallback) { + + if (!BBSPluginLogin.getInstance().hasLogin()) { + String userName = DesignerEnvManager.getEnvManager().getBBSName(); + String password = DesignerEnvManager.getEnvManager().getBBSPassword(); + if (StringUtils.isNotBlank(userName)) { + BBSPluginLogin.getInstance().login(new BBSUserInfo(userName, password)); + } + } + BBSUserInfo bbsUserInfo = BBSPluginLogin.getInstance().getUserInfo(); + String username = bbsUserInfo == null ? "" : bbsUserInfo.getUserName(); + String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName(); + if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)) { + return; + } else { + String result = StringUtils.isEmpty(inShowUsername) ? username : inShowUsername; + jsCallback.execute(result); + } + } + + public static boolean pluginValidate(PluginView pluginView) { + return StringUtils.isNotEmpty(pluginView.getID()) + && StringUtils.isNotEmpty(pluginView.getName()) + && StringUtils.isNotEmpty(pluginView.getVersion()) + && StringUtils.isNotEmpty(pluginView.getEnvVersion()); + } + +} diff --git a/designer_base/src/com/fr/design/extra/PluginSelectListener.java b/designer_base/src/com/fr/design/extra/PluginSelectListener.java index b1962335b..4f82886f6 100644 --- a/designer_base/src/com/fr/design/extra/PluginSelectListener.java +++ b/designer_base/src/com/fr/design/extra/PluginSelectListener.java @@ -1,6 +1,7 @@ package com.fr.design.extra; -import com.fr.plugin.Plugin; + +import com.fr.plugin.view.PluginView; /** * @author richie @@ -9,5 +10,5 @@ import com.fr.plugin.Plugin; */ public interface PluginSelectListener { - public void valueChanged(Plugin plugin); + public void valueChanged(PluginView plugin); } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/PluginUpdatePane.java b/designer_base/src/com/fr/design/extra/PluginUpdatePane.java index e0b3ada35..5de8c9588 100644 --- a/designer_base/src/com/fr/design/extra/PluginUpdatePane.java +++ b/designer_base/src/com/fr/design/extra/PluginUpdatePane.java @@ -3,12 +3,21 @@ package com.fr.design.extra; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; +import com.fr.design.extra.tradition.callback.UpdateOnlineCallback; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginLoader; +import com.fr.json.JSONObject; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.bbs.BBSPluginLogin; +import com.fr.plugin.manage.control.PluginTaskResult; +import com.fr.plugin.manage.control.ProgressCallback; +import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; +import sun.plugin2.main.server.Plugin; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; @@ -20,7 +29,7 @@ import java.util.List; * @date 2015-03-10 * @since 8.0 */ -public class PluginUpdatePane extends PluginAbstractLoadingViewPane { +public class PluginUpdatePane extends PluginAbstractLoadingViewPane, Void> { private PluginControlPane controlPane; private JLabel errorMsgLabel; @@ -68,7 +77,7 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane loadData() throws Exception { return PluginsReaderFromStore.readPluginsForUpdate(); } @@ -131,9 +140,9 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane plugins) { controlPane.loadPlugins(plugins); - tabbedPane.setTitleAt(1, Inter.getLocText("FR-Designer-Plugin_Update") + "(" + plugins.length + ")"); + tabbedPane.setTitleAt(1, Inter.getLocText("FR-Designer-Plugin_Update") + "(" + plugins.size() + ")"); } /** @@ -167,101 +176,40 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane() { - - @Override - protected Void doInBackground() throws Exception { - Plugin plugin = controlPane.getSelectedPlugin(); - String id = null; - if (plugin != null) { - id = plugin.getId(); - } - String username = DesignerEnvManager.getEnvManager().getBBSName(); - String password = DesignerEnvManager.getEnvManager().getBBSPassword(); - try { - PluginHelper.downloadPluginFile(id, username, password, new Process() { - @Override - public void process(Double integer) { - publish(integer); - } - }); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - return null; - } + if (BBSPluginLogin.getInstance().hasLogin()) { + try{ + PluginView plugin = controlPane.getSelectedPlugin(); + PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion()); + JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID()); + String latestPluginVersion = (String) latestPluginInfo.get("version"); + PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion); + PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane)); + }catch (Exception e){} - public void process(List list) { - pane.setProgress(list.get(list.size() - 1) * PERSENT); - } - - public void done() { - //下载完成,开始执行安装 - try { - get(); - pane.didTaskFinished(); - doUpdateFromFile(PluginHelper.getDownloadTempFile()); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - } - }.execute(); } } private void doUpdateFromFile(File chosenFile) { - try { - Plugin plugin = PluginHelper.readPlugin(chosenFile); - if (plugin == null) { - JOptionPane.showMessageDialog(PluginUpdatePane.this, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - return; + PluginManager.getController().update(chosenFile, new ProgressCallback() { + @Override + public void updateProgress(String description, double progress) { + } - Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); - if (oldPlugin != null) { - // 说明安装了同ID的插件,再比较两个插件的版本 - if (PluginHelper.isNewThan(plugin, oldPlugin)) { - // 说明是新的插件,删除老的然后安装新的 - final String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); - PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { - @Override - public void done() { - int rv = JOptionPane.showOptionDialog( - PluginUpdatePane.this, - Inter.getLocText("FR-Designer-Plugin_Update_Successful"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.YES_NO_OPTION, - JOptionPane.INFORMATION_MESSAGE, - null, - new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), - Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later") - }, - null - ); - - if (rv == JOptionPane.OK_OPTION) { - RestartHelper.restart(); - } - - // 如果不是立即重启,就把要删除的文件存放起来 - if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { - RestartHelper.saveFilesWhichToDelete(files); - } - } - }); + + @Override + public void done(PluginTaskResult result) { + if (result.isSuccess()) { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); } else { - JOptionPane.showMessageDialog(PluginUpdatePane.this, Inter.getLocText("FR-Designer-Plugin_Version_Is_Lower_Than_Current"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } - } else { - JOptionPane.showMessageDialog(PluginUpdatePane.this, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } - } catch (Exception e1) { - JOptionPane.showMessageDialog(PluginUpdatePane.this, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } + }); } /** diff --git a/designer_base/src/com/fr/design/extra/PluginUtils.java b/designer_base/src/com/fr/design/extra/PluginUtils.java new file mode 100644 index 000000000..20f19c144 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/PluginUtils.java @@ -0,0 +1,161 @@ +package com.fr.design.extra; + +import com.fr.base.TemplateUtils; +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginMarker; + +import com.fr.plugin.view.PluginView; +import com.fr.stable.EncodeConstants; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URLDecoder; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by ibm on 2017/5/25. + */ +public class PluginUtils { + + + public static PluginMarker createPluginMarker(String pluginInfo) { + //todo 判空 + String[] plugin = pluginInfo.split("_"); + PluginMarker pluginMarker = PluginMarker.create(plugin[0], plugin[1]); + return pluginMarker; + } + + public static JSONObject getLatestPluginInfo(String pluginID) throws Exception { + String result = ""; + String plistUrl = SiteCenter.getInstance().acquireUrlByKind("plugin.searchAPI"); + if (StringUtils.isNotEmpty(plistUrl)) { + StringBuilder url = new StringBuilder(plistUrl); + if (StringUtils.isNotBlank(pluginID)) { + url.append("?keyword=").append(pluginID); + } + try { + HttpClient httpClient = new HttpClient(url.toString()); + httpClient.asGet(); + result = httpClient.getResponseText(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } else { + result = PluginConstants.CONNECTION_404; + } + JSONObject resultJSONObject = new JSONObject(result); + JSONArray resultArr = resultJSONObject.getJSONArray("result"); + JSONObject latestPluginInfo = JSONObject.create(); + latestPluginInfo = (JSONObject) resultArr.get(0); + return latestPluginInfo; + } + + public static String transPluginsToString(List plugins) throws Exception { + JSONArray jsonArray = new JSONArray(); + for (PluginContext plugin : plugins) { + JSONObject jo = new JSONObject(); + jo.put("id", plugin.getID()); + jo.put("version", plugin.getVersion()); + jsonArray.put(jo); + } + return jsonArray.toString(); + } + + public static void downloadShopScripts(String id, String username, String password, Process p) throws Exception { + HttpClient httpClient = new HttpClient(getDownloadPath(id, username, password)); + if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { + int totalSize = httpClient.getContentLength(); + InputStream reader = httpClient.getResponseStream(); + String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE); + StableUtils.makesureFileExist(new File(temp)); + FileOutputStream writer = new FileOutputStream(temp); + byte[] buffer = new byte[PluginConstants.BYTES_NUM]; + int bytesRead = 0; + int totalBytesRead = 0; + + while ((bytesRead = reader.read(buffer)) > 0) { + writer.write(buffer, 0, bytesRead); + buffer = new byte[PluginConstants.BYTES_NUM]; + totalBytesRead += bytesRead; + p.process(totalBytesRead / (double) totalSize); + } + reader.close(); + writer.flush(); + writer.close(); + } else { + throw new com.fr.plugin.PluginVerifyException(Inter.getLocText("FR-Designer-Plugin_Connect_Server_Error")); + } + } + + private static String getDownloadPath(String id, String username, String password) throws Exception { + HashMap map = new HashMap(); + map.put("id", id); + map.put("username", username); + map.put("password", password); + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.download"), map); + String resText = httpClient.getResponseText(); + String charSet = EncodeConstants.ENCODING_UTF_8; + resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet); + + return resText; + } + + public static boolean isPluginMatch(PluginView pluginView, String text) { + return StringUtils.contains(pluginView.getID(), text) + || StringUtils.contains(pluginView.getName(), text) + || StringUtils.contains(pluginView.getVersion(), text) + || StringUtils.contains(pluginView.getEnvVersion(), text) + || StringUtils.contains(pluginView.getVendor(), text) + || StringUtils.contains(pluginView.getDescription(), text) + || StringUtils.contains(pluginView.getChangeNotes(), text); + + } + + public static String pluginToHtml(PluginView pluginView) { + String pluginName = Inter.getLocText("FR-Plugin-Plugin_Name"); + String pluginVersion = Inter.getLocText("FR-Plugin-Plugin_Version"); + String startVersion = Inter.getLocText("FR-Plugin-Start_Version"); + String developer = Inter.getLocText("FR-Plugin_Developer"); + String desc = Inter.getLocText("FR-Plugin-Function_Description"); + String updateLog = Inter.getLocText("FR-Plugin-Update_Log"); + Map map = new HashMap(); + + map.put("name", pluginName); + map.put("name_value", pluginView.getName()); + + map.put("version", pluginVersion); + map.put("version_value", pluginView.getVersion()); + + map.put("env", startVersion); + map.put("env_value", pluginView.getEnvVersion()); + + map.put("dev", developer); + map.put("dev_value", pluginView.getVendor()); + + map.put("fun", desc); + map.put("fun_value", pluginView.getDescription()); + + map.put("update", updateLog); + map.put("update_value", pluginView.getDescription()); + + try { + return TemplateUtils.renderTemplate("/com/fr/plugin/plugin.html", map); + } catch (IOException e) { + return StringUtils.EMPTY; + } + } + +} diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index f1759f016..126a85fa9 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -4,18 +4,16 @@ import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; import com.fr.design.dialog.UIDialog; -import com.fr.design.extra.exe.*; +import com.fr.design.extra.exe.callback.JSCallback; import com.fr.design.gui.ilable.UILabel; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.general.SiteCenter; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginLicense; -import com.fr.plugin.PluginLicenseManager; -import com.fr.plugin.PluginLoader; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.manage.PluginManager; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; -import javafx.concurrent.Task; import javafx.scene.web.WebEngine; import javafx.stage.FileChooser; import javafx.stage.Stage; @@ -46,6 +44,8 @@ public class PluginWebBridge { private UILabel uiLabel; + private static final String DESIGNERI18PREFIX = "FR-Designer-"; + /** * 动作枚举 */ @@ -143,42 +143,50 @@ public class PluginWebBridge { /** * 从插件服务器上安装插件 * - * @param pluginID 插件的ID - * @param callback 回调函数 + * @param pluginInfo 插件的ID + * @param callback 回调函数 */ - public void installPluginOnline(final String pluginID, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new InstallOnlineExecutor(pluginID)); - new Thread(task).start(); + public void installPluginOnline(final String pluginInfo, final JSObject callback) { + JSCallback jsCallback = new JSCallback(webEngine, callback); + PluginOperateUtils.installPluginOnline(pluginInfo, jsCallback); } + /** * 从磁盘上选择插件安装包进行安装 * * @param filePath 插件包的路径 */ public void installPluginFromDisk(final String filePath, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new InstallFromDiskExecutor(filePath)); - new Thread(task).start(); + JSCallback jsCallback = new JSCallback(webEngine, callback); + File file = new File(filePath); + PluginOperateUtils.installPluginFromDisk(file, jsCallback); } /** * 卸载当前选中的插件 * - * @param pluginIDs 插件集合 + * @param pluginInfo 插件信息 */ - public void uninstallPlugin(JSObject pluginIDs, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new UninstallExecutor(jsObjectToStringArray(pluginIDs))); - new Thread(task).start(); + public void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSObject callback) { + JSCallback jsCallback = new JSCallback(webEngine, callback); + PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback); } + /** * 从插件服务器上更新选中的插件 * * @param pluginIDs 插件集合 */ public void updatePluginOnline(JSObject pluginIDs, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new UpdateOnlineExecutor(jsObjectToStringArray(pluginIDs))); - new Thread(task).start(); + JSCallback jsCallback = new JSCallback(webEngine, callback); + String[] pluginInfos = jsObjectToStringArray(pluginIDs); + List pluginMarkerList = new ArrayList(); + for (int i = 0; i < pluginInfos.length; i++) { + pluginMarkerList.add(PluginUtils.createPluginMarker(pluginInfos[i])); + } + PluginOperateUtils.updatePluginOnline(pluginMarkerList, jsCallback); } /** @@ -187,8 +195,8 @@ public class PluginWebBridge { * @param filePath 插件包的路径 */ public void updatePluginFromDisk(String filePath, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new UpdateFromDiskExecutor(filePath)); - new Thread(task).start(); + JSCallback jsCallback = new JSCallback(webEngine, callback); + PluginOperateUtils.updatePluginFromDisk(filePath, jsCallback); } /** @@ -197,16 +205,16 @@ public class PluginWebBridge { * @param pluginID 插件ID */ public void setPluginActive(String pluginID, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new ModifyStatusExecutor(pluginID)); - new Thread(task).start(); + JSCallback jsCallback = new JSCallback(webEngine, callback); + PluginOperateUtils.setPluginActive(pluginID, jsCallback); } /** * 已安装插件检查更新 */ public void readUpdateOnline(final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new ReadUpdateOnlineExecutor()); - new Thread(task).start(); + JSCallback jsCallback = new JSCallback(webEngine, callback); + PluginOperateUtils.readUpdateOnline(jsCallback); } /** @@ -266,20 +274,11 @@ public class PluginWebBridge { * * @return 已安装的插件组成的数组 */ - public Plugin[] getInstalledPlugins() { - return PluginLoader.getLoader().getInstalled(); + public PluginContext[] getInstalledPlugins() { + List plugins = PluginManager.getContexts(); + return plugins.toArray(new PluginContext[plugins.size()]); } - - - /** - * 获取已经安装的插件的授权情况 - * - * @return 已安装的插件授权对象 - */ - public PluginLicense getPluginLicenseByID(String pluginID) { - return PluginLicenseManager.getInstance().getPluginLicenseByID(pluginID); - } - + private String[] jsObjectToStringArray(JSObject obj) { if (obj == null) { return ArrayUtils.EMPTY_STRING_ARRAY; @@ -298,8 +297,8 @@ public class PluginWebBridge { * @param keyword 关键字 */ public void searchPlugin(String keyword, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new SearchOnlineExecutor(keyword)); - new Thread(task).start(); + JSCallback jsCallback = new JSCallback(webEngine, callback); + PluginOperateUtils.searchPlugin(keyword, jsCallback); } /** @@ -311,18 +310,25 @@ public class PluginWebBridge { * @param callback 回调函数 */ public void getPluginFromStore(String category, String seller, String fee, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(category, seller, fee)); - new Thread(task).start(); + JSCallback jsCallback = new JSCallback(webEngine, callback); + PluginOperateUtils.getPluginFromStore(category, seller, fee, jsCallback); + } + + + public void getPluginPrefix(final JSObject callback){ + JSCallback jsCallback = new JSCallback(webEngine, callback); + PluginOperateUtils.getPluginPrefix(jsCallback); } + /** * 在线获取插件分类 * * @param callback 回调函数 */ public void getPluginCategories(final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new GetPluginCategoriesExecutor()); - new Thread(task).start(); + JSCallback jsCallback = new JSCallback(webEngine, callback); + PluginOperateUtils.getPluginCategories(jsCallback); } /** @@ -372,8 +378,8 @@ public class PluginWebBridge { * @param callback */ public void getLoginInfo(final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new GetLoginInfoExecutor()); - new Thread(task).start(); + JSCallback jsCallback = new JSCallback(webEngine, callback); + PluginOperateUtils.getLoginInfo(jsCallback); } /** @@ -439,60 +445,6 @@ public class PluginWebBridge { } } - /** - * 从硬盘升级 - * - * @param fileOnDisk 硬盘上的文件 - */ - public void updateFileFromDisk(File fileOnDisk) { - try { - Plugin plugin = PluginHelper.readPlugin(fileOnDisk); - if (plugin == null) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - return; - } - Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); - if (oldPlugin != null) { - // 说明安装了同ID的插件,再比较两个插件的版本 - if (PluginHelper.isNewThan(plugin, oldPlugin)) { - // 说明是新的插件,删除老的然后安装新的 - final String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); - PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { - @Override - public void done() { - int rv = JOptionPane.showOptionDialog( - null, - Inter.getLocText("FR-Designer-Plugin_Update_Successful"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.YES_NO_OPTION, - JOptionPane.INFORMATION_MESSAGE, - null, - new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), - Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later") - }, - null - ); - - if (rv == JOptionPane.OK_OPTION) { - RestartHelper.restart(); - } - // 如果不是立即重启,就把要删除的文件存放起来 - if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { - RestartHelper.saveFilesWhichToDelete(files); - } - } - }); - } else { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Version_Is_Lower_Than_Current"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } - } else { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(null, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } - } - /*-------------------------------登录部分的处理----------------------------------*/ @@ -529,8 +481,11 @@ public class PluginWebBridge { * @param password * @return */ - public String defaultLogin(String username, String password) { - return LoginWebBridge.getHelper().pluginManageLogin(username, password, uiLabel); + public void defaultLogin(String username, String password, final JSObject callback) { + JSCallback jsCallback = new JSCallback(webEngine, callback); + String result = LoginWebBridge.getHelper().pluginManageLogin(username, password, uiLabel); + jsCallback.execute(result); + } /** @@ -549,4 +504,26 @@ public class PluginWebBridge { DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY); uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); } + + /** + * 初始化设计器部分 + */ + public void initExtraDiff(final JSObject callback){ + + } + + /** + * 国际化 + */ + public String parseI18(final String key){ + return Inter.getLocText(DESIGNERI18PREFIX + key); + } + + /** + * 是否是在设计器中操作 + */ + public boolean isDesigner(){ + return true; + } + } diff --git a/designer_base/src/com/fr/design/extra/PluginsReaderFromStore.java b/designer_base/src/com/fr/design/extra/PluginsReaderFromStore.java index abd053362..add949796 100644 --- a/designer_base/src/com/fr/design/extra/PluginsReaderFromStore.java +++ b/designer_base/src/com/fr/design/extra/PluginsReaderFromStore.java @@ -6,15 +6,14 @@ import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONException; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginLoader; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.view.PluginView; +import com.fr.plugin.view.PluginViewReader; import com.fr.stable.EncodeConstants; import com.fr.stable.StringUtils; import java.net.URLDecoder; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; +import java.util.*; /** * @author richie @@ -22,15 +21,15 @@ import java.util.Set; * @since 8.0 */ public class PluginsReaderFromStore { - private static Set plugins = new HashSet(); - private static Set pluginsToUpdate = new HashSet(); + private static Set plugins = new HashSet(); + private static Set pluginsToUpdate = new HashSet(); /** * 从插件商店服务器读取插件信息,以JSON形式返回 * * @return 插件信息 */ - public static Plugin[] readPlugins() throws Exception { + public static List readPlugins() throws Exception { String resText; try { HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.store")); @@ -40,23 +39,7 @@ public class PluginsReaderFromStore { } catch (Exception e) { throw new Exception(Inter.getLocText("FR-Designer-Plugin_PluginMarket_Coding")); } - if (StringUtils.isNotEmpty(resText)) { - try { - plugins.clear();//先清空set - JSONArray jsonArray = new JSONArray(resText); - for (int i = 0, size = jsonArray.length(); i < size; i++) { - Plugin plugin = new Plugin(); - plugin.parseJSON(jsonArray.optJSONObject(i)); - if (plugin.isValidate()) { - plugins.add(plugin); - } - } - } catch (JSONException e) { - throw new Exception(Inter.getLocText("FR-Designer-Plugin_Read_Plugin_List_Error")); - } - } - - return plugins.toArray(new Plugin[plugins.size()]); + return parseResText(resText, plugins); } /** @@ -64,12 +47,12 @@ public class PluginsReaderFromStore { * * @return 插件信息 */ - public static Plugin[] readPluginsForUpdate() throws Exception { + public static List readPluginsForUpdate() throws Exception { String resText = null; String url = SiteCenter.getInstance().acquireUrlByKind("plugin.update"); if (StringUtils.isNotEmpty(url)) { HashMap para = new HashMap(); - para.put("plugins", PluginLoader.getLoader().pluginsToString()); + para.put("plugins", PluginUtils.transPluginsToString(PluginManager.getContexts())); //只有当前设计器的jar高于插件新版本需要的jarTime时, 才提示更新该插件. para.put("jarTime", GeneralUtils.readBuildNO()); HttpClient httpClient = new HttpClient(url, para); @@ -77,22 +60,25 @@ public class PluginsReaderFromStore { String charSet = EncodeConstants.ENCODING_UTF_8; resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet); } + return parseResText(resText, pluginsToUpdate); + } + + private static List parseResText(String resText, Set plugins) throws Exception { if (StringUtils.isNotEmpty(resText)) { try { - pluginsToUpdate.clear(); + plugins.clear(); JSONArray jsonArray = new JSONArray(resText); for (int i = 0, size = jsonArray.length(); i < size; i++) { - Plugin plugin = new Plugin(); - plugin.parseJSON(jsonArray.optJSONObject(i)); - if (plugin.isValidate()) { - pluginsToUpdate.add(plugin); + PluginView pluginView = PluginViewReader.readFromJson(jsonArray.optJSONObject(i)); + if (PluginOperateUtils.pluginValidate(pluginView)) { + plugins.add(pluginView); } } } catch (JSONException e) { throw new Exception(Inter.getLocText("FR-Designer-Plugin_Read_Plugin_List_Error")); } } - return pluginsToUpdate.toArray(new Plugin[pluginsToUpdate.size()]); + return new ArrayList<>(plugins); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/QQLoginWebPane.java b/designer_base/src/com/fr/design/extra/QQLoginWebPane.java index f3c96d219..096f9bb25 100644 --- a/designer_base/src/com/fr/design/extra/QQLoginWebPane.java +++ b/designer_base/src/com/fr/design/extra/QQLoginWebPane.java @@ -1,10 +1,7 @@ package com.fr.design.extra; import com.fr.base.FRContext; -import com.fr.general.ComparatorUtils; -import com.fr.general.FRLogger; -import com.fr.general.Inter; -import com.fr.general.SiteCenter; +import com.fr.general.*; import javafx.application.Platform; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; @@ -74,7 +71,7 @@ public class QQLoginWebPane extends JFXPanel { try { primaryStage.initStyle(StageStyle.TRANSPARENT); primaryStage.setScene(new Scene(layout)); - webView.getScene().getStylesheets().add(getClass().getResource("modal-dialog.css").toExternalForm()); + webView.getScene().getStylesheets().add(IOUtils.getResource("modal-dialog.css", getClass()).toExternalForm()); primaryStage.initStyle(StageStyle.UTILITY); primaryStage.setScene(new Scene(new Group(), DEFAULT_PRIMARYSTAGE_WIDTH, DEFAULT_PRIMARYSTAGE_HEIGHT)); primaryStage.setX(0); @@ -193,7 +190,7 @@ public class QQLoginWebPane extends JFXPanel { ); configDrag(dialog); // style and show the dialog. - dialog.getScene().getStylesheets().add(getClass().getResource("modal-dialog.css").toExternalForm()); + dialog.getScene().getStylesheets().add(IOUtils.getResource("modal-dialog.css", getClass()).toExternalForm()); dialog.setOnCloseRequest(new EventHandler() { @Override public void handle(WindowEvent event) { diff --git a/designer_base/src/com/fr/design/extra/WebViewDlgHelper.java b/designer_base/src/com/fr/design/extra/WebViewDlgHelper.java index 481498fc8..bccc259f2 100644 --- a/designer_base/src/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer_base/src/com/fr/design/extra/WebViewDlgHelper.java @@ -33,20 +33,20 @@ public class WebViewDlgHelper { public static void createPluginDialog() { if (StableUtils.getMajorJavaVersion() >= VERSION_8) { - String relativePath = "/scripts/store/web/index.html"; - String mainJsPath = StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath); + String relativePath = "index.html"; + String mainJsPath = StableUtils.pathJoin(FRContext.getCurrentEnv().getWebReportPath(), relativePath); File file = new File(mainJsPath); if (!file.exists()) { - int rv = JOptionPane.showConfirmDialog( - null, - Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE - ); - if (rv == JOptionPane.OK_OPTION) { - downloadShopScripts(SHOP_SCRIPTS); - } +// int rv = JOptionPane.showConfirmDialog( +// null, +// Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), +// Inter.getLocText("FR-Designer-Plugin_Warning"), +// JOptionPane.OK_CANCEL_OPTION, +// JOptionPane.INFORMATION_MESSAGE +// ); +// if (rv == JOptionPane.OK_OPTION) { +// downloadShopScripts(SHOP_SCRIPTS); +// } } else { updateShopScripts(SHOP_SCRIPTS); showPluginDlg(mainJsPath); @@ -111,7 +111,7 @@ public class WebViewDlgHelper { } private static void showLoginDlg() { - LoginWebPane webPane = new LoginWebPane(new File(installHome).getAbsolutePath()); + LoginWebPane webPane = new LoginWebPane(FRContext.getCurrentEnv().getWebReportPath()); UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(), webPane); LoginWebBridge.getHelper().setDialogHandle(qqdlg); qqdlg.setVisible(true); @@ -133,7 +133,7 @@ public class WebViewDlgHelper { String username = DesignerEnvManager.getEnvManager().getBBSName(); String password = DesignerEnvManager.getEnvManager().getBBSPassword(); try { - PluginHelper.downloadPluginFile(scriptsId, username, password, new Process() { + PluginUtils.downloadShopScripts(scriptsId, username, password, new Process() { @Override public void process(Double integer) { } @@ -153,7 +153,8 @@ public class WebViewDlgHelper { try { if (get()) { - IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); + IOUtils.unzip(new File(StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE)), FRContext.getCurrentEnv().getWebReportPath()); + // TODO: 2017/4/17 删除之前存放在安装目录下的script int rv = JOptionPane.showOptionDialog( null, Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), @@ -184,16 +185,16 @@ public class WebViewDlgHelper { if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { String text = httpClient.getResponseText(); if (!ComparatorUtils.equals(text, LATEST)) { - int rv = JOptionPane.showConfirmDialog( - null, - Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE - ); - if (rv == JOptionPane.OK_OPTION) { - downloadShopScripts(scriptsId); - } +// int rv = JOptionPane.showConfirmDialog( +// null, +// Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), +// Inter.getLocText("FR-Designer-Plugin_Warning"), +// JOptionPane.OK_CANCEL_OPTION, +// JOptionPane.INFORMATION_MESSAGE +// ); +// if (rv == JOptionPane.OK_OPTION) { +// downloadShopScripts(scriptsId); +// } } } return null; diff --git a/designer_base/src/com/fr/design/extra/exe/GetLoginInfoExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetLoginInfoExecutor.java deleted file mode 100644 index 91402c47c..000000000 --- a/designer_base/src/com/fr/design/extra/exe/GetLoginInfoExecutor.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.design.DesignerEnvManager; -import com.fr.design.extra.Process; -import com.fr.stable.StringUtils; - -/** - * Created by lp on 2016/8/16. - */ -public class GetLoginInfoExecutor implements Executor { - private String result = "[]"; - - @Override - public String getTaskFinishMessage() { - return result; - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return null; - } - - @Override - public void run(Process process) { - String username = DesignerEnvManager.getEnvManager().getBBSName(); - String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName(); - if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)) { - }else { - result = StringUtils.isEmpty(inShowUsername) ? username : inShowUsername; - } - } - } - }; - } -} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java deleted file mode 100644 index 92aa0bbe8..000000000 --- a/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.design.extra.PluginHelper; -import com.fr.design.extra.Process; -import com.fr.general.SiteCenter; -import com.fr.general.http.HttpClient; - -/** - * Created by vito on 16/5/16. - */ -public class GetPluginCategoriesExecutor implements Executor { - private String result = "[]"; - - @Override - public String getTaskFinishMessage() { - return result; - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return null; - } - - @Override - public void run(Process process) { - String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category"); - if (url != null) { - HttpClient httpClient = new HttpClient(url); - result = httpClient.getResponseText(); - } else { - result = PluginHelper.CONNECTION_404; - } - - } - } - }; - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java deleted file mode 100644 index 9bd7e2bbe..000000000 --- a/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.design.extra.PluginHelper; -import com.fr.design.extra.Process; -import com.fr.general.FRLogger; -import com.fr.general.SiteCenter; -import com.fr.general.http.HttpClient; -import com.fr.stable.StringUtils; - -/** - * Created by vito on 16/4/18. - * 获取插件分类信息 - */ -public class GetPluginFromStoreExecutor implements Executor { - private String result = "[]"; - private String category; - private String seller; - private String fee; - - public GetPluginFromStoreExecutor(String category, String seller, String fee) { - this.category = category; - this.seller = seller; - this.fee = fee; - } - - @Override - public String getTaskFinishMessage() { - return result; - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return StringUtils.EMPTY; - } - - @Override - public void run(Process process) { - String plistUrl = SiteCenter.getInstance().acquireUrlByKind("plugin.plist"); - if (StringUtils.isNotBlank(plistUrl)) { - StringBuilder url = new StringBuilder(); - url.append(plistUrl); - if (StringUtils.isNotBlank(category)) { - url.append("&cid=").append(category.split("-")[1]); - } - if (StringUtils.isNotBlank(seller)) { - url.append("&seller=").append(seller.split("-")[1]); - } - if (StringUtils.isNotBlank(fee)) { - url.append("&fee=").append(fee.split("-")[1]); - } - try { - HttpClient httpClient = new HttpClient(url.toString()); - result = httpClient.getResponseText(); - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); - } - } else { - result = PluginHelper.CONNECTION_404; - } - } - } - }; - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java b/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java deleted file mode 100644 index da5222f96..000000000 --- a/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.design.extra.After; -import com.fr.design.extra.PluginHelper; -import com.fr.design.extra.PluginWebBridge; -import com.fr.design.extra.Process; -import com.fr.general.FRLogger; -import com.fr.general.Inter; -import com.fr.plugin.PluginVerifyException; - -import javax.swing.*; -import java.io.File; - -/** - * Created by richie on 16/3/19. - */ -public class InstallFromDiskExecutor implements Executor { - private String filePath; - - public InstallFromDiskExecutor(String filePath) { - this.filePath = filePath; - - } - - @Override - public String getTaskFinishMessage() { - return "已成功安装"; - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return "正在解压文件" + filePath; - } - - @Override - public void run(Process process) { - - } - }, - new Command() { - @Override - public String getExecuteMessage() { - return "正在安装"; - } - - @Override - public void run(Process process) { - try { - PluginHelper.installPluginFromDisk(new File(filePath), new After() { - @Override - public void done() { - FRLogger.getLogger().info("插件安装成功"); - PluginWebBridge.getHelper().showRestartMessage(Inter.getLocText("FR-Designer-Plugin_Install_Successful")); - } - }); - } catch (PluginVerifyException e) { - JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); - } - } - } - }; - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java deleted file mode 100644 index 53fc738ad..000000000 --- a/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.base.FRContext; -import com.fr.design.DesignerEnvManager; -import com.fr.design.RestartHelper; -import com.fr.design.extra.After; -import com.fr.design.extra.LoginCheckContext; -import com.fr.design.extra.PluginHelper; -import com.fr.design.extra.Process; -import com.fr.general.Inter; -import com.fr.plugin.PluginVerifyException; -import com.fr.plugin.dependence.PluginDependenceException; -import com.fr.stable.StringUtils; - -import javax.swing.*; - -/** - * Created by richie on 16/3/19. - */ -public class InstallOnlineExecutor implements Executor { - - private String pluginID; - - public InstallOnlineExecutor(String pluginID) { - this.pluginID = pluginID; - } - - @Override - public String getTaskFinishMessage() { - return "task succeed"; - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return "正在下载插件:" + pluginID; - } - - @Override - public void run(final Process process) { - //下载插件 - if(StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())){ - LoginCheckContext.fireLoginCheckListener(); - } - if(StringUtils.isNotBlank(DesignerEnvManager.getEnvManager().getBBSName())) { - String username = DesignerEnvManager.getEnvManager().getBBSName(); - String password = DesignerEnvManager.getEnvManager().getBBSPassword(); - try { - PluginHelper.downloadPluginFile(pluginID, username, password, new Process() { - @Override - public void process(Double integer) { - process.process(Math.round(integer * 100) + "%"); - } - }); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - } - } - }, - new Command() { - @Override - public String getExecuteMessage() { - return "正在安装插件:" + pluginID; - } - - @Override - public void run(Process process) { - try { - PluginHelper.installPluginFromDisk(PluginHelper.getDownloadTempFile(), new After() { - @Override - public void done() { - int rv = JOptionPane.showOptionDialog( - null, - Inter.getLocText("FR-Designer-Plugin_Install_Successful"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.YES_NO_OPTION, - JOptionPane.INFORMATION_MESSAGE, - null, - new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")}, - null - ); - if (rv == JOptionPane.OK_OPTION) { - RestartHelper.restart(); - } - } - }); - } catch (PluginVerifyException e) { - JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } catch (PluginDependenceException e){ - JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - }; - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java b/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java deleted file mode 100644 index c544858dd..000000000 --- a/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.base.FRContext; -import com.fr.design.extra.PluginWebBridge; -import com.fr.design.extra.Process; -import com.fr.general.Inter; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginLoader; -import com.fr.stable.StringUtils; - -/** - * Created by richie on 16/3/19. - */ -public class ModifyStatusExecutor implements Executor { - - private String pluginID; - private boolean active; - private Plugin plugin; - - public ModifyStatusExecutor(String pluginID) { - this.pluginID = pluginID; - } - - @Override - public String getTaskFinishMessage() { - return plugin.isActive() ? Inter.getLocText("FR-Designer-Plugin_Has_Been_Actived") : Inter.getLocText("FR-Designer-Plugin_Has_Been_Disabled"); - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return StringUtils.EMPTY; - } - - @Override - public void run(Process process) { - plugin = PluginLoader.getLoader().getPluginById(pluginID); - active = !plugin.isActive(); - plugin.setActive(active); - try { - FRContext.getCurrentEnv().writePlugin(plugin); - PluginWebBridge.getHelper().showRestartMessage(plugin.isActive() ? Inter.getLocText("FR-Designer-Plugin_Has_Been_Actived") : Inter.getLocText("FR-Designer-Plugin_Has_Been_Disabled")); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); - } - } - } - }; - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java b/designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java deleted file mode 100644 index c1101f800..000000000 --- a/designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.design.extra.LoginWebBridge; -import com.fr.design.extra.Process; -import com.fr.design.gui.ilable.UILabel; - -/** - * Created by Slpire on 2016/11/7. - */ -public class PluginLoginExecutor implements Executor { - - private String result = "[]"; - - private String username; - private String password; - private UILabel uiLabel; - - public PluginLoginExecutor(String username, String password, UILabel uiLabel) { - this.username = username; - this.password = password; - this.uiLabel = uiLabel; - } - - @Override - public String getTaskFinishMessage() { - return result; - } - - @Override - public Command[] getCommands() { - return new Command[] { - new Command() { - @Override - public String getExecuteMessage() { - return null; - } - - @Override - public void run(Process process) { - String loginResult = LoginWebBridge.getHelper().login(username, password, uiLabel); - if (Integer.valueOf(loginResult) == 0) { - LoginWebBridge.getHelper().updateMessageCount(); - } - result = loginResult; - } - } - }; - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java deleted file mode 100644 index c510a67cc..000000000 --- a/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.design.extra.PluginsReaderFromStore; -import com.fr.design.extra.Process; -import com.fr.general.FRLogger; - -import com.fr.plugin.Plugin; -import com.fr.stable.StringUtils; -import org.json.JSONArray; -import org.json.JSONObject; - -/** - * Created by vito on 16/4/19. - */ -public class ReadUpdateOnlineExecutor implements Executor { - private Plugin[] plugins; - private String result; - - @Override - public String getTaskFinishMessage() { - return result; - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return StringUtils.EMPTY; - } - - @Override - public void run(Process process) { - try { - plugins = PluginsReaderFromStore.readPluginsForUpdate(); - JSONArray jsonArray = new JSONArray(); - for (Plugin plugin : plugins) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("pluginid", plugin.getId()); - jsonArray.put(jsonObject); - } - result = jsonArray.toString(); - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); - } - } - } - }; - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/SearchOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/SearchOnlineExecutor.java deleted file mode 100644 index 089173c98..000000000 --- a/designer_base/src/com/fr/design/extra/exe/SearchOnlineExecutor.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.design.extra.Process; -import com.fr.general.FRLogger; -import com.fr.general.SiteCenter; -import com.fr.general.http.HttpClient; -import com.fr.stable.StringUtils; - -/** - * Created by vito on 16/4/18. - */ -public class SearchOnlineExecutor implements Executor { - private String result; - private String keyword; - - public SearchOnlineExecutor(String keyword) { - this.keyword = keyword; - } - - @Override - public String getTaskFinishMessage() { - return result; - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return StringUtils.EMPTY; - } - - @Override - public void run(Process process) { - try { - HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword); - result = httpClient.getResponseText(); - - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); - } - } - } - }; - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java b/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java deleted file mode 100644 index d8fc7d9ec..000000000 --- a/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.base.FRContext; -import com.fr.design.RestartHelper; -import com.fr.design.extra.PluginHelper; -import com.fr.design.extra.Process; -import com.fr.general.Inter; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginLoader; - -import javax.swing.*; - -/** - * Created by richie on 16/3/19. - */ -public class UninstallExecutor implements Executor { - - private String[] pluginIDs; - private String result = "undo"; - - public UninstallExecutor(String[] pluginIDs) { - this.pluginIDs = pluginIDs; - } - - @Override - public String getTaskFinishMessage() { - return result; - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return null; - } - - @Override - public void run(Process process) { - int rv = JOptionPane.showOptionDialog( - null, - Inter.getLocText("FR-Designer-Plugin_Will_Be_Delete"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, - null, - new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), - Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later"), - Inter.getLocText("FR-Designer-Basic_Cancel") - }, - null - ); - if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { - return; - } - for (String pluginID : pluginIDs) { - try { - Plugin plugin = PluginLoader.getLoader().getPluginById(pluginID); - String[] filesToBeDelete = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), plugin); - RestartHelper.saveFilesWhichToDelete(filesToBeDelete); - } catch (Exception e) { - JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } - } - result = "done"; - if (rv == JOptionPane.OK_OPTION) { - RestartHelper.restart(); - } - } - } - }; - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java b/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java deleted file mode 100644 index 5c8c6e361..000000000 --- a/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.design.extra.PluginWebBridge; -import com.fr.design.extra.Process; - -import java.io.File; - -/** - * Created by richie on 16/3/19. - */ -public class UpdateFromDiskExecutor implements Executor { - - private String filePath; - - public UpdateFromDiskExecutor(String filePath) { - this.filePath = filePath; - } - - @Override - public String getTaskFinishMessage() { - return "插件更新操作结束"; - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return null; - } - - @Override - public void run(Process process) { - PluginWebBridge.getHelper().updateFileFromDisk(new File(filePath)); - } - } - }; - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java deleted file mode 100644 index fa295cd36..000000000 --- a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.fr.design.extra.exe; - -import com.fr.base.FRContext; -import com.fr.design.DesignerEnvManager; -import com.fr.design.RestartHelper; -import com.fr.design.extra.After; -import com.fr.design.extra.LoginCheckContext; -import com.fr.design.extra.PluginHelper; -import com.fr.design.extra.Process; -import com.fr.general.Inter; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginLoader; -import com.fr.plugin.PluginVerifyException; -import com.fr.stable.StringUtils; - -import javax.swing.*; -import java.io.File; - -/** - * Created by richie on 16/3/19. - */ -public class UpdateOnlineExecutor implements Executor { - - private String[] pluginIDs; - private static final int PERCENT_100 = 100; - - public UpdateOnlineExecutor(String[] pluginIDs) { - this.pluginIDs = pluginIDs; - } - - @Override - public String getTaskFinishMessage() { - return "task succeed"; - } - - @Override - public Command[] getCommands() { - return new Command[]{ - new Command() { - @Override - public String getExecuteMessage() { - return null; - } - - @Override - public void run(Process process) { - if (StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())) { - LoginCheckContext.fireLoginCheckListener(); - } - if (StringUtils.isNotBlank(DesignerEnvManager.getEnvManager().getBBSName())) { - try { - for (int i = 0; i < pluginIDs.length; i++) { - try { - Plugin plugin = PluginLoader.getLoader().getPluginById(pluginIDs[i]); - String id = null; - if (plugin != null) { - id = plugin.getId(); - } - String username = DesignerEnvManager.getEnvManager().getBBSName(); - String password = DesignerEnvManager.getEnvManager().getBBSPassword(); - PluginHelper.downloadPluginFile(id, username, password, new Process() { - @Override - public void process(Double integer) { - } - }); - updateFileFromDisk(PluginHelper.getDownloadTempFile()); - process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%"); - } catch (PluginVerifyException e) { - throw e; - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - } - int rv = JOptionPane.showOptionDialog( - null, - Inter.getLocText("FR-Designer-Plugin_Update_Successful"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.YES_NO_OPTION, - JOptionPane.INFORMATION_MESSAGE, - null, - new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), - Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later") - }, - null - ); - if (rv == JOptionPane.OK_OPTION) { - RestartHelper.restart(); - } - } catch (PluginVerifyException e) { - JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } - } - } - } - }; - } - - private void updateFileFromDisk(File fileOnDisk) throws Exception { - Plugin plugin = PluginHelper.readPlugin(fileOnDisk); - if (plugin == null) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - return; - } - Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); - if (oldPlugin != null) { - String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); - PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { - @Override - public void done() { - } - }); - } else { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/callback/AbstractPluginTaskCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/AbstractPluginTaskCallback.java new file mode 100644 index 000000000..3f13f531d --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/callback/AbstractPluginTaskCallback.java @@ -0,0 +1,19 @@ +package com.fr.design.extra.exe.callback; + +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.manage.control.ProgressCallback; + + +/** + * Created by ibm on 2017/5/26. + */ +public abstract class AbstractPluginTaskCallback implements ProgressCallback{ + + protected PluginMarker pluginMarker; + + @Override + public void updateProgress(String description, double aProgress) { + } + + +} diff --git a/designer_base/src/com/fr/design/extra/exe/callback/DownloadCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/DownloadCallback.java new file mode 100644 index 000000000..1c851b5d6 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/callback/DownloadCallback.java @@ -0,0 +1,36 @@ +package com.fr.design.extra.exe.callback; + +import com.fr.design.extra.exe.extratask.ExtraPluginTask; +import com.fr.general.Inter; +import com.fr.plugin.manage.control.PluginTaskResult; + +import javax.swing.*; + +/** + * Created by ibm on 2017/5/26. + */ +public class DownloadCallback extends AbstractPluginTaskCallback { + private ExtraPluginTask extraPluginTask; + private JSCallback jsCallback; + private static int HUNDRED_PERCENT = 100; + + public DownloadCallback(final ExtraPluginTask extraPluginTask, final JSCallback jsCallback) { + this.extraPluginTask = extraPluginTask; + this.jsCallback = jsCallback; + } + + @Override + public void updateProgress(String description, double aProgress) { + jsCallback.execute(String.valueOf(aProgress * HUNDRED_PERCENT + "%")); + } + + @Override + public void done(PluginTaskResult result) { + if (result.isSuccess()) { + extraPluginTask.doExtraPluginTask(); + } else { + jsCallback.execute("failed"); + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java new file mode 100644 index 000000000..9f0fdcdbe --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -0,0 +1,57 @@ +package com.fr.design.extra.exe.callback; + +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTaskResult; + +import javax.swing.*; +import java.io.File; + +/** + * Created by ibm on 2017/5/26. + */ +public class InstallFromDiskCallback extends AbstractPluginTaskCallback { + private File zipFile; + private JSCallback jsCallback; + private static int HUNDRED_PERCENT = 100; + + public InstallFromDiskCallback(final File zipFile, final JSCallback jsCallback) { + this.zipFile = zipFile; + this.jsCallback = jsCallback; + } + + @Override + public void updateProgress(String description, double aProgress) { + jsCallback.execute(String.valueOf(aProgress * HUNDRED_PERCENT + "%")); + } + + + @Override + public void done(PluginTaskResult result) { + jsCallback.execute("success"); + if (result.isSuccess()) { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Success")); + } else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) { + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + null, + null + ); + if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + return; + } + PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback)); + } else { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Failed")); + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java new file mode 100644 index 000000000..aa1666179 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -0,0 +1,57 @@ +package com.fr.design.extra.exe.callback; + +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTaskResult; + +import javax.swing.*; + +/** + * Created by ibm on 2017/5/26. + */ +public class InstallOnlineCallback extends AbstractPluginTaskCallback { + protected JSCallback jsCallback; + private static int HUNDRED_PERCENT = 100; + + public InstallOnlineCallback(PluginMarker pluginMarker, JSCallback jsCallback){ + this.pluginMarker = pluginMarker; + this.jsCallback = jsCallback; + } + + @Override + public void updateProgress(String description, double aProgress) { + jsCallback.execute(String.valueOf(aProgress * HUNDRED_PERCENT + "%")); + } + + + @Override + public void done(PluginTaskResult result) { + jsCallback.execute("success"); + if (result.isSuccess()) { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Success")); + } else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) { + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + null, + null + ); + if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + return; + } + //执行JS回调 + PluginManager.getController().install(pluginMarker, new InstallOnlineCallback(pluginMarker, jsCallback)); + } else { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Failed")); + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java new file mode 100644 index 000000000..bf421e67f --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java @@ -0,0 +1,95 @@ +package com.fr.design.extra.exe.callback; + +import com.fr.stable.StringUtils; +import javafx.application.Platform; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.concurrent.Task; +import javafx.scene.web.WebEngine; +import netscape.javascript.JSObject; + +/** + * Created by ibm on 2017/5/27. + */ +public class JSCallback extends Task { + + + public JSCallback(final WebEngine webEngine, final JSObject callback) { + init(webEngine, callback); + } + + public void init(final WebEngine webEngine, final JSObject callback){ + messageProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, String oldValue, String newValue) { + Platform.runLater(new Runnable() { + @Override + public void run() { + String fun = "(" + callback + ")(\"" + trimText(newValue) + "\")"; + try { + webEngine.executeScript(fun); + } catch (Exception e) { + webEngine.executeScript("alert(\"" + e.getMessage() + "\")"); + } + } + }); + } + }); + } + @Override + protected T call() throws Exception { + return null; + } + + public void execute(String newValue) { + updateMessage(newValue); + } + + + /** + * vito:由于使用webEngine.executeScript("(" + callback + ")(\"" + newValue + "\")") + * 执行脚本,所以原来规范的json格式也会在拼接字符串后可能抛出参数异常,需要转换掉一些会造成错误的特殊字符, + * 选择在java端替换的原因是异常抛出自executeScript方法的参数. + *

+ * 1.""中的""必须转义 + * 2.js字符串中的\n会导致js字符串变成多行,而js字符串不支持多行拼接 + * 3.由JSONObject.toString()得到的字符串中html标签的属性会自动加上\造成替换难度加大, + * 这边建议去除所有的html标签 + * 字符\在java中实际存储的是\\,替换字符串\\n, 需要用\\\\n + * "\t"和"\n" 都要转义成" " 不然会解析出错 + * "\\"需要转换成"\" + * 过滤掉html标签及内容 + * + * @param old 原始字符串 + * @return 处理之后的字符串 + */ + private String trimText(String old) { + if (StringUtils.isNotBlank(old)) { + String a = filterHtmlTag(old, "a"); + String b = filterHtmlTag(a, "font"); + return b.replaceAll("\\\\n", "").replaceAll("\\\\t", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'").replaceAll("\\\\\\\\", "\\\\"); + } + return StringUtils.EMPTY; + } + + /** + * 进行html标签过滤 + * @param origin 原始字符串 + * @param tag html标签 + * @return 处理之后的字符串 + */ + private String filterHtmlTag(String origin, String tag) { + String matter1 = "<" + tag; + String matter2 = tag + ">"; + int a = origin.indexOf(matter1); + int b = origin.indexOf(matter2); + while (a != -1 && b != -1) { + origin = origin.substring(0, a) + origin.substring(b + matter2.length(), origin.length()); + a = origin.indexOf(matter1); + b = origin.indexOf(matter2); + } + return origin; + } + +} + diff --git a/designer_base/src/com/fr/design/extra/exe/callback/ModifyStatusCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/ModifyStatusCallback.java new file mode 100644 index 000000000..5545c06c4 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/callback/ModifyStatusCallback.java @@ -0,0 +1,31 @@ +package com.fr.design.extra.exe.callback; + +import com.fr.general.Inter; +import com.fr.plugin.manage.control.PluginTaskCallback; +import com.fr.plugin.manage.control.PluginTaskResult; + +import javax.swing.*; + +/** + * Created by ibm on 2017/5/27. + */ +public class ModifyStatusCallback implements PluginTaskCallback{ + private boolean isActive; + private JSCallback jsCallback; + + public ModifyStatusCallback (boolean isActive, JSCallback jsCallback){ + this.isActive = isActive; + this.jsCallback = jsCallback; + } + @Override + public void done(PluginTaskResult result) { + if (result.isSuccess()) { + jsCallback.execute("success"); + String modifyMessage = isActive ? Inter.getLocText("FR-Designer-Plugin_Disabled") : Inter.getLocText("FR-Designer-Plugin_Actived"); + JOptionPane.showMessageDialog(null, modifyMessage); + } else { + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } + +} diff --git a/designer_base/src/com/fr/design/extra/exe/callback/UninstallPluginCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/UninstallPluginCallback.java new file mode 100644 index 000000000..52fec77dd --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/callback/UninstallPluginCallback.java @@ -0,0 +1,49 @@ +package com.fr.design.extra.exe.callback; + +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTaskResult; + +import javax.swing.*; + +/** + * Created by ibm on 2017/5/27. + */ +public class UninstallPluginCallback extends AbstractPluginTaskCallback { + private JSCallback jsCallback; + + public UninstallPluginCallback(PluginMarker pluginMarker, JSCallback jsCallback){ + this.jsCallback = jsCallback; + this.pluginMarker = pluginMarker; + } + + @Override + public void done(PluginTaskResult result) { + if (result.isSuccess()) { + jsCallback.execute("success"); + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Success")); + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Delete_Success")); + }else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) { + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Delete_Dependence")), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + null, + null + ); + if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + return; + } + PluginManager.getController().uninstall(pluginMarker, true, new UninstallPluginCallback(pluginMarker, jsCallback)); + } else { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Failed")); + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java new file mode 100644 index 000000000..978503983 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -0,0 +1,57 @@ +package com.fr.design.extra.exe.callback; + +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTaskResult; + +import javax.swing.*; +import java.io.File; + +/** + * Created by ibm on 2017/5/27. + */ +public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { + private File zipFile; + private JSCallback jsCallback; + private static int HUNDRED_PERCENT = 100; + + public UpdateFromDiskCallback(File zipFile, JSCallback jsCallback) { + this.zipFile = zipFile; + this.jsCallback = jsCallback; + } + + @Override + public void updateProgress(String description, double aProgress) { + jsCallback.execute(String.valueOf(aProgress * HUNDRED_PERCENT + "%")); + } + + + @Override + public void done(PluginTaskResult result) { + jsCallback.execute("success"); + if (result.isSuccess()) { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Update_Success")); + } else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) { + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Update_Dependence")), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + null, + null + ); + if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + return; + } + PluginManager.getController().update(zipFile, new UpdateFromDiskCallback(zipFile, jsCallback)); + } else { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Failed")); + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java new file mode 100644 index 000000000..51f5a3597 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -0,0 +1,57 @@ +package com.fr.design.extra.exe.callback; + +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTaskResult; + +import javax.swing.*; + +/** + * Created by ibm on 2017/5/26. + */ +public class UpdateOnlineCallback extends AbstractPluginTaskCallback { + public PluginMarker toPluginMarker; + protected JSCallback jsCallback; + private static int HUNDRED_PERCENT = 100; + + public UpdateOnlineCallback(PluginMarker pluginMarker, PluginMarker toPluginMarker, JSCallback jsCallback) { + this.pluginMarker = pluginMarker; + this.toPluginMarker = toPluginMarker; + this.jsCallback = jsCallback; + } + + @Override + public void updateProgress(String description, double aProgress) { + jsCallback.execute(String.valueOf(aProgress * HUNDRED_PERCENT + "%")); + } + + @Override + public void done(PluginTaskResult result) { + jsCallback.execute("success"); + if (result.isSuccess()) { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Update_Success")); + } else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) { + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Update_Dependence")), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + null, + null + ); + if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + return; + } + PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, jsCallback)); + } else { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Failed")); + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/extratask/AbstractExtraPluginTask.java b/designer_base/src/com/fr/design/extra/exe/extratask/AbstractExtraPluginTask.java new file mode 100644 index 000000000..a287ca7ed --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/extratask/AbstractExtraPluginTask.java @@ -0,0 +1,10 @@ +package com.fr.design.extra.exe.extratask; + +import com.fr.plugin.context.PluginMarker; + +/** + * Created by ibm on 2017/5/27. + */ +public abstract class AbstractExtraPluginTask implements ExtraPluginTask { + protected PluginMarker pluginMarker; +} diff --git a/designer_base/src/com/fr/design/extra/exe/extratask/ExtraPluginTask.java b/designer_base/src/com/fr/design/extra/exe/extratask/ExtraPluginTask.java new file mode 100644 index 000000000..834d59e38 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/extratask/ExtraPluginTask.java @@ -0,0 +1,10 @@ +package com.fr.design.extra.exe.extratask; + + +/** + * Created by ibm on 2017/5/27. + */ +public interface ExtraPluginTask { + + void doExtraPluginTask(); +} diff --git a/designer_base/src/com/fr/design/extra/exe/extratask/InstallPluginTask.java b/designer_base/src/com/fr/design/extra/exe/extratask/InstallPluginTask.java new file mode 100644 index 000000000..37ac42d4d --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/extratask/InstallPluginTask.java @@ -0,0 +1,26 @@ +package com.fr.design.extra.exe.extratask; + + +import com.fr.design.extra.exe.callback.InstallOnlineCallback; +import com.fr.design.extra.exe.callback.JSCallback; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.manage.PluginManager; + + +/** + * Created by ibm on 2017/5/27. + */ +public class InstallPluginTask extends AbstractExtraPluginTask { + protected JSCallback jsCallback; + + + public InstallPluginTask(PluginMarker pluginMarker, JSCallback jsCallback) { + this.pluginMarker = pluginMarker; + this.jsCallback = jsCallback; + } + + @Override + public void doExtraPluginTask() { + PluginManager.getController().install(pluginMarker, new InstallOnlineCallback(pluginMarker, jsCallback)); + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/extratask/UpdatePluginTask.java b/designer_base/src/com/fr/design/extra/exe/extratask/UpdatePluginTask.java new file mode 100644 index 000000000..7cfdf9622 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/extratask/UpdatePluginTask.java @@ -0,0 +1,26 @@ +package com.fr.design.extra.exe.extratask; + +import com.fr.design.extra.exe.callback.JSCallback; +import com.fr.design.extra.exe.callback.UpdateOnlineCallback; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.manage.PluginManager; + +/** + * Created by ibm on 2017/5/27. + */ +public class UpdatePluginTask extends AbstractExtraPluginTask { + + public PluginMarker toPluginMarker; + protected JSCallback jsCallback; + + public UpdatePluginTask(PluginMarker pluginMarker, PluginMarker toPluginMarker, JSCallback jsCallback) { + this.pluginMarker = pluginMarker; + this.toPluginMarker = toPluginMarker; + this.jsCallback = jsCallback; + } + + @Override + public void doExtraPluginTask() { + PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, jsCallback)); + } +} diff --git a/designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java b/designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java deleted file mode 100644 index 29097a5ee..000000000 --- a/designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java +++ /dev/null @@ -1,281 +0,0 @@ -package com.fr.design.extra.plugindependence; - -import com.fr.base.FRContext; -import com.fr.design.extra.PluginHelper; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.DesignerContext; -import com.fr.general.IOUtils; -import com.fr.general.Inter; -import com.fr.general.SiteCenter; -import com.fr.general.http.HttpClient; -import com.fr.plugin.dependence.PluginDependenceException; -import com.fr.plugin.dependence.PluginDependenceUnit; -import com.fr.stable.StableUtils; -import com.fr.stable.StringUtils; -import com.fr.stable.plugin.PluginConstants; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.util.List; - -/** - * Created by hufan on 2016/9/5. - */ -public class DownLoadDependenceUI implements ActionListener { - //进度显示界面 - private JDialog frame = null; - //进度条 - private JProgressBar progressbar; - //进度信息 - private JLabel label; - //进度条更新时钟 - private Timer timer; - //是否继续下载 - private boolean flag = true; - - // 定义加载窗口大小 - private static final int LOAD_WIDTH = 455; - - private static final int INCIDENT_WIDTH = 15; - - private static final int LOAD_HEIGHT = 295; - - - //安装环境相关信息 - private String currentID; - private List list = null; - //安装结果 - private boolean result = false; - //链接服务器的客户端 - private HttpClient httpClient; - //已读文件字节数 - private int totalBytesRead = 0; - //文件总长度 - private int totalSize = 0; - - public DownLoadDependenceUI() { - } - public DownLoadDependenceUI(String currentID, List list) { - this.currentID = currentID; - this.list = list; - this.totalSize = getFileLength(); - init(); - } - - private void init() { - // 创建标签,并在标签上放置一张图片 - BufferedImage image = IOUtils.readImage("/com/fr/design/extra/plugindependence/image/background.png"); - ImageIcon imageIcon = new ImageIcon(image); - label = new UILabel(imageIcon); - label.setBounds(0, 0, LOAD_WIDTH, LOAD_HEIGHT - INCIDENT_WIDTH); - - progressbar = new JProgressBar(); - // 显示当前进度值信息 - progressbar.setStringPainted(true); - // 设置进度条边框不显示 - progressbar.setBorderPainted(false); - // 设置进度条的前景色 - progressbar.setForeground(new Color(0x38aef5)); - // 设置进度条的背景色 - progressbar.setBackground(new Color(188, 190, 194)); - progressbar.setBounds(0, LOAD_HEIGHT - INCIDENT_WIDTH, LOAD_WIDTH, INCIDENT_WIDTH); - progressbar.setMinimum(0); - progressbar.setMaximum(totalSize); - progressbar.setValue(0); - - timer = new Timer(100, this); - - frame = new JDialog(DesignerContext.getDesignerFrame(), true); - frame.setTitle(Inter.getLocText("FR-Designer-Dependence_Install_Online")); - frame.setSize(LOAD_WIDTH, LOAD_HEIGHT); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - frame.setLocation(screenSize.width / 2 - LOAD_WIDTH / 2, screenSize.height / 2 - LOAD_HEIGHT / 2); - frame.setResizable(false); - // 设置布局为空 - frame.setLayout(new BorderLayout(0, 0)); - frame.getContentPane().add(label, BorderLayout.CENTER); - frame.getContentPane().add(progressbar, BorderLayout.SOUTH); - - frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - //取消下载 - flag = false; - frame.dispose(); - } - }); - } - - - //是否可以连接服务器 - private boolean connectToServer() { - for (int i = 0; i < list.size(); i++) { - PluginDependenceUnit dependenceUnit = list.get(i); - httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(dependenceUnit.getDependenceID())); - if (httpClient.getResponseCode() != HttpURLConnection.HTTP_OK){ - return false; - } - } - return true; - } - - //获取依赖文件大小 - private int getFileLength(){ - int size = 0; - for (int i = 0; i < list.size(); i++) { - PluginDependenceUnit dependenceUnit = list.get(i); - HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(dependenceUnit.getDependenceID())); - if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { - size += httpClient.getContentLength(); - }else { - return -1; - } - } - return size; - } - - //安装 - private boolean install() { - //开始时钟 - timer.start(); - //开始下载 - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - installDependenceOnline(); - } - }); - thread.start(); - - frame.setVisible(true); - //等待下载线程处理结束 - try { - thread.join(); - } catch (InterruptedException e) { - FRContext.getLogger().error(e.getMessage()); - return false; - } - //停止时钟 - timer.stop(); - return result; - } - - /** - * 下载和安装不分开是因为,本地如果只安装好了一个依赖,下次就不需要重复下载了 - * 如果下载依赖后不安装,则后面的插件会把前面的插件覆盖,故而下载好了一个安装一个 - * @return - * @throws Exception - */ - private void downloadAndInstallPluginDependenceFile() throws Exception { - totalBytesRead = 0; - for (int i = 0; i < list.size(); i++) { - PluginDependenceUnit dependenceUnit = list.get(i); - httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(dependenceUnit.getDependenceID())); - if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { - InputStream reader = httpClient.getResponseStream(); - String temp = StableUtils.pathJoin(PluginHelper.DEPENDENCE_DOWNLOAD_PATH, PluginHelper.TEMP_FILE); - StableUtils.makesureFileExist(new File(temp)); - FileOutputStream writer = new FileOutputStream(temp); - byte[] buffer = new byte[PluginConstants.BYTES_NUM]; - int bytesRead = 0; - while ((bytesRead = reader.read(buffer)) > 0 && flag) { - writer.write(buffer, 0, bytesRead); - buffer = new byte[PluginConstants.BYTES_NUM]; - totalBytesRead += bytesRead; - } - reader.close(); - writer.flush(); - writer.close(); - - //下载被取消 - if (flag == false) { - result = false; - throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed")); - } - - //安装文件 - IOUtils.unZipFilesGBK(temp, FRContext.getCurrentEnv().getPath() + dependenceUnit.getDependenceDir()); - - } else { - result = false; - throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed")); - } - } - //所有依赖都正常安装下载完毕,则结果为true - result = true; - } - - public void installDependenceOnline() { - try { - //下载并安装文件 - downloadAndInstallPluginDependenceFile(); - } catch (Exception e) { - result = false; - FRContext.getLogger().error(e.getMessage()); - } - } - - //安装已经下载好的文件,如果是服务文件,则需要复制一份到安装目录下, - //以便切换远程时,使用本地的服务 - //如果是服务器环境,则只会安装一份 - private void installPluginDependenceFile(List filePathList){ - if (filePathList.isEmpty()){ - result = false; - return; - } - for(int i = 0; i < filePathList.size(); i++) { - if (StringUtils.EMPTY.equals(filePathList.get(i))){ - result = false; - return; - } - PluginDependenceUnit dependenceUnit = list.get(i); - IOUtils.unzip(new File(filePathList.get(i)), FRContext.getCurrentEnv().getPath() + dependenceUnit.getDependenceDir()); - result = true; - } - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == timer) { - int value = progressbar.getValue(); - if (value < totalSize) { - progressbar.setValue(totalBytesRead); - } else { - timer.stop(); - frame.dispose(); - } - } - } - - public void installOnline()throws PluginDependenceException { - - int choose = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer-Plugin_DownLoadMessage", showFileLength()), "install tooltip", JOptionPane.YES_NO_OPTION); - if (choose == 0) {//下载安装 - if (!connectToServer()) { - throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Connect_Server_Error")); - } - //安装依赖环境 - if (install()) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Dependence_Install_Succeed") + "!!"); - } else { - throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed")); - } - }else {//不选择下载,则不安装图标插件 - throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed")); - } - } - - private String showFileLength(){ - double len = totalSize / Math.pow(10, 6); - String lenStr = String.format("%.2f", len); - return totalSize == -1 ? "NAN" : lenStr; - } -} diff --git a/designer_base/src/com/fr/design/extra/plugindependence/image/background.png b/designer_base/src/com/fr/design/extra/plugindependence/image/background.png deleted file mode 100644 index 45bf328e3..000000000 Binary files a/designer_base/src/com/fr/design/extra/plugindependence/image/background.png and /dev/null differ diff --git a/designer_base/src/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java b/designer_base/src/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java new file mode 100644 index 000000000..ff52efaa3 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java @@ -0,0 +1,55 @@ +package com.fr.design.extra.tradition.callback; + +import com.fr.design.extra.PluginStatusCheckCompletePane; +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTaskResult; +import com.fr.plugin.manage.control.ProgressCallback; + +import javax.swing.*; + +/** + * Created by ibm on 2017/5/31. + */ +public class UpdateOnlineCallback implements ProgressCallback { + private PluginStatusCheckCompletePane pane; + private PluginMarker pluginMarker; + private PluginMarker toPluginMarker; + + public UpdateOnlineCallback(PluginMarker pluginMarker, PluginMarker toPluginMarker, PluginStatusCheckCompletePane pane){ + this.pluginMarker = pluginMarker; + this.toPluginMarker = toPluginMarker; + this.pane = pane; + } + public void updateProgress(String description, double progress){ + pane.setProgress(progress); + } + + public void done(PluginTaskResult result){ + if (result.isSuccess()) { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); + } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), + Inter.getLocText("FR-Designer-Plugin_Install_Success"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + null, + null + ); + if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + return; + } + PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane)); + } else { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Failed")); + JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractServerTableDataDefineProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractServerTableDataDefineProvider.java index de7be2750..c149d8f33 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractServerTableDataDefineProvider.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractServerTableDataDefineProvider.java @@ -34,6 +34,12 @@ public abstract class AbstractServerTableDataDefineProvider extends AbstractProv classForInitTableData(), appearanceForTableData() ); - TableDataFactory.register(classForTableData(), creator); + TableDataFactory.registerExtra(classForTableData(), creator); + } + + @Override + public void undo() { + + TableDataFactory.removeExtra(classForTableData()); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractTableDataDefineProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractTableDataDefineProvider.java index 42433a68b..187e7948c 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractTableDataDefineProvider.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractTableDataDefineProvider.java @@ -34,6 +34,12 @@ public abstract class AbstractTableDataDefineProvider extends AbstractProvider i classForInitTableData(), appearanceForTableData() ); - TableDataFactory.register(classForTableData(), creator); + TableDataFactory.registerExtra(classForTableData(), creator); + } + + @Override + public void undo() { + + TableDataFactory.removeExtra(classForTableData()); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/fun/impl/GlobalListenerProviderManager.java b/designer_base/src/com/fr/design/fun/impl/GlobalListenerProviderManager.java new file mode 100644 index 000000000..fed142bf3 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/impl/GlobalListenerProviderManager.java @@ -0,0 +1,109 @@ +package com.fr.design.fun.impl; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.GlobalListenerProvider; +import com.fr.general.GeneralContext; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginRuntime; +import com.fr.plugin.injectable.PluginModule; +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 java.awt.*; +import java.awt.event.AWTEventListener; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Created by juhaoyu on 2017/6/15. + * 管理正在运行中插件的GlobalListenerProvider接口 + */ +public class GlobalListenerProviderManager { + + private static final GlobalListenerProviderManager INSTANCE = new GlobalListenerProviderManager(); + + private Map map = new HashMap<>(); + + private GlobalListenerProviderManager() {} + + public static GlobalListenerProviderManager getInstance() { + + return INSTANCE; + } + + public void init() { + + Set providers = ExtraDesignClassManager.getInstance().getArray(GlobalListenerProvider.XML_TAG); + addAWTEventListeners(providers); + listenPlugin(); + } + + private void listenPlugin() { + + PluginFilter filter = new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign, GlobalListenerProvider.XML_TAG); + } + }; + PluginEventListener onRun = new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + PluginRuntime runtime = event.getContext().getRuntime(); + Set providers = runtime.get(PluginModule.ExtraDesign, GlobalListenerProvider.XML_TAG); + addAWTEventListeners(providers); + } + }; + PluginEventListener onStop = new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + PluginRuntime runtime = event.getContext().getRuntime(); + Set providers = runtime.get(PluginModule.ExtraDesign, GlobalListenerProvider.XML_TAG); + removeAWTEventListeners(providers); + } + }; + GeneralContext.listenPlugin(PluginEventType.AfterRun, onRun, filter); + GeneralContext.listenPlugin(PluginEventType.BeforeStop, onStop, filter); + + + } + + private void addAWTEventListeners(Set providers) { + + AWTEventListener listener; + for (GlobalListenerProvider provider : providers) { + listener = provider.listener(); + Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.KEY_EVENT_MASK); + add(provider, listener); + } + } + + private void removeAWTEventListeners(Set providers) { + + AWTEventListener listener; + for (GlobalListenerProvider provider : providers) { + listener = pop(provider); + Toolkit.getDefaultToolkit().removeAWTEventListener(listener); + } + } + + private synchronized void add(GlobalListenerProvider provider, AWTEventListener listener) { + + map.put(provider, listener); + } + + private synchronized AWTEventListener pop(GlobalListenerProvider provider) { + + return map.remove(provider); + } + +} diff --git a/designer_base/src/com/fr/design/gui/UILookAndFeel.java b/designer_base/src/com/fr/design/gui/UILookAndFeel.java index 3bdf14d31..205abed29 100644 --- a/designer_base/src/com/fr/design/gui/UILookAndFeel.java +++ b/designer_base/src/com/fr/design/gui/UILookAndFeel.java @@ -3,10 +3,12 @@ package com.fr.design.gui; import com.fr.base.BaseUtils; import com.fr.design.gui.borders.*; import com.fr.design.gui.frpane.UIBasicOptionPaneUI; +import com.fr.design.gui.ibutton.UIBasicButtonUI; import com.fr.design.gui.ibutton.UIButtonBorder; import com.fr.design.gui.ibutton.UIRadioButtonMenuItemUI; import com.fr.design.gui.ibutton.UIRadioButtonUI; import com.fr.design.gui.icheckbox.UICheckBoxUI; +import com.fr.design.gui.icombobox.UIBasicComboBoxUI; import com.fr.design.gui.icontainer.UIScrollPaneBorder; import com.fr.design.gui.icontainer.UIScrollPaneUI; import com.fr.design.gui.icontainer.UITableScrollPaneBorder; @@ -16,6 +18,7 @@ import com.fr.design.gui.imenu.UIPopupMenuBorder; import com.fr.design.gui.imenu.UIPopupMenuSeparatorUI; import com.fr.design.gui.iprogressbar.UIProgressBarBorder; import com.fr.design.gui.iprogressbar.UIProgressBarUI; +import com.fr.design.gui.iscrollbar.UIBasicScrollBarUI; import com.fr.design.gui.ispinner.UISpinnerUI; import com.fr.design.gui.isplitpanedivider.UISplitPaneUI; import com.fr.design.gui.itable.UIBasicTableUI; @@ -23,10 +26,8 @@ import com.fr.design.gui.itoolbar.UIToolBarBorder; import com.fr.design.gui.itoolbar.UIToolBarSeparatorUI; import com.fr.design.gui.itooltip.UIToolTipBorder; import com.fr.design.gui.itree.UITreeUI; -import com.fr.design.gui.iscrollbar.UIBasicScrollBarUI; -import com.fr.design.gui.icombobox.UIBasicComboBoxUI; -import com.fr.design.gui.ibutton.UIBasicButtonUI; import com.fr.general.FRLogger; +import com.fr.general.IOUtils; import javax.swing.*; import javax.swing.border.Border; @@ -187,8 +188,8 @@ public class UILookAndFeel extends MetalLookAndFeel { if (url == null) { // Another try - url = UILookAndFeel.class.getResource( - "com/fr/design/images/lookandfeel/" + fileName); + url = IOUtils.getResource( + "com/fr/design/images/lookandfeel/" + fileName, UILookAndFeel.class); if (url == null) { FRLogger.getLogger().error("Icon directory could not be resolved."); diff --git a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java index 99fc5948e..3408bf371 100644 --- a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java @@ -1,8 +1,6 @@ package com.fr.design.gui.frpane; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.actions.HyperlinkPluginAction; -import com.fr.design.actions.UpdateAction; import com.fr.design.fun.HyperlinkProvider; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; @@ -12,14 +10,12 @@ import com.fr.general.NameObject; import com.fr.js.JavaScript; import com.fr.js.NameJavaScript; import com.fr.js.NameJavaScriptGroup; -import com.fr.plugin.PluginManager; import com.fr.stable.ListMap; import com.fr.stable.Nameable; import java.util.ArrayList; import java.util.Map; import java.util.Set; -import java.util.TreeMap; /** * 超级链接 界面. @@ -40,15 +36,6 @@ public class HyperlinkGroupPane extends JListControlPane { for (NameableCreator creator : creators) { nameCreators.put(creator.menuName(), creator); } - PluginManager.getInstance().setExtensionPoint(HyperlinkPluginAction.XML_TAG); - ArrayList templateArrayLisy = PluginManager.getInstance().getResultList(); -// if (templateArrayLisy.isEmpty()) { -// return creators; -// } - for (int i = 0; i < templateArrayLisy.size(); i++) { - NameableCreator nameableCreator = ((HyperlinkPluginAction) templateArrayLisy.get(i)).getHyperlinkCreator(); - nameCreators.put(nameableCreator.menuName(), nameableCreator); - } Set providers = ExtraDesignClassManager.getInstance().getArray(HyperlinkProvider.XML_TAG); for (HyperlinkProvider provider : providers) { NameableCreator nc = provider.createHyperlinkCreator(); diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 96aaff01c..5e197ba34 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -543,7 +543,6 @@ FR-Designer_Allow_Null=Allow null FR-Designer_PageSetup_Page=Page FR-Designer_Custom_Job_Description=Description FR-Designer_Property=Property -FR-Designer_ClassName=Class Name FR-Designer_Polyblock_Edit=Polyblock Edit FR-Designer_Function_Description_Area_Text=The class must inherit 'com.fr.script.AbstractFunction'. The compiled class should be copied to\nJ2EE server '{R1}' directory.\nAdd the source code(.java file) into the same folder if need.\nExample: {R2}} FR-Designer_PageSetup_Horizontal=Horizontal @@ -559,10 +558,6 @@ FR-Designer_Show_As_Download=Display the binary content using download link FR-Designer_File_Name_For_Download=File Name For Download FR-Designer_No=No FR-Designer_Pagination=Page Break -FR-Designer-Move_Tab_First=move to first -FR-Designer-Move_Tab_End=move to end -FR-Designer-Move_Tab_Next=move to next -FR-Designer-Move_Tab_Prev=move to previous FR-Designer_DS_TableData=Data Set FR-Designer_Parameter-Formula=Formula FR-Designer_Plugin_Should_Update_Please_Contact_Developer=Plugin version is too low, and is not compatible with current API. Please contact the developer to update. @@ -849,7 +844,6 @@ PageSetup-Placement_Center_on_Page=Page Center sure_to_delete=sure to delete Already_exists_not_add_repeat=Already exists, do not add repeat Axis_Title=Axis title -FR-Designer-Plugin_Install_Failed=Install failed FR-Designer-Widget-Style_Frame= MainGraduationUnit=MainGraduationUnit Second_Axis=Second Axis @@ -2007,6 +2001,80 @@ FR-Designer_AlphaFine_Latest=Latest FR-Designer_AlphaFine_ShowLess=show less FR-Designer_Alphafine=AlphaFine FR-Designer-Alphafine_No_Remind= +<<<<<<< HEAD +FR-Designer-Plugin_Install_Success= +FR-Designer-Plugin_Install_Failed= +FR-Designer-Plugin_Install_Dependence= +FR-Designer-Plugin-Install_Package= +FR-Designer-Plugin_Delete_Dependence= +FR-Designer-Plugin_Delete_Success= +FR-Designer-Plugin_Delete_Failed= +FR-Designer-Plugin_Update_Dependence= +FR-Designer-Plugin_Update_Success= +FR-Designer-Plugin_Update_Failed= +FR-Designer-Plugin_Actived= +FR-Designer-Plugin_Disabled= +FR-Designer-Plugin-Store_App= +FR-Designer-Plugin-Store_Businesses= +FR-Designer-Plugin-Store_Official= +FR-Designer-Plugin-Store_Not_Official= +FR-Designer-Plugin-Store_Cost= +FR-Designer-Plugin-Store_Pay= +FR-Designer-Plugin-Store_Free= +FR-Designer-Plugin-Store_Category= +FR-Designer-Plugin-Store_Designer= +FR-Designer-Plugin-Store_Front_End_Display= +FR-Designer-Plugin-Store_Report_Write= +FR-Designer-Plugin-Store_Chart= +FR-Designer-Plugin-Store_BI= +FR-Designer-Plugin-Store_Export_Print= +FR-Designer-Plugin-Store_Mobile_Terminal= +FR-Designer-Plugin-Store_Integrate_Deployment= +FR-Designer-Plugin-Store_Data_Interface= +FR-Designer-Plugin-Store_Form_Components= +FR-Designer-Plugin-Store_Function= +FR-Designer-Plugin-Store_Recommend= +FR-Designer-Plugin-Store_Commodity_Description= +FR-Designer-Plugin-Store_Install= +FR-Designer-Plugin-Store_Install_From_Local= +FR-Designer-Plugin-Store_My_Plugins= +FR-Designer-Plugin-Store_No_Plugins= +FR-Designer-Plugin-Store_Disabled= +FR-Designer-Plugin-Store_Enable= +FR-Designer-Plugin-Store_Delete= +FR-Designer-Plugin-Store_Update= +FR-Designer-Plugin-Store_Update-ALL= +FR-Designer-Plugin-Store_Update_From_Local= +FR-Designer-Plugin-Store_BBS_Account_Login= +FR-Designer-Plugin-Store_Register= +FR-Designer-Plugin-Store_Forgot_Password= +FR-Designer-Plugin-Store_Quick_Login= +FR-Designer-Plugin-Store_Account= +FR-Designer-Plugin-Store_Password= +FR-Designer-Plugin-Store_Not_Login= +FR-Designer-Plugin-Store_Installed= +FR-Designer-Plugin-Store_Plugins_Count= +FR-Designer-Plugin-Store_Key_Word= +FR-Designer-Plugin-Store_Login= +FR-Designer-Plugin-Store_Login_By_QQ= +FR-Designer-Plugin-Store_User_Not_Exist= +FR-Designer-Plugin-Store_User_Password_Error= +FR-Designer-Plugin-Store_Unexpected_Error= +FR-Designer-Plugin-Store_Net_Connect_Failed= +FR-Designer-Plugin-Store_Not_Null= +FR-Designer-Plugin-Store_Switch_Account= +FR-Designer-Plugin-Store_Private_Message= +FR-Designer-Plugin-Store_Jar_Damaged= +FR-Designer-Plugin-Store_Probation= +FR-Designer-Plugin-Store_Authorize= +FR-Designer-Plugin-Store_Permanent= +FR-Designer-Plugin-Store_Expired= +FR-Designer-Plugin-Store_Day= +FR-Designer-Plugin-Store_Finereport= +FR-Designer-Plugin-Store_Version= +FR-Designer-Plugin-Store_Developer= +FR-Designer-Plugin-Store_Jar= +FR-Designer-Plugin-Store_Disconnected= FR-Designer_AlphaFine_NoResult=no results FR-Designer_ConnectionFailed=connection failed -FR-Designer_NoResult=No results \ No newline at end of file +FR-Designer_NoResult=No results diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 8c8e4046a..0d48fd184 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -115,7 +115,6 @@ FR-Designer_Format_explan=Format explain FR-Designer_Allow-Blank=Allow Blank FR-Designer_Formula=Formula FR-Designer_Forum=Forum -FR-Designer_Get-CubeGetting cube= FR-Designer_Help=Help FR-Designer_Hide=Hide FR-Designer_Hyperlink=Hyperlink @@ -559,10 +558,6 @@ FR-Designer_Show_As_Download=Display the binary content using download link FR-Designer_File_Name_For_Download=File Name For Download FR-Designer_No=No FR-Designer_Pagination=Page Break -FR-Designer-Move_Tab_First=move to first -FR-Designer-Move_Tab_End=move to end -FR-Designer-Move_Tab_Next=move to next -FR-Designer-Move_Tab_Prev=move to previous FR-Designer_DS_TableData=Data Set FR-Designer_Parameter-Formula=Formula FR-Designer_Plugin_Should_Update_Please_Contact_Developer=Plugin version is too low, and is not compatible with current API. Please contact the developer to update. @@ -850,7 +845,6 @@ PageSetup-Placement_Center_on_Page=Center on Page sure_to_delete=sure to delete Already_exists_not_add_repeat=Already exist, please do not repeat Axis_Title=Axis title -FR-Designer-Plugin_Install_Failed=Install failed FR-Designer-Widget-Style_Frame=Frame MainGraduationUnit=Major Graduation Unit Second_Axis=Secondary Axis @@ -2004,7 +1998,81 @@ FR-Designer_AlphaFine_ShowAll=Show all FR-Designer_AlphaFine_Latest=Recent FR-Designer_AlphaFine_ShowLess=Show less FR-Designer_Alphafine=AlphaFine -FR-Designer-Alphafine_No_Remind=Don't remind +<<<<<<< HEAD +FR-Designer-Alphafine_No_Remind=don't remind +Designer-Plugin_Install_Success= +FR-Designer-Plugin_Install_Failed= +FR-Designer-Plugin_Install_Dependence= +FR-Designer-Plugin-Install_Package= +FR-Designer-Plugin_Delete_Dependence= +FR-Designer-Plugin_Delete_Success= +FR-Designer-Plugin_Delete_Failed= +FR-Designer-Plugin_Update_Dependence= +FR-Designer-Plugin_Update_Success= +FR-Designer-Plugin_Update_Failed= +FR-Designer-Plugin_Actived= +FR-Designer-Plugin_Disabled= +FR-Designer-Plugin-Store_App= +FR-Designer-Plugin-Store_Businesses= +FR-Designer-Plugin-Store_Official= +FR-Designer-Plugin-Store_Not_Official= +FR-Designer-Plugin-Store_Cost= +FR-Designer-Plugin-Store_Pay= +FR-Designer-Plugin-Store_Free= +FR-Designer-Plugin-Store_Category= +FR-Designer-Plugin-Store_Designer= +FR-Designer-Plugin-Store_Front_End_Display= +FR-Designer-Plugin-Store_Report_Write= +FR-Designer-Plugin-Store_Chart= +FR-Designer-Plugin-Store_BI= +FR-Designer-Plugin-Store_Export_Print= +FR-Designer-Plugin-Store_Mobile_Terminal= +FR-Designer-Plugin-Store_Integrate_Deployment= +FR-Designer-Plugin-Store_Data_Interface= +FR-Designer-Plugin-Store_Form_Components= +FR-Designer-Plugin-Store_Function= +FR-Designer-Plugin-Store_Recommend= +FR-Designer-Plugin-Store_Commodity_Description= +FR-Designer-Plugin-Store_Install= +FR-Designer-Plugin-Store_Install_From_Local= +FR-Designer-Plugin-Store_My_Plugins= +FR-Designer-Plugin-Store_No_Plugins= +FR-Designer-Plugin-Store_Disabled= +FR-Designer-Plugin-Store_Enable= +FR-Designer-Plugin-Store_Delete= +FR-Designer-Plugin-Store_Update= +FR-Designer-Plugin-Store_Update-ALL= +FR-Designer-Plugin-Store_Update_From_Local= +FR-Designer-Plugin-Store_BBS_Account_Login= +FR-Designer-Plugin-Store_Register= +FR-Designer-Plugin-Store_Forgot_Password= +FR-Designer-Plugin-Store_Quick_Login= +FR-Designer-Plugin-Store_Account= +FR-Designer-Plugin-Store_Password= +FR-Designer-Plugin-Store_Not_Login= +FR-Designer-Plugin-Store_Installed= +FR-Designer-Plugin-Store_Plugins_Count= +FR-Designer-Plugin-Store_Key_Word= +FR-Designer-Plugin-Store_Login= +FR-Designer-Plugin-Store_Login_By_QQ= +FR-Designer-Plugin-Store_User_Not_Exist= +FR-Designer-Plugin-Store_User_Password_Error= +FR-Designer-Plugin-Store_Unexpected_Error= +FR-Designer-Plugin-Store_Net_Connect_Failed= +FR-Designer-Plugin-Store_Not_Null= +FR-Designer-Plugin-Store_Switch_Account= +FR-Designer-Plugin-Store_Private_Message= +FR-Designer-Plugin-Store_Jar_Damaged= +FR-Designer-Plugin-Store_Probation= +FR-Designer-Plugin-Store_Authorize= +FR-Designer-Plugin-Store_Permanent= +FR-Designer-Plugin-Store_Expired= +FR-Designer-Plugin-Store_Day= +FR-Designer-Plugin-Store_Finereport= +FR-Designer-Plugin-Store_Version= +FR-Designer-Plugin-Store_Developer= +FR-Designer-Plugin-Store_Jar= +FR-Designer-Plugin-Store_Disconnected= FR-Designer_AlphaFine_NoResult=No results FR-Designer_ConnectionFailed=Connection failed FR-Designer_AlphaFine_EnableAlphaFine=Enable AlphaFine diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 794181a57..45715f666 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -845,7 +845,6 @@ PageSetup-Placement_Center_on_Page=\u4E2D\u592E\u63C3\u3048 sure_to_delete=\u524A\u9664\u3092\u78BA\u8A8D\u3057\u307E\u3059 Already_exists_not_add_repeat=\u3059\u3067\u306B\u5B58\u5728\u3057\u3066\u3044\u308B\u3001\u30EA\u30D4\u30FC\u30C8\u3092\u8FFD\u52A0\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 Axis_Title=\u8EF8\u306E\u8868\u984C -FR-Designer-Plugin_Install_Failed=\u30D7\u30E9\u30B0\u30A4\u30F3\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306B\u5931\u6557\u3057\u307E\u3057\u305F FR-Designer-Widget-Style_Frame=\u30D5\u30EC\u30FC\u30E0 MainGraduationUnit=\u4E3B\u306A\u76EE\u76DB\u308A\u5358\u4F4D Second_Axis=\u6B21\u5EA7\u6A19\u8EF8 @@ -1982,4 +1981,77 @@ FR-Designer_Edit_String_To_Formula=\u30AD\u30E3\u30E9\u30AF\u30BF\u30FC\u6587\u5 FR-Base_UnSignIn=\ \u672A\u30ED\u30B0\u30A4\u30F3 Every=\u6BCF CellWrite-Preview_Cell_Content=\u30BB\u30EB\u306E\u5185\u5BB9\u3092\u30D7\u30EC\u30D3\u30E5\u30FC\u3059\u308B -FormulaD-Data_Fields=\u30C7\u30FC\u30BF\u30D5\u30A3\u30FC\u30EB\u30C9 \ No newline at end of file +FormulaD-Data_Fields=\u30C7\u30FC\u30BF\u30D5\u30A3\u30FC\u30EB\u30C9 +Designer-Plugin_Install_Success= +FR-Designer-Plugin_Install_Failed= +FR-Designer-Plugin_Install_Dependence= +FR-Designer-Plugin-Install_Package= +FR-Designer-Plugin_Delete_Dependence= +FR-Designer-Plugin_Delete_Success= +FR-Designer-Plugin_Delete_Failed= +FR-Designer-Plugin_Update_Dependence= +FR-Designer-Plugin_Update_Success= +FR-Designer-Plugin_Update_Failed= +FR-Designer-Plugin_Actived= +FR-Designer-Plugin_Disabled= +FR-Designer-Plugin-Store_App= +FR-Designer-Plugin-Store_Businesses= +FR-Designer-Plugin-Store_Official= +FR-Designer-Plugin-Store_Not_Official= +FR-Designer-Plugin-Store_Cost= +FR-Designer-Plugin-Store_Pay= +FR-Designer-Plugin-Store_Free= +FR-Designer-Plugin-Store_Category= +FR-Designer-Plugin-Store_Designer= +FR-Designer-Plugin-Store_Front_End_Display= +FR-Designer-Plugin-Store_Report_Write= +FR-Designer-Plugin-Store_Chart= +FR-Designer-Plugin-Store_BI= +FR-Designer-Plugin-Store_Export_Print= +FR-Designer-Plugin-Store_Mobile_Terminal= +FR-Designer-Plugin-Store_Integrate_Deployment= +FR-Designer-Plugin-Store_Data_Interface= +FR-Designer-Plugin-Store_Form_Components= +FR-Designer-Plugin-Store_Function= +FR-Designer-Plugin-Store_Recommend= +FR-Designer-Plugin-Store_Commodity_Description= +FR-Designer-Plugin-Store_Install= +FR-Designer-Plugin-Store_Install_From_Local= +FR-Designer-Plugin-Store_My_Plugins= +FR-Designer-Plugin-Store_No_Plugins= +FR-Designer-Plugin-Store_Disabled= +FR-Designer-Plugin-Store_Enable= +FR-Designer-Plugin-Store_Delete= +FR-Designer-Plugin-Store_Update= +FR-Designer-Plugin-Store_Update-ALL= +FR-Designer-Plugin-Store_Update_From_Local= +FR-Designer-Plugin-Store_BBS_Account_Login= +FR-Designer-Plugin-Store_Register= +FR-Designer-Plugin-Store_Forgot_Password= +FR-Designer-Plugin-Store_Quick_Login= +FR-Designer-Plugin-Store_Account= +FR-Designer-Plugin-Store_Password= +FR-Designer-Plugin-Store_Not_Login= +FR-Designer-Plugin-Store_Installed= +FR-Designer-Plugin-Store_Plugins_Count= +FR-Designer-Plugin-Store_Key_Word= +FR-Designer-Plugin-Store_Login= +FR-Designer-Plugin-Store_Login_By_QQ= +FR-Designer-Plugin-Store_User_Not_Exist= +FR-Designer-Plugin-Store_User_Password_Error= +FR-Designer-Plugin-Store_Unexpected_Error= +FR-Designer-Plugin-Store_Net_Connect_Failed= +FR-Designer-Plugin-Store_Not_Null= +FR-Designer-Plugin-Store_Switch_Account= +FR-Designer-Plugin-Store_Private_Message= +FR-Designer-Plugin-Store_Jar_Damaged= +FR-Designer-Plugin-Store_Probation= +FR-Designer-Plugin-Store_Authorize= +FR-Designer-Plugin-Store_Permanent= +FR-Designer-Plugin-Store_Expired= +FR-Designer-Plugin-Store_Day= +FR-Designer-Plugin-Store_Finereport= +FR-Designer-Plugin-Store_Version= +FR-Designer-Plugin-Store_Developer= +FR-Designer-Plugin-Store_Jar= +FR-Designer-Plugin-Store_Disconnected= \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index 593f372a5..d7d7b0401 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -846,7 +846,6 @@ PageSetup-Placement_Center_on_Page=\uAC00\uC6B4\uB370\uC815\uB82C\uBC29\uC2DD sure_to_delete=\uC0AD\uC81C\uD655\uC778 Already_exists_not_add_repeat=\uC774\uBBF8\uC874\uC7AC\uD569\uB2C8\uB2E4.\uC911\uBCF5\uCD94\uAC00\uD558\uC9C0\uB9C8\uC2ED\uC2DC\uC624. Axis_Title=\uCD95\uC81C\uBAA9 -FR-Designer-Plugin_Install_Failed=\uD50C\uB7EC\uADF8\uC778\uC124\uCE58\uC2E4\uD328 FR-Designer-Widget-Style_Frame=\uD504\uB808\uC784 MainGraduationUnit=\uC8FC\uB208\uAE08\uB2E8\uC704 Second_Axis=\uBCF4\uC870\uC88C\uD45C\uCD95 @@ -1983,4 +1982,77 @@ FR-Designer_Edit_String_To_Formula=\uBB38\uC790\uC5F4\uC744\uC218\uC2DD\uC73C\uB FR-Base_UnSignIn=\uC544\uC9C1 \uB4F1\uB85D Every=\uAC01 CellWrite-Preview_Cell_Content=\uC140\uB0B4\uC6A9\uBBF8\uB9AC\uBCF4\uAE30 -FormulaD-Data_Fields=\uB370\uC774\uD130\uD56D\uBAA9 \ No newline at end of file +FormulaD-Data_Fields=\uB370\uC774\uD130\uD56D\uBAA9 +Designer-Plugin_Install_Success= +FR-Designer-Plugin_Install_Failed= +FR-Designer-Plugin_Install_Dependence= +FR-Designer-Plugin-Install_Package= +FR-Designer-Plugin_Delete_Dependence= +FR-Designer-Plugin_Delete_Success= +FR-Designer-Plugin_Delete_Failed= +FR-Designer-Plugin_Update_Dependence= +FR-Designer-Plugin_Update_Success= +FR-Designer-Plugin_Update_Failed= +FR-Designer-Plugin_Actived= +FR-Designer-Plugin_Disabled= +FR-Designer-Plugin-Store_App= +FR-Designer-Plugin-Store_Businesses= +FR-Designer-Plugin-Store_Official= +FR-Designer-Plugin-Store_Not_Official= +FR-Designer-Plugin-Store_Cost= +FR-Designer-Plugin-Store_Pay= +FR-Designer-Plugin-Store_Free= +FR-Designer-Plugin-Store_Category= +FR-Designer-Plugin-Store_Designer= +FR-Designer-Plugin-Store_Front_End_Display= +FR-Designer-Plugin-Store_Report_Write= +FR-Designer-Plugin-Store_Chart= +FR-Designer-Plugin-Store_BI= +FR-Designer-Plugin-Store_Export_Print= +FR-Designer-Plugin-Store_Mobile_Terminal= +FR-Designer-Plugin-Store_Integrate_Deployment= +FR-Designer-Plugin-Store_Data_Interface= +FR-Designer-Plugin-Store_Form_Components= +FR-Designer-Plugin-Store_Function= +FR-Designer-Plugin-Store_Recommend= +FR-Designer-Plugin-Store_Commodity_Description= +FR-Designer-Plugin-Store_Install= +FR-Designer-Plugin-Store_Install_From_Local= +FR-Designer-Plugin-Store_My_Plugins= +FR-Designer-Plugin-Store_No_Plugins= +FR-Designer-Plugin-Store_Disabled= +FR-Designer-Plugin-Store_Enable= +FR-Designer-Plugin-Store_Delete= +FR-Designer-Plugin-Store_Update= +FR-Designer-Plugin-Store_Update-ALL= +FR-Designer-Plugin-Store_Update_From_Local= +FR-Designer-Plugin-Store_BBS_Account_Login= +FR-Designer-Plugin-Store_Register= +FR-Designer-Plugin-Store_Forgot_Password= +FR-Designer-Plugin-Store_Quick_Login= +FR-Designer-Plugin-Store_Account= +FR-Designer-Plugin-Store_Password= +FR-Designer-Plugin-Store_Not_Login= +FR-Designer-Plugin-Store_Installed= +FR-Designer-Plugin-Store_Plugins_Count= +FR-Designer-Plugin-Store_Key_Word= +FR-Designer-Plugin-Store_Login= +FR-Designer-Plugin-Store_Login_By_QQ= +FR-Designer-Plugin-Store_User_Not_Exist= +FR-Designer-Plugin-Store_User_Password_Error= +FR-Designer-Plugin-Store_Unexpected_Error= +FR-Designer-Plugin-Store_Net_Connect_Failed= +FR-Designer-Plugin-Store_Not_Null= +FR-Designer-Plugin-Store_Switch_Account= +FR-Designer-Plugin-Store_Private_Message= +FR-Designer-Plugin-Store_Jar_Damaged= +FR-Designer-Plugin-Store_Probation= +FR-Designer-Plugin-Store_Authorize= +FR-Designer-Plugin-Store_Permanent= +FR-Designer-Plugin-Store_Expired= +FR-Designer-Plugin-Store_Day= +FR-Designer-Plugin-Store_Finereport= +FR-Designer-Plugin-Store_Version= +FR-Designer-Plugin-Store_Developer= +FR-Designer-Plugin-Store_Jar= +FR-Designer-Plugin-Store_Disconnected= \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index f37ed736f..ed27f84a9 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -845,7 +845,6 @@ PageSetup-Placement_Center_on_Page=\u5C45\u4E2D\u65B9\u5F0F sure_to_delete=\u786E\u8BA4\u5220\u9664 Already_exists_not_add_repeat=\u5DF2\u7ECF\u5B58\u5728\uFF0C\u8BF7\u4E0D\u8981\u91CD\u590D\u6DFB\u52A0 Axis_Title=\u8F74\u6807\u9898 -FR-Designer-Plugin_Install_Failed=\u63D2\u4EF6\u5B89\u88C5\u5931\u8D25 FR-Designer-Widget-Style_Frame=\u6846\u67B6 MainGraduationUnit=\u4E3B\u8981\u523B\u5EA6\u5355\u4F4D Second_Axis=\u6B21\u5750\u6807\u8F74 @@ -1207,7 +1206,6 @@ FS_Start_Date=\u8D77\u59CB\u65E5\u671F FR-ConditionB_Operator=\u64CD\u4F5C\u7B26 Printer-Alias=\u522B\u540D DS-Class_Name=\u7C7B\u540D -FR-Designer-Plugin_Has_Been_Disabled=\u63D2\u4EF6\u5DF2\u88AB\u7981\u7528\uFF0C\u91CD\u542F\u8BBE\u8BA1\u5668\u53CA\u670D\u52A1\u5668\u751F\u6548\uFF0C\u670D\u52A1\u5668\u9700\u624B\u52A8\u91CD\u542F Sort-Original=\u4E0D\u6392\u5E8F Utils-Top_to_Bottom_a=\u4ECE\u4E0A\u5F80\u4E0B Parameter-String=\u5B57\u7B26\u4E32 @@ -1460,7 +1458,6 @@ DBCP_TEST_ON_BORROW=\u83B7\u53D6\u8FDE\u63A5\u524D\u68C0\u9A8C FR-Designer_layerIndex=\u4F9D\u8D56\u7684\u5C42\u6570 WEB-Write_Setting=\u586B\u62A5\u9875\u9762\u8BBE\u7F6E M-New_WorkBook=\u65B0\u5EFA\u5DE5\u4F5C\u7C3F -FR-Designer-Plugin_Has_Been_Actived=\u63D2\u4EF6\u5DF2\u88AB\u542F\u7528\uFF0C\u91CD\u542F\u8BBE\u8BA1\u5668\u53CA\u670D\u52A1\u5668\u751F\u6548\uFF0C\u670D\u52A1\u5668\u9700\u624B\u52A8\u91CD\u542F Datasource-Maximum_Number_of_Preview_Rows=\u6700\u5927\u7684\u9884\u89C8\u884C\u6570 ExpandD-Cell_Expand_Attributes=\u6269\u5C55\u5C5E\u6027 Select_the_repeated_row_and_column=\u9009\u62E9\u9700\u8981\u91CD\u590D\u7684\u884C\u5217 @@ -1987,7 +1984,6 @@ FR-Designer_Role=\u89D2\u8272 FR-Designer_Permissions=\u6743\u9650 FR-Designer_Form_Button=\u6309\u94AE FR-Designer_WF_Name=\u540D\u79F0 -FR-Designer_ClassName=\u7C7B\u540D FR-Designer_AlphaFine_Enable=\u5F00\u542F FR-Designer_AlphaFine_EnableAlphaFine=\u5F00\u542FAlphaFine\u529F\u80FD FR-Designer_AlphaFine_EnableInternet=\u8054\u7F51 @@ -2003,6 +1999,80 @@ FR-Designer_AlphaFine_Latest=\u672C\u5730\u5E38\u7528 FR-Designer_AlphaFine_ShowLess=\u6536\u8D77 FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22 FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A +FR-Designer-Plugin_Install_Success=\u63D2\u4EF6\u5B89\u88C5\u6210\u529F +FR-Designer-Plugin_Install_Failed=\u63D2\u4EF6\u5B89\u88C5\u5931\u8D25 +FR-Designer-Plugin_Install_Dependence=\u662F\u5426\u5B89\u88C5\u4F9D\u8D56\u73AF\u5883 +FR-Designer-Plugin-Install_Package=\u63D2\u4EF6\u5B89\u88C5\u5305 +FR-Designer-Plugin_Delete_Dependence=\u662F\u5426\u5220\u9664\u4F9D\u8D56\u73AF\u5883 +FR-Designer-Plugin_Delete_Success=\u63D2\u4EF6\u5220\u9664\u6210\u529F +FR-Designer-Plugin_Delete_Failed=\u63D2\u4EF6\u5220\u9664\u5931\u8D25 +FR-Designer-Plugin_Update_Dependence=\u662F\u5426\u66F4\u65B0\u4F9D\u8D56\u73AF\u5883 +FR-Designer-Plugin_Update_Success=\u63D2\u4EF6\u66F4\u65B0\u6210\u529F +FR-Designer-Plugin_Update_Failed=\u63D2\u4EF6\u66F4\u65B0\u5931\u8D25 +FR-Designer-Plugin_Actived=\u63D2\u4EF6\u5DF2\u88AB\u542F\u7528 +FR-Designer-Plugin_Disabled=\u63D2\u4EF6\u5DF2\u88AB\u7981\u7528 +FR-Designer-Plugin-Store_App=\u5E94\u7528\u5546\u57CE +FR-Designer-Plugin-Store_Businesses=\u5546\u5BB6 +FR-Designer-Plugin-Store_Official=\u5B98\u65B9(\u5E06\u8F6F) +FR-Designer-Plugin-Store_Not_Official=\u975E\u5B98\u65B9 +FR-Designer-Plugin-Store_Cost=\u8D39\u7528 +FR-Designer-Plugin-Store_Pay=\u4ED8\u8D39 +FR-Designer-Plugin-Store_Free=\u514D\u8D39 +FR-Designer-Plugin-Store_Category=\u7C7B\u522B +FR-Designer-Plugin-Store_Designer=\u8BBE\u8BA1\u5668 +FR-Designer-Plugin-Store_Front_End_Display=\u524D\u7AEF\u5C55\u73B0 +FR-Designer-Plugin-Store_Report_Write=\u586B\u62A5 +FR-Designer-Plugin-Store_Chart=\u56FE\u8868 +FR-Designer-Plugin-Store_BI=\u51B3\u7B56\u5E73\u53F0 +FR-Designer-Plugin-Store_Export_Print=\u5BFC\u51FA\u6253\u5370 +FR-Designer-Plugin-Store_Mobile_Terminal=\u79FB\u52A8\u7AEF +FR-Designer-Plugin-Store_Integrate_Deployment=\u90E8\u7F72\u96C6\u6210 +FR-Designer-Plugin-Store_Data_Interface=\u6570\u636E\u63A5\u53E3 +FR-Designer-Plugin-Store_Form_Components=\u8868\u5355\u7EC4\u4EF6 +FR-Designer-Plugin-Store_Function=\u51FD\u6570 +FR-Designer-Plugin-Store_Recommend=\u63A8\u8350 +FR-Designer-Plugin-Store_Commodity_Description=\u5546\u54C1|\u7248\u672C\u53F7|\u8BF4\u660E +FR-Designer-Plugin-Store_Install=\u5B89\u88C5 +FR-Designer-Plugin-Store_Install_From_Local=\u4ECE\u672C\u5730\u5B89\u88C5 +FR-Designer-Plugin-Store_My_Plugins=\u6211\u7684\u63D2\u4EF6 +FR-Designer-Plugin-Store_No_Plugins=\u5DF2\u5B89\u88C5\u4E860\u4E2A\u63D2\u4EF6 +FR-Designer-Plugin-Store_Disabled=\u7981\u7528 +FR-Designer-Plugin-Store_Enable=\u542F\u7528 +FR-Designer-Plugin-Store_Delete=\u5220\u9664 +FR-Designer-Plugin-Store_Update=\u66F4\u65B0 +FR-Designer-Plugin-Store_Update-ALL=\u5168\u90E8\u66F4\u65B0 +FR-Designer-Plugin-Store_Update_From_Local=\u4ECE\u672C\u5730\u66F4\u65B0 +FR-Designer-Plugin-Store_BBS_Account_Login=\u8BBA\u575B\u8D26\u53F7\u767B\u5F55 +FR-Designer-Plugin-Store_Register=\u6CE8\u518C +FR-Designer-Plugin-Store_Forgot_Password=\u5FD8\u8BB0\u5BC6\u7801 +FR-Designer-Plugin-Store_Quick_Login=\u5FEB\u6377\u767B\u5F55: +FR-Designer-Plugin-Store_Account=\u8D26\u53F7 +FR-Designer-Plugin-Store_Password=\u5BC6\u7801 +FR-Designer-Plugin-Store_Not_Login=\u672A\u767B\u5F55 +FR-Designer-Plugin-Store_Installed=\u5DF2\u5B89\u88C5 +FR-Designer-Plugin-Store_Plugins_Count=\u4E2A\u63D2\u4EF6 +FR-Designer-Plugin-Store_Key_Word=\u5173\u952E\u5B57 +FR-Designer-Plugin-Store_Login=\u767B\u5F55 +FR-Designer-Plugin-Store_Login_By_QQ=\u7528QQ\u53F7\u767B\u5F55 +FR-Designer-Plugin-Store_User_Not_Exist=\u7528\u6237\u540D\u4E0D\u5B58\u5728 +FR-Designer-Plugin-Store_User_Password_Error=\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF +FR-Designer-Plugin-Store_Unexpected_Error=\u672A\u77E5\u9519\u8BEF +FR-Designer-Plugin-Store_Net_Connect_Failed=\u7F51\u7EDC\u8FDE\u63A5\u5931\u8D25 +FR-Designer-Plugin-Store_Not_Null=\u7528\u6237\u540D\u6216\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A +FR-Designer-Plugin-Store_Switch_Account=\u5207\u6362\u8D26\u6237 +FR-Designer-Plugin-Store_Private_Message=\u79C1\u4EBA\u6D88\u606F +FR-Designer-Plugin-Store_Jar_Damaged=Jar\u5305\u635F\u574F +FR-Designer-Plugin-Store_Probation=\u8BD5\u7528: +FR-Designer-Plugin-Store_Authorize=\u6388\u6743: +FR-Designer-Plugin-Store_Permanent=\u6C38\u4E45 +FR-Designer-Plugin-Store_Expired=\u8FC7\u671F +FR-Designer-Plugin-Store_Day=\u5929 +FR-Designer-Plugin-Store_Finereport=\u5E06\u8F6F +FR-Designer-Plugin-Store_Version=\u7248\u672C +FR-Designer-Plugin-Store_Developer=\u5F00\u53D1\u8005 +FR-Designer-Plugin-Store_Jar=jar\u5305 +FR-Designer-Plugin-Store_Disconnected=\u65E0\u6CD5\u8FDE\u63A5\u5E94\u7528\u4E2D\u5FC3 FR-Designer_AlphaFine_NoResult=\u6682\u65E0\u76F8\u5173\u5185\u5BB9 FR-Designer_ConnectionFailed=\u94FE\u63A5\u5931\u8D25 FR-Designer_NoResult=\u6682\u4E0D\u652F\u6301\u663E\u793A +>>>>>>> d2de164e77196e797f514ec75b52974b32b99ac5 diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 01fb047ff..4e7fa5056 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -845,7 +845,6 @@ PageSetup-Placement_Center_on_Page=\u7F6E\u4E2D\u65B9\u5F0F sure_to_delete=\u78BA\u8A8D\u522A\u9664 Already_exists_not_add_repeat=\u5DF2\u7D93\u5B58\u5728\uFF0C\u8ACB\u4E0D\u8981\u91CD\u8907\u65B0\u589E Axis_Title=\u8EF8\u6A19\u984C -FR-Designer-Plugin_Install_Failed=Install failed FR-Designer-Widget-Style_Frame=\u6846\u67B6 MainGraduationUnit=\u4E3B\u8981\u523B\u5EA6\u55AE\u4F4D Second_Axis=\u6B21\u5750\u6A19\u8EF8 @@ -2001,6 +2000,79 @@ FR-Designer_AlphaFine_ShowLess=\u6536\u8D77 FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22 FR-Designer_AlphaFine_ShowAll=\u986F\u793A\u5168\u90E8 FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A +Designer-Plugin_Install_Success= +FR-Designer-Plugin_Install_Failed= +FR-Designer-Plugin_Install_Dependence= +FR-Designer-Plugin-Install_Package= +FR-Designer-Plugin_Delete_Dependence= +FR-Designer-Plugin_Delete_Success= +FR-Designer-Plugin_Delete_Failed= +FR-Designer-Plugin_Update_Dependence= +FR-Designer-Plugin_Update_Success= +FR-Designer-Plugin_Update_Failed= +FR-Designer-Plugin_Actived= +FR-Designer-Plugin_Disabled= +FR-Designer-Plugin-Store_App= +FR-Designer-Plugin-Store_Businesses= +FR-Designer-Plugin-Store_Official= +FR-Designer-Plugin-Store_Not_Official= +FR-Designer-Plugin-Store_Cost= +FR-Designer-Plugin-Store_Pay= +FR-Designer-Plugin-Store_Free= +FR-Designer-Plugin-Store_Category= +FR-Designer-Plugin-Store_Designer= +FR-Designer-Plugin-Store_Front_End_Display= +FR-Designer-Plugin-Store_Report_Write= +FR-Designer-Plugin-Store_Chart= +FR-Designer-Plugin-Store_BI= +FR-Designer-Plugin-Store_Export_Print= +FR-Designer-Plugin-Store_Mobile_Terminal= +FR-Designer-Plugin-Store_Integrate_Deployment= +FR-Designer-Plugin-Store_Data_Interface= +FR-Designer-Plugin-Store_Form_Components= +FR-Designer-Plugin-Store_Function= +FR-Designer-Plugin-Store_Recommend= +FR-Designer-Plugin-Store_Commodity_Description= +FR-Designer-Plugin-Store_Install= +FR-Designer-Plugin-Store_Install_From_Local= +FR-Designer-Plugin-Store_My_Plugins= +FR-Designer-Plugin-Store_No_Plugins= +FR-Designer-Plugin-Store_Disabled= +FR-Designer-Plugin-Store_Enable= +FR-Designer-Plugin-Store_Delete= +FR-Designer-Plugin-Store_Update= +FR-Designer-Plugin-Store_Update-ALL= +FR-Designer-Plugin-Store_Update_From_Local= +FR-Designer-Plugin-Store_BBS_Account_Login= +FR-Designer-Plugin-Store_Register= +FR-Designer-Plugin-Store_Forgot_Password= +FR-Designer-Plugin-Store_Quick_Login= +FR-Designer-Plugin-Store_Account= +FR-Designer-Plugin-Store_Password= +FR-Designer-Plugin-Store_Not_Login= +FR-Designer-Plugin-Store_Installed= +FR-Designer-Plugin-Store_Plugins_Count= +FR-Designer-Plugin-Store_Key_Word= +FR-Designer-Plugin-Store_Login= +FR-Designer-Plugin-Store_Login_By_QQ= +FR-Designer-Plugin-Store_User_Not_Exist= +FR-Designer-Plugin-Store_User_Password_Error= +FR-Designer-Plugin-Store_Unexpected_Error= +FR-Designer-Plugin-Store_Net_Connect_Failed= +FR-Designer-Plugin-Store_Not_Null= +FR-Designer-Plugin-Store_Switch_Account= +FR-Designer-Plugin-Store_Private_Message= +FR-Designer-Plugin-Store_Jar_Damaged= +FR-Designer-Plugin-Store_Probation= +FR-Designer-Plugin-Store_Authorize= +FR-Designer-Plugin-Store_Permanent= +FR-Designer-Plugin-Store_Expired= +FR-Designer-Plugin-Store_Day= +FR-Designer-Plugin-Store_Finereport= +FR-Designer-Plugin-Store_Version= +FR-Designer-Plugin-Store_Developer= +FR-Designer-Plugin-Store_Jar= +FR-Designer-Plugin-Store_Disconnected= FR-Designer_AlphaFine_NoResult=\u66AB\u7121\u76F8\u95DC\u5167\u5BB9 FR-Designer_ConnectionFailed=\u93C8\u63A5\u5931\u6557 FR-Designer_NoResult=\u66AB\u4E0D\u652F\u6301\u986F\u793A diff --git a/designer_base/src/com/fr/design/mainframe/AbstractAppProvider.java b/designer_base/src/com/fr/design/mainframe/AbstractAppProvider.java index f4f6bea97..25b0931f2 100644 --- a/designer_base/src/com/fr/design/mainframe/AbstractAppProvider.java +++ b/designer_base/src/com/fr/design/mainframe/AbstractAppProvider.java @@ -23,4 +23,10 @@ public abstract class AbstractAppProvider extends AbstractProv public void process() { DesignerFrame.registApp(this); } + + @Override + public void undo() { + + DesignerFrame.removeApp(this); + } } diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java index c3b6abee2..717674f22 100644 --- a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java @@ -15,11 +15,7 @@ import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.MutilTempalteTabPane; -import com.fr.design.file.NewTemplatePane; -import com.fr.design.file.SaveSomeTemplatePane; -import com.fr.design.file.TemplateTreePane; +import com.fr.design.file.*; import com.fr.design.fun.TitlePlaceProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.UIMenuHighLight; @@ -40,12 +36,15 @@ import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.GeneralContext; import com.fr.general.Inter; +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.stable.CoreConstants; import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; -import com.fr.stable.plugin.PluginReadListener; import com.fr.stable.project.ProjectConstants; import javax.swing.*; @@ -53,20 +52,8 @@ import javax.swing.border.MatteBorder; import java.awt.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DropTarget; -import java.awt.dnd.DropTargetDragEvent; -import java.awt.dnd.DropTargetDropEvent; -import java.awt.dnd.DropTargetEvent; -import java.awt.dnd.DropTargetListener; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; +import java.awt.dnd.*; +import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -162,6 +149,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta appList.add(app); } } + + public static void removeApp(App app) { + + if (app != null) { + appList.remove(app); + } + } protected DesktopCardPane getCenterTemplateCardPane() { return centerTemplateCardPane; @@ -186,27 +180,44 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta //hugh: private修改为protected方便oem的时候修改右上的组件构成 //顶部日志+登陆按钮 final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - GeneralContext.addPluginReadListener(new PluginReadListener() { + + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + refreshNorthEastPane(northEastPane, ad); + } + }, new PluginFilter() { + @Override - public void success(Status status) { - TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); - if (processor == null) { - processor = new DefaultTitlePlace(); - } - processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane()); + public boolean accept(PluginContext context) { + + return context.contain(TitlePlaceProcessor.MARK_STRING); } }); - + refreshNorthEastPane(northEastPane, ad); if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { northEastPane.add(ad.createAlphafinePane(), BorderLayout.CENTER); } return northEastPane; } - - public DesignerFrame(ToolBarMenuDock ad) { - setName(DESIGNER_FRAME_NAME); - this.ad = ad; - this.initTitleIcon(); + + private void refreshNorthEastPane(JPanel northEastPane, ToolBarMenuDock ad) { + + northEastPane.removeAll(); + TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); + if (processor == null) { + processor = new DefaultTitlePlace(); + } + processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane()); + } + + public DesignerFrame(ToolBarMenuDock ad) { + + setName(DESIGNER_FRAME_NAME); + this.ad = ad; + this.initTitleIcon(); this.setTitle();// james:因为有默认的了 // set this to context. DesignerContext.setDesignerFrame(this); diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 352fc1564..60f5067f1 100644 --- a/designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -27,9 +27,7 @@ import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; -import com.fr.general.GeneralContext; import com.fr.general.Inter; -import com.fr.plugin.proxy.PluginProxyCompatibleUtils; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; @@ -44,7 +42,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.io.File; import java.util.HashMap; -import java.util.Locale; import java.util.Map; import java.util.Set; @@ -131,8 +128,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt toolbarDef.addShortCut(openFolderAction, renameAction); } toolbarDef.addShortCut(delFileAction); - Set extraShortCuts = ExtraDesignClassManager.getInstance().getArray(ShortCut.TEMPLATE_TREE); - extraShortCuts = PluginProxyCompatibleUtils.toOriObjectHashSet(extraShortCuts); + Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); for (ShortCut shortCut : extraShortCuts){ toolbarDef.addShortCut(shortCut); } diff --git a/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java index 7fa8012fe..e2a6d64d5 100644 --- a/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java @@ -3,10 +3,14 @@ package com.fr.design.mainframe; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.icontainer.UIResizableContainer; 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.stable.Constants; -import com.fr.stable.plugin.PluginReadListener; public class WestRegionContainerPane extends UIResizableContainer { @@ -27,12 +31,25 @@ public class WestRegionContainerPane extends UIResizableContainer { public WestRegionContainerPane() { super(DesignerFrameFileDealerPane.getInstance(), Constants.RIGHT); - GeneralContext.addPluginReadListener(new PluginReadListener() { + + setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); + + GeneralContext.listenPluginRunningChanged(new PluginEventListener(TableDataTreePane.PLUGIN_LISTENER_PRIORITY - 1) { + @Override - public void success(Status status) { + public void on(PluginEvent event) { + setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(TableDataPaneProcessor.XML_TAG); + } }); + setContainerWidth(165); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index d71bd9b5f..669b447aa 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -11,9 +11,9 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.actions.community.*; import com.fr.design.actions.file.*; import com.fr.design.actions.help.AboutAction; -import com.fr.design.actions.help.alphafine.AlphaFineAction; import com.fr.design.actions.help.TutorialAction; import com.fr.design.actions.help.WebDemoAction; +import com.fr.design.actions.help.alphafine.AlphaFineAction; import com.fr.design.actions.server.*; import com.fr.design.file.NewTemplatePane; import com.fr.design.fun.MenuHandler; @@ -31,7 +31,14 @@ import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.env.RemoteEnv; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralContext; import com.fr.general.Inter; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginRuntime; +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.stable.ArrayUtils; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; @@ -574,17 +581,56 @@ public abstract class ToolBarMenuDock { protected void insertMenu(MenuDef menuDef, String anchor) { insertMenu(menuDef, anchor, new NoTargetAction()); } - + protected void insertMenu(MenuDef menuDef, String anchor, ShortCutMethodAction action) { - // 下面是插件接口接入点 - Set set = ExtraDesignClassManager.getInstance().getArray(MenuHandler.MARK_STRING); - java.util.List target = new ArrayList<>(); + + listenPluginMenuChange(menuDef, anchor, action); + addExtraMenus(menuDef, anchor, action, ExtraDesignClassManager.getInstance().getArray(MenuHandler.MARK_STRING)); + + } + + private void listenPluginMenuChange(MenuDef menuDef, String anchor, ShortCutMethodAction action) { + + PluginFilter filter = new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(MenuHandler.MARK_STRING); + } + }; + + GeneralContext.listenPlugin(PluginEventType.BeforeStop, new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + PluginRuntime runtime = event.getContext().getRuntime(); + Set menuHandlers = runtime.get(MenuHandler.MARK_STRING); + removeExtraMenus(menuDef, anchor, action, menuHandlers); + } + }, filter); + GeneralContext.listenPlugin(PluginEventType.AfterRun, new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + PluginRuntime runtime = event.getContext().getRuntime(); + Set menuHandlers = runtime.get(MenuHandler.MARK_STRING); + addExtraMenus(menuDef, anchor, action, menuHandlers); + } + }, filter); + } + + private void removeExtraMenus(MenuDef menuDef, String anchor, ShortCutMethodAction action, Set set) { + + + List target = new ArrayList<>(); for (MenuHandler handler : set) { if (ComparatorUtils.equals(handler.category(), anchor)) { target.add(handler); } } - + for (MenuHandler handler : target) { int insertPosition = handler.insertPosition(menuDef.getShortCutCount()); if (insertPosition == MenuHandler.HIDE) { @@ -594,7 +640,29 @@ public abstract class ToolBarMenuDock { if (shortCut == null){ continue; } - + menuDef.removeShortCut(shortCut); + } + } + + private void addExtraMenus(MenuDef menuDef, String anchor, ShortCutMethodAction action, Set set) { + + List target = new ArrayList<>(); + for (MenuHandler handler : set) { + if (ComparatorUtils.equals(handler.category(), anchor)) { + target.add(handler); + } + } + + for (MenuHandler handler : target) { + int insertPosition = handler.insertPosition(menuDef.getShortCutCount()); + if (insertPosition == MenuHandler.HIDE) { + return; + } + ShortCut shortCut = action.methodAction(handler); + if (shortCut == null){ + continue; + } + if (insertPosition == MenuHandler.LAST) { if (handler.insertSeparatorBefore()) { menuDef.addShortCut(SeparatorDef.DEFAULT); @@ -613,7 +681,7 @@ public abstract class ToolBarMenuDock { } } } - + /** * 设计器退出时, 做的一些操作. * diff --git a/designer_base/src/com/fr/design/menu/MenuDef.java b/designer_base/src/com/fr/design/menu/MenuDef.java index 9de4dba4e..319b94f2e 100644 --- a/designer_base/src/com/fr/design/menu/MenuDef.java +++ b/designer_base/src/com/fr/design/menu/MenuDef.java @@ -117,6 +117,11 @@ public class MenuDef extends ShortCut { this.shortcutList.add(i); } } + + public void removeShortCut(ShortCut shortCut) { + + this.shortcutList.remove(shortCut); + } /** * 清理 @@ -349,6 +354,6 @@ public class MenuDef extends ShortCut { public void setPopupMenu(JPopupMenu popupMenu) { this.popupMenu = popupMenu; } - - + + } \ No newline at end of file diff --git a/designer_base/src/com/fr/env/RemoteEnv.java b/designer_base/src/com/fr/env/RemoteEnv.java index ac5732e73..a17815092 100644 --- a/designer_base/src/com/fr/env/RemoteEnv.java +++ b/designer_base/src/com/fr/env/RemoteEnv.java @@ -27,10 +27,6 @@ import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginLicense; -import com.fr.plugin.PluginLicenseManager; -import com.fr.plugin.PluginLoader; import com.fr.share.ShareConstants; import com.fr.stable.*; import com.fr.stable.file.XMLFileManagerProvider; @@ -388,7 +384,6 @@ public class RemoteEnv extends AbstractEnv { private void extraChangeEnvPara() { //在env连接之前, 加载一下不依赖env的插件. 看看需不需要改变参数. - PluginLoader.init(); DesignerEnvProcessor envProcessor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG); if (envProcessor != null) { this.path = envProcessor.changeEnvPathBeforeConnect(user, password, path); @@ -1993,7 +1988,8 @@ public class RemoteEnv extends AbstractEnv { public void setLicName(String licName) { //do nth } - + + /** * 获取当前env的build文件路径 */ @@ -2029,74 +2025,8 @@ public class RemoteEnv extends AbstractEnv { info.parseJSON(jo); return info; } - - /** - * 将文件拷贝到插件目录 - * - * @param dir 要拷贝的文件 - * @param plugin 插件 - */ - public void copyFilesToPluginAndLibFolder(File dir, Plugin plugin) throws Exception { - - } - - /** - * 将文件添加到指定目录或者删除指定目录的文件 - * - * @param file 解压插件的临时目录 - * @param plugin 当前处理的插件 - */ - public void movePluginEmbFile(File file, Plugin plugin) throws Exception { - - } - - /** - * 将文件从插件目录删除 - * - * @param plugin 要删除插件 - * @return 同上 - */ - public String[] deleteFileFromPluginAndLibFolder(Plugin plugin) { - return new String[0]; - } - - /** - * 保存插件的配置文件 - * - * @param plugin 插件 - */ - public void writePlugin(Plugin plugin) throws Exception { - - } - - - /** - * 获取插件的配置目录 - * - * @param plugin - */ - public String getPluginFilePath(Plugin plugin) { - - return StringUtils.EMPTY; - } - - public void readPluginLicenses() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - HashMap para = new HashMap(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_plugin_licenses"); - - InputStream inputStream = postBytes2ServerB(out.toByteArray(), para); - String pluginsLicensesStr = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); - if (StringUtils.isNotBlank(pluginsLicensesStr) && pluginsLicensesStr.startsWith("[")) { - JSONArray jsonArray = new JSONArray(pluginsLicensesStr); - for (int i = 0; i < jsonArray.length(); i++) { - PluginLicense pluginLicense = new PluginLicense(); - pluginLicense.parseJSON(jsonArray.getJSONObject(i)); - PluginLicenseManager.getInstance().addRemotePluginLicense(pluginLicense); - } - } - } + + @Override public String pluginServiceAction(String serviceID, String req) throws Exception { @@ -2117,12 +2047,6 @@ public class RemoteEnv extends AbstractEnv { @Override public void pluginServiceStart(String serviceID){ } - - @Override - public void checkAndRegisterLic(FileNode node, Plugin plugin) throws Exception { - - } - @Override public File[] loadREUFile() throws Exception { File target = new File(CacheManager.getProviderInstance().getCacheDirectory(), @@ -2238,4 +2162,34 @@ public class RemoteEnv extends AbstractEnv { return StringUtils.EMPTY; } } + + @Override + public boolean isLocalEnv() { + + return false; + } + + @Override + public boolean hasPluginServiceStarted(String key) { + + return true; + } + + @Override + public JSONArray getPluginStatus() { + + try { + HashMap para = new HashMap(); + para.put("op", "plugin"); + para.put("cmd", "get_states"); + para.put("current_uid", this.createUserID()); + para.put("currentUsername", this.getUser()); + + HttpClient client = createHttpMethod(para); + InputStream input = execute4InputStream(client); + return new JSONArray(stream2String(input)); + } catch (Exception e) { + return JSONArray.create(); + } + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/plugin/PluginManager.java b/designer_base/src/com/fr/plugin/PluginManager.java deleted file mode 100644 index c539db874..000000000 --- a/designer_base/src/com/fr/plugin/PluginManager.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.fr.plugin; - -import com.fr.design.actions.UpdateAction; -import com.fr.file.XMLFileManager; -import com.fr.general.ComparatorUtils; -import com.fr.general.FRLogger; -import com.fr.general.GeneralUtils; -import com.fr.stable.StringUtils; -import com.fr.stable.xml.XMLPrintWriter; -import com.fr.stable.xml.XMLReadable; -import com.fr.stable.xml.XMLableReader; - -import java.util.ArrayList; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 13-12-20 - * Time: 下午5:05 - */ -public class PluginManager extends XMLFileManager { - - private static PluginManager pluginManager = null; - - private String extensionPoint = StringUtils.EMPTY; - - private ArrayList resultList = new ArrayList(); - - - public synchronized static PluginManager getInstance() { - if (pluginManager == null) { - pluginManager = new PluginManager(); - } - return pluginManager; - } - - - public PluginManager() { - - } - - /** - * 文件名 - * @return 文件名 - */ - public String fileName() { - return "plugin.xml"; - } - - - public void setExtensionPoint(String point) { - extensionPoint = point; - resultList.clear(); - pluginManager.readXMLFile(); - } - - - @Override - public void readXML(XMLableReader reader) { - if (extensionPoint == StringUtils.EMPTY) { - return; - } - if (reader.getTagName().equals("PluginManager")) { - reader.readXMLObject(new XMLReadable() { - @Override - public void readXML(XMLableReader reader) { - readExtension(reader); - } - }); - } - - - } - - private void readExtension(XMLableReader reader) { - if (reader.isChildNode()) { - if (reader.getTagName().equals("Extension")) { - String name = null, tmpVal = null; - if ((tmpVal = reader.getAttrAsString("position", null)) != null) { - name = tmpVal; - } - if (!ComparatorUtils.equals(name, extensionPoint)) { - return; - } - reader.readXMLObject(new XMLReadable() { - @Override - public void readXML(XMLableReader reader) { - readActions(reader); - } - }); - - } - } - } - - private void readActions(XMLableReader reader) { - if (reader.isChildNode()) { - if (reader.getTagName().equals("Action")) { - String name = null, tmpVal = null; - if ((tmpVal = reader.getAttrAsString("class", null)) != null) { - name = tmpVal; - } - //读取模板数据集菜单 - if (name.isEmpty()) { - return; - } - try { - UpdateAction action = (UpdateAction) GeneralUtils.classForName(name).newInstance(); - PluginManager.this.resultList.add(action); - } catch (Exception exp) { - FRLogger.getLogger().error(exp.getMessage(), exp); - } - } - } - - } - - - public ArrayList getResultList() { - return resultList; - } - - @Override - public void writeXML(XMLPrintWriter writer) { - } - -} \ No newline at end of file diff --git a/designer_base/src/com/fr/start/BaseDesigner.java b/designer_base/src/com/fr/start/BaseDesigner.java index 301a9191f..0d5332cc8 100644 --- a/designer_base/src/com/fr/start/BaseDesigner.java +++ b/designer_base/src/com/fr/start/BaseDesigner.java @@ -13,6 +13,7 @@ import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerStartOpenFileProcessor; import com.fr.design.fun.GlobalListenerProvider; +import com.fr.design.fun.impl.GlobalListenerProviderManager; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.TemplatePane; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; @@ -26,6 +27,7 @@ import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.general.ModuleContext; import com.fr.plugin.PluginCollector; +import com.fr.plugin.manage.PluginManager; import com.fr.stable.*; import javax.swing.*; @@ -89,6 +91,8 @@ public abstract class BaseDesigner extends ToolBarMenuDock { switch2LastEnv(); initDefaultFont(); + //PluginManager要在环境切换和模块启动之前初始化 + PluginManager.init(); // 必须先初始化Env再去startModule, 不然会导致lic读取不到 ModuleContext.startModule(module2Start()); @@ -111,10 +115,8 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } private void bindGlobalListener() { - Set providers = ExtraDesignClassManager.getInstance().getArray(GlobalListenerProvider.XML_TAG); - for (GlobalListenerProvider provider : providers) { - Toolkit.getDefaultToolkit().addAWTEventListener(provider.listener(), AWTEvent.KEY_EVENT_MASK); - } + + GlobalListenerProviderManager.getInstance().init(); } private void showErrorPluginsMessage() { diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index c67a6aea5..b23954ab4 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -19,128 +19,124 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.module.DesignModuleFactory; -import com.fr.file.XMLFileManager; import com.fr.form.ui.ChartEditor; -import com.fr.general.*; -import com.fr.plugin.PluginCollector; -import com.fr.plugin.PluginLicenseManager; -import com.fr.plugin.PluginMessage; -import com.fr.design.extra.ChartTypeInterfaceCloseableHandler; -import com.fr.plugin.proxy.PluginInstanceProxyFactory; -import com.fr.plugin.proxy.PluginInvocationHandler; +import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; +import com.fr.general.Inter; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.injectable.PluginSingleInjection; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.ArrayUtils; -import com.fr.stable.EnvChangedListener; import com.fr.stable.StringUtils; +import com.fr.stable.bridge.StableFactory; import com.fr.stable.collections.map.CloseableContainedMap; -import com.fr.stable.fun.Authorize; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; -import com.fr.stable.plugin.PluginReadListener; -import com.fr.stable.plugin.PluginSimplify; -import com.fr.stable.plugin.closeable.Closeable; -import com.fr.stable.xml.XMLPrintWriter; -import com.fr.stable.xml.XMLableReader; import javax.swing.*; import java.util.*; /** - * Created by eason on 14/12/29. + * Created by eason on 14/12/29. */ -public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraChartDesignClassManagerProvider { - - private static ClassLoader loader = Thread.currentThread().getContextClassLoader(); - - private static ChartTypeInterfaceManager classManager = null; - +public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerProvider { + + + private static ChartTypeInterfaceManager classManager = new ChartTypeInterfaceManager(); + private static LinkedHashMap> chartTypeInterfaces = - new LinkedHashMap<>(); - + new LinkedHashMap>(); + public synchronized static ChartTypeInterfaceManager getInstance() { - if (classManager == null) { - classManager = new ChartTypeInterfaceManager(); - chartTypeInterfaces.clear(); - classManager.readDefault(); - } + return classManager; } - + static { - GeneralContext.addEnvChangedListener(new EnvChangedListener() { - public void envChanged() { - ChartTypeInterfaceManager.envChanged(); - } - }); + readDefault(); + StableFactory.registerMarkedObject(XML_TAG, classManager); } - + static { - GeneralContext.addPluginReadListener(new PluginReadListener() { + + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override - public void success(Status status) { + public void on(PluginEvent event) { //重新注册designModuleFactory DesignModuleFactory.registerExtraWidgetOptions(initWidgetOption()); } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraChartType); + } }); } - - public static WidgetOption[] initWidgetOption(){ - + + private static WidgetOption[] initWidgetOption() { + ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; final Chart[][] allCharts = new Chart[typeName.length][]; for (int i = 0; i < typeName.length; i++) { String plotID = typeName[i].getPlotID(); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); - if(ArrayUtils.isEmpty(rowChart)) { + if (ArrayUtils.isEmpty(rowChart)) { continue; } String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); Icon icon = IOUtils.readIcon(iconPath); child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); - + allCharts[i] = rowChart; } - + //异步加载图片 new Thread(new Runnable() { + @Override public void run() { + initAllChartsDemoImage(allCharts); } }).start(); - + return child; } - + //加载所有图表图片 - private static void initAllChartsDemoImage(Chart[][] allCharts){ - for (int i = 0; i < allCharts.length; i++) { - Chart[] rowChart = allCharts[i]; - if(rowChart == null) { + private static void initAllChartsDemoImage(Chart[][] allCharts) { + + for (Chart[] rowChart : allCharts) { + if (rowChart == null) { continue; } //加载初始化图表模型图片 initChartsDemoImage(rowChart); } } - + private static void initChartsDemoImage(Chart[] rowChart) { - int rowChartsCount = rowChart.length; - for (int j = 0; j < rowChartsCount; j++) { + + for (Chart aRowChart : rowChart) { //此时,为图片生成模型数据 - rowChart[j].createSlotImage(); + aRowChart.createSlotImage(); } } - - private synchronized static void envChanged() { - classManager = null; - } - + + private static void readDefault() { - if (chartTypeInterfaces.containsKey(ChartTypeManager.CHART_PRIORITY)){ + + if (chartTypeInterfaces.containsKey(ChartTypeManager.CHART_PRIORITY)) { return; } CloseableContainedMap chartUIList = - new CloseableContainedMap<>(LinkedHashMap.class); + new CloseableContainedMap(LinkedHashMap.class); chartUIList.put(ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface()); chartUIList.put(ChartConstants.LINE_CHART, new LineIndependentChartInterface()); chartUIList.put(ChartConstants.BAR_CHART, new BarIndependentChartInterface()); @@ -158,16 +154,16 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh chartUIList.put(ChartConstants.MAP_CHART, new MapIndependentChartInterface()); chartUIList.put(ChartConstants.GIS_CHAER, new GisMapIndependentChartInterface()); chartUIList.put(ChartConstants.FUNNEL_CHART, new FunnelIndependentChartInterface()); - + chartTypeInterfaces.put(ChartTypeManager.CHART_PRIORITY, chartUIList); } - + + public String getIconPath(String plotID) { + if (chartTypeInterfaces != null) { - Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - String priority = (String) entry.getKey(); + for (Map.Entry> entry : chartTypeInterfaces.entrySet()) { + String priority = entry.getKey(); String imagePath = getIconPath(priority, plotID); if (StringUtils.isNotEmpty(imagePath)) { return imagePath; @@ -176,25 +172,26 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } return StringUtils.EMPTY; } - + private String getIconPath(String priority, String plotID) { - + if (chartTypeInterfaces.get(priority) != null && chartTypeInterfaces.get(priority).get(plotID) != null) { return chartTypeInterfaces.get(priority).get(plotID).getIconPath(); - }else { + } else { return StringUtils.EMPTY; } } - - public static void addChartTypeInterface(IndependentChartUIProvider provider, String priority, String plotID) { - if (chartTypeInterfaces != null){ - if (!chartTypeInterfaces.containsKey(priority)){ + + private static void addChartTypeInterface(IndependentChartUIProvider provider, String priority, String plotID) { + + if (chartTypeInterfaces != null) { + if (!chartTypeInterfaces.containsKey(priority)) { //新建一个具体图表列表 CloseableContainedMap chartUIList - = new CloseableContainedMap<>(LinkedHashMap.class); + = new CloseableContainedMap(LinkedHashMap.class); chartUIList.put(plotID, provider); chartTypeInterfaces.put(priority, chartUIList); - }else { + } else { Map chartUIList = chartTypeInterfaces.get(priority); if (!chartUIList.containsKey(plotID)) { chartUIList.put(plotID, provider); @@ -202,54 +199,18 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } } } - - /** - * 增加界面接口定义 - * - * @param className 类名 - * @param plotID 标志ID - */ - public void addChartInterface(String className, String priority, String plotID, PluginSimplify simplify) { - if (StringUtils.isNotBlank(className)) { - try { - Class clazz = Class.forName(className); - Authorize authorize = clazz.getAnnotation(Authorize.class); - if (authorize != null) { - PluginLicenseManager.getInstance().registerPaid(authorize, simplify); - } - IndependentChartUIProvider provider = getProxyObj(plotID, simplify, clazz); - if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName())) { - PluginMessage.remindUpdate(className); - } else { - addChartTypeInterface(provider, priority, plotID); - } - } catch (ClassNotFoundException e) { - FRLogger.getLogger().error("class not found:" + e.getMessage()); - } catch (IllegalAccessException | InstantiationException e) { - FRLogger.getLogger().error("object create error:" + e.getMessage()); - } catch (NoSuchMethodException e) { - FRLogger.getLogger().error(e.getMessage()); - } - } - } - - private IndependentChartUIProvider getProxyObj(String plotID, PluginSimplify simplify, Class clazz) throws IllegalAccessException, InstantiationException, NoSuchMethodException { - - PluginInstanceProxyFactory factory = new PluginInstanceProxyFactory(clazz, simplify); - PluginInvocationHandler handler = new ChartTypeInterfaceCloseableHandler(plotID); - return (IndependentChartUIProvider) factory.addProxy(Closeable.class, handler).getProxyObj(); - } - - + + /** * 把所有的pane加到list里 * * @param paneList pane容器 */ public void addPlotTypePaneList(List> paneList) { + List priorityList = getPriorityInOrder(); - for (int i = 0; i < priorityList.size(); i++){ - String priority = String.valueOf(priorityList.get(i)); + for (Integer aPriorityList : priorityList) { + String priority = String.valueOf(aPriorityList); Iterator chartUIIterator = chartTypeInterfaces.get(priority).entrySet().iterator(); while (chartUIIterator.hasNext()) { Map.Entry chartUIEntry = (Map.Entry) chartUIIterator.next(); @@ -258,9 +219,10 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } } } - - public String[] getTitle4PopupWindow(String priority){ - if (priority.isEmpty()){ + + public String[] getTitle4PopupWindow(String priority) { + + if (priority.isEmpty()) { return getTitle4PopupWindow(); } String[] names = new String[getChartSize(priority)]; @@ -268,7 +230,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh Map chartUIList = chartTypeInterfaces.get(priority); Iterator iterator = chartUIList.entrySet().iterator(); int i = 0; - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); IndependentChartUIProvider provider = (IndependentChartUIProvider) entry.getValue(); names[i++] = provider.getPlotTypeTitle4PopupWindow(); @@ -277,19 +239,17 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } return new String[0]; } - + /** * 获取指定图表的标题 - * @param priority - * @return */ - public String getTitle4PopupWindow(String priority, String plotID){ - + public String getTitle4PopupWindow(String priority, String plotID) { + if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) { IndependentChartUIProvider provider = chartTypeInterfaces.get(priority).get(plotID); return provider.getPlotTypeTitle4PopupWindow(); } - + //兼容老的插件 if (chartTypeInterfaces != null) { Iterator iterator = chartTypeInterfaces.entrySet().iterator(); @@ -301,34 +261,36 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } } } - return new String(); + return StringUtils.EMPTY; } - - private String[] getTitle4PopupWindow(){ + + private String[] getTitle4PopupWindow() { + List priorityList = getPriorityInOrder(); - - if (priorityList.size() == 0){ + + if (priorityList.size() == 0) { return new String[0]; } - + int size = 0; //获取总得图表格式 - for (int i = 0; i < priorityList.size(); i++) { - size += getChartSize(String.valueOf(priorityList.get(i))); + for (Integer aPriorityList : priorityList) { + size += getChartSize(String.valueOf(aPriorityList)); } String[] names = new String[size]; - + int index = 0; - for (int i = 0; i < priorityList.size(); i++){ - String priority = String.valueOf(priorityList.get(i)); + for (Integer aPriorityList : priorityList) { + String priority = String.valueOf(aPriorityList); Iterator chartUI = chartTypeInterfaces.get(priority).entrySet().iterator(); index = fetchNames(chartUI, names, index); } - + return names; } - + private List getPriorityInOrder() { + List priorityList = new ArrayList(); if (chartTypeInterfaces != null) { Iterator iterator = chartTypeInterfaces.entrySet().iterator(); @@ -340,8 +302,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } return ChartTypeManager.orderInPriority(priorityList); } - + private int fetchNames(Iterator chartUI, String[] names, int index) { + while (chartUI.hasNext()) { Map.Entry chartUIEntry = (Map.Entry) chartUI.next(); IndependentChartUIProvider provider = (IndependentChartUIProvider) chartUIEntry.getValue(); @@ -349,10 +312,11 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } return index; } - + public ChartDataPane getChartDataPane(String plotID, AttributeChangeListener listener) { + Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); if (plotInChart(plotID, priority)) { @@ -361,26 +325,28 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } return getChartDataPane(ChartTypeManager.CHART_PRIORITY, plotID, listener); } - + private ChartDataPane getChartDataPane(String priority, String plotID, AttributeChangeListener listener) { + return chartTypeInterfaces.get(priority).get(plotID).getChartDataPane(listener); } - + /** * 获取对应ID的图表数量 - * @param key - * @return + * */ - private int getChartSize(String key){ - if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(key)){ + private int getChartSize(String key) { + + if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(key)) { return chartTypeInterfaces.get(key).size(); } return 0; } - + public AbstractChartAttrPane[] getAttrPaneArray(String plotID, AttributeChangeListener listener) { + Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); if (plotInChart(plotID, priority)) { @@ -389,14 +355,16 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } return getAttrPaneArray(ChartTypeManager.CHART_PRIORITY, plotID, listener); } - + private AbstractChartAttrPane[] getAttrPaneArray(String priority, String plotID, AttributeChangeListener listener) { + return chartTypeInterfaces.get(priority).get(plotID).getAttrPaneArray(listener); } - + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { + Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); if (plotInChart(plot.getPlotID(), priority)) { @@ -405,15 +373,17 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } return getTableDataSourcePane(ChartTypeManager.CHART_PRIORITY, plot, parent); } - + private AbstractTableDataContentPane getTableDataSourcePane(String priority, Plot plot, ChartDataPane parent) { + return chartTypeInterfaces.get(priority).get(plot.getPlotID()).getTableDataSourcePane(plot, parent); } - - + + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { + Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); String plotID = plot.getPlotID(); @@ -423,21 +393,24 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } return getReportDataSourcePane(ChartTypeManager.CHART_PRIORITY, plot, parent); } - + private boolean plotInChart(String plotID, String priority) { + return chartTypeInterfaces != null - && chartTypeInterfaces.containsKey(priority) + && chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID); } - + private AbstractReportDataContentPane getReportDataSourcePane(String priority, Plot plot, ChartDataPane parent) { + return chartTypeInterfaces.get(priority).get(plot.getPlotID()).getReportDataSourcePane(plot, parent); } - - + + public ConditionAttributesPane getPlotConditionPane(Plot plot) { + Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); if (plotInChart(plot.getPlotID(), priority)) { @@ -446,15 +419,17 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } return getPlotConditionPane(ChartTypeManager.CHART_PRIORITY, plot); } - + private ConditionAttributesPane getPlotConditionPane(String priority, Plot plot) { + return chartTypeInterfaces.get(priority).get(plot.getPlotID()).getPlotConditionPane(plot); } - - + + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { + Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); if (plotInChart(plot.getPlotID(), priority)) { @@ -463,11 +438,12 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } return getPlotSeriesPane(ChartTypeManager.CHART_PRIORITY, parent, plot); } - + private BasicBeanPane getPlotSeriesPane(String priority, ChartStylePane parent, Plot plot) { + return chartTypeInterfaces.get(priority).get(plot.getPlotID()).getPlotSeriesPane(parent, plot); } - + /** * 是否使用默认的界面,为了避免界面来回切换 * @@ -475,55 +451,60 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh * @return 是否使用默认的界面 */ public boolean isUseDefaultPane(String plotID) { + Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); if (chartTypeInterfaces.get(priority).containsKey(plotID)) { return isUseDefaultPane(priority, plotID); } } - + return true; } - + private boolean isUseDefaultPane(String priority, String plotID) { - - if (chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) { - return chartTypeInterfaces.get(priority).get(plotID).isUseDefaultPane(); - } - - return true; + + return !(chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) || chartTypeInterfaces.get(priority).get(plotID).isUseDefaultPane(); + } - - public void readXML(XMLableReader reader) { - readXML(reader, null, PluginSimplify.NULL); + + @Override + public void mount(PluginSingleInjection injection) { + + if (isIndependentChartUIProvider(injection)) { + String priority = injection.getAttribute("priority"); + String plotID = injection.getAttribute("plotID"); + IndependentChartUIProvider instance = (IndependentChartUIProvider) injection.getObject(); + addChartTypeInterface(instance, priority, plotID); + } } - + + @Override - public void readXML(XMLableReader reader, List extraChartDesignInterfaceList, PluginSimplify simplify) { - if (reader.isChildNode()) { - String tagName = reader.getTagName(); - if (extraChartDesignInterfaceList != null) { - extraChartDesignInterfaceList.add(tagName); - } - if (IndependentChartUIProvider.XML_TAG.equals(tagName)) { - addChartInterface(reader.getAttrAsString("class", ""), reader.getAttrAsString("priority", ChartTypeManager.CHART_PRIORITY),reader.getAttrAsString("plotID", ""), simplify); - } + public void demount(PluginSingleInjection injection) { + + if (isIndependentChartUIProvider(injection)) { + String priority = injection.getAttribute("priority"); + String plotID = injection.getAttribute("plotID"); + removeChartTypeInterface(priority, plotID); } } - - /** - * 文件名 - * - * @return 文件名 - */ - public String fileName() { - return "chart.xml"; + + private void removeChartTypeInterface(String priority, String plotID) { + + if (chartTypeInterfaces != null) { + if (chartTypeInterfaces.containsKey(priority)) { + Map chartUIList = chartTypeInterfaces.get(priority); + chartUIList.remove(plotID); + } + } } - - @Override - public void writeXML(XMLPrintWriter writer) { - + + + private boolean isIndependentChartUIProvider(PluginSingleInjection injection) { + + return !(injection == null || injection.getObject() == null) && IndependentChartUIProvider.XML_TAG.equals(injection.getName()) && injection.getObject() instanceof IndependentChartUIProvider; } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java b/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java deleted file mode 100644 index 8e9715574..000000000 --- a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.fr.design.extra; - -import com.fr.chart.charttypes.ChartTypeManager; -import com.fr.plugin.proxy.CloseableInvocationHandler; - -/** - * Created by juhaoyu on 2016/12/27. - */ -public class ChartTypeInterfaceCloseableHandler extends CloseableInvocationHandler { - - - private final String plotID; - - public ChartTypeInterfaceCloseableHandler(String plotID) throws NoSuchMethodException { - - super(); - this.plotID = plotID; - } - - @Override - protected boolean invokeIsClosed() { - - //UI对应的chart如果关闭或者不存在,则UI关闭 - return super.invokeIsClosed() || !containsChart(); - } - - private boolean containsChart() { - - return ChartTypeManager.getInstance().containsPlot(plotID); - } -} diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java index f56146b8b..7b35b8d8d 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui.type; import com.fr.design.chart.series.PlotStyle.ChartSelectDemoPane; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; +import com.fr.general.IOUtils; import javax.swing.*; import java.awt.*; @@ -14,9 +15,9 @@ public class ChartImagePane extends ChartSelectDemoPane { public boolean isDoubleClicked = false; public ChartImagePane(String iconPath, String tipName) {// 建立太复杂? 耗费内存.. - UILabel image = new UILabel(new ImageIcon(getClass().getResource(iconPath))); - this.setLayout(new BorderLayout()); - this.add(image, BorderLayout.CENTER); + UILabel image = new UILabel(IOUtils.readIcon(iconPath)); + this.setLayout(new BorderLayout()); + this.add(image, BorderLayout.CENTER); addMouseListener(this); this.setToolTipText(tipName); @@ -28,7 +29,8 @@ public class ChartImagePane extends ChartSelectDemoPane { } private void constructImagePane(String fullIconPath, String tipName, boolean isDrawRightLine){ - UILabel image = new UILabel(new ImageIcon(getClass().getResource(fullIconPath))); + + UILabel image = new UILabel(IOUtils.readIcon(fullIconPath)); this.setLayout(new BorderLayout()); this.add(image, BorderLayout.CENTER); addMouseListener(this); diff --git a/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java b/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java index 3c58e2f19..4b6b4240a 100644 --- a/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java @@ -5,13 +5,9 @@ package com.fr.design.designer.creator; import com.fr.base.FRContext; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.designer.creator.cardlayout.XCardAddButton; -import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; -import com.fr.design.designer.creator.cardlayout.XWCardLayout; -import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; -import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; -import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; -import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; +import com.fr.design.designer.creator.cardlayout.*; +import com.fr.design.fun.FormWidgetOptionProvider; +import com.fr.design.fun.ParameterWidgetOptionProvider; import com.fr.design.module.DesignModuleFactory; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.parameter.FormSubmitButton; @@ -24,7 +20,13 @@ import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.GeneralContext; import com.fr.general.IOUtils; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.StringUtils; import javax.swing.*; @@ -38,11 +40,66 @@ import java.lang.reflect.Constructor; * @since 6.5.3 */ public class XCreatorUtils { - + public static java.util.Map, Class> objectMap = new java.util.HashMap, Class>(); + + private static java.util.Map, Class> extraObjectMap = new java.util.HashMap, Class>(); + public static java.util.Map, Class> xLayoutMap = new java.util.HashMap, Class>(); - + static { + init(); + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + reInitExtra(); + } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign, ParameterWidgetOptionProvider.XML_TAG) + || context.contain(PluginModule.ExtraDesign, FormWidgetOptionProvider.XML_TAG); + } + }); + } + + private static void init() { + + putDefault(); + putExtraEditor(); + putDefaultLayouts(); + reInitExtra(); + } + + private static void putDefaultLayouts() { + + xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class); + xLayoutMap.put(WParameterLayout.class, XWParameterLayout.class); + xLayoutMap.put(WAbsoluteBodyLayout.class, XWAbsoluteBodyLayout.class); + xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class); + xLayoutMap.put(WHorizontalBoxLayout.class, XWHorizontalBoxLayout.class); + xLayoutMap.put(WBorderLayout.class, XWBorderLayout.class); + xLayoutMap.put(WCardLayout.class, XWCardLayout.class); + xLayoutMap.put(WVerticalBoxLayout.class, XWVerticalBoxLayout.class); + xLayoutMap.put(WHorizontalSplitLayout.class, XWHorizontalSplitLayout.class); + xLayoutMap.put(WVerticalSplitLayout.class, XWVerticalSplitLayout.class); + xLayoutMap.put(WGridLayout.class, XWGridLayout.class); + + xLayoutMap.put(WFitLayout.class, XWFitLayout.class); + xLayoutMap.put(WScaleLayout.class, XWScaleLayout.class); + xLayoutMap.put(WTitleLayout.class, XWTitleLayout.class); + xLayoutMap.put(WCardTagLayout.class, XWCardTagLayout.class); + xLayoutMap.put(WCardTitleLayout.class, XWCardTitleLayout.class); + xLayoutMap.put(WTabFitLayout.class, XWTabFitLayout.class); + xLayoutMap.put(WCardMainBorderLayout.class, XWCardMainBorderLayout.class); + } + + private static void putDefault() { + objectMap.put(TextEditor.class, XTextEditor.class); objectMap.put(TextArea.class, XTextArea.class); objectMap.put(NumberEditor.class, XNumberEditor.class); @@ -73,40 +130,28 @@ public class XCreatorUtils { objectMap.put(NameWidget.class, XNameWidget.class); objectMap.put(CardSwitchButton.class, XCardSwitchButton.class); objectMap.put(CardAddButton.class, XCardAddButton.class); - putExtraEditor(); - - xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class); - xLayoutMap.put(WParameterLayout.class, XWParameterLayout.class); - xLayoutMap.put(WAbsoluteBodyLayout.class, XWAbsoluteBodyLayout.class); - xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class); - xLayoutMap.put(WHorizontalBoxLayout.class, XWHorizontalBoxLayout.class); - xLayoutMap.put(WBorderLayout.class, XWBorderLayout.class); - xLayoutMap.put(WCardLayout.class, XWCardLayout.class); - xLayoutMap.put(WVerticalBoxLayout.class, XWVerticalBoxLayout.class); - xLayoutMap.put(WHorizontalSplitLayout.class, XWHorizontalSplitLayout.class); - xLayoutMap.put(WVerticalSplitLayout.class, XWVerticalSplitLayout.class); - xLayoutMap.put(WGridLayout.class, XWGridLayout.class); - - xLayoutMap.put(WFitLayout.class, XWFitLayout.class); - xLayoutMap.put(WScaleLayout.class, XWScaleLayout.class); - xLayoutMap.put(WTitleLayout.class, XWTitleLayout.class); - xLayoutMap.put(WCardTagLayout.class, XWCardTagLayout.class); - xLayoutMap.put(WCardTitleLayout.class, XWCardTitleLayout.class); - xLayoutMap.put(WTabFitLayout.class, XWTabFitLayout.class); - xLayoutMap.put(WCardMainBorderLayout.class, XWCardMainBorderLayout.class); - - objectMap.putAll(ExtraDesignClassManager.getInstance().getParameterWidgetOptionsMap()); - objectMap.putAll(ExtraDesignClassManager.getInstance().getFormWidgetOptionsMap()); } - + + private static void reInitExtra() { + + extraObjectMap.clear(); + extraObjectMap.putAll(ExtraDesignClassManager.getInstance().getParameterWidgetOptionsMap()); + extraObjectMap.putAll(ExtraDesignClassManager.getInstance().getFormWidgetOptionsMap()); + } + private static void putExtraEditor() { if (DesignModuleFactory.getChartEditorClass() != null) { objectMap.put(DesignModuleFactory.getChartEditorClass(), XChartEditor.class); } } - + + @SuppressWarnings("unchecked") private static Class searchXCreatorClass(Class clazz) { + Class xClazz = (Class) objectMap.get(clazz); + if (xClazz == null) { + xClazz = (Class) extraObjectMap.get(clazz); + } if (xClazz == null) { xClazz = (Class) xLayoutMap.get(clazz); } diff --git a/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java b/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java index 6187bbd48..c3855c3c9 100644 --- a/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java @@ -6,6 +6,7 @@ import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.gui.core.FormWidgetOption; import com.fr.design.gui.core.UserDefinedWidgetOption; import com.fr.design.gui.core.WidgetOption; @@ -16,7 +17,13 @@ import com.fr.design.module.DesignModuleFactory; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.*; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralContext; import com.fr.general.Inter; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.ArrayUtils; import javax.swing.*; @@ -55,8 +62,28 @@ public class FormParaWidgetPane extends JPanel { private UILabel paraLabel; private FormDesigner designer; - - public static final FormParaWidgetPane getInstance(FormDesigner designer) { + + static { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + synchronized (FormParaWidgetPane.class) { + THIS = null; + } + } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign, FormWidgetOptionProvider.XML_TAG); + } + }); + } + + public static synchronized final FormParaWidgetPane getInstance(FormDesigner designer) { if (THIS == null) { THIS = new FormParaWidgetPane(); }