eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/SaveTaxonAction.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/SwapSynonymAndTaxonAction.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/TaxonActionFactory.java -text
+eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/io/ImportAction.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/AdaptCompositeToGroupAction.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/AddBasionymCompositeAction.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/AddQuickNameAction.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/NameViewer.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditorView.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/messages.properties -text
+eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/io/InputWizard.java -text
+eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/io/InputWizard2.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/CdmUtil.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/NameEditorInput.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/PropertySheetNode.java -text
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
+import eu.etaxonomy.taxeditor.actions.io.ImportAction;
import eu.etaxonomy.taxeditor.actions.ui.OpenNameRelationWizardAction;
import eu.etaxonomy.taxeditor.actions.ui.OpenTaxonEditorAction;
private IWorkbenchAction undoAction;
private IAction newNameAction;
+ private IAction importAction;
public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
newNameAction = new OpenTaxonEditorAction();
register(newNameAction);
+ importAction = new ImportAction();
+ register(importAction);
+
preferencesAction = ActionFactory.PREFERENCES.create(window);
}
fileMenu.add(saveAction);
fileMenu.add(undoAction);
fileMenu.add(new Separator());
+ fileMenu.add(importAction);
+ fileMenu.add(new Separator());
fileMenu.add(exitAction);
MenuManager preferencesMenu = new MenuManager("&Preferences",
--- /dev/null
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+\r
+package eu.etaxonomy.taxeditor.actions.io;\r
+\r
+import java.io.File;\r
+import java.net.MalformedURLException;\r
+import java.util.UUID;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.jface.action.Action;\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+\r
+import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
+import eu.etaxonomy.cdm.database.ICdmDataSource;\r
+import eu.etaxonomy.cdm.io.common.CdmDefaultImport;\r
+import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;\r
+import eu.etaxonomy.cdm.io.tcs.TcsImportConfigurator;\r
+import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
+import eu.etaxonomy.taxeditor.UiUtil;\r
+import eu.etaxonomy.taxeditor.io.InputWizard2;\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 05.11.2008\r
+ * @version 1.0\r
+ */\r
+public class ImportAction extends Action {\r
+ private static final Logger logger = Logger.getLogger(ImportAction.class);\r
+\r
+ private static String text = "Import ...";\r
+ private ImageDescriptor image = null;\r
+ public static final String ID = "eu.etaxonomy.taxeditor.actions.io.importaction"; //$NON-NLS-1$\r
+\r
+ private FileDialog dialog;\r
+\r
+ private File file;\r
+\r
+ private InputWizard2 wizard;\r
+ \r
+ public ImportAction() {\r
+ super(text);\r
+ setImageDescriptor(image);\r
+ setId(ID);\r
+ }\r
+ \r
+ public void run() {\r
+ dialog = new FileDialog(UiUtil.getShell());\r
+ String filePath = dialog.open();\r
+ file = new File(filePath);\r
+ \r
+// wizard = new InputWizard2();\r
+ \r
+// WizardDialog dialog = new WizardDialog(UiUtil.getShell(), wizard);\r
+// dialog.create();\r
+// dialog.open();\r
+ \r
+ ICdmDataSource destination = TaxEditorPlugin.getDefault().getCdmDataSource();\r
+ String source = null;\r
+ try {\r
+ source = file.toURI().toURL().toString();\r
+ } catch (MalformedURLException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ TcsImportConfigurator tcsImportConfigurator = TcsImportConfigurator.NewInstance(source, destination);\r
+ \r
+// tcsImportConfigurator.setSecUuid(UUID.fromString("5f32b8af-0c97-48ac-8d33-6099ed68c625"));\r
+// tcsImportConfigurator.setSourceSecId("palm_pub_ed_999999");\r
+// \r
+// tcsImportConfigurator.setDoAuthors(false);\r
+// tcsImportConfigurator.setDoReferences(DO_REFERENCES.ALL);\r
+// tcsImportConfigurator.setDoTaxonNames(false);\r
+// tcsImportConfigurator.setDoRelNames(false);\r
+ //tcsImportConfigurator.setDoNameStatus(doNameStatus);\r
+ //tcsImportConfigurator.setDoTypes(doTypes);\r
+ //tcsImportConfigurator.setDoNameFacts(doNameFacts);\r
+// \r
+// tcsImportConfigurator.setDoTaxa(false);\r
+// tcsImportConfigurator.setDoRelTaxa(false);\r
+// tcsImportConfigurator.setDoFacts(false);\r
+ \r
+ tcsImportConfigurator.setCheck(CHECK.IMPORT_WITHOUT_CHECK);\r
+ tcsImportConfigurator.setDbSchemaValidation(DbSchemaValidation.CREATE);\r
+ \r
+ \r
+ CdmDefaultImport<TcsImportConfigurator> tcsImport = new CdmDefaultImport<TcsImportConfigurator>();\r
+ //new Test().invoke(tcsImportConfigurator);\r
+ boolean successful = tcsImport.invoke(tcsImportConfigurator); \r
+ logger.warn("Successful? " + successful);\r
+ }\r
+}\r
}\r
\r
Wizard wizard = new NameRelationWizard(relationModel);\r
-\r
- // Instantiates the wizard container with the wizard and opens it\r
- WizardDialog dialog = new WizardDialog(UiUtil.getShell(), wizard);\r
- dialog.create();\r
- dialog.open();\r
}\r
}
\ No newline at end of file
--- /dev/null
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+\r
+package eu.etaxonomy.taxeditor.io;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.jface.wizard.Wizard;\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 05.11.2008\r
+ * @version 1.0\r
+ */\r
+public class InputWizard extends Wizard {\r
+ private static final Logger logger = Logger.getLogger(InputWizard.class);\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()\r
+ */\r
+ @Override\r
+ public boolean performFinish() {\r
+ // TODO Auto-generated method stub\r
+ return false;\r
+ }\r
+ \r
+// public void addPages() {\r
+// addPage();\r
+// }\r
+}\r
--- /dev/null
+package eu.etaxonomy.taxeditor.io;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.jface.wizard.WizardPage;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.layout.FillLayout;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Text;\r
+\r
+public class InputWizard2 extends WizardPage {\r
+ private Text text;\r
+ private static final Logger logger = Logger.getLogger(InputWizard2.class);\r
+\r
+ /**\r
+ * Create the wizard\r
+ */\r
+ public InputWizard2() {\r
+ super("wizardPage");\r
+ setTitle("Input data from file");\r
+ }\r
+\r
+ /**\r
+ * Create contents of the wizard\r
+ * @param parent\r
+ */\r
+ public void createControl(Composite parent) {\r
+ Composite container = new Composite(parent, SWT.NULL);\r
+ final GridLayout gridLayout = new GridLayout();\r
+ gridLayout.numColumns = 2;\r
+ container.setLayout(gridLayout);\r
+ //\r
+ setControl(container);\r
+\r
+ final Composite composite = new Composite(container, SWT.NONE);\r
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
+ composite.setLayout(new GridLayout());\r
+\r
+ final Label chooseFileFormatLabel = new Label(composite, SWT.NONE);\r
+ final GridData gd_chooseFileFormatLabel = new GridData(SWT.LEFT, SWT.CENTER, true, false);\r
+ chooseFileFormatLabel.setLayoutData(gd_chooseFileFormatLabel);\r
+ chooseFileFormatLabel.setText("Choose file format:");\r
+\r
+ final Button tcsButton = new Button(composite, SWT.RADIO);\r
+ tcsButton.setText("TCS");\r
+\r
+ final Button abcdButton = new Button(composite, SWT.RADIO);\r
+ abcdButton.setText("ABCD");\r
+ new Label(container, SWT.NONE);\r
+\r
+ final Composite composite_1 = new Composite(container, SWT.NONE);\r
+ composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
+ composite_1.setLayout(new GridLayout());\r
+\r
+ final Label chooseFileLabel = new Label(composite_1, SWT.NONE);\r
+ final GridData gd_chooseFileLabel = new GridData(SWT.LEFT, SWT.CENTER, true, false);\r
+ chooseFileLabel.setLayoutData(gd_chooseFileLabel);\r
+ chooseFileLabel.setText("Choose file:");\r
+ new Label(container, SWT.NONE);\r
+\r
+ text = new Text(container, SWT.BORDER);\r
+ text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
+\r
+ final Button browseButton = new Button(container, SWT.NONE);\r
+ browseButton.setText("Browse ...");\r
+ }\r
+}\r
import org.eclipse.ui.views.properties.TextPropertyDescriptor;\r
\r
import eu.etaxonomy.cdm.common.CdmUtils;\r
+import eu.etaxonomy.cdm.model.agent.Team;\r
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;\r
import eu.etaxonomy.cdm.model.reference.Article;\r
import eu.etaxonomy.cdm.model.reference.BibtexReference;\r
import eu.etaxonomy.cdm.model.reference.Book;\r
\r
// Property display keys\r
public static final String P_REFERENCETYPE = "00:Reference Type";\r
- public static final String P_AUTHORTEAM = "01:Author Team";\r
+ public static final String P_AUTHORTEAM = "01:Author Team (Cache)";\r
public static final String P_YEAR = "02:Year";\r
public static final String P_CITATION = "03:Citation";\r
public static final String P_URI = "04:URI";\r
public static final String P_CROSSREF = "38:BibTeX Crossref";\r
public static final String P_NOMREFBASE = "39:Nomenclatural Citation"; \r
\r
- \r
private static HashMap<Class, String> referenceTypeMap = null;\r
\r
private void populateReferenceTypes() {\r
// Default type of ReferenceBase is Generic\r
if (reference == null) {\r
reference = Generic.NewInstance();\r
- }\r
- \r
+ } \r
this.reference = reference;\r
\r
List<String> displayFields = new ArrayList<String>();\r
}\r
\r
if (referenceClass == Generic.class) {\r
- displayFields.add(P_ID_INJOURNAL);\r
displayFields.add(P_ID_NOMENCLATURAL_CITATION);\r
displayFields.add(P_ID_PAGES);\r
displayFields.add(P_ID_SERIES);\r
*/\r
@Override\r
public Object getPropertyValue(Object id) {\r
+ \r
+ // Reference Type: get integer index of drop-down menu\r
if (id.equals(P_ID_REFERENCETYPE)) {\r
Class referenceClass = reference.getClass();\r
int menuIndex = 0;\r
}\r
return 0;\r
}\r
+\r
+ // Author Team: for now, just edit the cache\r
+ // TODO AuthorTeamPropertySource\r
+ if (id.equals(P_ID_AUTHORTEAM)) {\r
+ TeamOrPersonBase authorTeam = reference.getAuthorTeam();\r
+ \r
+ if (authorTeam == null) {\r
+ return "";\r
+ }\r
+ \r
+ return CdmUtils.Nz(authorTeam.getTitleCache());\r
+ }\r
+ \r
+ // Year\r
+ if (id.equals(P_ID_YEAR)) {\r
+ return CdmUtils.Nz(reference.getYear());\r
+ }\r
+ \r
+ // Title: used by StrictReferenceBase\r
+ if (id.equals(P_ID_TITLE)) {\r
+ String title = (String) invokeMethod(reference, "getTitle", null);\r
+ return CdmUtils.Nz(title);\r
+ }\r
+ \r
+ // InJournal: return an instance of BibRefPropertySource\r
+ if (id.equals(P_ID_INJOURNAL)) {\r
+ \r
+ Journal inJournal = null;\r
+ try {\r
+ inJournal = ((Article) reference).getInJournal();\r
+ } catch (ClassCastException e) {\r
+ // Leave method on class cast error\r
+ logger.error(e.getMessage());\r
+ return null;\r
+ }\r
+ \r
+ if (inJournal == null) {\r
+ inJournal = Journal.NewInstance();\r
+ }\r
+ \r
+ BibRefPropertySource bibRefPropertySource = new BibRefPropertySource(inJournal);\r
+ bibRefPropertySource.addPropertyChangeListener(new PropertyChangeListener() {\r
+ @Override\r
+ public void propertyChange(PropertyChangeEvent evt) {\r
+ if (reference instanceof Article && evt.getNewValue() instanceof Journal) { \r
+ ((Article) reference).setInJournal((Journal) evt.getNewValue());\r
+ }\r
+ }\r
+ });\r
+ return bibRefPropertySource;\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * Executes <code>methodName</code> on <code>obj</code> with\r
+ * the arguments <code>args</code>.\r
+ * <p>\r
+ * On failure, returns <code>null</code>. \r
+ * @param obj\r
+ * @param methodName\r
+ * @param args\r
+ * @return\r
+ */\r
+ private Object invokeMethod(Object obj, String methodName, Object... args) {\r
+ try {\r
+ if (args != null) {\r
+ logger.warn(args.length);\r
+ for (Object arg : args) {\r
+ logger.warn("ARG " + arg.toString());\r
+ }\r
+ }\r
+ Method method = null;\r
+ if (methodName.equals("setTitle"))\r
+ method= obj.getClass().getMethod(methodName, String.class);\r
+ else\r
+ method = obj.getClass().getMethod(methodName, null);\r
+ return method.invoke(obj, args);\r
+ } catch (SecurityException e) {\r
+ logger.error(e.getMessage());\r
+ } catch (IllegalArgumentException e) {\r
+ logger.error(e .getMessage());\r
+ } catch (NoSuchMethodException e) {\r
+ logger.error(e.getMessage());\r
+ } catch (IllegalAccessException e) {\r
+ logger.error(e.getMessage());\r
+ } catch (InvocationTargetException e) {\r
+ logger.error(e.getMessage());\r
+ }\r
+ return null;\r
+ }\r
+\r
+ private Object createBibRefPropertySource(Journal inJournal) {\r
+ // TODO Auto-generated method stub\r
return null;\r
}\r
\r
@Override\r
public void setPropertyValue(Object id, Object value) {\r
\r
+ // Reference Type\r
if (id.equals(P_ID_REFERENCETYPE)) {\r
\r
// NOTE: this code will only be reached if user actually changes choice in reference type\r
// dropdown list, not if focus is merely gained and lost without changing the value\r
\r
- // Guard against class cast error\r
- if (!( value instanceof Integer)) {\r
- return;\r
- }\r
- \r
// Grab reference's title cache\r
String oldTitleCache = reference.getTitleCache();\r
\r
// Get reference's class\r
- int menuIndex = ((Integer) value).intValue(); \r
+ int menuIndex;\r
+ try {\r
+ menuIndex = ((Integer) value).intValue();\r
+ } catch (ClassCastException e) {\r
+ // Leave method / no change on class cast error\r
+ logger.error(e.getMessage());\r
+ return;\r
+ } \r
Class referenceClass = (Class)(referenceTypeMap.keySet().toArray())[menuIndex];\r
\r
// Make a new reference using the class\r
reference = makeNewReference(referenceClass);\r
\r
// Set new reference's title cache\r
- reference.setTitleCache(oldTitleCache); \r
+ reference.setTitleCache(oldTitleCache);\r
+ }\r
+ \r
+ // Author Team\r
+ if (id.equals(P_ID_AUTHORTEAM)) {\r
+ TeamOrPersonBase authorTeam = reference.getAuthorTeam();\r
+ if (authorTeam == null) {\r
+ authorTeam = Team.NewInstance();\r
+ reference.setAuthorTeam(authorTeam);\r
+ }\r
+ try {\r
+ authorTeam.setTitleCache((String) value);\r
+ } catch (ClassCastException e) {\r
+ // Leave method / no change on class cast error\r
+ logger.error(e.getMessage());\r
+ return;\r
+ }\r
+ }\r
+ \r
+ // Year\r
+ if (id.equals(P_ID_YEAR)) {\r
+// reference.getYear\r
+ }\r
+\r
+ // Title: used by StrictReferenceBase\r
+ if (id.equals(P_ID_TITLE)) {\r
+ String title = null;\r
+ try {\r
+ title = (String) value;\r
+ } catch (ClassCastException e) {\r
+ // Leave method / no change on class cast error\r
+ logger.error(e.getMessage());\r
+ return;\r
+ }\r
+ invokeMethod(reference, "setTitle", title);\r
}\r
\r
propertyChangeSupport.firePropertyChange(ITaxEditorConstants.PROPERTY_SHEET_CHANGE, null, reference); \r
this.relationModel = relationModel;\r
}\r
\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.wizard.Wizard#addPages()\r
+ */\r
public void addPages() {\r
IWizardPage chooseNamePage = new ChooseRelatedNameWizardPage(relationModel);\r
addPage(chooseNamePage);\r