Search in sources :

Example 11 with ToolButton

use of com.sldeditor.tool.ToolButton in project sldeditor by robward-scisys.

the class BatchUpdateFontTool method createUI.

/**
 * Creates the ui.
 */
private void createUI() {
    panel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) panel.getLayout();
    flowLayout.setVgap(0);
    flowLayout.setHgap(0);
    panel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(BatchUpdateFontTool.class, "BatchUpdateFontTool.title")));
    scaleButton = new ToolButton(Localisation.getString(BatchUpdateFontTool.class, "BatchUpdateFontTool.title"), "tool/batchupdatefont.png");
    panel.add(scaleButton);
    scaleButton.setEnabled(false);
    scaleButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            BatchUpdateFontPanel scalePanel = new BatchUpdateFontPanel(application);
            scalePanel.populate(sldDataList);
            scalePanel.setVisible(true);
        }
    });
    panel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) ToolButton(com.sldeditor.tool.ToolButton) ActionEvent(java.awt.event.ActionEvent) Dimension(java.awt.Dimension)

Example 12 with ToolButton

use of com.sldeditor.tool.ToolButton in project sldeditor by robward-scisys.

the class DatabaseConnectionListTool method createUI.

/**
 * Creates the ui.
 */
private void createUI() {
    panel = new JPanel();
    panel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(DatabaseConnectionListTool.class, "DatabaseConnectionListTool.title")));
    FlowLayout flowLayout = (FlowLayout) panel.getLayout();
    flowLayout.setVgap(0);
    flowLayout.setHgap(0);
    btnNew = new ToolButton(Localisation.getString(DatabaseConnectionListTool.class, "DatabaseConnectionListTool.new"), "tool/newconnection.png");
    btnNew.setEnabled(true);
    btnNew.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (databaseConnectUpdate != null) {
                DatabaseConnection connectionDetails = DatabaseConnectionFactory.getNewConnection(selectedDatabaseType);
                DatabaseConnection newConnectionDetails = DBConnectorDetailsPanel.showDialog(null, connectionDetails);
                if (newConnectionDetails != null) {
                    databaseConnectUpdate.addNewConnection(newConnectionDetails);
                }
            }
        }
    });
    panel.add(btnNew);
    btnDuplicate = new ToolButton(Localisation.getString(DatabaseConnectionListTool.class, "DatabaseConnectionListTool.duplicate"), "tool/duplicateconnection.png");
    btnDuplicate.setEnabled(false);
    btnDuplicate.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (databaseConnectUpdate != null) {
                if (!connectionList.isEmpty()) {
                    DatabaseConnection selectedConnectionDetails = connectionList.get(0);
                    DatabaseConnection duplicateItem = selectedConnectionDetails.duplicate();
                    databaseConnectUpdate.addNewConnection(duplicateItem);
                }
            }
        }
    });
    panel.add(btnDuplicate);
    btnEdit = new ToolButton(Localisation.getString(DatabaseConnectionListTool.class, "DatabaseConnectionListTool.edit"), "tool/editconnection.png");
    btnEdit.setEnabled(false);
    btnEdit.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (databaseConnectUpdate != null) {
                if (!connectionList.isEmpty()) {
                    DatabaseConnection selectedConnectionDetails = connectionList.get(0);
                    DatabaseConnection newConnectionDetails = DBConnectorDetailsPanel.showDialog(null, selectedConnectionDetails);
                    if (newConnectionDetails != null) {
                        databaseConnectUpdate.updateConnectionDetails(selectedConnectionDetails, newConnectionDetails);
                    }
                }
            }
        }
    });
    panel.add(btnEdit);
    btnDelete = new ToolButton(Localisation.getString(DatabaseConnectionListTool.class, "DatabaseConnectionListTool.delete"), "tool/deleteconnection.png");
    btnDelete.setEnabled(false);
    btnDelete.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (databaseConnectUpdate != null) {
                databaseConnectUpdate.deleteConnections(connectionList);
            }
        }
    });
    panel.add(btnDelete);
    panel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) ToolButton(com.sldeditor.tool.ToolButton) ActionEvent(java.awt.event.ActionEvent) DatabaseConnection(com.sldeditor.common.data.DatabaseConnection) Dimension(java.awt.Dimension)

Example 13 with ToolButton

use of com.sldeditor.tool.ToolButton in project sldeditor by robward-scisys.

the class GeoServerConnectionTool method createUI.

/**
 * Creates the ui.
 */
private void createUI() {
    panel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) panel.getLayout();
    flowLayout.setVgap(0);
    flowLayout.setHgap(0);
    panel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(GeoServerConnectionTool.class, "GeoServerConnectionTool.title")));
    // 
    // Connect button
    // 
    connectButton = new ToolButton(Localisation.getString(GeoServerConnectionTool.class, "GeoServerConnectionTool.connect"), "tool/connect.png");
    connectButton.setEnabled(true);
    connectButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (geoServerConnectState != null) {
                connectButton.setEnabled(false);
                disconnectButton.setEnabled(false);
                geoServerConnectState.connect(connectionList);
                for (GeoServerConnection connection : connectionList) {
                    if (!geoServerConnectState.isConnected(connection)) {
                        connectButton.setEnabled(true);
                    }
                }
            }
        }
    });
    panel.add(connectButton);
    // 
    // Disconnect button
    // 
    disconnectButton = new ToolButton(Localisation.getString(GeoServerConnectionTool.class, "GeoServerConnectionTool.disconnect"), "tool/disconnect.png");
    disconnectButton.setEnabled(false);
    disconnectButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (geoServerConnectState != null) {
                connectButton.setEnabled(false);
                disconnectButton.setEnabled(false);
                geoServerConnectState.disconnect(connectionList);
            }
        }
    });
    panel.add(disconnectButton);
    panel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) ToolButton(com.sldeditor.tool.ToolButton) ActionEvent(java.awt.event.ActionEvent) Dimension(java.awt.Dimension) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection)

Example 14 with ToolButton

use of com.sldeditor.tool.ToolButton in project sldeditor by robward-scisys.

the class GeoServerConnectionListTool method createUI.

/**
 * Creates the ui.
 */
private void createUI() {
    panel = new JPanel();
    panel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(GeoServerConnectionListTool.class, "GeoServerConnectionListTool.title")));
    FlowLayout flowLayout = (FlowLayout) panel.getLayout();
    flowLayout.setVgap(0);
    flowLayout.setHgap(0);
    btnNew = new ToolButton(Localisation.getString(GeoServerConnectionListTool.class, "GeoServerConnectionListTool.new"), "tool/newconnection.png");
    btnNew.setEnabled(true);
    btnNew.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (geoServerConnectUpdate != null) {
                GeoServerConnection connectionDetails = new GeoServerConnection();
                GeoServerConnection newConnectionDetails = ConnectorDetailsPanel.showDialog(null, connectionDetails);
                if (newConnectionDetails != null) {
                    geoServerConnectUpdate.addNewConnection(newConnectionDetails);
                }
            }
        }
    });
    panel.add(btnNew);
    btnDuplicate = new ToolButton(Localisation.getString(GeoServerConnectionListTool.class, "GeoServerConnectionListTool.duplicate"), "tool/duplicateconnection.png");
    btnDuplicate.setEnabled(false);
    btnDuplicate.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (geoServerConnectUpdate != null) {
                if (!connectionList.isEmpty()) {
                    GeoServerConnection selectedConnectionDetails = connectionList.get(0);
                    GeoServerConnection duplicateItem = selectedConnectionDetails.duplicate();
                    geoServerConnectUpdate.addNewConnection(duplicateItem);
                }
            }
        }
    });
    panel.add(btnDuplicate);
    btnEdit = new ToolButton(Localisation.getString(GeoServerConnectionListTool.class, "GeoServerConnectionListTool.edit"), "tool/editconnection.png");
    btnEdit.setEnabled(false);
    btnEdit.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (geoServerConnectUpdate != null) {
                if (!connectionList.isEmpty()) {
                    GeoServerConnection selectedConnectionDetails = connectionList.get(0);
                    GeoServerConnection newConnectionDetails = ConnectorDetailsPanel.showDialog(null, selectedConnectionDetails);
                    if (newConnectionDetails != null) {
                        geoServerConnectUpdate.updateConnectionDetails(selectedConnectionDetails, newConnectionDetails);
                    }
                }
            }
        }
    });
    panel.add(btnEdit);
    btnDelete = new ToolButton(Localisation.getString(GeoServerConnectionListTool.class, "GeoServerConnectionListTool.delete"), "tool/deleteconnection.png");
    btnDelete.setEnabled(false);
    btnDelete.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (geoServerConnectUpdate != null) {
                geoServerConnectUpdate.deleteConnections(connectionList);
            }
        }
    });
    panel.add(btnDelete);
    panel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) ToolButton(com.sldeditor.tool.ToolButton) ActionEvent(java.awt.event.ActionEvent) Dimension(java.awt.Dimension) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection)

Example 15 with ToolButton

use of com.sldeditor.tool.ToolButton in project sldeditor by robward-scisys.

the class YSLDToolTest method testSetSelectedItems.

/**
 * Test sld file.
 */
@Test
public void testSetSelectedItems() {
    YSLDTool tool = new YSLDTool();
    JPanel panel = tool.getPanel();
    ToolButton toSLD = null;
    ToolButton toYSLD = null;
    for (Component c : panel.getComponents()) {
        if (c instanceof ToolButton) {
            ToolButton button = (ToolButton) c;
            String toolTipText = button.getToolTipText();
            if (toolTipText.compareTo(Localisation.getString(YSLDTool.class, "YSLDTool.exportToSLD")) == 0) {
                toSLD = button;
            } else if (toolTipText.compareTo(Localisation.getString(YSLDTool.class, "YSLDTool.exportToYSLD")) == 0) {
                toYSLD = button;
            }
        }
    }
    File testFile1 = null;
    File testFile3 = null;
    try {
        testFile1 = File.createTempFile("invalid", ".tst");
        testFile3 = File.createTempFile("valid", ".ysld");
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    // Should both be disabled
    assertFalse(toSLD.isEnabled());
    assertFalse(toYSLD.isEnabled());
    tool.setSelectedItems(null, null);
    // Invalid file
    List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
    SLDData sldData1 = new SLDData(null, null);
    sldData1.setSLDFile(testFile1);
    sldDataList.add(sldData1);
    tool.setSelectedItems(null, sldDataList);
    // Should both be disabled
    assertFalse(toSLD.isEnabled());
    assertFalse(toYSLD.isEnabled());
    // Try with valid sld file
    sldDataList = new ArrayList<SLDDataInterface>();
    SLDData sldData2 = getSLDDataFile("/point/sld/point_simplepoint.sld");
    sldDataList.add(sldData2);
    tool.setSelectedItems(null, sldDataList);
    // YSLD should be enabled
    assertTrue(toYSLD.isEnabled());
    assertFalse(toSLD.isEnabled());
    toYSLD.doClick();
    // Try with valid ysld file
    sldDataList = new ArrayList<SLDDataInterface>();
    SLDData sldData3 = getSLDDataFile("/point/ysld/point_simplepoint.ysld");
    sldDataList.add(sldData3);
    tool.setSelectedItems(null, sldDataList);
    // SLD should be enabled
    assertTrue(toSLD.isEnabled());
    assertFalse(toYSLD.isEnabled());
    toSLD.doClick();
    // Try with valid sld and ysld files
    sldDataList = new ArrayList<SLDDataInterface>();
    sldDataList.add(sldData2);
    sldDataList.add(sldData3);
    tool.setSelectedItems(null, sldDataList);
    // SLD and YSLD should be enabled
    assertTrue(toSLD.isEnabled());
    assertTrue(toYSLD.isEnabled());
    testFile1.delete();
    testFile3.delete();
    tidyUpTempFiles(sldData2.getSLDFile());
    tidyUpTempFiles(sldData3.getSLDFile());
}
Also used : JPanel(javax.swing.JPanel) SLDData(com.sldeditor.common.data.SLDData) ToolButton(com.sldeditor.tool.ToolButton) SLDDataInterface(com.sldeditor.common.SLDDataInterface) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Component(java.awt.Component) File(java.io.File) YSLDTool(com.sldeditor.tool.ysld.YSLDTool) Test(org.junit.Test)

Aggregations

ToolButton (com.sldeditor.tool.ToolButton)15 JPanel (javax.swing.JPanel)15 Dimension (java.awt.Dimension)13 ActionEvent (java.awt.event.ActionEvent)13 ActionListener (java.awt.event.ActionListener)13 FlowLayout (java.awt.FlowLayout)12 File (java.io.File)5 SLDDataInterface (com.sldeditor.common.SLDDataInterface)3 ArrayList (java.util.ArrayList)3 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)2 SLDData (com.sldeditor.common.data.SLDData)2 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)2 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)2 Component (java.awt.Component)2 IOException (java.io.IOException)2 JFileChooser (javax.swing.JFileChooser)2 Test (org.junit.Test)2 DataSourceConnectorInterface (com.sldeditor.common.DataSourceConnectorInterface)1 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)1 LoadSLDInterface (com.sldeditor.common.LoadSLDInterface)1