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));
}
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));
}
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));
}
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));
}
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());
}
Aggregations