Search in sources :

Example 1 with ExtensionInterface

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();
}
Also used : SLDDataInterface(com.sldeditor.common.SLDDataInterface) ExtensionInterface(com.sldeditor.extension.ExtensionInterface) URL(java.net.URL)

Example 2 with ExtensionInterface

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);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ExtensionInterface(com.sldeditor.extension.ExtensionInterface) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) CheckUpdatePanel(com.sldeditor.update.CheckUpdatePanel)

Example 3 with ExtensionInterface

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));
}
Also used : ExtensionInterface(com.sldeditor.extension.ExtensionInterface) Test(org.junit.Test)

Example 4 with ExtensionInterface

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);
    }
}
Also used : SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) ExtensionInterface(com.sldeditor.extension.ExtensionInterface)

Example 5 with ExtensionInterface

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);
        }
    }
}
Also used : JPanel(javax.swing.JPanel) MapRender(com.sldeditor.map.MapRender) BorderLayout(java.awt.BorderLayout) ChangeEvent(javax.swing.event.ChangeEvent) JFrame(javax.swing.JFrame) JTabbedPane(javax.swing.JTabbedPane) JComponent(javax.swing.JComponent) ToolManager(com.sldeditor.tool.ToolManager) ExtensionInterface(com.sldeditor.extension.ExtensionInterface) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

ExtensionInterface (com.sldeditor.extension.ExtensionInterface)7 SLDDataInterface (com.sldeditor.common.SLDDataInterface)3 ToolManager (com.sldeditor.tool.ToolManager)2 URL (java.net.URL)2 JFrame (javax.swing.JFrame)2 Test (org.junit.Test)2 CContentArea (bibliothek.gui.dock.common.CContentArea)1 CControl (bibliothek.gui.dock.common.CControl)1 CGrid (bibliothek.gui.dock.common.CGrid)1 DefaultSingleCDockable (bibliothek.gui.dock.common.DefaultSingleCDockable)1 SingleCDockable (bibliothek.gui.dock.common.SingleCDockable)1 SLDEditorInterface (com.sldeditor.common.SLDEditorInterface)1 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)1 MapRender (com.sldeditor.map.MapRender)1 CheckUpdatePanel (com.sldeditor.update.CheckUpdatePanel)1 BorderLayout (java.awt.BorderLayout)1 GridLayout (java.awt.GridLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JComponent (javax.swing.JComponent)1