/**
* The core of jSite.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
/** List of currently connected nodes. */
private List<Node> connectedNodes = new ArrayList<Node>();
- /**
- * Creates a new core.
- */
- public Core() {
- }
-
//
// LISTENER MANAGEMENT
//
/**
* Adds the given listener to the list of registered listeners.
- *
+ *
* @param coreListener
* The listener to add
*/
/**
* Removes the given listener from the list of registered listeners.
- *
+ *
* @param coreListener
* The listener to remove
*/
/**
* Notifies all core listeners that loading the projects from the given
* directory has failed.
- *
+ *
* @param directory
* The directory the projects were tried to load from
+ * @param throwable
+ * The exception that occured when loading projects
+ */
+ private void fireLoadingProjectsFailed(String directory, Throwable throwable) {
+ for (CoreListener coreListener: coreListeners) {
+ coreListener.loadingProjectsFailed(directory, throwable);
+ }
+ }
+
+ /**
+ * Notifies all listeners that the projects were successfully saved.
+ *
+ * @param directory
+ * The directory the projects were saved to
*/
- private void fireLoadingProjectsFailed(String directory) {
+ private void fireSavingProjectsDone(String directory) {
for (CoreListener coreListener: coreListeners) {
- coreListener.loadingProjectsFailed(directory);
+ coreListener.savingProjectsDone(directory);
+ }
+ }
+
+ /**
+ * Notifies all listeners that the projects could not be saved.
+ *
+ * @param directory
+ * The directory the projects were to be saved to
+ * @param throwable
+ * The exception that occured when saving the projects
+ */
+ private void fireSavingProjectsFailed(String directory, Throwable throwable) {
+ for (CoreListener coreListener: coreListeners) {
+ coreListener.savingProjectsFailed(directory, throwable);
}
}
}
}
+ /**
+ * Notifies all listeners that the core was stopped.
+ */
+ private void fireCoreStopped() {
+ for (CoreListener coreListener: coreListeners) {
+ coreListener.coreStopped();
+ }
+ }
+
//
// ACCESSORS
//
/**
* Returns the project manager.
- *
+ *
* @return The project manager
*/
public ProjectManager getProjectManager() {
/**
* Sets the project manager to use.
- *
+ *
* @param projectManager
* The project manager to use
*/
/**
* Returns the list of all configured nodes.
- *
+ *
* @return All configured nodes
*/
public List<Node> getNodes() {
/**
* Returns whether the core is currently connected to the given node.
- *
+ *
* @param node
* The node to check
* @return <code>true</code> if the core is currently connected to the
try {
projectManager.load();
} catch (IOException ioe1) {
- fireLoadingProjectsFailed(projectManager.getDirectory());
+ fireLoadingProjectsFailed(projectManager.getDirectory(), ioe1);
}
fireCoreLoaded();
}
/**
+ * Stops the core.
+ */
+ public void stop() {
+ try {
+ projectManager.save();
+ fireSavingProjectsDone(projectManager.getDirectory());
+ } catch (IOException ioe1) {
+ fireSavingProjectsFailed(projectManager.getDirectory(), ioe1);
+ }
+ fireCoreStopped();
+ }
+
+ /**
* Connects to the given node.
- *
+ *
* @param node
* The node to connect to
*/
public void connectToNode(Node node) {
+ /* TODO */
+ }
+
+ //
+ // PRIVATE METHODS
+ //
+
+ /**
+ * Loads the configuration.
+ */
+ @SuppressWarnings("unused")
+ private void loadConfig() {
+ /* TODO */
+ }
+
+ /**
+ * Saves the configuration.
+ */
+ @SuppressWarnings("unused")
+ private void saveConfig() {
+ /* TODO */
}
}
/**
* Interface definition for user interfaces.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
public interface CoreListener {
+ //
+ // configuration stuff
+ //
+
/**
* Notifies all listeners that loading the projects has failed.
- *
+ *
* @param directory
* The directory the projects were tried to load from
+ * @param throwable
+ * The exception that occured while saving, if any
+ */
+ public void loadingProjectsFailed(String directory, Throwable throwable);
+
+ /**
+ * Notifies a listener that the projects were successfully saved to the
+ * given directory.
+ *
+ * @param directory
+ * The directory the projects were saved to
*/
- public void loadingProjectsFailed(String directory);
+ public void savingProjectsDone(String directory);
+
+ /**
+ * Notifies a listener that saving the projects has failed.
+ *
+ * @param directory
+ * The directory the projects were to be saved to
+ * @param throwable
+ * The exception that occured when saving the projects, if any
+ */
+ public void savingProjectsFailed(String directory, Throwable throwable);
+
+ //
+ // basic core functionality
+ //
/**
* Notifies all listeners that the core has loaded.
public void coreLoaded();
/**
+ * Notifies a listener that the core was stopped.
+ */
+ public void coreStopped();
+
+ //
+ // node stuff
+ //
+
+ /**
* Notifies all listeners that the core started connecting to the given
* node.
- *
+ *
* @param node
* The node that is being connected
*/
/**
* Notifies all listeners that the core connected to the given node.
- *
+ *
* @param node
* The node that is connected
*/
/**
* Notifies all listeners that the core disconnected from the given node.
- *
+ *
* @param node
* The node that was diconnected
*/
actionCancel();
}
};
- antialiasAction = new I18nAction("configurationDialog.page.interface.item.antialias") {
+ antialiasAction = new I18nAction("configurationDialog.page.interfaceTweaks.item.antialias") {
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
/* do nothing. */
}
};
- useCustomControlFontAction = new I18nAction("configurationDialog.page.interface.item.useCustomControlFont") {
+ useCustomControlFontAction = new I18nAction("configurationDialog.page.interfaceTweaks.item.useCustomControlFont") {
/**
* {@inheritDoc}
controlFontSizeSpinner.setEnabled(selected);
}
};
- useCustomUserFontAction = new I18nAction("configurationDialog.page.interface.item.useCustomUserFont") {
+ useCustomUserFontAction = new I18nAction("configurationDialog.page.interfaceTweaks.item.useCustomUserFont") {
/**
* {@inheritDoc}
JTabbedPane tabbedPane = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
contentPane.add(tabbedPane, BorderLayout.CENTER);
+ JComponent interfaceConfig = createInterfaceConfig();
+ tabbedPane.add(I18n.get("configurationDialog.page.interface.name"), interfaceConfig);
+
JComponent interfaceTweaksConfig = createInterfaceTweaksConfig();
- tabbedPane.add(I18n.get("configurationDialog.page.interface.name"), interfaceTweaksConfig);
+ tabbedPane.add(I18n.get("configurationDialog.page.interfaceTweaks.name"), interfaceTweaksConfig);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 12, 12));
contentPane.add(buttonPanel, BorderLayout.PAGE_END);
}
/**
- * Creates the panel for the interface configuration.
+ * Creates the interface configuration panel.
*
* @return The interface configuration panel
*/
- private JComponent createInterfaceTweaksConfig() {
+ private JComponent createInterfaceConfig() {
JPanel interfaceConfigPanel = new JPanel(new GridBagLayout());
- interfaceConfigPanel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
+ return interfaceConfigPanel;
+ }
+
+ /**
+ * Creates the panel for the interface tweaks configuration.
+ *
+ * @return The interface tweaks configuration panel
+ */
+ private JComponent createInterfaceTweaksConfig() {
+ JPanel interfaceTweaksConfigPanel = new JPanel(new GridBagLayout());
+ interfaceTweaksConfigPanel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
- restartRequiredLabel = new I18nLabel("configurationDialog.page.interface.item.restartRequired");
- interfaceConfigPanel.add(restartRequiredLabel, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
+ restartRequiredLabel = new I18nLabel("configurationDialog.page.interfaceTweaks.item.restartRequired");
+ interfaceTweaksConfigPanel.add(restartRequiredLabel, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
antialiasCheckBox = new JCheckBox(antialiasAction);
- interfaceConfigPanel.add(antialiasCheckBox, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(18, 0, 0, 0), 0, 0));
+ interfaceTweaksConfigPanel.add(antialiasCheckBox, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(18, 0, 0, 0), 0, 0));
useCustomControlFontCheckBox = new JCheckBox(useCustomControlFontAction);
- interfaceConfigPanel.add(useCustomControlFontCheckBox, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 0, 0, 0), 0, 0));
+ interfaceTweaksConfigPanel.add(useCustomControlFontCheckBox, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 0, 0, 0), 0, 0));
controlFontList = new FontComboBox();
- interfaceConfigPanel.add(controlFontList, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
+ interfaceTweaksConfigPanel.add(controlFontList, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
controlFontSizeSpinner = new JSpinner(new SpinnerNumberModel(12, 6, 80, 1));
- interfaceConfigPanel.add(controlFontSizeSpinner, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
+ interfaceTweaksConfigPanel.add(controlFontSizeSpinner, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
useCustomUserFontCheckBox = new JCheckBox(useCustomUserFontAction);
- interfaceConfigPanel.add(useCustomUserFontCheckBox, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
+ interfaceTweaksConfigPanel.add(useCustomUserFontCheckBox, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
userFontList = new FontComboBox();
- interfaceConfigPanel.add(userFontList, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
+ interfaceTweaksConfigPanel.add(userFontList, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
userFontSizeSpinner = new JSpinner(new SpinnerNumberModel(12, 6, 80, 1));
- interfaceConfigPanel.add(userFontSizeSpinner, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
+ interfaceTweaksConfigPanel.add(userFontSizeSpinner, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
- interfaceConfigPanel.add(new JPanel(), new GridBagConstraints(0, 4, 3, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
+ interfaceTweaksConfigPanel.add(new JPanel(), new GridBagConstraints(0, 4, 3, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
- return interfaceConfigPanel;
+ return interfaceTweaksConfigPanel;
}
//
/**
* {@inheritDoc}
*/
- public void loadingProjectsFailed(String directory) {
+ 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 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 coreStopped() {
+ mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.coreStopped"));
}
/**
mainWindow.error.projectLoadingFailed.title: Loading Projects Failed
mainWindow.error.projectLoadingFailed.message: Loading the projects from \u201c{0}\u201d has failed.
+mainWindow.statusBar.coreLoaded: Core loaded.
+mainWindow.statusBar.coreStopped: Core stopped.
+mainWindow.statusBar.projectSavingDone: Projects saved.
+
# main menus
mainWindow.menu.jSite.name: jSite
mainWindow.menu.jSite.mnemonic: VK_J
#
configurationDialog.title: Configuration
-configurationDialog.page.interface.name: Interface Tweaks
+configurationDialog.page.interface.name: Interface
+
+configurationDialog.page.interfaceTweaks.name: Interface Tweaks
-configurationDialog.page.interface.item.restartRequired.name: All items on this page require a restart to take effect!
+configurationDialog.page.interfaceTweaks.item.restartRequired.name: All items on this page require a restart to take effect!
-configurationDialog.page.interface.item.antialias.name: Antialias GUI (requires restart)
-configurationDialog.page.interface.item.antialias.mnemonic: VK_A
-configurationDialog.page.interface.item.antialias.accelerator: Alt-VK_A
-configurationDialog.page.interface.item.antialias.shortDescription: Antialias all GUI elements
-configurationDialog.page.interface.item.antialias.longDescription: Antialias all GUI elements
+configurationDialog.page.interfaceTweaks.item.antialias.name: Antialias GUI (requires restart)
+configurationDialog.page.interfaceTweaks.item.antialias.mnemonic: VK_A
+configurationDialog.page.interfaceTweaks.item.antialias.accelerator: Alt-VK_A
+configurationDialog.page.interfaceTweaks.item.antialias.shortDescription: Antialias all GUI elements
+configurationDialog.page.interfaceTweaks.item.antialias.longDescription: Antialias all GUI elements
-configurationDialog.page.interface.item.useCustomControlFont.name: Use custom control font
-configurationDialog.page.interface.item.useCustomControlFont.mnemonic: VK_C
-configurationDialog.page.interface.item.useCustomControlFont.accelerator: Alt-VK_C
-configurationDialog.page.interface.item.useCustomControlFont.shortDescription: Use custom control font for the GUI
-configurationDialog.page.interface.item.useCustomControlFont.longDescription: Use custom control font for the GUI
+configurationDialog.page.interfaceTweaks.item.useCustomControlFont.name: Use custom control font
+configurationDialog.page.interfaceTweaks.item.useCustomControlFont.mnemonic: VK_C
+configurationDialog.page.interfaceTweaks.item.useCustomControlFont.accelerator: Alt-VK_C
+configurationDialog.page.interfaceTweaks.item.useCustomControlFont.shortDescription: Use custom control font for the GUI
+configurationDialog.page.interfaceTweaks.item.useCustomControlFont.longDescription: Use custom control font for the GUI
-configurationDialog.page.interface.item.useCustomUserFont.name: Use custom text font
-configurationDialog.page.interface.item.useCustomUserFont.mnemonic: VK_T
-configurationDialog.page.interface.item.useCustomUserFont.accelerator: Alt-VK_T
-configurationDialog.page.interface.item.useCustomUserFont.shortDescription: Use custom text font for the GUI
-configurationDialog.page.interface.item.useCustomUserFont.longDescription: Use custom text font for the GUI
+configurationDialog.page.interfaceTweaks.item.useCustomUserFont.name: Use custom text font
+configurationDialog.page.interfaceTweaks.item.useCustomUserFont.mnemonic: VK_T
+configurationDialog.page.interfaceTweaks.item.useCustomUserFont.accelerator: Alt-VK_T
+configurationDialog.page.interfaceTweaks.item.useCustomUserFont.shortDescription: Use custom text font for the GUI
+configurationDialog.page.interfaceTweaks.item.useCustomUserFont.longDescription: Use custom text font for the GUI
mainWindow.error.projectLoadingFailed.title: Laden der Projekte fehlgeschlagen
mainWindow.error.projectLoadingFailed.message: Die Projekte aus \u201e{0}\u201c konnten nicht geladen werden.
+mainWindow.statusBar.coreLoaded: Kern geladen.
+mainWindow.statusBar.coreStopped: Kern angehalten.
+mainWindow.statusBar.projectSavingDone: Projekte gespeichert.
+
# main menus
mainWindow.menu.jSite.name: jSite
mainWindow.menu.jSite.mnemonic: VK_J
#
configurationDialog.title: Einstellungen
-configurationDialog.page.interface.name: GUI Tweaks
+configurationDialog.page.interface.name: GUI
+
+configurationDialog.page.interfaceTweaks.name: GUI Tweaks
-configurationDialog.page.interface.item.restartRequired.name: Alle Einstellungen auf dieser Seite erfordern einen Neustart, um wirksam zu werden!
+configurationDialog.page.interfaceTweaks.item.restartRequired.name: Alle Einstellungen auf dieser Seite erfordern einen Neustart, um wirksam zu werden!
-configurationDialog.page.interface.item.antialias.name: Antialiasing f\u00fcr Oberfl\u00e4che aktivieren
-configurationDialog.page.interface.item.antialias.mnemonic: VK_A
-configurationDialog.page.interface.item.antialias.accelerator: Alt-VK_A
-configurationDialog.page.interface.item.antialias.shortDescription: Aktiviert Antialiasing f\u00fcr die Oberfl\u00e4che
-configurationDialog.page.interface.item.antialias.longDescription: Aktiviert Antialiasing f\u00fcr die Oberfl\u00e4che
+configurationDialog.page.interfaceTweaks.item.antialias.name: Antialiasing f\u00fcr Oberfl\u00e4che aktivieren
+configurationDialog.page.interfaceTweaks.item.antialias.mnemonic: VK_A
+configurationDialog.page.interfaceTweaks.item.antialias.accelerator: Alt-VK_A
+configurationDialog.page.interfaceTweaks.item.antialias.shortDescription: Aktiviert Antialiasing f\u00fcr die Oberfl\u00e4che
+configurationDialog.page.interfaceTweaks.item.antialias.longDescription: Aktiviert Antialiasing f\u00fcr die Oberfl\u00e4che
-configurationDialog.page.interface.item.useCustomControlFont.name: Andere Schriftart f\u00fcr Kontrollelemente
-configurationDialog.page.interface.item.useCustomControlFont.mnemonic: VK_K
-configurationDialog.page.interface.item.useCustomControlFont.accelerator: Alt-VK_K
-configurationDialog.page.interface.item.useCustomControlFont.shortDescription: Eine andere Schriftart f\u00fcr Kontrollelemente benutzen
-configurationDialog.page.interface.item.useCustomControlFont.longDescription: Eine andere Schriftart f\u00fcr Kontrollelemente benutzen
+configurationDialog.page.interfaceTweaks.item.useCustomControlFont.name: Andere Schriftart f\u00fcr Kontrollelemente
+configurationDialog.page.interfaceTweaks.item.useCustomControlFont.mnemonic: VK_K
+configurationDialog.page.interfaceTweaks.item.useCustomControlFont.accelerator: Alt-VK_K
+configurationDialog.page.interfaceTweaks.item.useCustomControlFont.shortDescription: Eine andere Schriftart f\u00fcr Kontrollelemente benutzen
+configurationDialog.page.interfaceTweaks.item.useCustomControlFont.longDescription: Eine andere Schriftart f\u00fcr Kontrollelemente benutzen
-configurationDialog.page.interface.item.useCustomUserFont.name: Andere Schriftart f\u00fcr Texteingaben
-configurationDialog.page.interface.item.useCustomUserFont.mnemonic: VK_T
-configurationDialog.page.interface.item.useCustomUserFont.accelerator: Alt-VK_T
-configurationDialog.page.interface.item.useCustomUserFont.shortDescription: Eine andere Schriftart f\u00fcr Texteingabefelder benutzen
-configurationDialog.page.interface.item.useCustomUserFont.longDescription: Eine andere Schriftart f\u00fcr Texteingabefelder benutzen
+configurationDialog.page.interfaceTweaks.item.useCustomUserFont.name: Andere Schriftart f\u00fcr Texteingaben
+configurationDialog.page.interfaceTweaks.item.useCustomUserFont.mnemonic: VK_T
+configurationDialog.page.interfaceTweaks.item.useCustomUserFont.accelerator: Alt-VK_T
+configurationDialog.page.interfaceTweaks.item.useCustomUserFont.shortDescription: Eine andere Schriftart f\u00fcr Texteingabefelder benutzen
+configurationDialog.page.interfaceTweaks.item.useCustomUserFont.longDescription: Eine andere Schriftart f\u00fcr Texteingabefelder benutzen