import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import eu.etaxonomy.taxeditor.model.Resources;
-
/**
* @author nho
*
*/
protected MultilineTextWithLabel(Composite parent, String labelString,
String initialText, int textHeight, int style) {
+ // experimenting with "SWT.V_SCROLL"
super(parent, labelString, initialText, style);
GridData gd = new GridData(SWT.FILL, SWT.TOP, true, true);
gd.heightHint = textHeight;
eu.etaxonomy.taxeditor.user.handler,
eu.etaxonomy.taxeditor.user.view,
eu.etaxonomy.taxeditor.user.wizard
-Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",org.eclipse.core.filesystem;bundle-version="1.2.0",org.eclipse.core.resources;bundle-version="3.4.1",org.eclipse.ui.editors;bundle-version="3.4.0",org.eclipse.jface.text;bundle-version="3.4.1",org.eclipse.ui.ide;bundle-version="3.4.2",eu.etaxonomy.cdmlib;bundle-version="2.3.0"
+Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.core.filesystem;bundle-version="1.2.0",
+ org.eclipse.core.resources;bundle-version="3.4.1",
+ org.eclipse.ui.editors;bundle-version="3.4.0",
+ org.eclipse.jface.text;bundle-version="3.4.1",
+ org.eclipse.ui.ide;bundle-version="3.4.2",
+ eu.etaxonomy.cdmlib;bundle-version="2.3.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: junit.framework,org.junit
Bundle-ActivationPolicy: lazy
package eu.etaxonomy.taxeditor.io;
import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.Assert;
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
+import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
+import eu.etaxonomy.cdm.io.common.IExportConfigurator;
+import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator;
+import eu.etaxonomy.cdm.io.jaxb.JaxbImportConfigurator;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
/**
* @author n.hoffmann
public static ExportHandler NewInstance(CdmApplicationController applicationController){
return new ExportHandler(applicationController);
}
+
+ public void doExport(final IExportConfigurator configurator){
+ Assert.isNotNull(configurator, "Configuration may not be null");
+
+ // terminate any open transactions
+ IConversationEnabled activePart = (IConversationEnabled) StoreUtil.getActivePage().getActivePart();
+ activePart.getConversationHolder().commit(false);
+
+
+ CdmDefaultExport<IExportConfigurator> exporter = new CdmDefaultExport<IExportConfigurator>();
+
+ exporter.setCdmAppController(applicationController);
+
+
+ try{
+ exporter.invoke(configurator);
+ }catch(RuntimeException e){
+ StoreUtil.errorDialog("Error exporting data", "An error occured while" +
+ "exporting to destination '" + configurator.getDestinationNameString() + "'.\n" +
+ "Please check error log for details.");
+ logger.error("Error exporting data", e);
+ }
+
+ // restarting transaction and committing it to trigger change listener
+ // TODO verify correct behaviour
+ activePart.getConversationHolder().startTransaction();
+ activePart.getConversationHolder().commit();
+ }
+
+ /**
+ * @param jaxb
+ * @return
+ */
+ private JaxbExportConfigurator getConfigurator(TYPE type) {
+ Assert.isNotNull(type, "Type should not be null");
+
+ switch (type){
+ case Jaxb:
+ return JaxbExportConfigurator.NewInstance(null, null);
+ default:
+ StoreUtil.notImplementedMessage();
+ throw new IllegalArgumentException("Export not supported yet");
+ }
+ }
+
+ public final JaxbExportConfigurator JaxbConfigurator() { return (JaxbExportConfigurator) getConfigurator(TYPE.Jaxb); }
+
+
}
package eu.etaxonomy.taxeditor.io.wizard;
import org.apache.log4j.Logger;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IExportWizard;
-import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
-import eu.etaxonomy.cdm.io.common.IExportConfigurator;
import eu.etaxonomy.cdm.io.common.IIoConfigurator;
/**
private GenericConfiguratorWizardPage pageConfiguration;
- private CdmDefaultExport export;
-
- public boolean doExport(final IExportConfigurator configurator){
- export = new CdmDefaultExport();
-
- Job exportJob = new Job("Export"){
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- return export.invoke(configurator) ? Status.OK_STATUS : Status.CANCEL_STATUS;
- }
- };
-
- exportJob.schedule();
-
- return true;
- }
-
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IImportWizard;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
import eu.etaxonomy.cdm.io.common.IIoConfigurator;
import eu.etaxonomy.taxeditor.datasource.wizard.NomenclaturalCodeWizardPage;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
/**
* @author n.hoffmann
private CdmDefaultImport<IImportConfigurator> importer;
- /**
- * Performs an import into a new database. The application context has to be changed
- * @param configurator
- * @return
- */
- public boolean doImportExternal(IImportConfigurator configurator){
-
-
-// try {
-// ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
-// ILaunchConfigurationType type = manager.getLaunchConfigurationType(ID_JAVA_APPLICATION);
-// ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
-//
-// // delete possible prior launch configurations
-// for (ILaunchConfiguration configuration : configurations) {
-// if (configuration.getName().equals("NewInstance")) {
-// configuration.delete();
-// break;
-// }
-// }
-//
-// ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, "NewInstance");
-//
-// workingCopy.setAttribute(ATTR_MAIN_TYPE_NAME, "eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin");
-//
-//
-// workingCopy.setAttribute(ATTR_VM_INSTALL_NAME, JavaRuntime.getDefaultVMInstall().getName());
-// workingCopy.setAttribute(ATTR_VM_INSTALL_TYPE, JavaRuntime.getDefaultVMInstall().getVMInstallType().getId());
-//
-//
-// workingCopy.launch(ILaunchManager.RUN_MODE, null);
-
-
-// IVMInstall vm = JavaRuntime.getDefaultVMInstall();//VMInstall(proj);
-// if (vm == null) vm = JavaRuntime.getDefaultVMInstall();
-// IVMRunner vmr = vm.getVMRunner(ILaunchManager.RUN_MODE);
-// String[] cp = JavaRuntime.computeDefaultRuntimeClassPath(proj);
-// VMRunnerConfiguration config = new VMRunnerConfiguration(main, cp);
-// ILaunch launch = new Launch(null,
-// ILaunchManager.RUN_MODE, null);
-// vmr.run(config, launch, null);
-
-// IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
-//
-// IVMInstall install = null;
-// for(IVMInstallType type : types){
-// install = type.createVMInstall(type.getId());
-// break;
-// }
-//
-//
-// IPath path = JavaRuntime.newJREContainerPath(install);
-// String jrePath = path.toPortableString();
-
-
-//
-// ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
-// ILaunchConfigurationType type = manager.getLaunchConfigurationType(ID_JAVA_APPLICATION);
-// ILaunchConfigurationWorkingCopy wc = type.newInstance(null, "NewInstance");
-// wc.setAttribute(ATTR_JRE_CONTAINER_PATH, jrePath);
-// wc.setAttribute(ATTR_MAIN_TYPE_NAME, "eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin");
-// ILaunchConfiguration config = wc.doSave();
-// config.launch(ILaunchManager.RUN_MODE, null);
-//
-//
-// Process p = Runtime.getRuntime().exec(cmdarray);
-//
-//
-// } catch (CoreException e) {
-// logger.error("Error launching import", e);
-// }
-
- StoreUtil.notImplementedMessage();
-
- return true;
- }
-
- /**
- * Use when importing data into the current application context
- *
- * @param configurator
- * @return
- */
- public boolean doImportInternal(final IImportConfigurator configurator){
-
- if(configurator == null){
- throw new IllegalArgumentException("Configuration may not be null");
- }
-
- // terminate any open transactions
- IConversationEnabled activePart = (IConversationEnabled) StoreUtil.getActivePage().getActivePart();
- activePart.getConversationHolder().commit(false);
-
-
-
-// ConversationHolder conversation = CdmStore.NewTransactionalConversation();
-
- importer = new CdmDefaultImport();
-//
-// Job importJob = new Job("Import"){
-// @Override
-// protected IStatus run(IProgressMonitor monitor) {
-// return importer.invoke(configurator) ? Status.OK_STATUS : Status.CANCEL_STATUS;
-// }
-// };
-//
-// importJob.schedule();
-
- importer.setCdmAppController(configurator.getCdmAppController());
-
- boolean result = importer.invoke(configurator);
-
- // restarting transaction and committing it to trigger change listener
- // TODO verify correct behaviour
- activePart.getConversationHolder().startTransaction();
- activePart.getConversationHolder().commit();
-
-
- return result;
- }
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#addPages()
destination.setUserAndPwd(dataSource.getUsername(), dataSource.getPassword());
configurator.setDestination(destination);
- configurator.setCdmAppController(CdmStore.getApplicationControllerWillBeObsolete());
+ CdmStore.getExportHandler().doExport(configurator);
- return doExport(configurator);
+ return true;
}
/* (non-Javadoc)
source.setUserAndPwd(dataSource.getUsername(), dataSource.getPassword());
configurator.setSource(source);
- // TODO should be obsolete because we want to pass application context but is not at the moment (throws NPE when not given)
-// configurator.setDestination(CdmDataSourceRepository.getDefault().getCurrentDataSource());
CdmStore.getImportHandler().doImport(configurator);
CdmStore.getImportHandler().doImport(configurator);
- return false;
+ return true;
}
/* (non-Javadoc)
import org.apache.log4j.Logger;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
Button button = new Button(composite, SWT.PUSH);
button.setText("Browse...");
- button.addMouseListener(new MouseAdapter(){
-
+ button.addSelectionListener(new SelectionAdapter(){
/* (non-Javadoc)
- * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
- public void mouseUp(MouseEvent e) {
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
String path = folderDialog.open();
- text_folder.setText(path);
- setPageComplete(true);
+ if(path != null){ // a folder was selected
+ text_folder.setText(path);
+ setPageComplete(true);
+ }
}
-
});
// make the composite the wizard pages control
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
this.setWindowTitle("JAXB Export");
- this.configurator = JaxbExportConfigurator.NewInstance(null, null);
+ this.configurator = CdmStore.getExportHandler().JaxbConfigurator();
}
/* (non-Javadoc)
String urlString = page.getFolderText() + File.pathSeparator + page.getExportFileName();
configurator.setDestination(urlString);
- configurator.setCdmAppController(CdmStore.getApplicationControllerWillBeObsolete());
- return doExport(configurator);
+ CdmStore.getExportHandler().doExport(configurator);
+
+ return true;
}
/* (non-Javadoc)
String urlString = page.getFolderText() + File.separator + page.getExportFileName();
configurator.setDestination(new File(urlString));
- configurator.setCdmAppController(CdmStore.getApplicationControllerWillBeObsolete());
- return doExport(configurator);
+ CdmStore.getExportHandler().doExport(configurator);
+
+ return true;
}
/* (non-Javadoc)