Project

General

Profile

Revision 8d6b7efd

ID8d6b7efd1c96489398a0e41dbd42d5fbe192ffeb
Parent 7d5cb398
Child aecd96e4

Added by Patrick Plitzner over 2 years ago

ref #6913 Remove remaining handlers

View differences:

eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/OpenExternalHelpHandler.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;
11

  
12
import java.io.IOException;
13
import java.net.URL;
14

  
15
import org.apache.log4j.Logger;
16
import org.eclipse.core.commands.AbstractHandler;
17
import org.eclipse.core.commands.ExecutionEvent;
18
import org.eclipse.core.commands.ExecutionException;
19

  
20
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
21

  
22
/**
23
 * <p>OpenExternalHelpHandler class.</p>
24
 *
25
 * @author p.ciardelli
26
 * @created 04.09.2009
27
 * @version 1.0
28
 */
29
public class OpenExternalHelpHandler extends AbstractHandler {
30
	private static final Logger logger = Logger.getLogger(OpenExternalHelpHandler.class);
31

  
32
	/** {@inheritDoc} */
33
	@Override
34
    public Object execute(ExecutionEvent event) throws ExecutionException {
35
		String url = "https://cybertaxonomy.eu/download/taxeditor/stable/EDITTaxonomicEditor-UserManual.pdf";
36

  
37
		try {
38
            WorkbenchUtility.openWebpage(new URL(url));
39
        } catch (IOException| RuntimeException e) {
40
            logger.error(e);
41
            throw new RuntimeException(e);
42
        }
43

  
44
		return null;
45
	}
46
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/EditInXper2Handler.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.taxeditor.editor.view.descriptive.operation;
5

  
6
import org.eclipse.core.commands.AbstractHandler;
7
import org.eclipse.core.commands.ExecutionEvent;
8
import org.eclipse.core.commands.ExecutionException;
9

  
10
import eu.etaxonomy.taxeditor.model.MessagingUtils;
11

  
12
/**
13
 * @author n.hoffmann
14
 *
15
 */
16
public class EditInXper2Handler extends AbstractHandler {
17

  
18
	/* (non-Javadoc)
19
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
20
	 */
21
	@Override
22
	public Object execute(ExecutionEvent event) throws ExecutionException {
23
		MessagingUtils.warningDialog("Operation not supported yet", getClass(), "This operation is not supported yet."); //$NON-NLS-1$ //$NON-NLS-2$
24
		return null;
25
	}
26

  
27
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/OpenHandler.java
1
package eu.etaxonomy.taxeditor.handler;
2

  
3
import org.eclipse.core.commands.AbstractHandler;
4
import org.eclipse.core.commands.ExecutionEvent;
5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.jface.viewers.ISelection;
7
import org.eclipse.jface.viewers.IStructuredSelection;
8
import org.eclipse.ui.handlers.HandlerUtil;
9

  
10
import eu.etaxonomy.taxeditor.view.CdmViewerChooser;
11

  
12
/**
13
 * Opens the (first) currently selected element in a viewer. Opens a list of
14
 * possible viewers if more than one are registered for this element.
15
 *
16
 * @author pplitzner
17
 * @date Jul 6, 2015
18
 *
19
 */
20
public class OpenHandler extends AbstractHandler {
21

  
22
    @Override
23
    public Object execute(ExecutionEvent event) throws ExecutionException {
24
        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
25
        if(currentSelection instanceof IStructuredSelection){
26
            Object firstElement = ((IStructuredSelection) currentSelection).getFirstElement();
27
            CdmViewerChooser viewerChooser = new CdmViewerChooser(HandlerUtil.getActiveShell(event));
28
            viewerChooser.chooseViewer(firstElement);
29
        }
30
        return null;
31
    }
32

  
33
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/OpenInspectSessionsHandler.java
1
/**
2
* Copyright (C) 2015 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
package eu.etaxonomy.taxeditor.handler;
10

  
11
import java.util.Collection;
12

  
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.IHandler;
17
import org.eclipse.swt.SWT;
18

  
19
import eu.etaxonomy.cdm.model.common.CdmBase;
20
import eu.etaxonomy.taxeditor.model.AbstractUtility;
21
import eu.etaxonomy.taxeditor.model.MessagingUtils;
22
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24
import eu.etaxonomy.taxeditor.view.sessions.InspectSessionsDialog;
25

  
26
/**
27
 * @author cmathew
28
 * @date 18 Feb 2015
29
 *
30
 */
31
public class OpenInspectSessionsHandler extends AbstractHandler implements IHandler {
32

  
33

  
34
    /* (non-Javadoc)
35
     * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
36
     */
37
    /** {@inheritDoc} */
38
    @Override
39
    public Object execute(ExecutionEvent event) throws ExecutionException {
40

  
41
        Object principal = CdmStore.getCurrentAuthentiation().getPrincipal();
42

  
43
        ICdmEntitySession activeSession = CdmStore.getCurrentSessionManager().getActiveSession();
44

  
45
        if(activeSession == null) {
46
            MessagingUtils.warningDialog("No Active Session", this, "Active Session is null");
47
        } else {
48
            Collection<CdmBase> rootEntities = activeSession.getRootEntities();
49
            if(rootEntities == null || rootEntities.isEmpty()) {
50
                MessagingUtils.warningDialog("No Root Entities", this, "No root entities to inspect");
51
            } else {
52
                InspectSessionsDialog dialog = new InspectSessionsDialog(AbstractUtility.getShell(), SWT.NONE);
53
                dialog.open();
54
            }
55

  
56
        }
57

  
58
        return null;
59

  
60
    }
61
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
70 70
import eu.etaxonomy.taxeditor.operation.IFeedbackGenerator;
71 71
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
72 72
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
73
import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
74 73
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
75 74
import eu.etaxonomy.taxeditor.store.CdmStore;
76 75
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
......
172 171
        return executeOperation_internal(operation, handler, sync);
173 172
    }
174 173

  
175
    public static IStatus executeOperation(final AbstractOperation operation, final RemotingCdmHandler handler, UISynchronize sync) {
176
        return executeOperation_internal(operation, handler, sync);
177
    }
178

  
179
    private static IStatus executeOperation_internal(final AbstractOperation operation, final Object handler,
174
    private static IStatus executeOperation_internal(final AbstractOperation operation, final RemotingCdmHandlerE4 handler,
180 175
            UISynchronize sync) {
181 176
        if (getOperationHistory() == null) {
182 177
            throw new IllegalArgumentException(
......
196 191
                    operation.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT);
197 192
                    status = operation.execute(monitor,
198 193
                            uiInfoAdapter);
199
                    if(handler instanceof RemotingCdmHandler) {
200
                        ((RemotingCdmHandler) handler).postOperation(status);
201
                    }
202
                    else if(handler instanceof RemotingCdmHandlerE4) {
203
                        ((RemotingCdmHandlerE4) handler).postOperation(status);
204
                    }
194
                    handler.postOperation(status);
205 195
                } catch (ExecutionException e) {
206 196
                    MessagingUtils.operationDialog(AbstractUtility.class, e, TaxeditorStorePlugin.PLUGIN_ID, operationlabel, null);
207 197
                } finally {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/RemotingCdmHandler.java
1
/**
2
* Copyright (C) 2015 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
package eu.etaxonomy.taxeditor.operation;
10

  
11
import org.eclipse.core.commands.AbstractHandler;
12
import org.eclipse.core.commands.ExecutionEvent;
13
import org.eclipse.core.commands.ExecutionException;
14
import org.eclipse.core.commands.operations.AbstractOperation;
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.jface.dialogs.ErrorDialog;
17

  
18
import eu.etaxonomy.taxeditor.model.MessagingUtils;
19

  
20
/**
21
 * @author cmathew
22
 * @date 16 Jun 2015
23
 *
24
 */
25
public abstract class RemotingCdmHandler extends AbstractHandler {
26

  
27
    private final String label;
28

  
29
    public RemotingCdmHandler(String label) {
30
        this.label = label;
31
    }
32

  
33
    /* (non-Javadoc)
34
     * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
35
     */
36
    @Override
37
    public Object execute(ExecutionEvent event) throws ExecutionException {
38
        IStatus allowStatus = allowOperations(event);
39
        if(allowStatus.isOK()) {
40
            AbstractOperation op = prepareOperation(event);
41
            if(op != null) {
42
//                AbstractUtility.executeOperation(op, this);
43
            }
44
        } else if(allowStatus.getSeverity() == IStatus.ERROR ||
45
                allowStatus.getSeverity() == IStatus.WARNING ||
46
                allowStatus.getSeverity() == IStatus.INFO) {
47
            MessagingUtils.warningDialog("Can not perform " + label, event.getTrigger(), allowStatus);
48
        }
49
        return null;
50
    }
51

  
52
    public void postOperation(IStatus status) {
53

  
54
        switch(status.getSeverity()) {
55
        case IStatus.WARNING:
56
            ErrorDialog.openError(null, "Operation successful but with warnings", null, status);
57
            break;
58
        case IStatus.ERROR:
59
            ErrorDialog.openError(null, "Error executing operation", null, status);
60
            break;
61
        default:
62
        }
63

  
64
        onComplete();
65
    }
66

  
67
    public abstract IStatus allowOperations(ExecutionEvent event);
68

  
69
    public abstract AbstractOperation prepareOperation(ExecutionEvent event);
70

  
71
    public abstract void onComplete();
72

  
73
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)