desktopCardPanel.getSelectedComponent().repaint();
} else if ((e.getSource() == bRedo) || (e.getSource() == miRedo)) {
redoAction.actionPerformed(e);
desktopCardPanel.getSelectedComponent().repaint();
} else if (e.getSource() == bAdjust) {
DiagramComponent d = getActiveDiagram();
if (d != null) {
d.adjust();
}
return;
} else if (e.getSource() == bAlign) {
DiagramComponent d = getActiveDiagram();
if (d != null) {
d.align();
}
return;
} else if (e.getSource() == cbxGrid) {
DiagramComponent d = getActiveDiagram();
if (d == null) {
return;
}
int value = 0;
try {
value = Long.decode((String) cbxGrid.getSelectedItem()).intValue();
} catch (Exception eg) {
value = 0;
}
d.setGrid(value);
return;
} else if (e.getSource() == tfZoom) {
DiagramComponent d = getActiveDiagram();
if (d == null) {
return;
}
int value = 0;
try {
String zoomInt = tfZoom.getText();
if (zoomInt.endsWith("%")) {
zoomInt = zoomInt.substring(0, zoomInt.length() - 1);
}
value = Long.decode(zoomInt).intValue();
} catch (Exception eg) {
value = 100;
}
d.setZoom((double) value / 100.0);
int zoomInt = (int)( d.getZoom() * 100) ;
tfZoom.setText(zoomInt + "%");
return;
} else if (e.getSource() == tbGridDisplay) {
DiagramComponent d = getActiveDiagram();
if (d == null) {
return;
}
d.setGridDisplay(tbGridDisplay.isSelected());
} else if (source == miSheetDisplay) {
setupSheetDisplay();
} else if ((source == miPrint) || (source == bPrint)) {
print(getActiveDiagram());
} else if ((source == miPrintImage) || (source == bPrintImage)) {
if (!canPrint()) {
return; // In fact, should not happen at this point
}
DiagramComponent d = getActiveDiagram();
if (d == null) {
return;
}
if (printImage == null) {
printImage = new PrintToImage();
}
try {
printImage.print(d, this.getActiveContainer().getDiagramParameters().backgr);
} catch (Exception ex) {
setStatus(messageWriter.print2args("cannotExport", d.toString(), ex.getMessage()));
ex.printStackTrace();
}
} else if ((source == miSnapShot) || (source == bSnapShot)) {
if (!canPrint()) {
return; // In fact, should not happen at this point
}
DiagramComponent d = getActiveDiagram();
if (d == null) {
return;
}
try {
ImageViewer imageViewer = new ImageViewer(getOwner(), resources.getString("snapshot"));
imageViewer.setImage(getActiveDiagram(), this.getActiveContainer().getDiagramParameters().backgr);
imageViewer.setLocation(getOwner().getLocation());
imageViewer.setSize(desktopCardPanel.getWidth(), desktopCardPanel.getHeight());
imageViewer.setVisible(true);
} catch (Exception ex) {
setStatus(messageWriter.print1args("printFailed", ex.getMessage()));
ex.printStackTrace();
}
} else if (e.getSource() == miChooseLanguage) {
DefaultListModel listModel = new DefaultListModel();
int nlang = resources.getIntValue("languageNumber");
String oldcode = Run.getProperties().getString("jsynoptic.language", "");
int sel = -1;
for (int i = 0; i < nlang; ++i) {
listModel.addElement(resources.getStringValue("languageName" + i));
if (resources.getStringValue("languageCode" + i).equals(oldcode)) {
sel = i;
}
}
JList langlist = new JList(listModel);
langlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
if (sel != -1) {
langlist.setSelectedIndex(sel);
}
int result = JOptionPane.showConfirmDialog(owner, langlist, resources.getString("chooseLanguageTitle"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if ((result == JOptionPane.OK_OPTION) && (langlist.getSelectedIndex() != -1)) {
String code = resources.getStringValue("languageCode" + langlist.getSelectedIndex());
Run.getProperties().setString("jsynoptic.language", (code != null) ? code : "");
}
} else if (e.getSource() == miFindPlugins) {
setStatus(messageWriter.print0args("lookingForPlugins"));
new LongAction() {
protected void doAction() {
if (PluginLookup.addPluginPaths(true, owner)) {
userProperties.setString("jsynoptic.class.path", PluginLookup.getClassPath());
Vector plugins = PluginLookup.lookup();
String[] plugs = new String[plugins.size()];
boolean[] checked = new boolean[plugins.size()];
for (int k = 0; k < plugins.size(); k++) {
plugs[k] = (String) plugins.get(k);
checked[k] = true;
}
boolean[] res = CheckBoxList.openDialog(messageWriter.print0args("foundPlugins"), owner, plugs,
checked);
if (res != null) {
String defaultPlugins = "";
for (int k = 0; k < plugins.size(); k++) {
if (res[k]) {
if (!defaultPlugins.equals("")) {
defaultPlugins += ",";
}
defaultPlugins += plugs[k];
}
}
if (!defaultPlugins.equals("")) {
userProperties.setString("jsynoptic.plugins", defaultPlugins);
JOptionPane.showMessageDialog(getOwner(),
messageWriter.print0args("restartForPlugins"), messageWriter
.print0args("Plugins:"), JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
}.start();
return;
} else if (e.getSource() == miPreferencesPanel) {
// Do always create a new instance of UPE, to have new contents, and
// not
// duplication of properties at each dialog call.
propEditor = new UserPropertiesEditor(owner);
setStaticProperties(userProperties);
if (propEditor.showAndUpdate(userProperties, true, Run.productName)) {
getStaticProperties(userProperties);
}
return;
} else if (e.getSource() == miAbout) {
if (aboutFrame == null) {
aboutFrame = new JFrame(messageWriter.print1args("aboutTitle", Run.productName));
String content = messageWriter.print0args("aboutContent");
boolean pluginLineWritten = false;
for (Iterator it = Run.plugins.iterator(); it.hasNext();) {
Plugin p = (Plugin) it.next();
String text = p.about();
if (text == null) {
continue;
}
if (!pluginLineWritten) {
content += "<p>" + messageWriter.print0args("Plugins:") + "<ul>";
pluginLineWritten = true;
}
content += "<li>" + p.about() + "</li>";
}
if (pluginLineWritten) {
content += "</ul></p>";
}
JEditorPane jdp = new JEditorPane("text/html", content);
jdp.setEditable(false);
aboutFrame.getContentPane().setLayout(new BoxLayout(aboutFrame.getContentPane(), BoxLayout.Y_AXIS));
// Set Header
JPanel header = new JPanel(new BorderLayout());
header.setBackground(Color.WHITE);
JLabel headerLogo = new JLabel(resources.getIcon("jsynIconHightResIcon"));
headerLogo.setBackground(Color.WHITE);
header.add(headerLogo, BorderLayout.WEST);
JLabel hearderTitle = new JLabel(messageWriter.print1args("aboutVersion", Run.fullProductVersion));
hearderTitle.setFont(new Font("Dialog", Font.PLAIN, 25));
hearderTitle.setOpaque(true);
hearderTitle.setBackground(Color.WHITE);
header.add(hearderTitle, BorderLayout.EAST);
aboutFrame.getContentPane().add(header);
aboutFrame.getContentPane().add(jdp);
aboutFrame.pack();
aboutFrame.doLayout();
}
aboutFrame.setVisible(true);
return;
} else if (e.getSource() == miHelp) {
if (helpFrame == null) {
helpFrame = new HelpViewer(getOwner(), messageWriter.print0args("helpContentTitle"));
helpFrame.setLocation(getOwner().getLocation());
helpFrame.setSize(getOwner().getWidth(), getOwner().getHeight());
}
helpFrame.setVisible(true);
return;
} else if (e.getSource() == miSheetInformation) {
if (!canPrint()) {
return; // In fact, should not happen at this point
}
DiagramComponent d = getActiveDiagram();
if (d == null) {
return;
}
ShapesContainer c = getActiveContainer();
if (c == null) {