Author: jflesch
Date: 2006-11-29 22:51:47 +0000 (Wed, 29 Nov 2006)
New Revision: 11123
Modified:
trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java
trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
Log:
Add some ugly icons in the toolbar (will be changed)
Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2006-11-29 22:19:49 UTC
(rev 11122)
+++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2006-11-29 22:51:47 UTC
(rev 11123)
@@ -1,10 +1,14 @@
package thaw.plugins;
+import javax.swing.JButton;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.ChangeEvent;
+
import thaw.core.*;
import thaw.plugins.index.*;
-public class IndexBrowser implements Plugin {
+public class IndexBrowser extends ToolbarModifier implements Plugin,
ChangeListener {
private Core core;
private Hsqldb hsqldb;
@@ -27,20 +31,47 @@
}
}
- this.hsqldb =
(Hsqldb)core.getPluginManager().getPlugin("thaw.plugins.Hsqldb");
+ hsqldb =
(Hsqldb)core.getPluginManager().getPlugin("thaw.plugins.Hsqldb");
- this.hsqldb.registerChild(this);
+ hsqldb.registerChild(this);
- TableCreator.createTables(this.hsqldb);
+ TableCreator.createTables(hsqldb);
- this.browserPanel = new IndexBrowserPanel(this.hsqldb,
core.getQueueManager(), core.getConfig());
+ browserPanel = new IndexBrowserPanel(hsqldb,
core.getQueueManager(), core.getConfig());
+ setMainWindow(core.getMainWindow());
+ core.getMainWindow().getTabbedPane().addChangeListener(this);
+
core.getMainWindow().addTab(I18n.getMessage("thaw.plugin.index.indexes"),
IconBox.minIndexBrowser,
- this.browserPanel.getPanel());
+ browserPanel.getPanel());
- this.browserPanel.restoreState();
+ browserPanel.restoreState();
+ JButton button;
+ IndexManagementHelper.IndexAction action;
+
+ button = new JButton(IconBox.refreshAction);
+
button.setToolTipText(I18n.getMessage("thaw.plugin.index.downloadIndexes"));
+ action = new IndexManagementHelper.IndexDownloader(button);
+ action.setTarget(browserPanel.getIndexTree().getRoot()); /*
TODO : Listen to tree to only refresh the selected node */
+ addButtonToTheToolbar(button);
+
+ button = new JButton(IconBox.indexReuse);
+
button.setToolTipText(I18n.getMessage("thaw.plugin.index.addAlreadyExistingIndex"));
+ action = new IndexManagementHelper.IndexReuser(hsqldb,
core.getQueueManager(), browserPanel.getIndexTree(), button);
+ action.setTarget(browserPanel.getIndexTree().getRoot());
+ addButtonToTheToolbar(button);
+
+ button = new JButton(IconBox.indexNew);
+
button.setToolTipText(I18n.getMessage("thaw.plugin.index.createIndex"));
+ action = new IndexManagementHelper.IndexCreator(hsqldb,
core.getQueueManager(), browserPanel.getIndexTree(), button);
+ action.setTarget(browserPanel.getIndexTree().getRoot());
+ addButtonToTheToolbar(button);
+
+
+ stateChanged(null);
+
return true;
}
@@ -60,4 +91,25 @@
}
+ /**
+ * Called when the JTabbedPane changed (ie change in the selected tab,
etc)
+ * @param e can be null.
+ */
+ public void stateChanged(ChangeEvent e) {
+ int tabId;
+
+ tabId =
core.getMainWindow().getTabbedPane().indexOfTab(I18n.getMessage("thaw.plugin.index.indexes"));
+
+ if (tabId < 0) {
+ Logger.warning(this, "Unable to find the tab !");
+ return;
+ }
+
+ if (core.getMainWindow().getTabbedPane().getSelectedIndex() ==
tabId) {
+ displayButtonsInTheToolbar();
+ } else {
+ hideButtonsInTheToolbar();
+ }
+ }
+
}
Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-29 22:19:49 UTC
(rev 11122)
+++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-29 22:51:47 UTC
(rev 11123)
@@ -87,11 +87,10 @@
}
setMainWindow(core.getMainWindow());
-
+ core.getMainWindow().getTabbedPane().addChangeListener(this);
core.getMainWindow().addTab(I18n.getMessage("thaw.common.status"),
IconBox.minQueue,
this.panelAdded);
- core.getMainWindow().getTabbedPane().addChangeListener(this);
this.dnd = new DragAndDropManager(core, this.queuePanels);
Modified: trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-11-29
22:19:49 UTC (rev 11122)
+++ trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-11-29
22:51:47 UTC (rev 11123)
@@ -60,8 +60,10 @@
public void hideButtonsInTheToolbar() {
if (mainWindow != null) {
- mainWindow.changeButtonsInTheToolbar(this, null);
- areDisplayed = false;
+ if (areDisplayed) {
+ mainWindow.changeButtonsInTheToolbar(this,
null);
+ areDisplayed = false;
+ }
} else
Logger.error(this, "MainWindow not SET !");
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2006-11-29 22:19:49 UTC (rev 11122)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2006-11-29 22:51:47 UTC (rev 11123)
@@ -58,6 +58,14 @@
tables.restoreState();
}
+ public Tables getTables() {
+ return tables;
+ }
+
+ public IndexTree getIndexTree() {
+ return indexTree;
+ }
+
public JSplitPane getPanel() {
return this.split;
}