Author: jflesch
Date: 2006-12-29 21:31:53 +0000 (Fri, 29 Dec 2006)
New Revision: 11528
Modified:
trunk/apps/Thaw/src/thaw/core/FileChooser.java
trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java
Log:
Thaw now remember from where the last inserted file came
Modified: trunk/apps/Thaw/src/thaw/core/FileChooser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/FileChooser.java 2006-12-29 20:25:00 UTC
(rev 11527)
+++ trunk/apps/Thaw/src/thaw/core/FileChooser.java 2006-12-29 21:31:53 UTC
(rev 11528)
@@ -12,6 +12,8 @@
public class FileChooser {
private JFileChooser fileChooser = null;
+ private String finalDir = null;
+
public FileChooser() {
fileChooser = new JFileChooser();
}
@@ -63,12 +65,20 @@
* @return null if nothing choosed.
*/
public File askOneFile() {
+ File file;
+
fileChooser.setMultiSelectionEnabled(false);
if(!showDialog())
return null;
- return fileChooser.getSelectedFile();
+ file = fileChooser.getSelectedFile();
+
+ if (file != null) {
+ finalDir = file.getParent();
+ }
+
+ return file;
}
@@ -109,12 +119,28 @@
* @return null if nothing choosed.
*/
public Vector askManyFiles() {
+ File[] files;
+
fileChooser.setMultiSelectionEnabled(true);
if(!showDialog())
return null;
- return this.expandRecursivly(fileChooser.getSelectedFiles());
+ files = fileChooser.getSelectedFiles();
+
+ if (files != null && files[0] != null) {
+ finalDir = files[0].getParent();
+ }
+
+ return this.expandRecursivly(files);
}
+
+ /**
+ * Return the main directory where the files where selected
+ */
+ public String getFinalDirectory() {
+ return finalDir;
+ }
+
}
Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-12-29 20:25:00 UTC
(rev 11527)
+++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-12-29 21:31:53 UTC
(rev 11528)
@@ -39,11 +39,6 @@
fetchPanel = new FetchPanel(core, this);
-
//core.getMainWindow().addTab(I18n.getMessage("thaw.common.download"),
- // IconBox.minDownloads,
- // this.fetchPanel.getPanel());
-
-
// Prepare the frame
fetchFrame = new
JFrame(I18n.getMessage("thaw.common.download"));
@@ -83,8 +78,6 @@
public boolean stop() {
Logger.info(this, "Stopping plugin \"FetchPlugin\" ...");
-
//this.core.getMainWindow().removeTab(this.fetchPanel.getPanel());
-
if (queueWatcher != null)
queueWatcher.removeButtonFromTheToolbar(buttonInToolBar);
@@ -113,10 +106,10 @@
if (key != null)
core.getQueueManager().addQueryToThePendingQueue(new FCPClientGet(key,
-
priority,
-
persistence,
-
globalQueue, -1,
-
destination));
+
priority,
+
persistence,
+
globalQueue, -1,
+
destination));
}
fetchFrame.setVisible(false);
Modified: trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-12-29 20:25:00 UTC
(rev 11527)
+++ trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-12-29 21:31:53 UTC
(rev 11528)
@@ -42,15 +42,11 @@
Logger.info(this, "Starting plugin \"InsertPlugin\" ...");
- insertPanel = new InsertPanel(this,
+ insertPanel = new InsertPanel(this, core.getConfig(),
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue());
scrollPane = new JScrollPane(insertPanel.getPanel());
-
//core.getMainWindow().addTab(I18n.getMessage("thaw.common.insertion"),
- // IconBox.minInsertions,
- // this.scrollPane);
-
insertionFrame = new
JFrame(I18n.getMessage("thaw.common.insertion"));
insertionFrame.setVisible(false);
insertionFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
@@ -93,8 +89,6 @@
public boolean stop() {
Logger.info(this, "Stopping plugin \"InsertPlugin\" ...");
- //this.core.getMainWindow().removeTab(this.scrollPane);
-
if (queueWatcher != null)
queueWatcher.removeButtonFromTheToolbar(buttonInToolBar);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2006-12-29 20:25:00 UTC (rev 11527)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2006-12-29 21:31:53 UTC (rev 11528)
@@ -44,7 +44,7 @@
unknownList = new UnknownIndexList(queueManager, this);
- indexTree = new
IndexTree(I18n.getMessage("thaw.plugin.index.indexes"), false, queueManager,
this);
+ indexTree = new
IndexTree(I18n.getMessage("thaw.plugin.index.indexes"), false, queueManager,
this, config);
leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
indexTree.getPanel(),
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2006-12-29 20:25:00 UTC (rev 11527)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2006-12-29 21:31:53 UTC (rev 11528)
@@ -32,6 +32,7 @@
import thaw.core.I18n;
import thaw.core.Logger;
import thaw.core.MainWindow;
+import thaw.core.Config;
import thaw.fcp.FCPClientPut;
import thaw.fcp.FCPQueueManager;
import thaw.fcp.FCPTransferQuery;
@@ -671,9 +672,11 @@
public static class FileInserterAndAdder extends BasicIndexAction {
+ private Config config;
- public FileInserterAndAdder(final FCPQueueManager queueManager,
final IndexBrowserPanel indexBrowser, final AbstractButton actionSource) {
+ public FileInserterAndAdder(final Config config, final
FCPQueueManager queueManager, final IndexBrowserPanel indexBrowser, final
AbstractButton actionSource) {
super(queueManager, indexBrowser, actionSource);
+ this.config = config;
}
public void setTarget(final IndexTreeNode node) {
@@ -682,8 +685,18 @@
}
public void apply() {
- final FileChooser fileChooser = new FileChooser();
+ final FileChooser fileChooser;
+ String lastDir = null;
+
+ if (config.getValue("lastSourceDirectory") != null)
+ lastDir =
config.getValue("lastSourceDirectory");
+
+ if (lastDir == null)
+ fileChooser = new FileChooser();
+ else
+ fileChooser = new FileChooser(lastDir);
+
fileChooser.setDirectoryOnly(false);
fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
fileChooser.setTitle(I18n.getMessage("thaw.plugin.index.addFilesWithInserting"));
@@ -693,6 +706,10 @@
if(files == null)
return;
+ if (files.size() > 0) {
+ config.setValue("lastSourceDirectory",
fileChooser.getFinalDirectory());
+ }
+
final String category =
FileCategory.promptForACategory();
IndexManagementHelper.addFiles(getQueueManager(),
getIndexBrowserPanel(), (Index)getTarget(), files, category, true);
@@ -701,8 +718,11 @@
public static class FileAdder extends BasicIndexAction {
- public FileAdder(final FCPQueueManager queueManager, final
IndexBrowserPanel indexBrowser, final AbstractButton actionSource) {
+ private Config config;
+
+ public FileAdder(final Config config, final FCPQueueManager
queueManager, final IndexBrowserPanel indexBrowser, final AbstractButton
actionSource) {
super(queueManager, indexBrowser, actionSource);
+ this.config = config;
}
public void setTarget(final IndexTreeNode node) {
@@ -711,8 +731,17 @@
}
public void apply() {
- final FileChooser fileChooser = new FileChooser();
+ final FileChooser fileChooser;
+ String lastDir = null;
+ if (config.getValue("lastSourceDirectory") != null)
+ lastDir =
config.getValue("lastSourceDirectory");
+
+ if (lastDir == null)
+ fileChooser = new FileChooser();
+ else
+ fileChooser = new FileChooser(lastDir);
+
fileChooser.setDirectoryOnly(false);
fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
fileChooser.setTitle(I18n.getMessage("thaw.plugin.index.addFilesWithoutInserting"));
@@ -722,6 +751,10 @@
if(files == null)
return;
+ if (files.size() > 0) {
+ config.setValue("lastSourceDirectory",
fileChooser.getFinalDirectory());
+ }
+
final String category =
FileCategory.promptForACategory();
IndexManagementHelper.addFiles(getQueueManager(),
getIndexBrowserPanel(), (Index)getTarget(), files, category, false);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java 2006-12-29
20:25:00 UTC (rev 11527)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java 2006-12-29
21:31:53 UTC (rev 11528)
@@ -70,7 +70,7 @@
upPanel = new JPanel();
Logger.info(this, "indexes");
- indexTree = new
IndexTree(I18n.getMessage("thaw.plugin.index.yourIndexes"), true, null,
indexBrowser);
+ indexTree = new
IndexTree(I18n.getMessage("thaw.plugin.index.yourIndexes"), true, null,
indexBrowser, null);
Logger.info(this, "plus indexes");
fieldPanel = new JPanel();
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-12-29
20:25:00 UTC (rev 11527)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-12-29
21:31:53 UTC (rev 11528)
@@ -26,6 +26,7 @@
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
+import thaw.core.Config;
import thaw.core.I18n;
import thaw.core.IconBox;
import thaw.core.Logger;
@@ -93,10 +94,12 @@
/**
* @param queueManager Not used if selectionOnly is set to true
+ * @param config Not used if selectionOnly is set to true (used for
lastDestinationDirectory and lastSourceDirectory)
*/
public IndexTree(final String rootName, boolean selectionOnly,
final FCPQueueManager queueManager,
- final IndexBrowserPanel indexBrowser) {
+ final IndexBrowserPanel indexBrowser,
+ final Config config) {
this.queueManager = queueManager;
this.selectionOnly = selectionOnly;
@@ -215,11 +218,11 @@
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.addFilesWithInserting"));
fileMenu.add(item);
- indexAndFileActions.add(new
IndexManagementHelper.FileInserterAndAdder(queueManager, indexBrowser, item));
+ indexAndFileActions.add(new
IndexManagementHelper.FileInserterAndAdder(config, queueManager, indexBrowser,
item));
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.addFilesWithoutInserting"));
fileMenu.add(item);
- indexAndFileActions.add(new
IndexManagementHelper.FileAdder(queueManager, indexBrowser, item));
+ indexAndFileActions.add(new
IndexManagementHelper.FileAdder(config, queueManager, indexBrowser, item));
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.addKeys"));
fileMenu.add(item);
Modified: trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java
2006-12-29 20:25:00 UTC (rev 11527)
+++ trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java
2006-12-29 21:31:53 UTC (rev 11528)
@@ -23,6 +23,7 @@
import javax.swing.JRadioButton;
import javax.swing.JTextField;
+import thaw.core.Config;
import thaw.core.FileChooser;
import thaw.core.I18n;
import thaw.core.Logger;
@@ -31,7 +32,6 @@
import thaw.plugins.InsertPlugin;
-
public class InsertPanel implements ActionListener, ItemListener, Observer {
private final static int MIN_PRIORITY = 6;
@@ -80,8 +80,11 @@
private boolean advancedMode = false;
- public InsertPanel(final InsertPlugin insertPlugin, final boolean
advancedMode) {
+ private Config config; /* keep a ref to the config for the
"lastSourceDirectory" option */
+
+ public InsertPanel(final InsertPlugin insertPlugin, final Config
config, final boolean advancedMode) {
this.insertPlugin = insertPlugin;
+ this.config = config;
this.advancedMode = advancedMode;
@@ -345,9 +348,19 @@
}
if(e.getSource() == browseButton) {
- final FileChooser fileChooser = new FileChooser();
+ final FileChooser fileChooser;
Vector files;
+ String lastDir = null;
+
+ if (config.getValue("lastSourceDirectory") != null)
+ lastDir =
config.getValue("lastSourceDirectory");
+
+ if (lastDir == null)
+ fileChooser = new FileChooser();
+ else
+ fileChooser = new FileChooser(lastDir);
+
fileChooser.setTitle(I18n.getMessage("thaw.common.selectFile"));
fileChooser.setDirectoryOnly(false);
fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
@@ -356,6 +369,10 @@
return;
}
+ if (files.size() > 0) {
+ config.setValue("lastSourceDirectory",
fileChooser.getFinalDirectory());
+ }
+
String fileList = "";
int i;