/**
* Defines the main window of the application.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class MainWindow extends JFrame implements WindowListener, I18nable, PropertyChangeListener {
/**
* Creates a new main window that redirects all actions to the given swing
* interface.
- *
+ *
* @param swingInterface
* The swing interface to receive all actions
*/
/**
* Sets the text of the status bar.
- *
+ *
* @param text
* The text of the status bar
*/
/**
* Returns the status bar clear delay (in milliseconds).
- *
+ *
* @return The status bar clear delay
*/
public int getStatusBarClearDelay() {
/**
* Sets the status bar clear delay (in milliseconds).
- *
+ *
* @param statusBarClearDelay
* The status bar clear delay
*/
/**
* Sets whether the advanced mode is activated.
- *
+ *
* @param advancedMode
* <code>true</code> if the advanced mode is activated,
* <code>false</code> if the simple mode is activated
/**
* Returns the currently selected project.
- *
+ *
* @return The currently selected project
*/
public Project getSelectedProject() {
/**
* Sets the given node to the “online” state.
- *
+ *
* @param node
* The node to set online
*/
/**
* Sets the given node to the “offline” state in the status bar.
- *
+ *
* @param node
* The node to set offline
*/
/**
* Sets the given node to the “error” state in the status bar.
- *
+ *
* @param node
* The node to set the error state for
*/
/**
* Adds a node to the menu.
- *
+ *
* @param node
* The node to add
*/
/**
* Removes a node from the menu.
- *
+ *
* @param node
* The node to remove
*/
/**
* Adds a project to the project pane.
- *
+ *
* @param project
* The project to add
* @param switchToProject
}
/**
+ * Removes the pane containing the given project.
+ *
+ * @param project
+ * The project whose pane to remove
+ */
+ void removeProject(Project project) {
+ int projectIndex = getProjectIndex(project);
+ projectPane.remove(projectIndex);
+ }
+
+ /**
* @param project
*/
void projectInsertStarted(Project project) {
/**
* Returns the index of the project panel that contains the given project.
- *
+ *
* @param project
* The wanted project
* @return The index of {@link #projectPane}’s tab that contains the given
setJMenuBar(menuBar);
JToolBar toolBar = new JToolBar(I18n.get("mainWindow.toolbar.name"));
- toolBar.add(swingInterface.getAddNodeAction());
- toolBar.addSeparator();
+ toolBar.add(swingInterface.getConfigureAction());
toolBar.add(swingInterface.getQuitAction());
+ toolBar.addSeparator();
+ toolBar.add(swingInterface.getAddNodeAction());
super.getContentPane().add(toolBar, BorderLayout.PAGE_START);
super.getContentPane().add(contentPane, BorderLayout.CENTER);
((ProjectPanel) tabComponent).updateI18n();
}
}
- SwingUtils.repackCentered(this);
}
//
/* if a project was changed, update the tab title and tooltip. */
if (Project.PROPERTY_NAME.equals(propertyName) || Project.PROPERTY_DESCRIPTION.equals(propertyName)) {
Project project = (Project) eventSource;
- int tabCount = projectPane.getTabCount();
- for (int tabIndex = 0; tabIndex < tabCount; tabIndex++) {
- Component tabComponent = projectPane.getComponentAt(tabIndex);
- if (tabComponent instanceof ProjectPanel) {
- Project tabProject = ((ProjectPanel) tabComponent).getProject();
- if (tabProject.equals(project)) {
- projectPane.setTitleAt(tabIndex, project.getName());
- projectPane.setToolTipTextAt(tabIndex, project.getDescription());
- projectPane.repaint();
- }
- }
+ int projectIndex = getProjectIndex(project);
+ if (projectIndex != -1) {
+ projectPane.setTitleAt(projectIndex, project.getName());
+ projectPane.setToolTipTextAt(projectIndex, project.getDescription());
+ projectPane.repaint();
}
}
} else if (eventSource instanceof Node) {