2 * jSite2 - SwingInterface.java -
3 * Copyright © 2008 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package net.pterodactylus.jsite.gui;
22 import java.awt.event.ActionEvent;
24 import java.io.FileInputStream;
25 import java.io.FileOutputStream;
26 import java.io.IOException;
27 import java.util.ArrayList;
28 import java.util.Collections;
29 import java.util.HashMap;
30 import java.util.List;
31 import java.util.Locale;
33 import java.util.Properties;
34 import java.util.concurrent.Executor;
35 import java.util.concurrent.Executors;
36 import java.util.logging.Level;
37 import java.util.logging.LogRecord;
38 import java.util.logging.Logger;
40 import javax.swing.AbstractAction;
41 import javax.swing.Action;
42 import javax.swing.JOptionPane;
43 import javax.swing.UIManager;
44 import javax.swing.UnsupportedLookAndFeelException;
46 import net.pterodactylus.jsite.core.Core;
47 import net.pterodactylus.jsite.core.CoreListener;
48 import net.pterodactylus.jsite.core.NoNodeException;
49 import net.pterodactylus.jsite.core.Node;
50 import net.pterodactylus.jsite.core.Project;
51 import net.pterodactylus.jsite.core.Request;
52 import net.pterodactylus.jsite.i18n.I18n;
53 import net.pterodactylus.jsite.i18n.gui.I18nAction;
54 import net.pterodactylus.util.image.IconLoader;
55 import net.pterodactylus.util.io.Closer;
56 import net.pterodactylus.util.logging.Logging;
57 import net.pterodactylus.util.logging.LoggingListener;
60 * The Swing user interface.
62 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
65 public class SwingInterface implements CoreListener, LoggingListener {
68 private static final Logger logger = Logging.getLogger(SwingInterface.class.getName());
70 /** The application core. */
71 private final Core core;
73 /** The configuration directory. */
74 private final String configDirectory;
76 /** The main window. */
77 private MainWindow mainWindow;
80 private Executor threadPool = Executors.newCachedThreadPool();
82 /** The logger window. */
83 private LogWindow logWindow;
85 /** The “configure” action. */
86 private I18nAction configureAction;
88 /** The “import config” action. */
89 private I18nAction importConfigAction;
91 /** The “quit” action. */
92 private I18nAction quitAction;
94 /** The “manage nodes” action. */
95 private I18nAction manageNodesAction;
97 /** The “connect to node” (simple mode) action. */
98 private I18nAction nodeConnectAction;
100 /** The “disconnect from node” (simple mode) action. */
101 private I18nAction nodeDisconnectAction;
103 /** All node menu items. */
104 private List<Action> nodeConnectActions = Collections.synchronizedList(new ArrayList<Action>());
106 /** Mapping from nodes to node connect actions. */
107 private Map<Node, Action> nodeNodeConnectActions = Collections.synchronizedMap(new HashMap<Node, Action>());
109 /** Mapping from node connect actions to nodes. */
110 private Map<Action, Node> nodeConnectActionNodes = Collections.synchronizedMap(new HashMap<Action, Node>());
112 /** All node disconnect actions. */
113 private List<Action> nodeDisconnectActions = Collections.synchronizedList(new ArrayList<Action>());
115 /** Mapping from nodes to node disconnect actions. */
116 private Map<Node, Action> nodeNodeDisconnectActions = Collections.synchronizedMap(new HashMap<Node, Action>());
118 /** Mapping from node disconnect actions to nodes. */
119 private Map<Action, Node> nodeDisconnectActionNodes = Collections.synchronizedMap(new HashMap<Action, Node>());
121 /** The node manager dialog. */
122 private ManageNodesDialog manageNodesDialog;
124 /** All lanugage menu items. */
125 private List<I18nAction> languageActions = new ArrayList<I18nAction>();
127 /** The “about” action. */
128 private I18nAction helpAboutAction;
130 /** The “add project” action. */
131 private I18nAction addProjectAction;
133 /** The “clone project” action. */
134 private I18nAction cloneProjectAction;
136 /** The “delete project” action. */
137 private I18nAction deleteProjectAction;
139 /** The “about” dialog. */
140 private AboutDialog aboutDialog;
142 /** The configuration dialog. */
143 private ConfigurationDialog configurationDialog;
145 /** The list of all defined nodes. */
146 private List<Node> nodeList = Collections.synchronizedList(new ArrayList<Node>());
148 /** The request table model. */
149 private RequestTableModel requestTableModel = new RequestTableModel();
155 /** The advanced mode. */
156 private boolean advancedMode;
158 /** Whether to antialias the GUI. */
159 private boolean antialias;
161 /** The control font. */
162 private String controlFont;
164 /** The user font. */
165 private String userFont;
167 /** The class name of the look and feel. */
168 private String lookAndFeel;
170 /** X coordinate of the main window. */
171 private int mainWindowX = -1;
173 /** Y coordinate of the main window. */
174 private int mainWindowY = -1;
176 /** Width of the main window. */
177 private int mainWindowWidth = -1;
179 /** Height of the main window. */
180 private int mainWindowHeight = -1;
183 * Creates a new swing interface.
186 * The core to operate on
187 * @param configDirectory
188 * The directory the configuration is stored in
190 public SwingInterface(Core core, String configDirectory) {
192 this.configDirectory = configDirectory;
193 I18n.setLocale(Locale.ENGLISH);
195 if (lookAndFeel != null) {
197 UIManager.setLookAndFeel(lookAndFeel);
198 } catch (ClassNotFoundException cnfe1) {
199 logger.log(Level.WARNING, "could not load look and feel", cnfe1);
200 } catch (InstantiationException ie1) {
201 logger.log(Level.WARNING, "could not load look and feel", ie1);
202 } catch (IllegalAccessException iae1) {
203 logger.log(Level.WARNING, "could not load look and feel", iae1);
204 } catch (UnsupportedLookAndFeelException ulafe1) {
205 logger.log(Level.WARNING, "could not load look and feel", ulafe1);
209 System.setProperty("swing.aatext", "true");
211 if (controlFont != null) {
212 System.setProperty("swing.plaf.metal.controlFont", controlFont);
214 if (userFont != null) {
215 System.setProperty("swing.plaf.metal.userFont", userFont);
219 mainWindow = new MainWindow(this);
220 mainWindow.setAdvancedMode(advancedMode);
221 if ((mainWindowX != -1) && (mainWindowY != -1) && (mainWindowWidth != -1) && (mainWindowHeight != -1)) {
222 mainWindow.setLocation(mainWindowX, mainWindowY);
223 mainWindow.setSize(mainWindowWidth, mainWindowHeight);
225 logWindow = new LogWindow();
233 * Returns the core that is controlled by the Swing interface.
242 * Returns the main window of the Swing interface.
244 * @return The main window
246 MainWindow getMainWindow() {
251 * Returns whether the advanced mode is activated.
253 * @return <code>true</code> if the advanced mode is activated,
254 * <code>false</code> if the simple mode is activated
256 boolean isAdvancedMode() {
261 * Returns the “configure” action.
263 * @return The “configure” action
265 I18nAction getConfigureAction() {
266 return configureAction;
270 * Returns the “import config” action.
272 * @return The “import config” action
274 I18nAction getImportConfigAction() {
275 return importConfigAction;
279 * Returns the “quit” action.
281 * @return The “quit” action
283 I18nAction getQuitAction() {
288 * Returns the “manage nodes” action.
290 * @return The “manage nodes” action
292 I18nAction getManageNodesAction() {
293 return manageNodesAction;
297 * Returns the “connect to node” action.
299 * @return The “connect to node” action
301 I18nAction getNodeConnectAction() {
302 return nodeConnectAction;
306 * Returns all “connect node” actions.
308 * @return All “connect node” actions
310 List<Action> getNodeConnectActions() {
311 return nodeConnectActions;
315 * Returns the “disconnect from node” action.
317 * @return The “disconnect from node” action
319 I18nAction getNodeDisconnectAction() {
320 return nodeDisconnectAction;
324 * Returns all “disconnect node” actions.
326 * @return All “disconnect node” action
328 List<Action> getNodeDisconnectActions() {
329 return nodeDisconnectActions;
333 * Returns all language actions.
335 * @return All language actions
337 List<I18nAction> getLanguageActions() {
338 return languageActions;
342 * Returns the “about” action.
344 * @return The “about” action
346 I18nAction getHelpAboutAction() {
347 return helpAboutAction;
351 * Returns the “add project” action.
353 * @return The “add project” action
355 I18nAction getAddProjectAction() {
356 return addProjectAction;
360 * Returns the “clone project” action.
362 * @return The “clone project” action
364 I18nAction getCloneProjectAction() {
365 return cloneProjectAction;
369 * Returns the “delete project” action.
371 * @return The “delete project” action
373 I18nAction getDeleteProjectAction() {
374 return deleteProjectAction;
378 * Returns the request table model.
380 * @return The request table model
382 RequestTableModel getRequestTableModel() {
383 return requestTableModel;
399 * Loads the configuration of the interface.
401 private void loadConfig() {
402 /* initialize default stuff. */
404 /* now read config. */
405 File configFile = new File(configDirectory, "swing-interface.properties");
406 if (!configFile.exists() || !configFile.canRead() || !configFile.isFile()) {
407 System.err.println("could not find “" + configFile.getAbsolutePath() + "”!");
410 Properties configProperties = new Properties();
411 FileInputStream configInputStream = null;
413 configInputStream = new FileInputStream(configFile);
414 configProperties.load(configInputStream);
415 } catch (IOException ioe1) {
416 System.err.println("could not load config, " + ioe1.getMessage());
418 Closer.close(configInputStream);
420 if (configProperties.containsKey("advancedMode")) {
421 advancedMode = Boolean.valueOf(configProperties.getProperty("advancedMode"));
423 if (configProperties.containsKey("antialias")) {
424 antialias = Boolean.valueOf(configProperties.getProperty("antialias"));
426 if (configProperties.containsKey("controlFont")) {
427 controlFont = configProperties.getProperty("controlFont");
429 if (configProperties.containsKey("userFont")) {
430 userFont = configProperties.getProperty("userFont");
432 if (configProperties.containsKey("lookAndFeel")) {
433 lookAndFeel = configProperties.getProperty("lookAndFeel");
435 if (configProperties.containsKey("language")) {
436 I18n.setLocale(new Locale(configProperties.getProperty("language")));
438 if (configProperties.containsKey("mainWindowX")) {
439 mainWindowX = Integer.valueOf(configProperties.getProperty("mainWindowX"));
441 if (configProperties.containsKey("mainWindowY")) {
442 mainWindowY = Integer.valueOf(configProperties.getProperty("mainWindowY"));
444 if (configProperties.containsKey("mainWindowWidth")) {
445 mainWindowWidth = Integer.valueOf(configProperties.getProperty("mainWindowWidth"));
447 if (configProperties.containsKey("mainWindowHeight")) {
448 mainWindowHeight = Integer.valueOf(configProperties.getProperty("mainWindowHeight"));
453 * Saves the configuration.
455 private void saveConfig() {
456 File configDirectory = new File(this.configDirectory);
457 if (!configDirectory.exists()) {
458 if (!configDirectory.mkdirs()) {
459 System.err.println("could not create “" + this.configDirectory + "”!");
463 if (!configDirectory.exists() || !configDirectory.isDirectory() || !configDirectory.canWrite()) {
464 System.err.println("can not access “" + this.configDirectory + "”!");
467 File configFile = new File(configDirectory, "swing-interface.properties");
468 Properties configProperties = new Properties();
469 configProperties.setProperty("advancedMode", String.valueOf(advancedMode));
470 configProperties.setProperty("antialias", String.valueOf(antialias));
471 if (controlFont != null) {
472 configProperties.setProperty("controlFont", controlFont);
474 if (userFont != null) {
475 configProperties.setProperty("userFont", userFont);
477 if (lookAndFeel != null) {
478 configProperties.setProperty("lookAndFeel", lookAndFeel);
480 configProperties.setProperty("language", I18n.getLocale().getLanguage());
481 configProperties.setProperty("mainWindowX", String.valueOf(mainWindowX));
482 configProperties.setProperty("mainWindowY", String.valueOf(mainWindowY));
483 configProperties.setProperty("mainWindowWidth", String.valueOf(mainWindowWidth));
484 configProperties.setProperty("mainWindowHeight", String.valueOf(mainWindowHeight));
485 FileOutputStream configOutputStream = null;
487 configOutputStream = new FileOutputStream(configFile);
488 configProperties.store(configOutputStream, "configuration of swing interface");
489 } catch (IOException ioe1) {
490 System.err.println("could not save config, " + ioe1.getMessage());
492 Closer.close(configOutputStream);
497 * Initializes all actions.
499 private void initActions() {
500 configureAction = new I18nAction("mainWindow.menu.jSite.configure", IconLoader.loadIcon("/preferences-system.png")) {
505 @SuppressWarnings("synthetic-access")
506 public void actionPerformed(ActionEvent actionEvent) {
510 importConfigAction = new I18nAction("mainWindow.menu.jSite.importConfig") {
515 @SuppressWarnings("synthetic-access")
516 public void actionPerformed(ActionEvent actionEvent) {
520 quitAction = new I18nAction("mainWindow.menu.jSite.quit", IconLoader.loadIcon("/system-log-out.png")) {
525 @SuppressWarnings("synthetic-access")
526 public void actionPerformed(ActionEvent actionEvent) {
530 manageNodesAction = new I18nAction("mainWindow.menu.node.item.manageNodes") {
535 @SuppressWarnings("synthetic-access")
536 public void actionPerformed(ActionEvent actionEvent) {
540 nodeConnectAction = new I18nAction("mainWindow.menu.node.item.connect", false) {
542 @SuppressWarnings("synthetic-access")
543 public void actionPerformed(ActionEvent actionEvent) {
544 List<Node> nodes = core.getNodes();
545 if (nodes.isEmpty()) {
548 nodeConnect(nodes.get(0));
552 nodeDisconnectAction = new I18nAction("mainWindow.menu.node.item.disconnect", false) {
557 @SuppressWarnings("synthetic-access")
558 public void actionPerformed(ActionEvent e) {
559 List<Node> nodes = core.getNodes();
560 if (nodes.isEmpty()) {
563 nodeDisconnect(nodes.get(0));
566 rebuildNodeActions(core.getNodes());
567 List<Locale> availableLanguages = I18n.findAvailableLanguages();
568 for (final Locale locale: availableLanguages) {
569 I18nAction languageAction = new I18nAction("general.language." + locale.getLanguage()) {
571 @SuppressWarnings("synthetic-access")
572 public void actionPerformed(ActionEvent e) {
573 changeLanguage(locale, this);
577 if (I18n.getLocale().getLanguage().equals(locale.getLanguage())) {
578 languageAction.setEnabled(false);
580 languageActions.add(languageAction);
582 helpAboutAction = new I18nAction("mainWindow.menu.help.item.about") {
587 @SuppressWarnings("synthetic-access")
588 public void actionPerformed(ActionEvent actionEvent) {
592 addProjectAction = new I18nAction("mainWindow.button.addProject") {
597 @SuppressWarnings("synthetic-access")
598 public void actionPerformed(ActionEvent actionEvent) {
602 cloneProjectAction = new I18nAction("mainWindow.button.cloneProject") {
607 @SuppressWarnings("synthetic-access")
608 public void actionPerformed(ActionEvent actionEvent) {
612 deleteProjectAction = new I18nAction("mainWindow.button.deleteProject") {
617 @SuppressWarnings("synthetic-access")
618 public void actionPerformed(ActionEvent actionEvent) {
625 * Initializes all child dialogs.
627 private void initDialogs() {
628 manageNodesDialog = new ManageNodesDialog(this);
629 aboutDialog = new AboutDialog(this);
630 configurationDialog = new ConfigurationDialog(this);
638 * Shows the configuration dialog.
640 private void configure() {
641 configurationDialog.setAdvancedMode(advancedMode);
642 configurationDialog.setAntialias(antialias);
643 configurationDialog.setControlFont(controlFont);
644 configurationDialog.setUserFont(userFont);
645 configurationDialog.setLookAndFeel(lookAndFeel);
646 configurationDialog.setVisible(true);
647 if (!configurationDialog.wasCancelled()) {
648 advancedMode = configurationDialog.isAdvancedMode();
649 if (!advancedMode && (nodeList.size() > 1)) {
650 JOptionPane.showMessageDialog(mainWindow, I18n.get("mainWindow.warning.multipleNodesNotAdvancedMode.message"), I18n.get("mainWindow.warning.multipleNodesNotAdvancedMode.title"), JOptionPane.WARNING_MESSAGE);
652 mainWindow.setAdvancedMode(advancedMode);
653 antialias = configurationDialog.isAntialias();
654 controlFont = configurationDialog.getControlFont();
655 userFont = configurationDialog.getUserFont();
656 lookAndFeel = configurationDialog.getLookAndFeel();
662 * Imports old jSite configuration.
664 private void importConfig() {
671 private void quit() {
674 mainWindowX = mainWindow.getX();
675 mainWindowY = mainWindow.getY();
676 mainWindowWidth = mainWindow.getWidth();
677 mainWindowHeight = mainWindow.getHeight();
683 * Rebuilds all node connect and disconnect actions.
688 private void rebuildNodeActions(List<Node> nodes) {
689 logger.fine("rebuilding node actions…");
690 nodeConnectActions.clear();
691 nodeNodeConnectActions.clear();
692 nodeConnectActionNodes.clear();
693 nodeDisconnectActions.clear();
694 nodeNodeDisconnectActions.clear();
695 nodeDisconnectActionNodes.clear();
696 for (Node node: nodes) {
697 logger.finer("adding node “" + node + "” to menus");
698 Action nodeConnectAction = new AbstractAction(node.getName()) {
703 @SuppressWarnings("synthetic-access")
704 public void actionPerformed(ActionEvent e) {
705 Node node = nodeConnectActionNodes.get(this);
709 nodeConnectActions.add(nodeConnectAction);
710 nodeConnectActionNodes.put(nodeConnectAction, node);
711 nodeNodeConnectActions.put(node, nodeConnectAction);
712 Action nodeDisconnectAction = new AbstractAction(node.getName()) {
717 @SuppressWarnings("synthetic-access")
718 public void actionPerformed(ActionEvent e) {
719 Node node = nodeDisconnectActionNodes.get(this);
720 nodeDisconnect(node);
723 // nodeDisconnectActions.add(nodeDisconnectAction);
724 nodeDisconnectActionNodes.put(nodeDisconnectAction, node);
725 nodeNodeDisconnectActions.put(node, nodeDisconnectAction);
730 * Pops up the “manage nodes” dialog.
732 private void manageNodes() {
734 manageNodesDialog.setNodeList(nodeList);
735 manageNodesDialog.setVisible(true);
736 nodeList = manageNodesDialog.getNodeList();
737 rebuildNodeActions(nodeList);
738 mainWindow.refreshNodeMenuItems();
740 if (nodeList.isEmpty()) {
741 Node newNode = new Node();
742 newNode.setName(I18n.get("general.defaultNode.name"));
743 newNode.setHostname("localhost");
744 newNode.setPort(9481);
745 nodeList.add(newNode);
747 Node firstNode = nodeList.get(0);
748 EditNodeDialog editNodeDialog = manageNodesDialog.getEditNodeDialog();
749 editNodeDialog.setNodeName(firstNode.getName());
750 editNodeDialog.setNodeHostname(firstNode.getHostname());
751 editNodeDialog.setNodePort(firstNode.getPort());
752 editNodeDialog.setVisible(true);
753 if (!editNodeDialog.wasCancelled()) {
754 firstNode.setName(editNodeDialog.getNodeName());
755 firstNode.setHostname(editNodeDialog.getNodeHostname());
756 firstNode.setPort(editNodeDialog.getNodePort());
757 /* TODO - give to core. */
763 * Connects to the node.
766 * The node to connect to
768 private void nodeConnect(final Node node) {
769 threadPool.execute(new Runnable() {
774 @SuppressWarnings("synthetic-access")
776 logger.log(Level.INFO, "connecting to node “" + node.getName() + "”…");
777 core.connectToNode(node);
783 * Disconnects from the node.
786 * The node to disconnect from
788 private void nodeDisconnect(Node node) {
789 logger.log(Level.INFO, "disconnecting from node “" + node.getName() + "”…");
790 core.disconnectFromNode(node);
794 * Changes the language of the interface. This method also disables the
795 * action for the newly set language and enables all others.
799 * @param languageAction
800 * The action that triggered the change
802 private void changeLanguage(Locale newLocale, I18nAction languageAction) {
803 for (I18nAction i18nAction: languageActions) {
804 i18nAction.setEnabled(i18nAction != languageAction);
806 I18n.setLocale(newLocale);
810 * Shows the “about” dialog.
812 private void helpAbout() {
813 aboutDialog.setVisible(true);
819 private void addProject() {
821 Project project = core.createProject();
822 project.setName(I18n.get("")); /* TODO - i18n */
823 project.setDescription(I18n.get("")); /* TODO - i18n */
824 System.out.println("private: " + project.getPrivateKey() + ", public: " + project.getPublicKey());
825 mainWindow.addProject(project);
826 } catch (NoNodeException nne1) {
827 /* TODO - add i18n */
828 JOptionPane.showMessageDialog(mainWindow, I18n.get(""), I18n.get(""), JOptionPane.ERROR_MESSAGE);
829 } catch (IOException e) {
830 /* TODO - add i18n */
831 JOptionPane.showMessageDialog(mainWindow, I18n.get(""), I18n.get(""), JOptionPane.ERROR_MESSAGE);
838 private void cloneProject() {
845 private void deleteProject() {
850 // INTERFACE CoreListener
856 public void loadingProjectsDone(String directory) {
857 mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.projectLoadingDone"));
863 public void loadingProjectsFailed(String directory, Throwable throwable) {
864 JOptionPane.showMessageDialog(mainWindow, I18n.get("mainWindow.error.projectLoadingFailed.message", directory), I18n.get("mainWindow.error.projectLoadingFailed.title"), JOptionPane.ERROR_MESSAGE);
870 public void savingProjectsDone(String directory) {
871 mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.projectSavingDone"));
877 public void savingProjectsFailed(String directory, Throwable throwabled) {
884 public void loadingNodesDone(String directory) {
885 mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.loadingNodesDone"));
891 public void loadingNodesFailed(String directory, Throwable throwable) {
898 public void savingNodesDone(String directory) {
899 mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.savingNodesDone"));
905 public void savingNodesFailed(String directory, Throwable throwable) {
912 public void coreLoaded() {
913 mainWindow.setVisible(true);
914 mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.coreLoaded"));
920 public void coreStopped() {
921 mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.coreStopped"));
927 public void nodeAdded(Node node) {
928 logger.log(Level.INFO, "node added: " + node);
930 logger.log(Level.FINE, "nodeList.size(): " + nodeList.size());
931 manageNodesDialog.setNodeList(nodeList);
932 rebuildNodeActions(nodeList);
933 mainWindow.refreshNodeMenuItems();
939 public void nodeRemoved(Node node) {
940 logger.log(Level.INFO, "node removed: " + node);
941 nodeList.remove(node);
942 rebuildNodeActions(nodeList);
943 mainWindow.refreshNodeMenuItems();
949 public void nodeConnecting(Node node) {
950 Action nodeConnectAction = nodeNodeConnectActions.get(node);
951 nodeConnectActions.remove(nodeConnectAction);
952 mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.connectingToNode", node.getName(), node.getHostname(), node.getPort()));
953 mainWindow.refreshNodeMenuItems();
959 public void nodeConnected(Node node) {
960 Action nodeDisconnectAction = nodeNodeDisconnectActions.get(node);
961 nodeDisconnectActions.add(nodeDisconnectAction);
962 mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.connectedToNode", node.getName(), node.getHostname(), node.getPort()));
963 mainWindow.refreshNodeMenuItems();
969 public void nodeConnectionFailed(Node node, Throwable cause) {
970 Action nodeConnectAction = nodeNodeConnectActions.get(node);
971 nodeConnectActions.add(nodeConnectAction);
972 mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.connectionToNodeFailed", node.getName(), node.getHostname(), node.getPort(), (cause != null) ? cause.getMessage() : "no reason given"));
973 JOptionPane.showMessageDialog(mainWindow, I18n.get("mainWindow.error.nodeConnectionFailed.message", node.getName(), node.getHostname(), node.getPort(), (cause != null) ? cause.getMessage() : "no reason given"), I18n.get("mainWindow.error.nodeConnectionFailed.title"), JOptionPane.ERROR_MESSAGE);
974 mainWindow.refreshNodeMenuItems();
980 public void nodeDisconnected(Node node, Throwable throwable) {
981 Action nodeConnectAction = nodeNodeConnectActions.get(node);
982 nodeConnectActions.add(nodeConnectAction);
983 Action nodeDisconnectAction = nodeNodeDisconnectActions.get(node);
984 nodeDisconnectActions.remove(nodeDisconnectAction);
985 mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.disconnectedFromNode", node.getName(), node.getHostname(), node.getPort()));
986 mainWindow.refreshNodeMenuItems();
992 public void requestAdded(Request request) {
993 logger.log(Level.INFO, "request added to node: " + request + ", " + request.getNode());
994 /* TODO - implement */
995 requestTableModel.addRequest(request);
1001 public void requestProgressed(Request request) {
1002 /* TODO - update table model */
1006 * @see net.pterodactylus.jsite.core.CoreListener#requestRemoved(net.pterodactylus.jsite.core.Request)
1008 public void requestRemoved(Request request) {
1009 requestTableModel.removeRequest(request);
1013 // INTERFACE LoggingListener
1019 public void logged(LogRecord logRecord) {
1020 logWindow.logged(logRecord);