Revision: 16572
http://sourceforge.net/p/gate/code/16572
Author: markagreenwood
Date: 2013-03-07 19:47:52 +0000 (Thu, 07 Mar 2013)
Log Message:
-----------
added code for the special case of the file dialog being used for creating a
new instance of DocumentImpl, at which point we should get the set of file
sufixes from the DocumentFormat static maps rather than the params of
DocumentImpl so that the set always reflects the document format plugins
currently loaded
Modified Paths:
--------------
gate/trunk/src/gate/gui/NewResourceDialog.java
gate/trunk/src/gate/gui/ResourceParametersEditor.java
Modified: gate/trunk/src/gate/gui/NewResourceDialog.java
===================================================================
--- gate/trunk/src/gate/gui/NewResourceDialog.java 2013-03-07 19:37:38 UTC
(rev 16571)
+++ gate/trunk/src/gate/gui/NewResourceDialog.java 2013-03-07 19:47:52 UTC
(rev 16572)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * Copyright (c) 1995-2013, The University of Sheffield. See the file
* COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
*
* This file is part of GATE (see http://gate.ac.uk/), and is free
@@ -202,7 +202,7 @@
if(rData != null) {
this.resourceData = rData;
nameField.setText("");
- parametersEditor.init(null,
+ parametersEditor.init(null, rData,
rData.getParameterList().getInitimeParameters());
pack();
setLocationRelativeTo(getOwner());
Modified: gate/trunk/src/gate/gui/ResourceParametersEditor.java
===================================================================
--- gate/trunk/src/gate/gui/ResourceParametersEditor.java 2013-03-07
19:37:38 UTC (rev 16571)
+++ gate/trunk/src/gate/gui/ResourceParametersEditor.java 2013-03-07
19:47:52 UTC (rev 16572)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * Copyright (c) 1995-2013, The University of Sheffield. See the file
* COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
*
* This file is part of GATE (see http://gate.ac.uk/), and is free
@@ -15,25 +15,66 @@
package gate.gui;
-import java.awt.*;
-import java.awt.event.*;
+import gate.DocumentFormat;
+import gate.Factory;
+import gate.FeatureMap;
+import gate.Gate;
+import gate.Resource;
+import gate.corpora.DocumentImpl;
+import gate.creole.Parameter;
+import gate.creole.ResourceData;
+import gate.creole.ResourceInstantiationException;
+import gate.event.CreoleEvent;
+import gate.event.CreoleListener;
+import gate.swing.XJFileChooser;
+import gate.swing.XJTable;
+import gate.util.Err;
+import gate.util.ExtensionFileFilter;
+import gate.util.GateException;
+import gate.util.LuckyException;
+import gate.util.NameBearer;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.io.IOException;
import java.lang.reflect.Method;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
import java.util.List;
+import java.util.Set;
-import javax.swing.*;
+import javax.swing.AbstractCellEditor;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.DefaultCellEditor;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.ListCellRenderer;
+import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
-import javax.swing.table.*;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellEditor;
-import gate.*;
-import gate.creole.*;
-import gate.event.CreoleEvent;
-import gate.event.CreoleListener;
-import gate.swing.XJTable;
-import gate.swing.XJFileChooser;
-import gate.util.*;
-
/**
* Allows the editing of a set of parameters for a resource. It needs a
* pointer to the resource and a list of the parameter names for the
@@ -53,18 +94,11 @@
setTabSkipUneditableCell(true);
setEditCellAsSoonAsFocus(true);
}
-
- /**
- * Initialises this GUI component.
- *
- * @param resource the resource for which the parameters need to be
- * set.
- * @param parameters a list of lists of {@link Parameter} representing
- * parameter disjunctions.
- */
- public void init(Resource resource, List parameters) {
+
+ public void init(Resource resource, ResourceData resourceData,
List<List<Parameter>> parameters) {
cleanup();
this.resource = resource;
+ this.resourceData = resourceData;
if(parameters != null) {
parameterDisjunctions = new
ArrayList<ParameterDisjunction>(parameters.size());
for(int i = 0; i < parameters.size(); i++) {
@@ -81,10 +115,23 @@
fileChooserResource = (resource != null) ?
resource.getClass().getName() : fileChooser.getResource();
}
+
+ /**
+ * Initialises this GUI component.
+ *
+ * @param resource the resource for which the parameters need to be
+ * set.
+ * @param parameters a list of lists of {@link Parameter} representing
+ * parameter disjunctions.
+ */
+ public void init(Resource resource, List parameters) {
+ init(resource, null, parameters);
+ }
protected void initLocalData() {
resource = null;
parameterDisjunctions = null;
+ resourceData = null;
}// protected void initLocalData()
protected void initGuiComponents() {
@@ -117,6 +164,7 @@
}
}
resource = null;
+ resourceData = null;
}
/**
@@ -218,6 +266,8 @@
ParametersTableModel tableModel;
Resource resource;
+
+ ResourceData resourceData;
/**
* A pointer to the filechooser from MainFrame.
@@ -778,12 +828,26 @@
fileChooser.setAcceptAllFileFilterUsed(true);
fileChooser.setFileFilter(fileChooser.getAcceptAllFileFilter());
Parameter param = pDisj.getParameter();
- Set sufixes = param.getSuffixes();
+
+ Set<String> sufixes = null;
+
+ //This handles the special case of the sourceUrl param when creating
documents
+ //so that we get the suffix list from the set of loaded document
formats rather
+ //than from the data for the resource type we are loading.
+ if (resourceData != null) {
+ if (param.getName().equals("sourceUrl") &&
resourceData.getClassName().equals(DocumentImpl.class.getName())) {
+ sufixes = DocumentFormat.getSupportedFileSuffixes();
+ }
+ }
+
+ //if we haven't loaded any suffixes then fall back to the original
behaviour
+ if (sufixes == null || sufixes.isEmpty()) sufixes =
param.getSuffixes();
+
if(sufixes != null) {
ExtensionFileFilter fileFilter = new ExtensionFileFilter();
- Iterator sufIter = sufixes.iterator();
+ Iterator<String> sufIter = sufixes.iterator();
while(sufIter.hasNext()) {
- fileFilter.addExtension((String)sufIter.next());
+ fileFilter.addExtension(sufIter.next());
}
fileFilter.setDescription("Known file types " +
sufixes.toString());
fileChooser.addChoosableFileFilter(fileFilter);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs