|
From: <ada...@us...> - 2013-09-27 09:59:25
|
Revision: 16947
http://sourceforge.net/p/gate/code/16947
Author: adamfunk
Date: 2013-09-27 09:59:23 +0000 (Fri, 27 Sep 2013)
Log Message:
-----------
Still debugging the reloading part
Modified Paths:
--------------
gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java
gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java 2013-09-27 09:01:08 UTC (rev 16946)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java 2013-09-27 09:59:23 UTC (rev 16947)
@@ -256,14 +256,16 @@
configPersistenceBox.add(Box.createHorizontalGlue());
JButton loadConfigButton = new JButton("Load configuration");
loadConfigButton.setToolTipText("Replace the configuration above with a previously saved one");
- loadConfigButton.addActionListener(new LoadConfigListener(config, dialog));
+ loadConfigButton.addActionListener(new LoadConfigListener(config, this));
configPersistenceBox.add(loadConfigButton);
configPersistenceBox.add(Box.createHorizontalGlue());
JButton saveConfigButton = new JButton("Save configuration");
saveConfigButton.setToolTipText("Save the configuration above for re-use");
- saveConfigButton.addActionListener(new SaveConfigListener(config, dialog));
+ saveConfigButton.addActionListener(new SaveConfigListener(config, this));
configPersistenceBox.add(saveConfigButton);
configPersistenceBox.add(Box.createHorizontalGlue());
+
+ // TODO keep these commented out on svn until reloading works properly
//dialog.add(configPersistenceBox);
//dialog.add(Box.createVerticalStrut(5));
@@ -318,6 +320,14 @@
}
+ protected void updateGui() {
+ this.encodingField.setText(config.getEncoding());
+ this.contentKeysEditor.setValues(config.getContentKeys());
+ this.featureKeysEditor.setValues(config.getFeatureKeys());
+ this.checkbox.setSelected(config.getOneDocCheckbox());
+ }
+
+
protected void loadFile() {
updateConfig();
@@ -417,4 +427,9 @@
return this.values;
}
+ public void setValues(List<String> values) {
+ this.values = values;
+ this.field.setText(Strings.toString(values));
+ }
+
}
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java 2013-09-27 09:01:08 UTC (rev 16946)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java 2013-09-27 09:59:23 UTC (rev 16947)
@@ -12,14 +12,12 @@
package gate.corpora.twitter;
+import gate.Gate;
import java.util.*;
import java.io.*;
import java.net.URL;
import java.awt.event.*;
-import java.awt.Component;
-
import javax.swing.JFileChooser;
-
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
import com.thoughtworks.xstream.io.xml.StaxDriver;
@@ -111,14 +109,17 @@
public static PopulationConfig load(File file) {
XStream xstream = new XStream(new StaxDriver());
+ xstream.setClassLoader(Gate.getClassLoader());
return (PopulationConfig) xstream.fromXML(file);
}
public static PopulationConfig load(URL url) {
XStream xstream = new XStream(new StaxDriver());
+ xstream.setClassLoader(Gate.getClassLoader());
return (PopulationConfig) xstream.fromXML(url);
}
+
public void saveXML(File file) throws IOException {
XStream xstream = new XStream(new StaxDriver());
PrettyPrintWriter ppw = new PrettyPrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
@@ -131,11 +132,11 @@
class LoadConfigListener implements ActionListener {
PopulationConfig config;
- Component parentDialog;
+ PopulationDialogWrapper wrapper;
- public LoadConfigListener(PopulationConfig config, Component dialog) {
+ public LoadConfigListener(PopulationConfig config, PopulationDialogWrapper wrapper) {
this.config = config;
- this.parentDialog = dialog;
+ this.wrapper = wrapper;
}
@Override
@@ -143,9 +144,10 @@
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Load XML configuration");
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- int chosen = chooser.showOpenDialog(this.parentDialog);
+ int chosen = chooser.showOpenDialog(this.wrapper.dialog);
if (chosen == JFileChooser.APPROVE_OPTION) {
config.reload(chooser.getSelectedFile());
+ wrapper.updateGui();
}
}
}
@@ -153,11 +155,11 @@
class SaveConfigListener implements ActionListener {
PopulationConfig config;
- Component parentDialog;
+ PopulationDialogWrapper wrapper;
- public SaveConfigListener(PopulationConfig config, Component dialog) {
+ public SaveConfigListener(PopulationConfig config, PopulationDialogWrapper wrapper) {
this.config = config;
- this.parentDialog = dialog;
+ this.wrapper = wrapper;
}
@Override
@@ -165,7 +167,7 @@
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Save configuration as XML");
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- int chosen = chooser.showSaveDialog(this.parentDialog);
+ int chosen = chooser.showSaveDialog(this.wrapper.dialog);
if (chosen == JFileChooser.APPROVE_OPTION) {
try {
config.saveXML(chooser.getSelectedFile());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|