Yvan
4 years ago
80 changed files with 3976 additions and 1926 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,19 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.event.Event; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2020-12-11 |
||||||
|
*/ |
||||||
|
public enum JTemplateEvent implements Event<JTemplate> { |
||||||
|
/** |
||||||
|
* 模板初始化之前 |
||||||
|
*/ |
||||||
|
BEFORE_TEMPLATE_INIT, |
||||||
|
|
||||||
|
/** |
||||||
|
* 模板激活之前 |
||||||
|
*/ |
||||||
|
BEFORE_TEMPLATE_ACTIVE |
||||||
|
|
||||||
|
} |
@ -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,23 @@ |
|||||||
|
package com.fr.van.chart.designer.component.format; |
||||||
|
|
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-10 |
||||||
|
*/ |
||||||
|
public class SummaryValueFormatPaneWithCheckBox extends VanChartFormatPaneWithCheckBox { |
||||||
|
|
||||||
|
public SummaryValueFormatPaneWithCheckBox(VanChartStylePane parent, JPanel showOnPane) { |
||||||
|
super(parent, showOnPane); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String getCheckBoxText() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Chart_Use_Summary_Value"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.fr.van.chart.designer.component.format; |
||||||
|
|
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-10 |
||||||
|
*/ |
||||||
|
public class SummaryValueFormatPaneWithoutCheckBox extends VanChartFormatPaneWithoutCheckBox { |
||||||
|
|
||||||
|
public SummaryValueFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { |
||||||
|
super(parent, showOnPane); |
||||||
|
} |
||||||
|
|
||||||
|
protected String getCheckBoxText() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Chart_Use_Summary_Value"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,64 @@ |
|||||||
|
package com.fr.van.chart.designer.style.label; |
||||||
|
|
||||||
|
import com.fr.chart.chartattr.Plot; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||||
|
import com.fr.van.chart.pie.style.VanChartPieCategoryLabelContentPane; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.Component; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-09 |
||||||
|
*/ |
||||||
|
public class VanChartPieCategoryLabelDetailPane extends VanChartPlotLabelDetailPane { |
||||||
|
|
||||||
|
public VanChartPieCategoryLabelDetailPane(Plot plot, VanChartStylePane parent, boolean inCondition) { |
||||||
|
super(plot, parent, inCondition); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initToolTipContentPane(Plot plot) { |
||||||
|
setDataLabelContentPane(new VanChartPieCategoryLabelContentPane(getParentPane(), this, isInCondition())); |
||||||
|
} |
||||||
|
|
||||||
|
protected JPanel createLabelPositionPane(String title, Plot plot) { |
||||||
|
String[] positionName = new String[]{ |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom"), |
||||||
|
Toolkit.i18nText("Fine-Design_Form_Center"), |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Axis_Top") |
||||||
|
}; |
||||||
|
|
||||||
|
Integer[] positionValue = new Integer[]{Constants.BOTTOM, Constants.CENTER, Constants.TOP}; |
||||||
|
|
||||||
|
UIButtonGroup<Integer> position = new UIButtonGroup<>(positionName, positionValue); |
||||||
|
setPosition(position); |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||||
|
double[] row = {p, p}; |
||||||
|
double[] col = {f, e}; |
||||||
|
|
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{null, null}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), position}, |
||||||
|
}; |
||||||
|
|
||||||
|
return TableLayoutHelper.createTableLayoutPane(components, row, col); |
||||||
|
} |
||||||
|
|
||||||
|
protected void checkPositionPane(String title) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
protected JPanel createBorderAndBackgroundPane() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,61 @@ |
|||||||
|
package com.fr.van.chart.designer.style.label; |
||||||
|
|
||||||
|
import com.fr.chart.chartattr.Plot; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.plugin.chart.attr.plot.VanChartPlot; |
||||||
|
import com.fr.plugin.chart.base.AttrLabel; |
||||||
|
import com.fr.plugin.chart.base.AttrLabelDetail; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-09 |
||||||
|
*/ |
||||||
|
public class VanChartPiePlotLabelPane extends VanChartPlotLabelPane { |
||||||
|
|
||||||
|
private VanChartPlotLabelDetailPane pieCategoryLabelPane; |
||||||
|
|
||||||
|
public VanChartPiePlotLabelPane(Plot plot, VanChartStylePane parent, boolean inCondition) { |
||||||
|
super(plot, parent, inCondition); |
||||||
|
} |
||||||
|
|
||||||
|
protected void createLabelPane() { |
||||||
|
setLabelPane(new JPanel(new BorderLayout(0, 4))); |
||||||
|
setLabelDetailPane(new VanChartPieValueLabelDetailPane(getPlot(), getParentPane(), isInCondition())); |
||||||
|
JPanel valuePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Label"), getLabelDetailPane()); |
||||||
|
getLabelPane().add(valuePane, BorderLayout.NORTH); |
||||||
|
|
||||||
|
if (!isInCondition()) { |
||||||
|
pieCategoryLabelPane = new VanChartPieCategoryLabelDetailPane(getPlot(), getParentPane(), isInCondition()); |
||||||
|
JPanel categoryPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Category_Label"), pieCategoryLabelPane); |
||||||
|
getLabelPane().add(categoryPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(AttrLabel attrLabel) { |
||||||
|
if (attrLabel == null) { |
||||||
|
attrLabel = ((VanChartPlot) this.getPlot()).getDefaultAttrLabel(); |
||||||
|
} |
||||||
|
super.populate(attrLabel); |
||||||
|
if (pieCategoryLabelPane != null) { |
||||||
|
AttrLabelDetail labelDetail = attrLabel.getSecondLabelDetail(); |
||||||
|
pieCategoryLabelPane.populate(labelDetail); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public AttrLabel update() { |
||||||
|
AttrLabel attrLabel = super.update(); |
||||||
|
if (pieCategoryLabelPane != null) { |
||||||
|
AttrLabelDetail labelDetail = attrLabel.getSecondLabelDetail(); |
||||||
|
pieCategoryLabelPane.update(labelDetail); |
||||||
|
} else { |
||||||
|
attrLabel.setSecondLabelDetail(null); |
||||||
|
} |
||||||
|
return attrLabel; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,72 @@ |
|||||||
|
package com.fr.van.chart.designer.style.label; |
||||||
|
|
||||||
|
import com.fr.chart.chartattr.Plot; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.utils.gui.UIComponentUtils; |
||||||
|
import com.fr.design.widget.FRWidgetFactory; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
import com.fr.van.chart.designer.component.background.VanChartBackgroundWithOutImagePane; |
||||||
|
import com.fr.van.chart.designer.component.border.VanChartBorderWithShapePane; |
||||||
|
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||||
|
import com.fr.van.chart.pie.style.VanChartPieValueLabelContentPane; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.Component; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-09 |
||||||
|
*/ |
||||||
|
public class VanChartPieValueLabelDetailPane extends VanChartPlotLabelDetailPane { |
||||||
|
|
||||||
|
public VanChartPieValueLabelDetailPane(Plot plot, VanChartStylePane parent, boolean inCondition) { |
||||||
|
super(plot, parent, inCondition); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initToolTipContentPane(Plot plot) { |
||||||
|
setDataLabelContentPane(new VanChartPieValueLabelContentPane(getParentPane(), this, isInCondition())); |
||||||
|
} |
||||||
|
|
||||||
|
protected JPanel getLabelLayoutPane(JPanel panel, String title) { |
||||||
|
return panel; |
||||||
|
} |
||||||
|
|
||||||
|
protected JPanel createLabelBorderPane() { |
||||||
|
VanChartBorderWithShapePane borderPane = new VanChartBorderWithShapePane() { |
||||||
|
@Override |
||||||
|
protected JPanel createLineTypePane() { |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||||
|
|
||||||
|
double[] columnSize = {f, e}; |
||||||
|
double[] rowSize = {p}; |
||||||
|
|
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Border")), |
||||||
|
UIComponentUtils.wrapWithBorderLayoutPane(getLineTypeBox())}}; |
||||||
|
|
||||||
|
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||||
|
} |
||||||
|
}; |
||||||
|
setBorderPane(borderPane); |
||||||
|
return borderPane; |
||||||
|
} |
||||||
|
|
||||||
|
protected JPanel createLabelBackgroundPane() { |
||||||
|
VanChartBackgroundWithOutImagePane backgroundPane = new VanChartBackgroundWithOutImagePane() { |
||||||
|
protected Component[][] getPaneComponents() { |
||||||
|
return new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Utils_Background")), typeComboBox}, |
||||||
|
new Component[]{null, centerPane}, |
||||||
|
new Component[]{getTransparentLabel(), transparent}, |
||||||
|
}; |
||||||
|
} |
||||||
|
}; |
||||||
|
setBackgroundPane(backgroundPane); |
||||||
|
return backgroundPane; |
||||||
|
} |
||||||
|
} |
@ -1,15 +0,0 @@ |
|||||||
package com.fr.van.chart.heatmap.designer.type; |
|
||||||
|
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
|
|
||||||
import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by Mitisky on 16/10/20. |
|
||||||
*/ |
|
||||||
public class VanChartHeatMapSourceChoosePane extends VanChartMapSourceChoosePane { |
|
||||||
@Override |
|
||||||
protected UILabel createSourceTitleLabel() { |
|
||||||
return new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Area_And_Point")); |
|
||||||
} |
|
||||||
} |
|
@ -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,258 @@ |
|||||||
|
package com.fr.van.chart.map.designer.type; |
||||||
|
|
||||||
|
import com.fr.base.Parameter; |
||||||
|
import com.fr.decision.webservice.v10.map.geojson.helper.GEOJSONHelper; |
||||||
|
import com.fr.design.constants.LayoutConstants; |
||||||
|
import com.fr.design.event.UIObserver; |
||||||
|
import com.fr.design.event.UIObserverListener; |
||||||
|
import com.fr.design.file.HistoryTemplateListCache; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.icombobox.FRTreeComboBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.itextfield.UITextField; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.plugin.chart.map.VanChartMapPlot; |
||||||
|
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; |
||||||
|
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; |
||||||
|
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; |
||||||
|
import com.fr.plugin.chart.type.MapType; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
import com.fr.van.chart.drillmap.designer.data.comp.MapDataTree; |
||||||
|
import com.fr.workspace.WorkContext; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.event.PopupMenuEvent; |
||||||
|
import javax.swing.event.PopupMenuListener; |
||||||
|
import javax.swing.tree.DefaultMutableTreeNode; |
||||||
|
import javax.swing.tree.TreeNode; |
||||||
|
import javax.swing.tree.TreePath; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-07 |
||||||
|
*/ |
||||||
|
public class GeoUrlPane extends JPanel implements UIObserver { |
||||||
|
|
||||||
|
private UILabel sourceTitleLabel; |
||||||
|
private FRTreeComboBox sourceComboBox; |
||||||
|
private MapDataTree mapDataTree; |
||||||
|
private TreePath selectTreePath; |
||||||
|
|
||||||
|
private UIObserverListener listener; |
||||||
|
|
||||||
|
private String[] oldParams; |
||||||
|
|
||||||
|
public GeoUrlPane() { |
||||||
|
initComps(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComps() { |
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.add(createMapSourcesPane(), BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void registerChangeListener(UIObserverListener listener) { |
||||||
|
this.listener = listener; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean shouldResponseChangeListener() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createMapSourcesPane() { |
||||||
|
|
||||||
|
mapDataTree = new MapDataTree(this.getRootNode()); |
||||||
|
mapDataTree.setEditable(false); |
||||||
|
mapDataTree.selectDefaultTreeNode(); |
||||||
|
sourceComboBox = new FRTreeComboBox(mapDataTree, mapDataTree.getCellRenderer()) { |
||||||
|
//搜索
|
||||||
|
protected void dealSamePath(TreePath parent, TreeNode node, UITextField textField) { |
||||||
|
String searchText = textField.getText(); |
||||||
|
GeoUrlPane.this.mapDataTree.search(searchText); |
||||||
|
} |
||||||
|
|
||||||
|
//选中 tree---combobox
|
||||||
|
public void setSelectedItem(Object o) { |
||||||
|
TreePath oldPath = mapDataTree.getSelectionPath(); |
||||||
|
Object oldText = getSelectedItem(); |
||||||
|
if (o != null && o instanceof TreePath) { |
||||||
|
selectTreePath = (TreePath) o; |
||||||
|
this.tree.setSelectionPath(selectTreePath); |
||||||
|
this.getModel().setSelectedItem(pathToString(selectTreePath)); |
||||||
|
if (ComparatorUtils.equals(oldText, getSelectedItem()) && !ComparatorUtils.equals(oldPath, selectTreePath)) { |
||||||
|
//point的江苏省切换到area的江苏省
|
||||||
|
listener.doChange(); |
||||||
|
} |
||||||
|
} else if (o instanceof String) {//list里面没有
|
||||||
|
selectTreePath = null; |
||||||
|
this.tree.setSelectionPath(null); |
||||||
|
this.getModel().setSelectedItem(ChartGEOJSONHelper.getPresentNameWithPath((String) o)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String pathToString(TreePath path) { |
||||||
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); |
||||||
|
//不显示后缀
|
||||||
|
return ChartGEOJSONHelper.getPresentNameWithPath(node.toString()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected boolean customSelectable(DefaultMutableTreeNode node) { |
||||||
|
return GEOJSONTreeHelper.isSelectableTreeNode(node); |
||||||
|
} |
||||||
|
}; |
||||||
|
sourceComboBox.setEditable(true); |
||||||
|
sourceComboBox.setOnlyLeafSelectable(false); |
||||||
|
sourceComboBox.addPopupMenuListener(popupMenuListener); |
||||||
|
sourceTitleLabel = createSourceTitleLabel(); |
||||||
|
|
||||||
|
|
||||||
|
boolean hasRefreshButton = !WorkContext.getCurrent().isLocal(); |
||||||
|
UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/images/control/refresh.png")); |
||||||
|
button.setToolTipText(Toolkit.i18nText("Fine-Design_Chart_Update_Remote_Map_JSON")); |
||||||
|
button.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
GEOJSONHelper.reset(); |
||||||
|
GEOJSONHelper.getInstance(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; |
||||||
|
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double[] rowSize = {p, p}; |
||||||
|
double[] columnSize = hasRefreshButton ? new double[]{d + 10, e - 20, 20} : new double[]{f, e}; |
||||||
|
|
||||||
|
Component[] comps = hasRefreshButton |
||||||
|
? new Component[]{sourceTitleLabel, sourceComboBox, button} |
||||||
|
: new Component[]{sourceTitleLabel, sourceComboBox}; |
||||||
|
|
||||||
|
double hGap = hasRefreshButton ? 0 : TableLayout4VanChartHelper.COMPONENT_INTERVAL; |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{null, null}, |
||||||
|
comps, |
||||||
|
}; |
||||||
|
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, hGap, LayoutConstants.VGAP_LARGE); |
||||||
|
} |
||||||
|
|
||||||
|
protected UILabel createSourceTitleLabel() { |
||||||
|
return new UILabel(Toolkit.i18nText("Fine-Design_Chart_Map_Area")); |
||||||
|
} |
||||||
|
|
||||||
|
protected TreeNode getRootNode() { |
||||||
|
return GEOJSONTreeHelper.getInstance().getRootNodeWithPara(); |
||||||
|
} |
||||||
|
|
||||||
|
private String[] getParamsName() { |
||||||
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||||
|
|
||||||
|
if (jTemplate == null) { |
||||||
|
return new String[0]; |
||||||
|
} |
||||||
|
|
||||||
|
Parameter[] parameters = jTemplate.getJTemplateParameters(); |
||||||
|
|
||||||
|
int len = parameters.length; |
||||||
|
String[] names = new String[len]; |
||||||
|
|
||||||
|
for (int i = 0; i < len; i++) { |
||||||
|
names[i] = parameters[i].getName(); |
||||||
|
} |
||||||
|
|
||||||
|
return names; |
||||||
|
} |
||||||
|
|
||||||
|
private PopupMenuListener popupMenuListener = new PopupMenuListener() { |
||||||
|
public void popupMenuCanceled(PopupMenuEvent e) { |
||||||
|
} |
||||||
|
|
||||||
|
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { |
||||||
|
} |
||||||
|
|
||||||
|
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { |
||||||
|
|
||||||
|
GEOJSONTreeHelper.reset(); |
||||||
|
mapDataTree.changeRootNode(GeoUrlPane.this.getRootNode()); |
||||||
|
GEOJSONTreeHelper.getInstance().updateParamRootNode(GeoUrlPane.this.getParamsName()); |
||||||
|
|
||||||
|
if (selectTreePath != null) { |
||||||
|
mapDataTree.setSelectNodePath(CompatibleGEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString())); |
||||||
|
selectTreePath = mapDataTree.getSelectionPath(); |
||||||
|
} |
||||||
|
|
||||||
|
mapDataTree.updateUI();//因为服务器那边可能随时编辑,所以这边要重画
|
||||||
|
mapDataTree.setSelectionPath(selectTreePath); |
||||||
|
mapDataTree.scrollPathToVisible(selectTreePath); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
public void populate(VanChartMapPlot mapPlot) { |
||||||
|
resetComponentValue(mapPlot, false); |
||||||
|
String geoUrl = mapPlot.getGeoUrl(); |
||||||
|
mapDataTree.setSelectNodePath(geoUrl); |
||||||
|
selectTreePath = mapDataTree.getSelectionPath(); |
||||||
|
|
||||||
|
if (selectTreePath == null) {//此url当前环境没有
|
||||||
|
sourceComboBox.setSelectedItem(geoUrl); |
||||||
|
} else { |
||||||
|
sourceComboBox.setSelectedItem(selectTreePath); |
||||||
|
} |
||||||
|
boolean enabled = !CompatibleGEOJSONHelper.isDeprecated(mapPlot.getGeoUrl()); |
||||||
|
GUICoreUtils.setEnabled(sourceComboBox, enabled); |
||||||
|
} |
||||||
|
|
||||||
|
public String update() { |
||||||
|
return mapDataTree.getSelectNodeJSONPath(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void resetComponentValue(VanChartMapPlot mapPlot, boolean samePlotChange) { |
||||||
|
MapType mapType = mapPlot.getMapType(); |
||||||
|
|
||||||
|
//获取最新的参数
|
||||||
|
String[] params = getParamsName(); |
||||||
|
|
||||||
|
if (!ComparatorUtils.equals(oldParams, params)) { |
||||||
|
oldParams = params; |
||||||
|
GEOJSONTreeHelper.getInstance().updateParamRootNode(params); |
||||||
|
} |
||||||
|
|
||||||
|
mapDataTree.changeRootNode(this.getRootNode()); |
||||||
|
if (samePlotChange) { |
||||||
|
String nodePath = ChartGEOJSONHelper.getDefaultJSONURL(); |
||||||
|
mapPlot.setGeoUrl(nodePath); |
||||||
|
mapDataTree.setSelectNodePath(nodePath); |
||||||
|
selectTreePath = mapDataTree.getSelectionPath(); |
||||||
|
sourceComboBox.setSelectedItem(selectTreePath); |
||||||
|
} |
||||||
|
switch (mapType) { |
||||||
|
case CUSTOM: |
||||||
|
sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Area_And_Point")); |
||||||
|
break; |
||||||
|
case POINT: |
||||||
|
sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Point")); |
||||||
|
break; |
||||||
|
case LINE: |
||||||
|
sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Point")); |
||||||
|
break; |
||||||
|
default: |
||||||
|
sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Area")); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,303 @@ |
|||||||
|
package com.fr.van.chart.map.designer.type; |
||||||
|
|
||||||
|
import com.fr.base.Utils; |
||||||
|
import com.fr.design.event.UIObserver; |
||||||
|
import com.fr.design.event.UIObserverListener; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.plugin.chart.base.GisLayer; |
||||||
|
import com.fr.plugin.chart.map.VanChartMapPlot; |
||||||
|
import com.fr.plugin.chart.map.server.MapLayerConfigManager; |
||||||
|
import com.fr.plugin.chart.type.GISLayerType; |
||||||
|
import com.fr.plugin.chart.type.GaoDeGisType; |
||||||
|
import com.fr.plugin.chart.type.ZoomLevel; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.DefaultComboBoxModel; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.event.PopupMenuEvent; |
||||||
|
import javax.swing.event.PopupMenuListener; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.CardLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.event.ItemEvent; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-07 |
||||||
|
*/ |
||||||
|
public class GisLayerPane extends JPanel implements UIObserver { |
||||||
|
|
||||||
|
private UIButtonGroup gisButton; |
||||||
|
private JPanel layerPaneCheckPane; |
||||||
|
private UIComboBox gisGaoDeLayer; |
||||||
|
private UIComboBox gisLayer; |
||||||
|
private JPanel layerCardPane; |
||||||
|
|
||||||
|
private WMSLayerPane wmsLayerPane; |
||||||
|
private TileLayerPane tileLayerPane; |
||||||
|
|
||||||
|
private UIComboBox zoomLevel; |
||||||
|
|
||||||
|
private String[] layers = MapLayerConfigManager.getLayerItems(); |
||||||
|
|
||||||
|
public GisLayerPane() { |
||||||
|
initComps(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComps() { |
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.add(createGISLayerPane(), BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void registerChangeListener(UIObserverListener listener) { |
||||||
|
this.wmsLayerPane.registerChangeListener(listener); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean shouldResponseChangeListener() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public void registerZoomLevel(UIComboBox zoomLevel) { |
||||||
|
this.zoomLevel = zoomLevel; |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isStandardGis() { |
||||||
|
return gisButton.getSelectedIndex() == 0; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private JPanel createGISLayerPane() { |
||||||
|
gisButton = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Form_Widget_Style_Standard"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); |
||||||
|
gisGaoDeLayer = new UIComboBox(MapLayerConfigManager.getGaoDeLayerItems()); |
||||||
|
gisButton.addActionListener(event -> { |
||||||
|
refreshZoomLevel(); |
||||||
|
checkLayerCardPane(); |
||||||
|
}); |
||||||
|
|
||||||
|
gisGaoDeLayer.addItemListener(event -> refreshZoomLevel()); |
||||||
|
|
||||||
|
initCustomGISLayerPane(); |
||||||
|
initLayerCardPane(); |
||||||
|
|
||||||
|
layerPaneCheckPane = new JPanel(new CardLayout()) { |
||||||
|
@Override |
||||||
|
public Dimension getPreferredSize() { |
||||||
|
if (isStandardGis()) { |
||||||
|
return gisGaoDeLayer.getPreferredSize(); |
||||||
|
} else { |
||||||
|
return gisLayer.getPreferredSize(); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
layerPaneCheckPane.add(gisGaoDeLayer, "standard"); |
||||||
|
layerPaneCheckPane.add(gisLayer, "custom"); |
||||||
|
|
||||||
|
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||||
|
double[] row = {p, p, p}; |
||||||
|
double[] col = {f, e}; |
||||||
|
|
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gis_Layer")), gisButton}, |
||||||
|
new Component[]{null, layerPaneCheckPane}, |
||||||
|
new Component[]{layerCardPane, null}, |
||||||
|
}; |
||||||
|
|
||||||
|
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); |
||||||
|
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||||
|
return panel; |
||||||
|
} |
||||||
|
|
||||||
|
private void initLayerCardPane() { |
||||||
|
tileLayerPane = new TileLayerPane(); |
||||||
|
wmsLayerPane = new WMSLayerPane(); |
||||||
|
|
||||||
|
layerCardPane = new JPanel(new CardLayout()) { |
||||||
|
@Override |
||||||
|
public Dimension getPreferredSize() { |
||||||
|
if (isStandardGis()) { |
||||||
|
return new Dimension(0, 0); |
||||||
|
} |
||||||
|
String itemName = Utils.objectToString(gisLayer.getSelectedItem()); |
||||||
|
if (MapLayerConfigManager.isCustomLayer(itemName)) { |
||||||
|
return tileLayerPane.getPreferredSize(); |
||||||
|
} else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { |
||||||
|
return wmsLayerPane.getPreferredSize(); |
||||||
|
} |
||||||
|
return new Dimension(0, 0); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
for (String itemName : layers) { |
||||||
|
JPanel pane = new JPanel(); |
||||||
|
if (MapLayerConfigManager.isCustomLayer(itemName)) { |
||||||
|
pane = tileLayerPane; |
||||||
|
} else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { |
||||||
|
pane = wmsLayerPane; |
||||||
|
} |
||||||
|
layerCardPane.add(pane, itemName); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void initCustomGISLayerPane() { |
||||||
|
gisLayer = new UIComboBox(layers); |
||||||
|
|
||||||
|
gisLayer.addItemListener(e -> |
||||||
|
{ |
||||||
|
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||||
|
checkCustomLayerCardPane(); |
||||||
|
} |
||||||
|
refreshZoomLevel(); |
||||||
|
} |
||||||
|
); |
||||||
|
|
||||||
|
gisLayer.addPopupMenuListener(new PopupMenuListener() { |
||||||
|
public void popupMenuCanceled(PopupMenuEvent e) { |
||||||
|
} |
||||||
|
|
||||||
|
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { |
||||||
|
} |
||||||
|
|
||||||
|
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { |
||||||
|
|
||||||
|
String selected = Utils.objectToString(gisLayer.getSelectedItem()); |
||||||
|
ZoomLevel zoomSelected = (ZoomLevel) zoomLevel.getSelectedItem(); |
||||||
|
|
||||||
|
gisLayer.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getLayerItems())); |
||||||
|
|
||||||
|
gisLayer.setSelectedItem(selected); |
||||||
|
zoomLevel.setSelectedItem(zoomSelected); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void refreshZoomLevel() { |
||||||
|
//gis图层不同,对应的缩放等级不同。
|
||||||
|
ZoomLevel[] levels; |
||||||
|
if (isStandardGis()) { |
||||||
|
if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { |
||||||
|
levels = MapStatusPane.ZOOM_LEVELS; |
||||||
|
} else { |
||||||
|
levels = MapStatusPane.GAODE_ZOOM_LEVELS; |
||||||
|
} |
||||||
|
} else { |
||||||
|
if (ComparatorUtils.equals(gisLayer.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_Blue"))) { |
||||||
|
levels = MapStatusPane.BLUE_ZOOM_LEVELS; |
||||||
|
} else if (ComparatorUtils.equals(gisLayer.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_GaoDe"))) { |
||||||
|
levels = MapStatusPane.GAODE_ZOOM_LEVELS; |
||||||
|
} else { |
||||||
|
levels = MapStatusPane.ZOOM_LEVELS; |
||||||
|
} |
||||||
|
} |
||||||
|
zoomLevel.setModel(new DefaultComboBoxModel(levels)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void checkLayerCardPane() { |
||||||
|
CardLayout cardLayout = (CardLayout) layerPaneCheckPane.getLayout(); |
||||||
|
cardLayout.show(layerPaneCheckPane, isStandardGis() ? "standard" : "custom"); |
||||||
|
} |
||||||
|
|
||||||
|
private void checkCustomLayerCardPane() { |
||||||
|
CardLayout cardLayout = (CardLayout) layerCardPane.getLayout(); |
||||||
|
cardLayout.show(layerCardPane, Utils.objectToString(gisLayer.getSelectedItem())); |
||||||
|
} |
||||||
|
|
||||||
|
public void resetGisLayer(VanChartMapPlot mapPlot) { |
||||||
|
//TODO Bjorn 地图gis图层自动逻辑
|
||||||
|
/* mapPlot.getGisLayer().setGisLayerType(GISLayerType.AUTO); |
||||||
|
mapPlot.getGisLayer().setLayerName(GISLayerType.getLocString(GISLayerType.AUTO));*/ |
||||||
|
|
||||||
|
GaoDeGisType gaoDeGisType= mapPlot.getDefaultGisLayerType(); |
||||||
|
|
||||||
|
mapPlot.getGisLayer().setGisLayerType(GISLayerType.GAO_DE_API); |
||||||
|
mapPlot.getGisLayer().setLayerName(gaoDeGisType.getTypeName()); |
||||||
|
mapPlot.getGisLayer().setGaoDeGisType(gaoDeGisType); |
||||||
|
populate(mapPlot.getGisLayer()); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(GisLayer layer) { |
||||||
|
switch (layer.getGisLayerType()) { |
||||||
|
case GAO_DE_API: |
||||||
|
case LAYER_NULL: |
||||||
|
populateStandardGis(layer); |
||||||
|
break; |
||||||
|
default: |
||||||
|
populateCustomGis(layer); |
||||||
|
} |
||||||
|
refreshZoomLevel(); |
||||||
|
|
||||||
|
checkCustomLayerCardPane(); |
||||||
|
checkLayerCardPane(); |
||||||
|
} |
||||||
|
|
||||||
|
private void populateStandardGis(GisLayer layer) { |
||||||
|
gisButton.setSelectedIndex(0); |
||||||
|
if (layer.getGisLayerType() == GISLayerType.LAYER_NULL) { |
||||||
|
gisGaoDeLayer.setSelectedIndex(gisGaoDeLayer.getItemCount() - 1); |
||||||
|
} else { |
||||||
|
gisGaoDeLayer.setSelectedItem(layer.getGaoDeGisType().getTypeName()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void populateCustomGis(GisLayer layer) { |
||||||
|
gisButton.setSelectedIndex(1); |
||||||
|
gisLayer.setSelectedItem(layer.getShowItemName()); |
||||||
|
|
||||||
|
switch (layer.getGisLayerType()) { |
||||||
|
case CUSTOM_WMS_LAYER: |
||||||
|
wmsLayerPane.populate(layer); |
||||||
|
break; |
||||||
|
case CUSTOM_TILE_LAYER: |
||||||
|
tileLayerPane.populate(layer); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void update(GisLayer layer) { |
||||||
|
if (isStandardGis()) { |
||||||
|
updateStandardGis(layer); |
||||||
|
} else { |
||||||
|
updateCustomGis(layer); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void updateStandardGis(GisLayer layer) { |
||||||
|
String layerName = Utils.objectToString(gisGaoDeLayer.getSelectedItem()); |
||||||
|
layer.setLayerName(layerName); |
||||||
|
if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { |
||||||
|
layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); |
||||||
|
} else { |
||||||
|
layer.setGisLayerType(GISLayerType.GAO_DE_API); |
||||||
|
layer.setGaoDeGisType(GaoDeGisType.parseByLocaleName(layerName)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void updateCustomGis(GisLayer layer) { |
||||||
|
String layerName = Utils.objectToString(gisLayer.getSelectedItem()); |
||||||
|
layer.setLayerName(layerName); |
||||||
|
layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); |
||||||
|
|
||||||
|
switch (layer.getGisLayerType()) { |
||||||
|
case CUSTOM_WMS_LAYER: |
||||||
|
wmsLayerPane.update(layer); |
||||||
|
break; |
||||||
|
case CUSTOM_TILE_LAYER: |
||||||
|
tileLayerPane.update(layer); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,167 @@ |
|||||||
|
package com.fr.van.chart.map.designer.type; |
||||||
|
|
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
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.plugin.chart.base.ViewCenter; |
||||||
|
import com.fr.plugin.chart.map.VanChartMapPlot; |
||||||
|
import com.fr.plugin.chart.type.ZoomLevel; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-07 |
||||||
|
*/ |
||||||
|
public class MapStatusPane extends JPanel { |
||||||
|
|
||||||
|
public static final ZoomLevel[] ZOOM_LEVELS = new ZoomLevel[]{ |
||||||
|
ZoomLevel.AUTO, |
||||||
|
ZoomLevel.ZERO, ZoomLevel.ZEROPOINTFIVE, |
||||||
|
ZoomLevel.ONE, ZoomLevel.ONEPOINTFIVE, |
||||||
|
ZoomLevel.TWO, ZoomLevel.TWOPOINTFIVE, |
||||||
|
ZoomLevel.THREE, ZoomLevel.THREEPOINTFIVE, |
||||||
|
ZoomLevel.FOUR, ZoomLevel.FOURPOINTFIVE, |
||||||
|
ZoomLevel.FIVE, ZoomLevel.FIVEPOINTFIVE, |
||||||
|
ZoomLevel.SIX, ZoomLevel.SIXPOINTFIVE, |
||||||
|
ZoomLevel.SEVEN, ZoomLevel.SEVENPOINTFIVE, |
||||||
|
ZoomLevel.EIGHT, ZoomLevel.EIGHTPOINTFIVE, |
||||||
|
ZoomLevel.NINE, ZoomLevel.NINEPOINTFIVE, |
||||||
|
ZoomLevel.TEN, ZoomLevel.TENPOINTFIVE, |
||||||
|
ZoomLevel.ELEVEN, ZoomLevel.ELEVENTPOINTFIVE, |
||||||
|
ZoomLevel.TWELVE, ZoomLevel.TWELVEPOINTFIVE, |
||||||
|
ZoomLevel.THIRTEEN, ZoomLevel.THIRTEENPOINTFIVE, |
||||||
|
ZoomLevel.FOURTEEN, ZoomLevel.FOURTEENPOINTFIVE, |
||||||
|
ZoomLevel.FIFTEEN, ZoomLevel.FIFTEENPOINTFIVE, |
||||||
|
ZoomLevel.SIXTEEN, ZoomLevel.SIXTEENPOINTFIVE, |
||||||
|
ZoomLevel.SEVENTEEN, ZoomLevel.SEVENTEENPOINTFIVE, |
||||||
|
ZoomLevel.EIGHTEEN |
||||||
|
}; |
||||||
|
//深蓝和高德地图下拉框层级
|
||||||
|
public static final ZoomLevel[] BLUE_ZOOM_LEVELS = ArrayUtils.subarray(ZOOM_LEVELS, 0, 34); |
||||||
|
public static final ZoomLevel[] GAODE_ZOOM_LEVELS = ArrayUtils.addAll(new ZoomLevel[]{ZoomLevel.AUTO}, (ZoomLevel[]) ArrayUtils.subarray(ZOOM_LEVELS, 7, 38)); |
||||||
|
private static final String AUTO_CENTER_STRING = Toolkit.i18nText("Fine-Design_Chart_Automatic"); |
||||||
|
private static final String CUSTOM_CENTER_STRING = Toolkit.i18nText("Fine-Design_Chart_Custom"); |
||||||
|
|
||||||
|
|
||||||
|
private JPanel levelAndCenterPane; |
||||||
|
private JPanel longAndLatPane; |
||||||
|
|
||||||
|
private UIComboBox zoomLevel; |
||||||
|
private UIButtonGroup viewCenterCom; |
||||||
|
private UISpinner longitude; |
||||||
|
private UISpinner latitude; |
||||||
|
|
||||||
|
public MapStatusPane() { |
||||||
|
initComps(); |
||||||
|
} |
||||||
|
|
||||||
|
public UIComboBox getZoomLevel() { |
||||||
|
return zoomLevel; |
||||||
|
} |
||||||
|
|
||||||
|
private void initComps() { |
||||||
|
zoomLevel = new UIComboBox(ZOOM_LEVELS); |
||||||
|
viewCenterCom = new UIButtonGroup(new String[]{AUTO_CENTER_STRING, CUSTOM_CENTER_STRING}); |
||||||
|
longitude = new UISpinner(-Double.MAX_VALUE, Double.MAX_VALUE, 1, 0.0); |
||||||
|
latitude = new UISpinner(-Double.MAX_VALUE, Double.MAX_VALUE, 1, 0.0); |
||||||
|
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; |
||||||
|
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||||
|
double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; |
||||||
|
double[] rowSize = {p, p, p}; |
||||||
|
double[] columnSize = {d, e}; |
||||||
|
double[] column = {d, s}; |
||||||
|
|
||||||
|
Component[][] comps = new Component[][]{ |
||||||
|
new Component[]{null, null}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Layer")), zoomLevel}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_View_Center")), viewCenterCom}, |
||||||
|
}; |
||||||
|
levelAndCenterPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, columnSize); |
||||||
|
|
||||||
|
Component[][] longAndLatComps = new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Longitude")), longitude}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Latitude")), latitude} |
||||||
|
}; |
||||||
|
longAndLatPane = TableLayout4VanChartHelper.createGapTableLayoutPane(longAndLatComps, rowSize, column); |
||||||
|
longAndLatPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); |
||||||
|
longAndLatPane.setVisible(false); |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout(0, 6)); |
||||||
|
|
||||||
|
this.add(levelAndCenterPane, BorderLayout.NORTH); |
||||||
|
this.add(longAndLatPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
viewCenterCom.addActionListener(event -> |
||||||
|
longAndLatPane.setVisible(!isAutoViewCenter())); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Dimension getPreferredSize() { |
||||||
|
if (longAndLatPane.isVisible()) { |
||||||
|
return super.getPreferredSize(); |
||||||
|
} else { |
||||||
|
return levelAndCenterPane.getPreferredSize(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isAutoViewCenter() { |
||||||
|
return viewCenterCom.getSelectedIndex() == 0; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void resetViewCenter(VanChartMapPlot mapPlot) { |
||||||
|
mapPlot.setViewCenter(new ViewCenter()); |
||||||
|
viewCenterCom.setSelectedIndex(0); |
||||||
|
longitude.setValue(0); |
||||||
|
latitude.setValue(0); |
||||||
|
longAndLatPane.setVisible(false); |
||||||
|
} |
||||||
|
|
||||||
|
public void resetZoomLevel(VanChartMapPlot mapPlot) { |
||||||
|
mapPlot.setZoomLevel(ZoomLevel.AUTO); |
||||||
|
zoomLevel.setSelectedItem(mapPlot.getZoomLevel()); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(VanChartMapPlot mapPlot) { |
||||||
|
zoomLevel.setSelectedItem(mapPlot.getZoomLevel()); |
||||||
|
|
||||||
|
ViewCenter viewCenter = mapPlot.getViewCenter(); |
||||||
|
if (viewCenter.isAuto()) { |
||||||
|
viewCenterCom.setSelectedIndex(0); |
||||||
|
longitude.setValue(0); |
||||||
|
latitude.setValue(0); |
||||||
|
} else { |
||||||
|
viewCenterCom.setSelectedIndex(1); |
||||||
|
longitude.setValue(viewCenter.getLongitude()); |
||||||
|
latitude.setValue(viewCenter.getLatitude()); |
||||||
|
} |
||||||
|
|
||||||
|
longAndLatPane.setVisible(!isAutoViewCenter()); |
||||||
|
} |
||||||
|
|
||||||
|
public void update(VanChartMapPlot mapPlot) { |
||||||
|
mapPlot.setZoomLevel((ZoomLevel) zoomLevel.getSelectedItem()); |
||||||
|
|
||||||
|
ViewCenter viewCenter = mapPlot.getViewCenter(); |
||||||
|
if (isAutoViewCenter()) { |
||||||
|
viewCenter.setAuto(true); |
||||||
|
} else { |
||||||
|
viewCenter.setAuto(false); |
||||||
|
viewCenter.setLongitude(longitude.getValue()); |
||||||
|
viewCenter.setLatitude(latitude.getValue()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
package com.fr.van.chart.map.designer.type; |
||||||
|
|
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.itextarea.UITextArea; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.plugin.chart.base.GisLayer; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-07 |
||||||
|
*/ |
||||||
|
public class TileLayerPane extends JPanel { |
||||||
|
|
||||||
|
private UITextArea customTileLayer; |
||||||
|
private UITextArea attribution; |
||||||
|
|
||||||
|
|
||||||
|
public TileLayerPane() { |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double[] rowSize = {p, p}; |
||||||
|
double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH - 3}; |
||||||
|
|
||||||
|
customTileLayer = new UITextArea(); |
||||||
|
attribution = new UITextArea(); |
||||||
|
Component[][] comps = new Component[][]{ |
||||||
|
new Component[]{new UILabel("url"), customTileLayer}, |
||||||
|
new Component[]{new UILabel("Attribution"), attribution} |
||||||
|
}; |
||||||
|
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); |
||||||
|
panel.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.add(panel, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(GisLayer layer) { |
||||||
|
customTileLayer.setText(layer.getCustomTileLayer()); |
||||||
|
attribution.setText(layer.getAttribution()); |
||||||
|
} |
||||||
|
|
||||||
|
public void update(GisLayer layer) { |
||||||
|
layer.setCustomTileLayer(customTileLayer.getText()); |
||||||
|
layer.setAttribution(attribution.getText()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,165 @@ |
|||||||
|
package com.fr.van.chart.map.designer.type; |
||||||
|
|
||||||
|
import com.fr.decision.webservice.v10.map.WMSFactory; |
||||||
|
import com.fr.design.dialog.FineJOptionPane; |
||||||
|
import com.fr.design.event.UIObserver; |
||||||
|
import com.fr.design.event.UIObserverListener; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.itextarea.UITextArea; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.general.http.HttpClient; |
||||||
|
import com.fr.plugin.chart.base.GisLayer; |
||||||
|
import com.fr.plugin.chart.map.layer.WMSLayer; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.SwingConstants; |
||||||
|
import javax.swing.SwingWorker; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-07 |
||||||
|
*/ |
||||||
|
public class WMSLayerPane extends JPanel implements UIObserver { |
||||||
|
private static final double[] COLUMN_SIZE = {48, TableLayout.FILL, TableLayout.PREFERRED}; |
||||||
|
|
||||||
|
private UITextArea wmsUrl; |
||||||
|
private UIButton connectButton; |
||||||
|
private JPanel wmsLayerPane; |
||||||
|
|
||||||
|
private List<UICheckBox> wmsLayerCheckBoxs = new ArrayList<>(); |
||||||
|
|
||||||
|
private UIObserverListener listener; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void registerChangeListener(UIObserverListener listener) { |
||||||
|
this.listener = listener; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean shouldResponseChangeListener() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public WMSLayerPane() { |
||||||
|
final double p = TableLayout.PREFERRED; |
||||||
|
double[] rowSize = {p}; |
||||||
|
double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, 84, 44}; |
||||||
|
|
||||||
|
|
||||||
|
wmsUrl = new UITextArea(); |
||||||
|
connectButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); |
||||||
|
|
||||||
|
Component[][] comps = new Component[][]{ |
||||||
|
new Component[]{new UILabel("url"), wmsUrl, connectButton} |
||||||
|
}; |
||||||
|
JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); |
||||||
|
northPane.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); |
||||||
|
|
||||||
|
wmsLayerPane = new JPanel(new BorderLayout()); |
||||||
|
resetWMSLayerPane(new ArrayList<>()); |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout(0, 6)); |
||||||
|
this.add(northPane, BorderLayout.NORTH); |
||||||
|
this.add(wmsLayerPane, BorderLayout.CENTER); |
||||||
|
addListener(); |
||||||
|
} |
||||||
|
|
||||||
|
private void addListener() { |
||||||
|
connectButton.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
|
||||||
|
new SwingWorker<Void, Double>() { |
||||||
|
private java.util.List<WMSLayer> list = new ArrayList<>(); |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Void doInBackground() { |
||||||
|
HttpClient httpClient = new HttpClient(wmsUrl.getText() + "service=WMS&request=GetCapabilities"); |
||||||
|
httpClient.asGet(); |
||||||
|
|
||||||
|
if (!httpClient.isServerAlive()) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
String res = httpClient.getResponseText(); |
||||||
|
List<String> layers = WMSFactory.readLayers(res); |
||||||
|
list.clear(); |
||||||
|
for (String layer : layers) { |
||||||
|
list.add(new WMSLayer(layer, false)); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void done() { |
||||||
|
connectButton.setText(Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); |
||||||
|
if (list != null && list.size() > 0) { |
||||||
|
resetWMSLayerPane(list); |
||||||
|
} else { |
||||||
|
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Chart_Invalid_WMS")); |
||||||
|
} |
||||||
|
} |
||||||
|
}.execute(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
connectButton.addMouseListener(new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mousePressed(MouseEvent e) { |
||||||
|
connectButton.setText(Toolkit.i18nText("Fine-Design_Chart_Connecting_WMP")); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void resetWMSLayerPane(java.util.List<WMSLayer> wmsLayers) { |
||||||
|
int size = wmsLayers.size(); |
||||||
|
double[] rowSize = new double[size]; |
||||||
|
Component[][] comps = new Component[size][2]; |
||||||
|
wmsLayerCheckBoxs.clear(); |
||||||
|
wmsLayerPane.removeAll(); |
||||||
|
for (int i = 0; i < size; i++) { |
||||||
|
rowSize[i] = TableLayout.PREFERRED; |
||||||
|
comps[i][0] = i == 0 ? new UILabel(Toolkit.i18nText("Fine-Design_Chart_WMS_Layers"), SwingConstants.RIGHT) : null; |
||||||
|
WMSLayer layer = wmsLayers.get(i); |
||||||
|
UICheckBox checkBox = new UICheckBox(layer.getLayer()); |
||||||
|
checkBox.registerChangeListener(listener); |
||||||
|
checkBox.setToolTipText(layer.getLayer()); |
||||||
|
checkBox.setSelected(layer.isSelected()); |
||||||
|
comps[i][1] = checkBox; |
||||||
|
wmsLayerCheckBoxs.add(checkBox); |
||||||
|
} |
||||||
|
|
||||||
|
wmsLayerPane.add(TableLayoutHelper.createCommonTableLayoutPane(comps, rowSize, COLUMN_SIZE, 0), BorderLayout.CENTER); |
||||||
|
|
||||||
|
updateUI(); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(GisLayer layer) { |
||||||
|
wmsUrl.setText(layer.getWmsUrl()); |
||||||
|
resetWMSLayerPane(layer.getWmsLayers()); |
||||||
|
} |
||||||
|
|
||||||
|
public void update(GisLayer layer) { |
||||||
|
layer.setWmsUrl(wmsUrl.getText()); |
||||||
|
layer.setWmsLayers(new ArrayList<>()); |
||||||
|
for (UICheckBox checkBox : wmsLayerCheckBoxs) { |
||||||
|
layer.addWmsLayer(new WMSLayer(checkBox.getText(), checkBox.isSelected())); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,130 @@ |
|||||||
|
package com.fr.van.chart.pie.style; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; |
||||||
|
import com.fr.plugin.chart.base.AttrTooltipContent; |
||||||
|
import com.fr.plugin.chart.base.AttrTooltipRichText; |
||||||
|
import com.fr.plugin.chart.base.format.AttrTooltipFormat; |
||||||
|
import com.fr.plugin.chart.pie.attr.PieCategoryLabelContent; |
||||||
|
import com.fr.van.chart.designer.component.VanChartLabelContentPane; |
||||||
|
import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; |
||||||
|
import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; |
||||||
|
import com.fr.van.chart.designer.component.format.SummaryValueFormatPaneWithCheckBox; |
||||||
|
import com.fr.van.chart.designer.component.format.SummaryValueFormatPaneWithoutCheckBox; |
||||||
|
import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; |
||||||
|
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.Component; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-10 |
||||||
|
*/ |
||||||
|
public class VanChartPieCategoryLabelContentPane extends VanChartLabelContentPane { |
||||||
|
|
||||||
|
private SummaryValueFormatPaneWithCheckBox summaryValueFormatPane; |
||||||
|
|
||||||
|
private SummaryValueFormatPaneWithoutCheckBox richTextSummaryValueFormatPane; |
||||||
|
|
||||||
|
public VanChartPieCategoryLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { |
||||||
|
super(parent, showOnPane, inCondition); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected JPanel getLabelContentPane(JPanel contentPane) { |
||||||
|
return contentPane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { |
||||||
|
setCategoryNameFormatPane(new CategoryNameFormatPaneWithCheckBox(parent, showOnPane)); |
||||||
|
summaryValueFormatPane = new SummaryValueFormatPaneWithCheckBox(parent, showOnPane); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { |
||||||
|
setRichTextCategoryNameFormatPane(new CategoryNameFormatPaneWithoutCheckBox(parent, showOnPane)); |
||||||
|
richTextSummaryValueFormatPane = new SummaryValueFormatPaneWithoutCheckBox(parent, showOnPane); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Component[][] getPaneComponents() { |
||||||
|
return new Component[][]{ |
||||||
|
new Component[]{getCategoryNameFormatPane(), null}, |
||||||
|
new Component[]{summaryValueFormatPane, null}, |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Component[][] getRichTextComponents() { |
||||||
|
return new Component[][]{ |
||||||
|
new Component[]{getRichTextCategoryNameFormatPane(), null}, |
||||||
|
new Component[]{richTextSummaryValueFormatPane, null}, |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected double[] getRowSize(double p) { |
||||||
|
return new double[]{p, p}; |
||||||
|
} |
||||||
|
|
||||||
|
public JPanel createCommonStylePane() { |
||||||
|
setTextAttrPane(new ChartTextAttrPane()); |
||||||
|
return getTextAttrPane(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { |
||||||
|
PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; |
||||||
|
super.populateFormatPane(pieCategoryLabelContent); |
||||||
|
summaryValueFormatPane.populate(pieCategoryLabelContent.getSummaryValueFormat()); |
||||||
|
} |
||||||
|
|
||||||
|
protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { |
||||||
|
PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; |
||||||
|
VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ |
||||||
|
getRichTextCategoryNameFormatPane(), |
||||||
|
richTextSummaryValueFormatPane |
||||||
|
}; |
||||||
|
|
||||||
|
AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ |
||||||
|
pieCategoryLabelContent.getRichTextCategoryFormat(), |
||||||
|
pieCategoryLabelContent.getRichTextSummaryValueFormat() |
||||||
|
}; |
||||||
|
|
||||||
|
setRichTextAttr(new AttrTooltipRichText()); |
||||||
|
populateRichTextFormat(formatPaneGroup, formatGroup); |
||||||
|
populateRichText(pieCategoryLabelContent.getRichTextAttr()); |
||||||
|
|
||||||
|
checkRichEditorState(pieCategoryLabelContent); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { |
||||||
|
PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; |
||||||
|
super.updateFormatPane(pieCategoryLabelContent); |
||||||
|
summaryValueFormatPane.update(pieCategoryLabelContent.getSummaryValueFormat()); |
||||||
|
} |
||||||
|
|
||||||
|
protected void updateRichEditor(AttrTooltipContent attrTooltipContent) { |
||||||
|
PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; |
||||||
|
super.updateRichEditor(pieCategoryLabelContent); |
||||||
|
richTextSummaryValueFormatPane.update(pieCategoryLabelContent.getRichTextSummaryValueFormat()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setDirty(boolean isDirty) { |
||||||
|
getCategoryNameFormatPane().setDirty(isDirty); |
||||||
|
summaryValueFormatPane.setDirty(isDirty); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isDirty() { |
||||||
|
return getCategoryNameFormatPane().isDirty() || summaryValueFormatPane.isDirty(); |
||||||
|
} |
||||||
|
|
||||||
|
protected AttrTooltipContent createAttrTooltip() { |
||||||
|
return new PieCategoryLabelContent(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,79 @@ |
|||||||
|
package com.fr.van.chart.pie.style; |
||||||
|
|
||||||
|
import com.fr.van.chart.designer.component.VanChartLabelContentPane; |
||||||
|
import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; |
||||||
|
import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; |
||||||
|
import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; |
||||||
|
import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; |
||||||
|
import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; |
||||||
|
import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; |
||||||
|
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.Component; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-12-09 |
||||||
|
*/ |
||||||
|
public class VanChartPieValueLabelContentPane extends VanChartLabelContentPane { |
||||||
|
|
||||||
|
public VanChartPieValueLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { |
||||||
|
super(parent, showOnPane, inCondition); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected JPanel getLabelContentPane(JPanel contentPane) { |
||||||
|
return contentPane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { |
||||||
|
setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); |
||||||
|
setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane)); |
||||||
|
setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { |
||||||
|
setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); |
||||||
|
setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); |
||||||
|
setRichTextPercentFormatPane(new PercentFormatPaneWithoutCheckBox(parent, showOnPane)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected double[] getRowSize(double p) { |
||||||
|
return new double[]{p, p, p}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Component[][] getPaneComponents() { |
||||||
|
return new Component[][]{ |
||||||
|
new Component[]{getSeriesNameFormatPane(), null}, |
||||||
|
new Component[]{getValueFormatPane(), null}, |
||||||
|
new Component[]{getPercentFormatPane(), null}, |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Component[][] getRichTextComponents() { |
||||||
|
return new Component[][]{ |
||||||
|
new Component[]{getRichTextSeriesNameFormatPane(), null}, |
||||||
|
new Component[]{getRichTextValueFormatPane(), null}, |
||||||
|
new Component[]{getRichTextPercentFormatPane(), null} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setDirty(boolean isDirty) { |
||||||
|
getSeriesNameFormatPane().setDirty(isDirty); |
||||||
|
getValueFormatPane().setDirty(isDirty); |
||||||
|
getPercentFormatPane().setDirty(isDirty); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isDirty() { |
||||||
|
return getSeriesNameFormatPane().isDirty() || getValueFormatPane().isDirty() || getPercentFormatPane().isDirty(); |
||||||
|
} |
||||||
|
} |
@ -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