/**
* The Swing user interface.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class SwingInterface implements CoreListener, LoggingListener, PropertyChangeListener {
private ConfigurationDialog configurationDialog;
/** The node editor dialog. */
- private EditNodeDialog editNodeDialog;
+ private AddNodeDialog addNodeDialog;
/** The list of all defined nodes. */
private List<Node> nodeList = Collections.synchronizedList(new ArrayList<Node>());
/**
* Creates a new swing interface.
- *
+ *
* @param core
* The core to operate on
* @param configDirectory
/**
* Returns the core that is controlled by the Swing interface.
- *
+ *
* @return The core
*/
Core getCore() {
/**
* Returns the main window of the Swing interface.
- *
+ *
* @return The main window
*/
MainWindow getMainWindow() {
/**
* Returns whether the advanced mode is activated.
- *
+ *
* @return <code>true</code> if the advanced mode is activated,
* <code>false</code> if the simple mode is activated
*/
/**
* Returns the “configure” action.
- *
+ *
* @return The “configure” action
*/
I18nAction getConfigureAction() {
/**
* Returns the “import config” action.
- *
+ *
* @return The “import config” action
*/
I18nAction getImportConfigAction() {
/**
* Returns the “quit” action.
- *
+ *
* @return The “quit” action
*/
I18nAction getQuitAction() {
/**
* Returns the “add node” action.
- *
+ *
* @return The “add node” action
*/
I18nAction getAddNodeAction() {
/**
* Returns the “connect to node” action for the given node.
- *
+ *
* @param node
* The node go get the “connect” action for
* @return The “connect to node” action
/**
* Returns the “disconnect from node” action for the given node.
- *
+ *
* @param node
* The node go get the “disconnect” action for
* @return The “disconnect from node” action
/**
* Returns the “edit node” action for the given node.
- *
+ *
* @param node
* The node to edit
* @return The “edit node” action
/**
* Returns the “delete node” action for the given node.
- *
+ *
* @param node
* The node to delete
* @return The “delete node” action
/**
* Returns all language actions.
- *
+ *
* @return All language actions
*/
List<I18nAction> getLanguageActions() {
/**
* Returns the “about” action.
- *
+ *
* @return The “about” action
*/
I18nAction getHelpAboutAction() {
/**
* Returns the “add project” action.
- *
+ *
* @return The “add project” action
*/
I18nAction getAddProjectAction() {
/**
* Returns the “clone project” action for the given project.
- *
+ *
* @param project
* The project to get the “clone project” action for
* @return The “clone project” action
/**
* Returns the “delete project” action for the given project.
- *
+ *
* @param project
* The project to get the “delete project” action for
* @return The “delete project” action
/**
* Returns all currently configured nodes.
- *
+ *
* @return All configured nodes
*/
List<Node> getNodes() {
/**
* Returns a list of all projects.
- *
+ *
* @return All projects
*/
List<Project> getProjects() {
/**
* Returns the thread pool used for off-thread processes.
- *
+ *
* @return The thread pool
*/
Executor getThreadPool() {
};
List<Locale> availableLanguages = I18n.findAvailableLanguages();
for (final Locale locale: availableLanguages) {
- I18nAction languageAction = new I18nAction("general.language." + locale.getLanguage()) {
+ String language = locale.getLanguage();
+ I18nAction languageAction = new I18nAction("general.language." + language, IconLoader.loadIcon("/flag-" + language + ".png")) {
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent e) {
}
};
- if (I18n.getLocale().getLanguage().equals(locale.getLanguage())) {
+ if (I18n.getLocale().getLanguage().equals(language)) {
languageAction.setEnabled(false);
}
languageActions.add(languageAction);
private void initDialogs() {
aboutDialog = new AboutDialog(this);
configurationDialog = new ConfigurationDialog(this);
- editNodeDialog = new EditNodeDialog(mainWindow);
+ addNodeDialog = new AddNodeDialog(mainWindow);
}
//
* Adds a node.
*/
private void addNode() {
- editNodeDialog.setNodeName(I18n.get(nodeList.isEmpty() ? "general.defaultNode.name" : "general.newNode.name"));
- editNodeDialog.setNodeHostname("localhost");
- editNodeDialog.setNodePort(9481);
- editNodeDialog.setVisible(true);
- if (!editNodeDialog.wasCancelled()) {
+ addNodeDialog.setNodeName(I18n.get(nodeList.isEmpty() ? "general.defaultNode.name" : "general.newNode.name"));
+ addNodeDialog.setNodeHostname("localhost");
+ addNodeDialog.setNodePort(9481);
+ addNodeDialog.setVisible(true);
+ if (!addNodeDialog.wasCancelled()) {
Node newNode = new Node();
- newNode.setName(editNodeDialog.getNodeName());
- newNode.setHostname(editNodeDialog.getNodeHostname());
- newNode.setPort(editNodeDialog.getNodePort());
+ newNode.setName(addNodeDialog.getNodeName());
+ newNode.setHostname(addNodeDialog.getNodeHostname());
+ newNode.setPort(addNodeDialog.getNodePort());
try {
core.addNode(newNode);
} catch (UnknownHostException e) {
/**
* Edits the given node.
- *
+ *
* @param node
* The node to edit
*/
private void editNode(Node node) {
- editNodeDialog.setNodeName(node.getName());
- editNodeDialog.setNodeHostname(node.getHostname());
- editNodeDialog.setNodePort(node.getPort());
- editNodeDialog.setVisible(true);
- if (!editNodeDialog.wasCancelled()) {
- node.setName(editNodeDialog.getNodeName());
- node.setHostname(editNodeDialog.getNodeHostname());
- node.setPort(editNodeDialog.getNodePort());
+ addNodeDialog.setNodeName(node.getName());
+ addNodeDialog.setNodeHostname(node.getHostname());
+ addNodeDialog.setNodePort(node.getPort());
+ addNodeDialog.setVisible(true);
+ if (!addNodeDialog.wasCancelled()) {
+ node.setName(addNodeDialog.getNodeName());
+ node.setHostname(addNodeDialog.getNodeHostname());
+ node.setPort(addNodeDialog.getNodePort());
}
}
/**
* Deletes the given node.
- *
+ *
* @param node
* The node to delete
*/
/**
* Connects to the node.
- *
+ *
* @param node
* The node to connect to
*/
/**
* Disconnects from the node.
- *
+ *
* @param node
* The node to disconnect from
*/
/**
* 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
private void addProject() {
try {
core.createProject();
- } catch (JSiteException nne1) {
- /* TODO - add i18n */
- JOptionPane.showMessageDialog(mainWindow, I18n.get(""), I18n.get(""), JOptionPane.ERROR_MESSAGE);
+ } catch (JSiteException jse1) {
+ JOptionPane.showMessageDialog(mainWindow, I18n.get("mainWindow.error.notConnected.message"), I18n.get("mainWindow.error.notConnected.title"), JOptionPane.ERROR_MESSAGE);
} catch (IOException e) {
/* TODO - add i18n */
JOptionPane.showMessageDialog(mainWindow, I18n.get(""), I18n.get(""), JOptionPane.ERROR_MESSAGE);
/**
* Clones a project.
- *
+ *
* @param project
* The project to clone
*/
/**
* Deletes a project.
- *
+ *
* @param project
* The project to delete
*/