X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FSwingInterface.java;h=6f97944ac34a097d3e383a972adb305c38549a02;hb=10b165ebaa51eccec487500b32f0c7b3106923af;hp=b5d651bd457934bc9fed36ce4f818dfc8fe59e46;hpb=aa72bfe9c0d91f7339a70218aa50824e2b321780;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/gui/SwingInterface.java b/src/net/pterodactylus/jsite/gui/SwingInterface.java index b5d651b..6f97944 100644 --- a/src/net/pterodactylus/jsite/gui/SwingInterface.java +++ b/src/net/pterodactylus/jsite/gui/SwingInterface.java @@ -25,27 +25,48 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Properties; - +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import javax.swing.AbstractAction; +import javax.swing.Action; import javax.swing.JOptionPane; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; import net.pterodactylus.jsite.core.Core; import net.pterodactylus.jsite.core.CoreListener; +import net.pterodactylus.jsite.core.JSiteException; import net.pterodactylus.jsite.core.Node; -import net.pterodactylus.jsite.core.Project; +import net.pterodactylus.jsite.core.Request; import net.pterodactylus.jsite.i18n.I18n; import net.pterodactylus.jsite.i18n.gui.I18nAction; +import net.pterodactylus.jsite.project.Project; +import net.pterodactylus.util.image.IconLoader; import net.pterodactylus.util.io.Closer; +import net.pterodactylus.util.logging.Logging; +import net.pterodactylus.util.logging.LoggingListener; /** * The Swing user interface. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> * @version $Id$ */ -public class SwingInterface implements CoreListener { +public class SwingInterface implements CoreListener, LoggingListener { + + /** The logger. */ + private static final Logger logger = Logging.getLogger(SwingInterface.class.getName()); /** The application core. */ private final Core core; @@ -56,6 +77,12 @@ public class SwingInterface implements CoreListener { /** The main window. */ private MainWindow mainWindow; + /** Thread pool. */ + private Executor threadPool = Executors.newCachedThreadPool(); + + /** The logger window. */ + private LogWindow logWindow; + /** The “configure” action. */ private I18nAction configureAction; @@ -68,12 +95,30 @@ public class SwingInterface implements CoreListener { /** The “manage nodes” action. */ private I18nAction manageNodesAction; - /** The “connect to node” action. */ + /** The “connect to node” (simple mode) action. */ private I18nAction nodeConnectAction; - /** The “disconnect from node” action. */ + /** The “disconnect from node” (simple mode) action. */ private I18nAction nodeDisconnectAction; + /** All node menu items. */ + private List nodeConnectActions = Collections.synchronizedList(new ArrayList()); + + /** Mapping from nodes to node connect actions. */ + private Map nodeNodeConnectActions = Collections.synchronizedMap(new HashMap()); + + /** Mapping from node connect actions to nodes. */ + private Map nodeConnectActionNodes = Collections.synchronizedMap(new HashMap()); + + /** All node disconnect actions. */ + private List nodeDisconnectActions = Collections.synchronizedList(new ArrayList()); + + /** Mapping from nodes to node disconnect actions. */ + private Map nodeNodeDisconnectActions = Collections.synchronizedMap(new HashMap()); + + /** Mapping from node disconnect actions to nodes. */ + private Map nodeDisconnectActionNodes = Collections.synchronizedMap(new HashMap()); + /** The node manager dialog. */ private ManageNodesDialog manageNodesDialog; @@ -99,12 +144,18 @@ public class SwingInterface implements CoreListener { private ConfigurationDialog configurationDialog; /** The list of all defined nodes. */ - private List nodeList; + private List nodeList = Collections.synchronizedList(new ArrayList()); + + /** The request table model. */ + private RequestTableModel requestTableModel = new RequestTableModel(); // // CONFIGURATION // + /** The advanced mode. */ + private boolean advancedMode; + /** Whether to antialias the GUI. */ private boolean antialias; @@ -114,9 +165,24 @@ public class SwingInterface implements CoreListener { /** The user font. */ private String userFont; + /** The class name of the look and feel. */ + private String lookAndFeel; + + /** X coordinate of the main window. */ + private int mainWindowX = -1; + + /** Y coordinate of the main window. */ + private int mainWindowY = -1; + + /** Width of the main window. */ + private int mainWindowWidth = -1; + + /** Height of the main window. */ + private int mainWindowHeight = -1; + /** * Creates a new swing interface. - * + * * @param core * The core to operate on * @param configDirectory @@ -127,6 +193,19 @@ public class SwingInterface implements CoreListener { this.configDirectory = configDirectory; I18n.setLocale(Locale.ENGLISH); loadConfig(); + if (lookAndFeel != null) { + try { + UIManager.setLookAndFeel(lookAndFeel); + } catch (ClassNotFoundException cnfe1) { + logger.log(Level.WARNING, "could not load look and feel", cnfe1); + } catch (InstantiationException ie1) { + logger.log(Level.WARNING, "could not load look and feel", ie1); + } catch (IllegalAccessException iae1) { + logger.log(Level.WARNING, "could not load look and feel", iae1); + } catch (UnsupportedLookAndFeelException ulafe1) { + logger.log(Level.WARNING, "could not load look and feel", ulafe1); + } + } if (antialias) { System.setProperty("swing.aatext", "true"); } @@ -138,6 +217,13 @@ public class SwingInterface implements CoreListener { } initActions(); initDialogs(); + mainWindow = new MainWindow(this); + mainWindow.setAdvancedMode(advancedMode); + if ((mainWindowX != -1) && (mainWindowY != -1) && (mainWindowWidth != -1) && (mainWindowHeight != -1)) { + mainWindow.setLocation(mainWindowX, mainWindowY); + mainWindow.setSize(mainWindowWidth, mainWindowHeight); + } + logWindow = new LogWindow(); } // @@ -146,7 +232,7 @@ public class SwingInterface implements CoreListener { /** * Returns the core that is controlled by the Swing interface. - * + * * @return The core */ Core getCore() { @@ -155,7 +241,7 @@ public class SwingInterface implements CoreListener { /** * Returns the main window of the Swing interface. - * + * * @return The main window */ MainWindow getMainWindow() { @@ -163,8 +249,18 @@ public class SwingInterface implements CoreListener { } /** + * Returns whether the advanced mode is activated. + * + * @return true if the advanced mode is activated, + * false if the simple mode is activated + */ + boolean isAdvancedMode() { + return advancedMode; + } + + /** * Returns the “configure” action. - * + * * @return The “configure” action */ I18nAction getConfigureAction() { @@ -173,7 +269,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “import config” action. - * + * * @return The “import config” action */ I18nAction getImportConfigAction() { @@ -182,7 +278,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “quit” action. - * + * * @return The “quit” action */ I18nAction getQuitAction() { @@ -191,7 +287,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “manage nodes” action. - * + * * @return The “manage nodes” action */ I18nAction getManageNodesAction() { @@ -200,7 +296,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “connect to node” action. - * + * * @return The “connect to node” action */ I18nAction getNodeConnectAction() { @@ -208,8 +304,17 @@ public class SwingInterface implements CoreListener { } /** + * Returns all “connect node” actions. + * + * @return All “connect node” actions + */ + List getNodeConnectActions() { + return nodeConnectActions; + } + + /** * Returns the “disconnect from node” action. - * + * * @return The “disconnect from node” action */ I18nAction getNodeDisconnectAction() { @@ -217,8 +322,17 @@ public class SwingInterface implements CoreListener { } /** + * Returns all “disconnect node” actions. + * + * @return All “disconnect node” action + */ + List getNodeDisconnectActions() { + return nodeDisconnectActions; + } + + /** * Returns all language actions. - * + * * @return All language actions */ List getLanguageActions() { @@ -227,7 +341,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “about” action. - * + * * @return The “about” action */ I18nAction getHelpAboutAction() { @@ -236,7 +350,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “add project” action. - * + * * @return The “add project” action */ I18nAction getAddProjectAction() { @@ -245,7 +359,7 @@ public class SwingInterface implements CoreListener { /** * Returns the “clone project” action. - * + * * @return The “clone project” action */ I18nAction getCloneProjectAction() { @@ -254,13 +368,22 @@ public class SwingInterface implements CoreListener { /** * Returns the “delete project” action. - * + * * @return The “delete project” action */ I18nAction getDeleteProjectAction() { return deleteProjectAction; } + /** + * Returns the request table model. + * + * @return The request table model + */ + RequestTableModel getRequestTableModel() { + return requestTableModel; + } + // // ACTIONS // @@ -269,13 +392,6 @@ public class SwingInterface implements CoreListener { // SERVICE METHODS // - /** - * Starts the interface. - */ - public void start() { - mainWindow = new MainWindow(this); - } - // // PRIVATE METHODS // @@ -302,6 +418,9 @@ public class SwingInterface implements CoreListener { } finally { Closer.close(configInputStream); } + if (configProperties.containsKey("advancedMode")) { + advancedMode = Boolean.valueOf(configProperties.getProperty("advancedMode")); + } if (configProperties.containsKey("antialias")) { antialias = Boolean.valueOf(configProperties.getProperty("antialias")); } @@ -311,6 +430,24 @@ public class SwingInterface implements CoreListener { if (configProperties.containsKey("userFont")) { userFont = configProperties.getProperty("userFont"); } + if (configProperties.containsKey("lookAndFeel")) { + lookAndFeel = configProperties.getProperty("lookAndFeel"); + } + if (configProperties.containsKey("language")) { + I18n.setLocale(new Locale(configProperties.getProperty("language"))); + } + if (configProperties.containsKey("mainWindowX")) { + mainWindowX = Integer.valueOf(configProperties.getProperty("mainWindowX")); + } + if (configProperties.containsKey("mainWindowY")) { + mainWindowY = Integer.valueOf(configProperties.getProperty("mainWindowY")); + } + if (configProperties.containsKey("mainWindowWidth")) { + mainWindowWidth = Integer.valueOf(configProperties.getProperty("mainWindowWidth")); + } + if (configProperties.containsKey("mainWindowHeight")) { + mainWindowHeight = Integer.valueOf(configProperties.getProperty("mainWindowHeight")); + } } /** @@ -330,6 +467,7 @@ public class SwingInterface implements CoreListener { } File configFile = new File(configDirectory, "swing-interface.properties"); Properties configProperties = new Properties(); + configProperties.setProperty("advancedMode", String.valueOf(advancedMode)); configProperties.setProperty("antialias", String.valueOf(antialias)); if (controlFont != null) { configProperties.setProperty("controlFont", controlFont); @@ -337,6 +475,14 @@ public class SwingInterface implements CoreListener { if (userFont != null) { configProperties.setProperty("userFont", userFont); } + if (lookAndFeel != null) { + configProperties.setProperty("lookAndFeel", lookAndFeel); + } + configProperties.setProperty("language", I18n.getLocale().getLanguage()); + configProperties.setProperty("mainWindowX", String.valueOf(mainWindowX)); + configProperties.setProperty("mainWindowY", String.valueOf(mainWindowY)); + configProperties.setProperty("mainWindowWidth", String.valueOf(mainWindowWidth)); + configProperties.setProperty("mainWindowHeight", String.valueOf(mainWindowHeight)); FileOutputStream configOutputStream = null; try { configOutputStream = new FileOutputStream(configFile); @@ -352,7 +498,7 @@ public class SwingInterface implements CoreListener { * Initializes all actions. */ private void initActions() { - configureAction = new I18nAction("mainWindow.menu.jSite.configure") { + configureAction = new I18nAction("mainWindow.menu.jSite.configure", IconLoader.loadIcon("/preferences-system.png")) { /** * {@inheritDoc} @@ -372,7 +518,7 @@ public class SwingInterface implements CoreListener { importConfig(); } }; - quitAction = new I18nAction("mainWindow.menu.jSite.quit") { + quitAction = new I18nAction("mainWindow.menu.jSite.quit", IconLoader.loadIcon("/system-log-out.png")) { /** * {@inheritDoc} @@ -396,7 +542,11 @@ public class SwingInterface implements CoreListener { @SuppressWarnings("synthetic-access") public void actionPerformed(ActionEvent actionEvent) { - nodeConnect(); + List nodes = core.getNodes(); + if (nodes.isEmpty()) { + return; + } + nodeConnect(nodes.get(0)); } }; @@ -407,9 +557,14 @@ public class SwingInterface implements CoreListener { */ @SuppressWarnings("synthetic-access") public void actionPerformed(ActionEvent e) { - nodeDisconnect(); + List nodes = core.getNodes(); + if (nodes.isEmpty()) { + return; + } + nodeDisconnect(nodes.get(0)); } }; + rebuildNodeActions(core.getNodes()); List availableLanguages = I18n.findAvailableLanguages(); for (final Locale locale: availableLanguages) { I18nAction languageAction = new I18nAction("general.language." + locale.getLanguage()) { @@ -484,14 +639,22 @@ public class SwingInterface implements CoreListener { * Shows the configuration dialog. */ private void configure() { + configurationDialog.setAdvancedMode(advancedMode); configurationDialog.setAntialias(antialias); configurationDialog.setControlFont(controlFont); configurationDialog.setUserFont(userFont); + configurationDialog.setLookAndFeel(lookAndFeel); configurationDialog.setVisible(true); if (!configurationDialog.wasCancelled()) { + advancedMode = configurationDialog.isAdvancedMode(); + if (!advancedMode && (nodeList.size() > 1)) { + JOptionPane.showMessageDialog(mainWindow, I18n.get("mainWindow.warning.multipleNodesNotAdvancedMode.message"), I18n.get("mainWindow.warning.multipleNodesNotAdvancedMode.title"), JOptionPane.WARNING_MESSAGE); + } + mainWindow.setAdvancedMode(advancedMode); antialias = configurationDialog.isAntialias(); controlFont = configurationDialog.getControlFont(); userFont = configurationDialog.getUserFont(); + lookAndFeel = configurationDialog.getLookAndFeel(); saveConfig(); } } @@ -500,41 +663,138 @@ public class SwingInterface implements CoreListener { * Imports old jSite configuration. */ private void importConfig() { + /* TODO */ } /** * Quits jSite. */ private void quit() { + /* TODO - ask */ + core.stop(); + mainWindowX = mainWindow.getX(); + mainWindowY = mainWindow.getY(); + mainWindowWidth = mainWindow.getWidth(); + mainWindowHeight = mainWindow.getHeight(); saveConfig(); System.exit(0); } /** + * Rebuilds all node connect and disconnect actions. + * + * @param nodes + * The list of nodes + */ + private void rebuildNodeActions(List nodes) { + logger.fine("rebuilding node actions…"); + nodeConnectActions.clear(); + nodeNodeConnectActions.clear(); + nodeConnectActionNodes.clear(); + nodeDisconnectActions.clear(); + nodeNodeDisconnectActions.clear(); + nodeDisconnectActionNodes.clear(); + for (Node node: nodes) { + logger.finer("adding node “" + node + "” to menus"); + Action nodeConnectAction = new AbstractAction(node.getName()) { + + /** + * {@inheritDoc} + */ + @SuppressWarnings("synthetic-access") + public void actionPerformed(ActionEvent e) { + Node node = nodeConnectActionNodes.get(this); + nodeConnect(node); + } + }; + nodeConnectActions.add(nodeConnectAction); + nodeConnectActionNodes.put(nodeConnectAction, node); + nodeNodeConnectActions.put(node, nodeConnectAction); + Action nodeDisconnectAction = new AbstractAction(node.getName()) { + + /** + * {@inheritDoc} + */ + @SuppressWarnings("synthetic-access") + public void actionPerformed(ActionEvent e) { + Node node = nodeDisconnectActionNodes.get(this); + nodeDisconnect(node); + } + }; + // nodeDisconnectActions.add(nodeDisconnectAction); + nodeDisconnectActionNodes.put(nodeDisconnectAction, node); + nodeNodeDisconnectActions.put(node, nodeDisconnectAction); + } + } + + /** * Pops up the “manage nodes” dialog. */ private void manageNodes() { - manageNodesDialog.setNodeList(nodeList); - manageNodesDialog.setVisible(true); - nodeList = manageNodesDialog.getNodeList(); + if (advancedMode) { + manageNodesDialog.setNodeList(nodeList); + manageNodesDialog.setVisible(true); + nodeList = manageNodesDialog.getNodeList(); + rebuildNodeActions(nodeList); + mainWindow.refreshNodeMenuItems(); + } else { + if (nodeList.isEmpty()) { + Node newNode = new Node(); + newNode.setName(I18n.get("general.defaultNode.name")); + newNode.setHostname("localhost"); + newNode.setPort(9481); + nodeList.add(newNode); + } + Node firstNode = nodeList.get(0); + EditNodeDialog editNodeDialog = manageNodesDialog.getEditNodeDialog(); + editNodeDialog.setNodeName(firstNode.getName()); + editNodeDialog.setNodeHostname(firstNode.getHostname()); + editNodeDialog.setNodePort(firstNode.getPort()); + editNodeDialog.setVisible(true); + if (!editNodeDialog.wasCancelled()) { + firstNode.setName(editNodeDialog.getNodeName()); + firstNode.setHostname(editNodeDialog.getNodeHostname()); + firstNode.setPort(editNodeDialog.getNodePort()); + /* TODO - give to core. */ + } + } } /** * Connects to the node. + * + * @param node + * The node to connect to */ - private void nodeConnect() { + private void nodeConnect(final Node node) { + threadPool.execute(new Runnable() { + + /** + * {@inheritDoc} + */ + @SuppressWarnings("synthetic-access") + public void run() { + logger.log(Level.INFO, "connecting to node “" + node.getName() + "”…"); + core.connectToNode(node); + } + }); } /** * Disconnects from the node. + * + * @param node + * The node to disconnect from */ - private void nodeDisconnect() { + private void nodeDisconnect(Node node) { + logger.log(Level.INFO, "disconnecting from node “" + node.getName() + "”…"); + core.disconnectFromNode(node); } /** * Changes the language of the interface. This method also disables the * action for the newly set language and enables all others. - * + * * @param newLocale * The new language * @param languageAction @@ -558,21 +818,32 @@ public class SwingInterface implements CoreListener { * Adds a project. */ private void addProject() { - Project project = new Project(); - project.setName("New Project"); - project.setDescription(""); + try { + Project project = core.createProject(); + mainWindow.addProject(project); + project.setName(I18n.get("general.newProject.name")); + project.setDescription(I18n.get("general.newProject.description", new Date())); + } catch (JSiteException nne1) { + /* TODO - add i18n */ + JOptionPane.showMessageDialog(mainWindow, I18n.get(""), I18n.get(""), JOptionPane.ERROR_MESSAGE); + } catch (IOException e) { + /* TODO - add i18n */ + JOptionPane.showMessageDialog(mainWindow, I18n.get(""), I18n.get(""), JOptionPane.ERROR_MESSAGE); + } } /** * Clones a project. */ private void cloneProject() { + /* TODO */ } /** * Deletes a project. */ private void deleteProject() { + /* TODO */ } // @@ -582,36 +853,174 @@ public class SwingInterface implements CoreListener { /** * {@inheritDoc} */ - public void loadingProjectsFailed(String directory) { + public void loadingProjectsDone(String directory) { + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.projectLoadingDone")); + for (Project project: core.getProjects()) { + mainWindow.addProject(project); + } + } + + /** + * {@inheritDoc} + */ + public void loadingProjectsFailed(String directory, Throwable throwable) { JOptionPane.showMessageDialog(mainWindow, I18n.get("mainWindow.error.projectLoadingFailed.message", directory), I18n.get("mainWindow.error.projectLoadingFailed.title"), JOptionPane.ERROR_MESSAGE); } /** * {@inheritDoc} */ + public void savingProjectsDone(String directory) { + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.projectSavingDone")); + } + + /** + * {@inheritDoc} + */ + public void savingProjectsFailed(String directory, Throwable throwabled) { + /* TODO */ + } + + /** + * {@inheritDoc} + */ + public void loadingNodesDone(String directory) { + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.loadingNodesDone")); + } + + /** + * {@inheritDoc} + */ + public void loadingNodesFailed(String directory, Throwable throwable) { + /* TODO */ + } + + /** + * {@inheritDoc} + */ + public void savingNodesDone(String directory) { + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.savingNodesDone")); + } + + /** + * {@inheritDoc} + */ + public void savingNodesFailed(String directory, Throwable throwable) { + /* TODO */ + } + + /** + * {@inheritDoc} + */ public void coreLoaded() { - this.nodeList = core.getNodes(); - manageNodesDialog.setNodeList(nodeList); mainWindow.setVisible(true); - mainWindow.setStatusBarText("Core loaded."); + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.coreLoaded")); } /** * {@inheritDoc} */ - public void nodeConnected(Node node) { + public void coreStopped() { + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.coreStopped")); + } + + /** + * {@inheritDoc} + */ + public void nodeAdded(Node node) { + logger.log(Level.INFO, "node added: " + node); + nodeList.add(node); + logger.log(Level.FINE, "nodeList.size(): " + nodeList.size()); + manageNodesDialog.setNodeList(nodeList); + rebuildNodeActions(nodeList); + mainWindow.refreshNodeMenuItems(); + } + + /** + * {@inheritDoc} + */ + public void nodeRemoved(Node node) { + logger.log(Level.INFO, "node removed: " + node); + nodeList.remove(node); + rebuildNodeActions(nodeList); + mainWindow.refreshNodeMenuItems(); } /** * {@inheritDoc} */ public void nodeConnecting(Node node) { + Action nodeConnectAction = nodeNodeConnectActions.get(node); + nodeConnectActions.remove(nodeConnectAction); + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.connectingToNode", node.getName(), node.getHostname(), node.getPort())); + mainWindow.refreshNodeMenuItems(); + } + + /** + * {@inheritDoc} + */ + public void nodeConnected(Node node) { + Action nodeDisconnectAction = nodeNodeDisconnectActions.get(node); + nodeDisconnectActions.add(nodeDisconnectAction); + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.connectedToNode", node.getName(), node.getHostname(), node.getPort())); + mainWindow.refreshNodeMenuItems(); + } + + /** + * {@inheritDoc} + */ + public void nodeConnectionFailed(Node node, Throwable cause) { + Action nodeConnectAction = nodeNodeConnectActions.get(node); + nodeConnectActions.add(nodeConnectAction); + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.connectionToNodeFailed", node.getName(), node.getHostname(), node.getPort(), (cause != null) ? cause.getMessage() : "no reason given")); + 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); + mainWindow.refreshNodeMenuItems(); + } + + /** + * {@inheritDoc} + */ + public void nodeDisconnected(Node node, Throwable throwable) { + Action nodeConnectAction = nodeNodeConnectActions.get(node); + nodeConnectActions.add(nodeConnectAction); + Action nodeDisconnectAction = nodeNodeDisconnectActions.get(node); + nodeDisconnectActions.remove(nodeDisconnectAction); + mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.disconnectedFromNode", node.getName(), node.getHostname(), node.getPort())); + mainWindow.refreshNodeMenuItems(); + } + + /** + * {@inheritDoc} + */ + public void requestAdded(Request request) { + logger.log(Level.INFO, "request added to node: " + request + ", " + request.getNode()); + /* TODO - implement */ + requestTableModel.addRequest(request); + } + + /** + * {@inheritDoc} + */ + public void requestProgressed(Request request) { + /* TODO - update table model */ + } + + /** + * @see net.pterodactylus.jsite.core.CoreListener#requestRemoved(net.pterodactylus.jsite.core.Request) + */ + public void requestRemoved(Request request) { + requestTableModel.removeRequest(request); } + // + // INTERFACE LoggingListener + // + /** * {@inheritDoc} */ - public void nodeDisconnected(Node node) { + public void logged(LogRecord logRecord) { + logWindow.logged(logRecord); } }