use of com.sldeditor.extension.ExtensionInterface in project sldeditor by robward-scisys.
the class SLDEditor method reloadSLDFile.
/*
* (non-Javadoc)
*
* @see com.sldeditor.common.LoadSLDInterface#reloadSLDFile()
*/
@Override
public void reloadSLDFile() {
boolean reloadFile = true;
if (!underTestFlag) {
reloadFile = sldEditorDlg.reload(frame);
}
if (reloadFile) {
SLDDataInterface sldData = SLDEditorFile.getInstance().getSLDData();
if (sldData != null) {
URL url = sldData.getSLDURL();
if (url != null) {
List<SLDDataInterface> sldDataList = null;
for (ExtensionInterface extension : extensionList) {
if (sldDataList == null) {
sldDataList = extension.open(url);
}
}
if ((sldDataList != null) && !sldDataList.isEmpty()) {
SLDDataInterface firstObject = sldDataList.get(0);
populate(firstObject);
}
}
}
// Inform UndoManager that a new SLD file has been
// loaded and to clear undo history
UndoManager.getInstance().fileLoaded();
Controller.getInstance().setPopulating(true);
uiMgr.populateUI(1);
Controller.getInstance().setPopulating(false);
}
ReloadManager.getInstance().reset();
}
use of com.sldeditor.extension.ExtensionInterface in project sldeditor by robward-scisys.
the class SLDEditorMenus method createToolsMenu.
/**
* Creates the tools menu.
*
* @param extensionList the extension list
* @param menuBar the menu bar
*/
private void createToolsMenu(List<ExtensionInterface> extensionList, JMenuBar menuBar) {
JMenu mnTools = new JMenu(Localisation.getString(SLDEditorMenus.class, "tools.menu"));
menuBar.add(mnTools);
JMenuItem mntmEnvVar = new JMenuItem(Localisation.getString(SLDEditorMenus.class, "tools.menu.envvar"));
mntmEnvVar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
EnvironmentVariableManager.getInstance().showDialog();
}
});
mnTools.add(mntmEnvVar);
JMenuItem mntmOptions = new JMenuItem(Localisation.getString(SLDEditorMenus.class, "tools.menu.options"));
mntmOptions.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PrefManagerUI.showPrefPanel();
}
});
JMenuItem mntmCheckUpdates = new JMenuItem(Localisation.getString(SLDEditorMenus.class, "tools.menu.checkUpdates"));
mntmCheckUpdates.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
CheckUpdatePanel panel = new CheckUpdatePanel();
panel.showPanel(Version.getVersionNumber());
}
});
// Create any extension specific menu items
if (extensionList != null) {
for (ExtensionInterface extension : extensionList) {
extension.createMenus(mnTools);
}
}
mnTools.add(mntmOptions);
mnTools.add(mntmCheckUpdates);
}
use of com.sldeditor.extension.ExtensionInterface in project sldeditor by robward-scisys.
the class ExtensionFactoryTest method testGetArgumentList.
/**
* Test method for
* {@link com.sldeditor.extension.ExtensionFactory#getArgumentList(java.lang.String[])}.
*/
@Test
public void testGetArgumentList() {
List<ExtensionInterface> extensionList = ExtensionFactory.getAvailableExtensions();
assertEquals(1, extensionList.size());
ExtensionInterface extension = extensionList.get(0);
// CHECKSTYLE:OFF
String[] args = { "-extension.file.folder=D:\\GitHub\\SLDEditor\\slddata", "-extension.zzz" };
// CHECKSTYLE:ON
List<String> extensionArgList = ExtensionFactory.getArgumentList(args);
List<String> extensionSpecificArgumentList = ExtensionFactory.getArguments(extension, extensionArgList);
assertEquals(1, extensionSpecificArgumentList.size());
assertEquals("folder=D:\\GitHub\\SLDEditor\\slddata", extensionSpecificArgumentList.get(0));
}
use of com.sldeditor.extension.ExtensionInterface in project sldeditor by robward-scisys.
the class SLDEditor method openFile.
/**
* Open file.
*
* @param url the url
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.SLDEditorInterface#openFile(java.net.URL)
*/
@Override
public void openFile(URL url) {
List<SLDDataInterface> sldDataList = null;
for (ExtensionInterface extension : extensionList) {
if (sldDataList == null) {
sldDataList = extension.open(url);
}
}
if (sldDataList != null) {
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setSldData(sldDataList);
loadSLDString(selectedFiles);
}
}
use of com.sldeditor.extension.ExtensionInterface in project sldeditor by robward-scisys.
the class SLDEditorDefaultLayout method createUI.
/**
* Creates the ui.
*
* @param application the application
* @param uiMgr the ui mgr
* @param extensionList the extension list
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.UILayoutInterface#createUI(com.sldeditor.SLDEditorInterface, com.sldeditor.SLDEditorUIPanels, java.util.List)
*/
@Override
public void createUI(SLDEditorInterface application, SLDEditorUIPanels uiMgr, List<ExtensionInterface> extensionList) {
if (application == null) {
return;
}
JPanel appPanel = application.getAppPanel();
appPanel.setLayout(new BorderLayout(0, 0));
// Console
JPanel consolePanel = ConsoleManager.getInstance().getPanel();
appPanel.add(consolePanel, BorderLayout.SOUTH);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout(0, 0));
appPanel.add(panel, BorderLayout.CENTER);
ToolManager toolManagerInstance = ToolManager.getInstance();
toolManagerInstance.setApplication(application);
// Initialise extensions
for (ExtensionInterface extension : extensionList) {
extension.initialise(application.getLoadSLDInterface(), toolManagerInstance);
}
// SLD symbol data panel
JComponent legendPanel = uiMgr.getLegendData();
JComponent dataPanel = uiMgr.getSLDSymbolData();
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.addTab(Localisation.getString(SLDEditorDefaultLayout.class, "panels.symbol"), null, dataPanel, Localisation.getString(SLDEditorDefaultLayout.class, "panels.symbol.tooltip"));
// Legend data panel
tabbedPane.addTab(Localisation.getString(SLDEditorDefaultLayout.class, "panels.legend"), null, legendPanel, Localisation.getString(SLDEditorDefaultLayout.class, "panels.legend.tooltip"));
// SLD raw data panel
JComponent sldPanel = SLDTextArea.getPanel();
tabbedPane.addTab(Localisation.getString(SLDEditorDefaultLayout.class, "panels.sld"), null, sldPanel, Localisation.getString(SLDEditorDefaultLayout.class, "panels.sld.tooltip"));
// Map renderer
MapRender mapTabPanel = RenderPanelFactory.getMapRenderer();
tabbedPane.addTab(Localisation.getString(SLDEditorDefaultLayout.class, "panels.map"), null, mapTabPanel, Localisation.getString(SLDEditorDefaultLayout.class, "panels.map.tooltip"));
// Data source
JComponent dataSourceConfig = uiMgr.getDataSourceConfig();
tabbedPane.addTab(Localisation.getString(SLDEditorDefaultLayout.class, "panels.dataSource"), null, dataSourceConfig, Localisation.getString(SLDEditorDefaultLayout.class, "panels.dataSource.tooltip"));
// Vendor option
JComponent vendorOptionConfig = uiMgr.getVendorOption();
tabbedPane.addTab(Localisation.getString(SLDEditorDefaultLayout.class, "panels.vendorOption"), null, vendorOptionConfig, Localisation.getString(SLDEditorDefaultLayout.class, "panels.vendorOption.tooltip"));
panel.add(tabbedPane);
tabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() instanceof JTabbedPane) {
JTabbedPane pane = (JTabbedPane) e.getSource();
if (pane.getSelectedComponent() == mapTabPanel) {
mapTabPanel.updateStyle();
}
}
}
});
// Extension tab
JTabbedPane extensionTab = new JTabbedPane(JTabbedPane.TOP);
panel.add(extensionTab, BorderLayout.WEST);
for (ExtensionInterface extension : extensionList) {
extensionTab.addTab(extension.getName(), null, extension.getPanel(), extension.getTooltip());
}
if (application != null) {
JFrame applicationFrame = application.getApplicationFrame();
if (applicationFrame != null) {
applicationFrame.getContentPane().add(appPanel);
}
}
}
Aggregations