blob: 5410455d754bbe91f96163a9a66b941cd3d3c6a1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*****************************************************************************
* Copyright (c) 2011 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.gmf.diagram.common.commands;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.gmf.runtime.common.core.command.AbstractCommand;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.util.StringStatics;
import org.eclipse.papyrus.infra.widgets.toolbox.notification.Type;
import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.CombinedPopupAndViewBuilder;
import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder;
/**
* A command that is always executable, undoable and redoable, but does nothing.
* It always returns the same OK command result.
*
* @author ldamus
*/
public class IdentityCommandWithNotification extends AbstractCommand {
protected String title = "Papyrus notification";
protected String message = "No message.";
protected Type type = Type.INFO;
/**
* Public constructor.
*/
public IdentityCommandWithNotification(String message) {
this();
this.message = message;
}
/**
* Public constructor.
*/
public IdentityCommandWithNotification(String title, String message, Type type) {
this(message);
this.title = title;
this.type = type;
}
/**
* Private constructor.
*/
private IdentityCommandWithNotification() {
super(StringStatics.BLANK, null);
setResult(CommandResult.newOKCommandResult());
}
/**
* Does nothing and returns an OK command result.
*/
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
new NotificationBuilder().setBuilderClass(CombinedPopupAndViewBuilder.class).setType(type).setTitle(title).setMessage(message).run();
return getCommandResult();
}
/**
* Does nothing and returns an OK command result.
*/
@Override
protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
return getCommandResult();
}
/**
* Does nothing and returns an OK command result.
*/
@Override
protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
return getCommandResult();
}
}
|