1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.view.datasource.e4.handler;
|
11
|
|
12
|
import javax.inject.Named;
|
13
|
|
14
|
import org.eclipse.core.runtime.IStatus;
|
15
|
import org.eclipse.e4.core.di.annotations.CanExecute;
|
16
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
17
|
import org.eclipse.jface.wizard.Wizard;
|
18
|
import org.eclipse.jface.wizard.WizardDialog;
|
19
|
import org.eclipse.swt.widgets.Shell;
|
20
|
|
21
|
import eu.etaxonomy.cdm.config.ICdmSource;
|
22
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
23
|
import eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceWizard;
|
24
|
import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer;
|
25
|
import eu.etaxonomy.taxeditor.view.datasource.e4.CdmDataSourceViewPartE4;
|
26
|
|
27
|
/**
|
28
|
*
|
29
|
* @author pplitzner
|
30
|
* @date 22.08.2017
|
31
|
*
|
32
|
*/
|
33
|
public class CloneDataSourceHandlerE4 extends AbstractDataSourceHandlerE4 {
|
34
|
|
35
|
/** {@inheritDoc} */
|
36
|
@Override
|
37
|
public boolean specificExecute(CdmDataSourceViewPartE4 dataSourceViewPart, CdmMetaDataAwareDataSourceContainer container, Shell shell) {
|
38
|
ICdmSource cdmSource = container.getCdmSource();
|
39
|
//FIXME:Remoting we need another wizard for ICdmRemoteSource
|
40
|
if(cdmSource instanceof ICdmDataSource) {
|
41
|
Wizard wizard = new CdmDataSourceWizard((ICdmDataSource)cdmSource, CdmDataSourceWizard.Mode.CLONE);
|
42
|
WizardDialog dialog = new WizardDialog(shell, wizard);
|
43
|
|
44
|
int result = dialog.open();
|
45
|
|
46
|
if(result == IStatus.OK){
|
47
|
if(dataSourceViewPart != null){
|
48
|
container.getMetaDataFromDataSource();
|
49
|
dataSourceViewPart.getViewer().update(new CdmMetaDataAwareDataSourceContainer[]{container}, null);
|
50
|
}
|
51
|
}
|
52
|
}
|
53
|
return true;
|
54
|
}
|
55
|
|
56
|
@CanExecute
|
57
|
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmMetaDataAwareDataSourceContainer container){
|
58
|
return container!=null;
|
59
|
}
|
60
|
}
|