Project

General

Profile

« Previous | Next » 

Revision 454581f5

Added by Katja Luther over 3 years ago

ref #9119: remove code not needed anymore

View differences:

eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties
52 52
command.label.3 = Error Log
53 53
command.label.4 = Reporting
54 54
command.label.5 = Switch User
55
command.label.6 = Create Data Model
56 55
command.label.7 = New
57 56
command.label.8 = Edit
58 57
command.label.9 = Delete
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties
52 52
command.label.3 = Fehlermeldungen
53 53
command.label.4 = Berichte
54 54
command.label.5 = Benutzer wechseln
55
command.label.6 = Datenmodell erstellen
56 55
command.label.7 = Neu
57 56
command.label.8 = Bearbeiten
58 57
command.label.9 = L\u00f6schen
eu.etaxonomy.taxeditor.store/fragment.e4xmi
10 10
    <elements xsi:type="basic:PartDescriptor" xmi:id="_zTXhUGvBEeeNmdqhxF1CnA" elementId="eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4" label="%view.name.4" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/accessories-text-editor.png" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4"/>
11 11
    <elements xsi:type="basic:PartDescriptor" xmi:id="_coTYkH3eEeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4" label="%view.name.3" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4"/>
12 12
    <elements xsi:type="basic:PartDescriptor" xmi:id="_eKzREIcpEee-HITNnU9cVw" elementId="eu.etaxonomy.taxeditor.view.datasource" label="%view.name" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/system-file-manager.png" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.datasource.e4.CdmDataSourceViewPartE4">
13
      <handlers xmi:id="_DINQoIctEee-HITNnU9cVw" elementId="eu.etaxonomy.taxeditor.view.datasource.e4.handler.ChangeConnectionHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.datasource.e4.handler.ChangeConnectionHandlerE4" command="_efb88IcsEee-HITNnU9cVw"/>
14 13
      <handlers xmi:id="_hAnq0IctEee-HITNnU9cVw" elementId="eu.etaxonomy.taxeditor.view.datasource.e4.handler.EditDataSourceHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.datasource.e4.handler.EditDataSourceHandlerE4" command="_cs5L0IctEee-HITNnU9cVw"/>
15 14
      <handlers xmi:id="_rsmsYIctEee-HITNnU9cVw" elementId="eu.etaxonomy.taxeditor.view.datasource.e4.handler.CloneDataSourceHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.datasource.e4.handler.CloneDataSourceHandlerE4" command="_o0HcUIctEee-HITNnU9cVw"/>
16 15
      <handlers xmi:id="_6VVQUIctEee-HITNnU9cVw" elementId="eu.etaxonomy.taxeditor.view.datasource.e4.handler.CreateDataSourceHandlerE4.dataSourceView" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.datasource.e4.handler.CreateDataSourceHandlerE4" command="_yJiTkIctEee-HITNnU9cVw"/>
17 16
      <handlers xmi:id="_ASDGYIcuEee-HITNnU9cVw" elementId="eu.etaxonomy.taxeditor.view.datasource.e4.handler.DeleteDataSourceHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.datasource.e4.handler.DeleteDataSourceHandlerE4" command="_-g_YcIctEee-HITNnU9cVw"/>
18
      <handlers xmi:id="_T-pz4IcuEee-HITNnU9cVw" elementId="eu.etaxonomy.taxeditor.view.datasource.e4.handler.UpdateDataSourceHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.datasource.e4.handler.UpdateDataSourceHandlerE4" command="_ShWvcIcuEee-HITNnU9cVw"/>
19 17
      <menus xsi:type="menu:PopupMenu" xmi:id="_3aJ1cIcpEee-HITNnU9cVw" elementId="eu.etaxonomy.taxeditor.store.popupmenu.datasourceview">
20 18
        <children xsi:type="menu:HandledMenuItem" xmi:id="_8D3ykIcpEee-HITNnU9cVw" elementId="eu.etaxonomy.taxeditor.store.datasource.handledmenuitem.newDataSource" label="%command.label.7" command="_yJiTkIctEee-HITNnU9cVw"/>
21 19
        <children xsi:type="menu:HandledMenuItem" xmi:id="_-ALHMIcpEee-HITNnU9cVw" elementId="eu.etaxonomy.taxeditor.store.datasource.handledmenuitem.edit" label="%command.label.8" command="_cs5L0IctEee-HITNnU9cVw"/>
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/e4/handler/ChangeConnectionHandlerE4.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 javax.inject.Named;
13

  
14
import org.eclipse.e4.core.di.annotations.CanExecute;
15
import org.eclipse.e4.core.di.annotations.Execute;
16
import org.eclipse.e4.core.di.annotations.Optional;
17
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
18
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
19
import org.eclipse.e4.ui.services.IServiceConstants;
20
import org.eclipse.jface.viewers.IStructuredSelection;
21

  
22
import eu.etaxonomy.cdm.model.metadata.CdmMetaDataPropertyName;
23
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
24
import eu.etaxonomy.taxeditor.l10n.Messages;
25
import eu.etaxonomy.taxeditor.model.MessagingUtils;
26
import eu.etaxonomy.taxeditor.store.CdmStore;
27
import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer;
28
import eu.etaxonomy.taxeditor.view.datasource.e4.CdmDataSourceViewPartE4;
29

  
30
/**
31
 * @author pplitzner
32
 * @date 22.08.2017
33
 */
34
public class ChangeConnectionHandlerE4 {
35

  
36
    @Execute
37
    public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection) {
38

  
39
			if(CdmStore.isConnecting()){
40
				MessagingUtils.warningDialog(Messages.ChangeConnectionHandler_ALREADY_CONNECTING, this, Messages.ChangeConnectionHandler_CURRENTLY_CONNECTING_ALREADY);
41
				return ;
42
			}
43

  
44
			try {
45
			    CdmMetaDataAwareDataSourceContainer container = (CdmMetaDataAwareDataSourceContainer) selection.getFirstElement();
46
				container.getCdmSource().checkConnection();
47
				boolean confirmed = MessagingUtils.confirmDialog(Messages.ChangeConnectionHandler_CREATE_DATAMODEL, String.format(Messages.ChangeConnectionHandler_REALLY_CREATE_DATAMODEL, container.getCdmSource().getName()));
48

  
49
				if(confirmed){
50
					CdmDataSourceRepository.changeDataSource(container.getCdmSource());
51
				}
52
			} catch (Exception e) {
53
				MessagingUtils.warningDialog(Messages.ChangeConnectionHandler_DATASOURCE_NOT_AVAILABLE, this, Messages.ChangeConnectionHandler_NOT_AVAILABLE_REASONS);
54
				MessagingUtils.warn(getClass(), e);
55
				return ;
56
		}
57

  
58
		return ;
59
	}
60

  
61
    @CanExecute
62
    public boolean canExecute(
63
            @Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
64
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
65
            MHandledMenuItem menuItem) {
66
        boolean canExecute = false;
67
        canExecute = thisPart.getObject() instanceof CdmDataSourceViewPartE4
68
                && selection!=null
69
                && selection.size()==1
70
                && selection.getFirstElement() instanceof CdmMetaDataAwareDataSourceContainer
71
                && ((CdmMetaDataAwareDataSourceContainer) selection.getFirstElement()).getMetaData(CdmMetaDataPropertyName.DB_SCHEMA_VERSION).equals(CdmMetaDataAwareDataSourceContainer.DEFAULT_ENTRY);
72
	    menuItem.setVisible(canExecute);
73
	    return canExecute;
74
	}
75
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/e4/handler/UpdateDataSourceHandlerE4.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 javax.inject.Named;
13

  
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.core.runtime.Status;
17
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.e4.core.di.annotations.CanExecute;
19
import org.eclipse.e4.core.di.annotations.Optional;
20
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
21
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
22
import org.eclipse.e4.ui.services.IServiceConstants;
23
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.jface.viewers.IStructuredSelection;
25
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.widgets.Shell;
27
import org.eclipse.ui.progress.IProgressConstants;
28

  
29
import eu.etaxonomy.cdm.config.ICdmSource;
30
import eu.etaxonomy.cdm.database.ICdmDataSource;
31
import eu.etaxonomy.cdm.database.update.CdmUpdater;
32
import eu.etaxonomy.cdm.database.update.SchemaUpdateResult;
33
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
34
import eu.etaxonomy.taxeditor.model.MessagingUtils;
35
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
36
import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer;
37
import eu.etaxonomy.taxeditor.view.datasource.e4.CdmDataSourceViewPartE4;
38

  
39
/**
40
 *
41
 * @author pplitzner
42
 * @date 22.08.2017
43
 *
44
 */
45
public class UpdateDataSourceHandlerE4 extends AbstractDataSourceHandlerE4 {
46

  
47
    /** {@inheritDoc} */
48
    @Override
49
    public boolean specificExecute(CdmDataSourceViewPartE4 dataSourceViewPart,
50
            CdmMetaDataAwareDataSourceContainer container, Shell shell) {
51
        if(! MessageDialog.open(MessageDialog.CONFIRM, shell, "Update Datasource", "WARNING!\n\n" +
52
                "This will change your data base structure! Be sure you have an up-to-date backup of your data before running the update! \n\n " +
53
                "Are you sure you want to update the datasource?", SWT.NONE)){
54
            return false;
55
        }
56
        Job job = new Job("Updating datasource " + container.getCdmSource().getName()){
57

  
58
            @Override
59
            protected IStatus run(IProgressMonitor monitor) {
60
                CdmUpdater updater = new CdmUpdater();
61
                IStatus status = null;
62
                ICdmSource cdmSource = container.getCdmSource();
63
                //FIXME:Remoting we need another updater for ICdmRemoteSource
64
                if(cdmSource instanceof ICdmDataSource) {
65
                    try{
66
                        SchemaUpdateResult result = updater.updateToCurrentVersion(
67
                                (ICdmDataSource)cdmSource, CdmProgressMonitorAdapter.CreateMonitor(monitor));
68
                        if(result.isSuccess()){
69
                           sync.asyncExec(()->{
70
                                    if(dataSourceViewPart!= null){
71
                                        container.getMetaDataFromDataSource();
72
                                        dataSourceViewPart.getViewer().update(new CdmMetaDataAwareDataSourceContainer[]{container}, null);
73
                                    }
74
                                }
75
                            );
76
                            status = Status.OK_STATUS;
77
                        }else{
78
                            throw new RuntimeException("An error occurred during the update.");
79
                        }
80
                    }catch(Exception e){
81
                        status = new Status(IStatus.ERROR, TaxeditorStorePlugin.PLUGIN_ID, e.getMessage(), e);
82
                        MessagingUtils.errorDialog("Could not complete updater", updater, status.getMessage(), status.getPlugin(), e, true);
83
                    }
84
                }
85

  
86
                return status;
87
            }
88

  
89
        };
90

  
91
        job.setPriority(Job.BUILD);
92
        job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
93
        job.schedule();
94

  
95
        return true;
96
    }
97

  
98

  
99
    @Override
100
    @CanExecute
101
    public boolean canExecute(
102
            @Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
103
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
104
            MHandledMenuItem menuItem) {
105
        boolean canExecute = false;
106
        canExecute = thisPart.getObject() instanceof CdmDataSourceViewPartE4
107
                && selection!=null
108
                && selection.size()==1
109
                && selection.getFirstElement() instanceof CdmMetaDataAwareDataSourceContainer
110
                && !((CdmMetaDataAwareDataSourceContainer) selection.getFirstElement()).isDataSourceCompatible();
111
        menuItem.setVisible(canExecute);
112
        return canExecute;
113
    }
114
}

Also available in: Unified diff