package net.pterodactylus.jsite.gui;
import java.awt.BorderLayout;
+import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.Timer;
import java.util.TimerTask;
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
-public class MainWindow extends JFrame implements WindowListener, I18nable {
+public class MainWindow extends JFrame implements WindowListener, I18nable, PropertyChangeListener {
/** The swing interface that receives all actions. */
private final SwingInterface swingInterface;
void addProject(Project project) {
ProjectPanel projectPanel = new ProjectPanel(swingInterface, project);
projectPane.add(project.getName(), projectPanel);
+ project.addPropertyChangeListener(this);
}
//
requestTable = new JTable(swingInterface.getRequestTableModel());
getContentPane().add(new JScrollPane(requestTable), BorderLayout.CENTER);
-// JPanel lowerPanel = new JPanel(new BorderLayout(12, 12));
-// getContentPane().add(lowerPanel, BorderLayout.CENTER);
+ // JPanel lowerPanel = new JPanel(new BorderLayout(12, 12));
+ // getContentPane().add(lowerPanel, BorderLayout.CENTER);
}
//
/* do nothing. */
}
+ //
+ // INTERFACE PropertyChangeListener
+ //
+
+ /**
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
+ Object eventSource = propertyChangeEvent.getSource();
+ String propertyName = propertyChangeEvent.getPropertyName();
+ if (eventSource instanceof Project) {
+ /* 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();
+ }
+ }
+ }
+ }
+ }
+ }
+
}