Browse Source
* commit '6276ee84e4f7b1cd691b98975bf9964cb31bbdaa': (21 commits) REPORT-45460 帆软市场国际化标签设计器适配 REPORT-44644 设计器接口开放 fix实现层级 REPORT-44644 fix无用import REPORT-44644 设计器接口开发 fix REPORT-44644 添加判断是否存在接口 REPORT-44644 fix调整名称 REPORT-44644 设计器接口开放 REPORT-44644 设计器接口开放 标记点兼容 REPORT-43744 【10.0.13】插件与jar包不匹配问题优化 REPORT-45558【设计器埋点】process表reuseCmptList字段准确性确认 梳理大数据模式中的标记点 修改populate CHART-17494 修改点地图标记点 REPORT-43744 【10.0.13】插件与jar包不匹配问题优化 REPORT-43744 【10.0.13】插件与jar包不匹配问题优化 REPORT-43744 【10.0.13】插件与jar包不匹配问题优化 REPORT-43744 【10.0.13】插件与jar包不匹配问题优化 REPORT-45402 插件管理-安装已经本地已经安装低版本的插件,点否不更新,还是会更新已安装的插件 CHART-17231 默认不选中任何项 ...feature/big-screen
38 changed files with 1171 additions and 179 deletions
@ -0,0 +1,71 @@ |
|||||||
|
package com.fr.design.file; |
||||||
|
|
||||||
|
import com.fr.common.annotations.Open; |
||||||
|
import com.fr.file.FILE; |
||||||
|
import java.io.InputStream; |
||||||
|
import java.io.OutputStream; |
||||||
|
|
||||||
|
/** |
||||||
|
* 模板资源操作,可操作模板及模板目录 |
||||||
|
* |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/12/23 |
||||||
|
*/ |
||||||
|
@Open |
||||||
|
public interface TemplateResource { |
||||||
|
|
||||||
|
/** |
||||||
|
* 读取模板 |
||||||
|
* @param path |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
InputStream readTemplate(String path) throws Exception; |
||||||
|
|
||||||
|
/** |
||||||
|
* 保存模板 |
||||||
|
* @param file |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
OutputStream saveTemplate(FILE file) throws Exception; |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除某个目录/某个模板 |
||||||
|
* @param file |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
boolean delete(FILE file); |
||||||
|
|
||||||
|
/** |
||||||
|
* 关闭模板 |
||||||
|
* @param path |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
boolean closeTemplate(String path); |
||||||
|
|
||||||
|
/** |
||||||
|
* 重命名模板/目录 |
||||||
|
* @param from |
||||||
|
* @param to |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
boolean rename(String from, String to); |
||||||
|
|
||||||
|
/** |
||||||
|
* 模板/目录是否存在 |
||||||
|
* @param path |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
boolean exist(String path); |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建目录 |
||||||
|
* @param path |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
boolean mkdir(String path); |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,66 @@ |
|||||||
|
package com.fr.design.file; |
||||||
|
|
||||||
|
import com.fr.design.ExtraDesignClassManager; |
||||||
|
import com.fr.design.file.impl.DefaultTemplateResource; |
||||||
|
import com.fr.design.fun.LocalResourceProvider; |
||||||
|
import com.fr.design.mainframe.DesignerFrameFileDealerPane; |
||||||
|
import com.fr.design.ui.util.UIUtil; |
||||||
|
import com.fr.file.filetree.FileNodes; |
||||||
|
import com.fr.file.filetree.LocalFileNodes; |
||||||
|
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 com.fr.plugin.observer.PluginListenerRegistration; |
||||||
|
import com.fr.workspace.WorkContext; |
||||||
|
import com.fr.workspace.engine.base.FineObjectPool; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/12/23 |
||||||
|
*/ |
||||||
|
public class TemplateResourceManager { |
||||||
|
|
||||||
|
private static final TemplateResource DEFAULT_OPERATION = new DefaultTemplateResource(); |
||||||
|
|
||||||
|
private static TemplateResource OPERATION = DEFAULT_OPERATION; |
||||||
|
|
||||||
|
static { |
||||||
|
PluginFilter filter = pluginContext -> pluginContext.contain(PluginModule.ExtraDesign, LocalResourceProvider.XML_TAG); |
||||||
|
|
||||||
|
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterStop, new PluginEventListener() { |
||||||
|
@Override |
||||||
|
public void on(PluginEvent event) { |
||||||
|
registerOperation(new DefaultTemplateResource()); |
||||||
|
FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, new LocalFileNodes()); |
||||||
|
UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); |
||||||
|
} |
||||||
|
}, filter); |
||||||
|
|
||||||
|
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, new PluginEventListener() { |
||||||
|
@Override |
||||||
|
public void on(PluginEvent event) { |
||||||
|
LocalResourceProvider provider = ExtraDesignClassManager.getInstance().getSingle(LocalResourceProvider.XML_TAG); |
||||||
|
if (provider != null && WorkContext.getCurrent().isLocal()) { |
||||||
|
registerOperation(provider.createResourceOperation()); |
||||||
|
FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, provider.createFileNodes()); |
||||||
|
UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); |
||||||
|
} |
||||||
|
} |
||||||
|
}, filter); |
||||||
|
} |
||||||
|
|
||||||
|
private static void registerOperation(TemplateResource operation) { |
||||||
|
OPERATION = operation; |
||||||
|
} |
||||||
|
|
||||||
|
public static TemplateResource getResource() { |
||||||
|
if (OPERATION == null) { |
||||||
|
return DEFAULT_OPERATION; |
||||||
|
} |
||||||
|
return OPERATION; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.fr.design.file.impl; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.design.file.TemplateResource; |
||||||
|
import com.fr.file.FILE; |
||||||
|
import com.fr.workspace.WorkContext; |
||||||
|
import com.fr.workspace.server.lock.TplOperator; |
||||||
|
import java.io.ByteArrayInputStream; |
||||||
|
import java.io.InputStream; |
||||||
|
import java.io.OutputStream; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/12/23 |
||||||
|
*/ |
||||||
|
public abstract class AbstractTemplateResource implements TemplateResource { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
package com.fr.design.file.impl; |
||||||
|
|
||||||
|
import com.fr.file.FILE; |
||||||
|
import com.fr.workspace.WorkContext; |
||||||
|
import com.fr.workspace.server.lock.TplOperator; |
||||||
|
import java.io.ByteArrayInputStream; |
||||||
|
import java.io.InputStream; |
||||||
|
import java.io.OutputStream; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/12/23 |
||||||
|
*/ |
||||||
|
public class DefaultTemplateResource extends AbstractTemplateResource { |
||||||
|
|
||||||
|
@Override |
||||||
|
public InputStream readTemplate(String path) throws Exception { |
||||||
|
return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public OutputStream saveTemplate(FILE file) throws Exception { |
||||||
|
return file.asOutputStream(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean closeTemplate(String path) { |
||||||
|
return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean delete(FILE file) { |
||||||
|
return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean rename(String from, String to) { |
||||||
|
return WorkContext.getCurrent().get(TplOperator.class).rename(from, to); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean exist(String path) { |
||||||
|
return WorkContext.getWorkResource().exist(path); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean mkdir(String path) { |
||||||
|
return WorkContext.getWorkResource().createDirectory(path); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.design.file.TemplateResource; |
||||||
|
import com.fr.file.filetree.FileNodes; |
||||||
|
import com.fr.stable.fun.mark.Immutable; |
||||||
|
|
||||||
|
/** |
||||||
|
* 本地资源操作插件接口 |
||||||
|
* |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/12/22 |
||||||
|
*/ |
||||||
|
public interface LocalResourceProvider extends Immutable { |
||||||
|
|
||||||
|
String XML_TAG = "LocalResourceProvider"; |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
/** |
||||||
|
* eg: DefaultResourceOperation |
||||||
|
* |
||||||
|
* @return 目录/模板的各种操作 |
||||||
|
*/ |
||||||
|
TemplateResource createResourceOperation(); |
||||||
|
|
||||||
|
/** |
||||||
|
* eg: LocalFileNodes |
||||||
|
* |
||||||
|
* @return 构建目录树的方式 |
||||||
|
*/ |
||||||
|
FileNodes createFileNodes(); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.stable.fun.mark.Immutable; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/12/14 |
||||||
|
*/ |
||||||
|
public interface TemplateTreeDefineProcessor extends Immutable { |
||||||
|
|
||||||
|
String XML_TAG = "TemplateTreeDefineProcessor"; |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
void rightClickAction(MouseEvent mouseEvent); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.design.fun.LocalResourceProvider; |
||||||
|
import com.fr.stable.fun.mark.API; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/12/22 |
||||||
|
*/ |
||||||
|
@API(level = LocalResourceProvider.CURRENT_LEVEL) |
||||||
|
public abstract class AbstractLocalResourceProvider implements LocalResourceProvider { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int layerIndex() { |
||||||
|
return DEFAULT_LAYER_INDEX; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.design.fun.TemplateTreeDefineProcessor; |
||||||
|
import com.fr.stable.fun.mark.API; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/12/21 |
||||||
|
*/ |
||||||
|
@API(level = TemplateTreeDefineProcessor.CURRENT_LEVEL) |
||||||
|
public abstract class AbstractTemplateTreeDefineProcessor implements TemplateTreeDefineProcessor { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int layerIndex() { |
||||||
|
return DEFAULT_LAYER_INDEX; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,108 @@ |
|||||||
|
package com.fr.env; |
||||||
|
|
||||||
|
import com.fr.design.actions.server.PluginManagerAction; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.general.GeneralContext; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.Icon; |
||||||
|
import javax.swing.JDialog; |
||||||
|
import javax.swing.JLabel; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.JTextArea; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.FlowLayout; |
||||||
|
import java.awt.Frame; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.util.Locale; |
||||||
|
|
||||||
|
/** |
||||||
|
* 插件启动失败提示窗 |
||||||
|
*/ |
||||||
|
public class PluginErrorRemindDialog extends JDialog implements ActionListener { |
||||||
|
|
||||||
|
public PluginErrorRemindDialog(Frame parent, String areaText) { |
||||||
|
super(parent, true); |
||||||
|
//上面的标签面板
|
||||||
|
JPanel topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
JPanel imagePanel = new JPanel(); |
||||||
|
Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/warning5.png"); |
||||||
|
|
||||||
|
JLabel imageLabel = new JLabel(); |
||||||
|
imageLabel.setIcon(icon); |
||||||
|
imagePanel.add(imageLabel); |
||||||
|
imagePanel.setPreferredSize(new Dimension(130, 100)); |
||||||
|
|
||||||
|
JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); |
||||||
|
|
||||||
|
JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Title")); |
||||||
|
label.setFont(FRFont.getInstance().applySize(18).applyStyle(1)); |
||||||
|
label.setPreferredSize(new Dimension(650, 100)); |
||||||
|
|
||||||
|
verticalPanel.add(label); |
||||||
|
|
||||||
|
topPanel.add(imagePanel, BorderLayout.WEST); |
||||||
|
topPanel.add(verticalPanel, BorderLayout.CENTER); |
||||||
|
topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); |
||||||
|
|
||||||
|
//中间的文本域面板
|
||||||
|
JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); |
||||||
|
centerPanel.setPreferredSize(new Dimension(480, 320)); |
||||||
|
|
||||||
|
JTextArea checkArea = new JTextArea(areaText); |
||||||
|
checkArea.setEnabled(false); |
||||||
|
centerPanel.add(checkArea, BorderLayout.CENTER); |
||||||
|
|
||||||
|
UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Not_Deal_With")); |
||||||
|
UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Deal_With")); |
||||||
|
|
||||||
|
cancelButton.addActionListener(this); |
||||||
|
okButton.addActionListener(new PluginManagerActionAdapter(this)); |
||||||
|
|
||||||
|
// 按钮
|
||||||
|
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
||||||
|
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); |
||||||
|
buttonPanel.add(cancelButton); |
||||||
|
buttonPanel.add(okButton); |
||||||
|
|
||||||
|
|
||||||
|
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")); |
||||||
|
this.setResizable(false); |
||||||
|
|
||||||
|
this.add(topPanel, BorderLayout.NORTH); |
||||||
|
this.add(centerPanel, BorderLayout.CENTER); |
||||||
|
this.add(buttonPanel, BorderLayout.SOUTH); |
||||||
|
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 750 : 600, 500)); |
||||||
|
|
||||||
|
GUICoreUtils.centerWindow(this); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
this.dispose(); |
||||||
|
} |
||||||
|
|
||||||
|
private static class PluginManagerActionAdapter extends PluginManagerAction { |
||||||
|
|
||||||
|
private JDialog jDialog; |
||||||
|
|
||||||
|
public PluginManagerActionAdapter(JDialog jDialog) { |
||||||
|
this.jDialog = jDialog; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
this.jDialog.dispose(); |
||||||
|
super.actionPerformed(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,155 @@ |
|||||||
|
package com.fr.design.extra; |
||||||
|
|
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.plugin.context.PluginContext; |
||||||
|
import com.fr.plugin.context.PluginMarker; |
||||||
|
import com.fr.plugin.context.PluginMarkerAdapter; |
||||||
|
import com.fr.plugin.error.PluginErrorCode; |
||||||
|
import com.fr.plugin.manage.PluginManager; |
||||||
|
import com.fr.plugin.manage.control.PluginTask; |
||||||
|
import com.fr.plugin.manage.control.PluginTaskResult; |
||||||
|
import org.easymock.EasyMock; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
import org.junit.runner.RunWith; |
||||||
|
import org.powermock.api.easymock.PowerMock; |
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||||
|
import org.powermock.modules.junit4.PowerMockRunner; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Lucian.Chen |
||||||
|
* @version 10.0 |
||||||
|
* Created by Lucian.Chen on 2020/12/17 |
||||||
|
*/ |
||||||
|
@RunWith(PowerMockRunner.class) |
||||||
|
@PrepareForTest({PluginManager.class, PluginUtils.class}) |
||||||
|
public class PluginOperateUtilsTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetSuccessInfo() { |
||||||
|
PluginTaskResult pluginTaskResult = EasyMock.mock(PluginTaskResult.class); |
||||||
|
PluginTaskResult pluginTaskResult1 = EasyMock.mock(PluginTaskResult.class); |
||||||
|
PluginTaskResult pluginTaskResult2 = EasyMock.mock(PluginTaskResult.class); |
||||||
|
|
||||||
|
List<PluginTaskResult> pluginTaskResults1 = new ArrayList<>(); |
||||||
|
pluginTaskResults1.add(pluginTaskResult1); |
||||||
|
List<PluginTaskResult> pluginTaskResults2 = new ArrayList<>(); |
||||||
|
pluginTaskResults2.add(pluginTaskResult1); |
||||||
|
pluginTaskResults2.add(pluginTaskResult2); |
||||||
|
|
||||||
|
PluginMarker pluginMarker1 = PluginMarker.create("plugin-1", "1.0"); |
||||||
|
PluginMarker pluginMarker2 = PluginMarkerAdapter.create("plugin-2", "2.0", "name-2"); |
||||||
|
PluginTask pluginTask1 = PluginTask.installTask(pluginMarker1); |
||||||
|
PluginTask pluginTask2 = PluginTask.installTask(pluginMarker2); |
||||||
|
|
||||||
|
EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults1).times(2); |
||||||
|
EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults2).times(2); |
||||||
|
EasyMock.expect(pluginTaskResult1.getCurrentTask()).andReturn(pluginTask1).anyTimes(); |
||||||
|
EasyMock.expect(pluginTaskResult2.getCurrentTask()).andReturn(pluginTask2).anyTimes(); |
||||||
|
|
||||||
|
EasyMock.expect(pluginTaskResult1.errorCode()).andReturn(PluginErrorCode.BelowSystem).anyTimes(); |
||||||
|
EasyMock.expect(pluginTaskResult2.errorCode()).andReturn(PluginErrorCode.BeyondSystem).anyTimes(); |
||||||
|
|
||||||
|
PluginContext plugin1 = EasyMock.mock(PluginContext.class); |
||||||
|
PluginContext plugin2 = EasyMock.mock(PluginContext.class); |
||||||
|
EasyMock.expect(plugin1.getName()).andReturn("context-1").anyTimes(); |
||||||
|
EasyMock.expect(plugin2.getName()).andReturn("context-2").anyTimes(); |
||||||
|
PowerMock.mockStatic(PluginManager.class); |
||||||
|
EasyMock.expect(PluginManager.getContext(pluginMarker1.getPluginID())) |
||||||
|
.andReturn(plugin1).once().andReturn(null).once().andReturn(plugin1).once().andReturn(null).once(); |
||||||
|
EasyMock.expect(PluginManager.getContext(pluginMarker2.getPluginID())) |
||||||
|
.andReturn(plugin2).once().andReturn(null).once(); |
||||||
|
|
||||||
|
EasyMock.replay(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2); |
||||||
|
PowerMock.replayAll(); |
||||||
|
|
||||||
|
// 1个
|
||||||
|
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem"); |
||||||
|
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem"); |
||||||
|
|
||||||
|
|
||||||
|
// 2个
|
||||||
|
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem\ncontext-2Fine-Core_Plugin_Error_BeyondSystem"); |
||||||
|
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem\nname-2Fine-Core_Plugin_Error_BeyondSystem"); |
||||||
|
|
||||||
|
EasyMock.verify(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2); |
||||||
|
PowerMock.verifyAll(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetPluginName() { |
||||||
|
PluginContext pluginContext = EasyMock.mock(PluginContext.class); |
||||||
|
EasyMock.expect(pluginContext.getName()).andReturn("pluginContext").once(); |
||||||
|
|
||||||
|
PluginMarker pluginMarker1 = PluginMarker.create("id-1", "1"); |
||||||
|
PluginMarker pluginMarker2 = PluginMarkerAdapter.create("id-2", "2", "name-2"); |
||||||
|
|
||||||
|
EasyMock.replay(pluginContext); |
||||||
|
|
||||||
|
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get(), ""); |
||||||
|
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", pluginContext, pluginMarker1).get(), "pluginContext"); |
||||||
|
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker1).get(), "id-1"); |
||||||
|
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker2).get(), "name-2"); |
||||||
|
|
||||||
|
EasyMock.verify(pluginContext); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testUpdateMarker2Online() { |
||||||
|
|
||||||
|
try { |
||||||
|
PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0"); |
||||||
|
String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}"; |
||||||
|
JSONObject object = new JSONObject(pluginJson); |
||||||
|
|
||||||
|
PowerMock.mockStatic(PluginUtils.class); |
||||||
|
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once(); |
||||||
|
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andThrow(new NullPointerException()).once(); |
||||||
|
|
||||||
|
PowerMock.replayAll(); |
||||||
|
|
||||||
|
PluginMarker marker1 = PluginOperateUtils.updateMarker2Online(pluginMarker); |
||||||
|
PluginMarker marker2 = PluginOperateUtils.updateMarker2Online(pluginMarker); |
||||||
|
|
||||||
|
Assert.assertTrue(marker1 instanceof PluginMarkerAdapter); |
||||||
|
Assert.assertEquals(marker1.getPluginID(), "plugin-1"); |
||||||
|
Assert.assertEquals(marker1.getVersion(), "1.0"); |
||||||
|
Assert.assertEquals(((PluginMarkerAdapter) marker1).getPluginName(), "图表(新特性)"); |
||||||
|
Assert.assertEquals(marker2, pluginMarker); |
||||||
|
|
||||||
|
PowerMock.verifyAll(); |
||||||
|
} catch (Exception e) { |
||||||
|
Assert.fail(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Test |
||||||
|
public void testUpdatePluginOnline() { |
||||||
|
try { |
||||||
|
PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0"); |
||||||
|
String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}"; |
||||||
|
JSONObject object = new JSONObject(pluginJson); |
||||||
|
|
||||||
|
PowerMock.mockStatic(PluginUtils.class); |
||||||
|
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once(); |
||||||
|
EasyMock.expect(PluginUtils.getInstalledPluginMarkerByID("plugin-1")).andReturn(pluginMarker).once(); |
||||||
|
|
||||||
|
PowerMock.replayAll(); |
||||||
|
|
||||||
|
PluginOperateUtils.updatePluginOnline(pluginMarker, null); |
||||||
|
|
||||||
|
PowerMock.verifyAll(); |
||||||
|
} catch (Exception e) { |
||||||
|
Assert.fail(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.fr.design.extra; |
||||||
|
|
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Lucian.Chen |
||||||
|
* @version 10.0 |
||||||
|
* Created by Lucian.Chen on 2020/12/18 |
||||||
|
*/ |
||||||
|
public class PluginUtilsTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testIsCompatibleCurrentEnv() { |
||||||
|
Assert.assertFalse(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "~9.0").get()); |
||||||
|
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9.0").get()); |
||||||
|
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9~").get()); |
||||||
|
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "10").get()); |
||||||
|
Assert.assertFalse(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "11").get()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
package com.fr.van.chart.map.designer.other.condition.item; |
||||||
|
|
||||||
|
import com.fr.chart.base.DataSeriesCondition; |
||||||
|
import com.fr.design.condition.ConditionAttributesPane; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.plugin.chart.base.VanChartAttrMarker; |
||||||
|
import com.fr.van.chart.designer.other.condition.item.AbstractNormalMultiLineConditionPane; |
||||||
|
import com.fr.van.chart.map.designer.style.series.VanChartMapAnchorMarkerPane; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
|
||||||
|
public class VanChartAnchorMarkerConditionPane extends AbstractNormalMultiLineConditionPane { |
||||||
|
private VanChartMapAnchorMarkerPane anchorMarkerPane; |
||||||
|
|
||||||
|
public VanChartAnchorMarkerConditionPane(ConditionAttributesPane conditionAttributesPane) { |
||||||
|
super(conditionAttributesPane); |
||||||
|
} |
||||||
|
|
||||||
|
protected String getItemLabelString() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Chart_Marker"); |
||||||
|
} |
||||||
|
|
||||||
|
protected JPanel initContentPane() { |
||||||
|
anchorMarkerPane = new VanChartMapAnchorMarkerPane(); |
||||||
|
return anchorMarkerPane; |
||||||
|
} |
||||||
|
|
||||||
|
public String nameForPopupMenuItem() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Chart_Marker"); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(DataSeriesCondition condition) { |
||||||
|
if (condition instanceof VanChartAttrMarker) { |
||||||
|
anchorMarkerPane.populateBean((VanChartAttrMarker) condition); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public DataSeriesCondition update() { |
||||||
|
return anchorMarkerPane.updateBean(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,26 @@ |
|||||||
|
package com.fr.van.chart.map.designer.other.condition.pane; |
||||||
|
|
||||||
|
import com.fr.chart.chartattr.Plot; |
||||||
|
import com.fr.plugin.chart.attr.EffectHelper; |
||||||
|
import com.fr.plugin.chart.base.AttrEffect; |
||||||
|
import com.fr.plugin.chart.base.AttrFloatColor; |
||||||
|
import com.fr.plugin.chart.base.VanChartAttrMarker; |
||||||
|
import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane; |
||||||
|
import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane; |
||||||
|
import com.fr.van.chart.map.designer.other.condition.item.VanChartAnchorMarkerConditionPane; |
||||||
|
|
||||||
|
public class VanChartAnchorPointMapConditionPane extends VanChartMapConditionPane { |
||||||
|
|
||||||
|
public VanChartAnchorPointMapConditionPane(Plot plot) { |
||||||
|
super(plot); |
||||||
|
} |
||||||
|
|
||||||
|
protected void addDiffAction() { |
||||||
|
classPaneMap.put(VanChartAttrMarker.class, new VanChartAnchorMarkerConditionPane(this)); |
||||||
|
if (addLabelOrEffectAction()) { |
||||||
|
addLabelAction(); |
||||||
|
classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); |
||||||
|
classPaneMap.put(AttrEffect.class, new VanChartEffectConditionPane(this, EffectHelper.getScatterPlotDefaultEffect())); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,64 @@ |
|||||||
|
package com.fr.van.chart.map.designer.style.series; |
||||||
|
|
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.plugin.chart.base.VanChartAttrMarker; |
||||||
|
import com.fr.plugin.chart.marker.type.MarkerType; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
|
||||||
|
public class VanChartMapAnchorMarkerPane extends BasicBeanPane<VanChartAttrMarker> { |
||||||
|
|
||||||
|
private UISpinner anchorSize; |
||||||
|
|
||||||
|
public VanChartMapAnchorMarkerPane() { |
||||||
|
anchorSize = new UISpinner(0, Double.MAX_VALUE, 0.5, 28); |
||||||
|
|
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Size")), anchorSize} |
||||||
|
}; |
||||||
|
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; |
||||||
|
double[] row = {p}; |
||||||
|
double[] col = {f, e}; |
||||||
|
|
||||||
|
JPanel content = TableLayoutHelper.createTableLayoutPane(components, row, col); |
||||||
|
content.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.add(content, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
public void populateBean(VanChartAttrMarker marker) { |
||||||
|
if (marker == null) { |
||||||
|
marker = new VanChartAttrMarker(); |
||||||
|
marker.setCommon(false); |
||||||
|
marker.setMarkerType(MarkerType.MARKER_AUTO); |
||||||
|
} |
||||||
|
|
||||||
|
this.anchorSize.setValue(marker.getAnchorSize()); |
||||||
|
} |
||||||
|
|
||||||
|
public VanChartAttrMarker updateBean() { |
||||||
|
VanChartAttrMarker marker = new VanChartAttrMarker(); |
||||||
|
|
||||||
|
marker.setCommon(false); |
||||||
|
marker.setMarkerType(MarkerType.MARKER_AUTO); |
||||||
|
marker.setAnchorSize(this.anchorSize.getValue()); |
||||||
|
|
||||||
|
return marker; |
||||||
|
} |
||||||
|
|
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "anchorMarker"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package com.fr.design.mainframe.alphafine.search.manager.impl; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Lucian.Chen |
||||||
|
* @version 10.0 |
||||||
|
* Created by Lucian.Chen on 2020/12/17 |
||||||
|
*/ |
||||||
|
public class PluginSearchManagerTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testIsCompatibleCurrentEnv() { |
||||||
|
|
||||||
|
Assert.assertFalse(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "~9.0").get()); |
||||||
|
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9.0").get()); |
||||||
|
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9~").get()); |
||||||
|
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "10").get()); |
||||||
|
Assert.assertFalse(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "11").get()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue