Merge branch 'release/5.17.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / datasource / e4 / handler / CloneDataSourceHandlerE4.java
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 org.eclipse.core.runtime.IStatus;
13 import org.eclipse.jface.wizard.Wizard;
14 import org.eclipse.jface.wizard.WizardDialog;
15 import org.eclipse.swt.widgets.Shell;
16
17 import eu.etaxonomy.cdm.config.ICdmSource;
18 import eu.etaxonomy.cdm.database.ICdmDataSource;
19 import eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceWizard;
20 import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer;
21 import eu.etaxonomy.taxeditor.view.datasource.e4.CdmDataSourceViewPartE4;
22
23 /**
24 *
25 * @author pplitzner
26 * @date 22.08.2017
27 *
28 */
29 public class CloneDataSourceHandlerE4 extends AbstractDataSourceHandlerE4 {
30
31 /** {@inheritDoc} */
32 @Override
33 public boolean specificExecute(CdmDataSourceViewPartE4 dataSourceViewPart, CdmMetaDataAwareDataSourceContainer container, Shell shell) {
34 ICdmSource cdmSource = container.getCdmSource();
35 //FIXME:Remoting we need another wizard for ICdmRemoteSource
36 if(cdmSource instanceof ICdmDataSource) {
37 Wizard wizard = new CdmDataSourceWizard((ICdmDataSource)cdmSource, CdmDataSourceWizard.Mode.CLONE);
38 WizardDialog dialog = new WizardDialog(shell, wizard);
39
40 int result = dialog.open();
41
42 if(result == IStatus.OK){
43 if(dataSourceViewPart != null){
44 container.getMetaDataFromDataSource();
45 dataSourceViewPart.getViewer().update(new CdmMetaDataAwareDataSourceContainer[]{container}, null);
46 }
47 }
48 }
49 return true;
50 }
51
52 }