2
* java-gnome, a UI library for writing GTK and GNOME programs from Java!
4
* Copyright © 2007-2012 Operational Dynamics Consulting, Pty Ltd and Others
6
* The code in this file, and the program it is a part of, is made available
7
* to you by its authors as open source software: you can redistribute it
8
* and/or modify it under the terms of the GNU General Public License version
9
* 2 ("GPL") as published by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GPL for more details.
15
* You should have received a copy of the GPL along with this program. If not,
16
* see http://www.gnu.org/licenses/. The authors of this program may be
17
* contacted through http://java-gnome.sourceforge.net/.
19
* Linking this library statically or dynamically with other modules is making
20
* a combined work based on this library. Thus, the terms and conditions of
21
* the GPL cover the whole combination. As a special exception (the
22
* "Classpath Exception"), the copyright holders of this library give you
23
* permission to link this library with independent modules to produce an
24
* executable, regardless of the license terms of these independent modules,
25
* and to copy and distribute the resulting executable under terms of your
26
* choice, provided that you also meet, for each linked independent module,
27
* the terms and conditions of the license of that module. An independent
28
* module is a module which is not derived from or based on this library. If
29
* you modify this library, you may extend the Classpath Exception to your
30
* version of the library, but you are not obligated to do so. If you do not
31
* wish to do so, delete this exception statement from your version.
33
package org.gnome.unique;
36
* Copied from the implementation in ResponseType.java
39
import org.freedesktop.bindings.Constant;
42
* Predefined commands that can be sent from one Application to another.
45
* If one of these responses constants fits your needs, it is recommended that
49
* If your needs require it, however, you can define your own responses codes
50
* by extending this class. For example:
53
* public class NinjaCommand extends Command
55
* protected NinjaCommand(String nickname) {
59
* public static final NinjaCommand HACK = new NinjaCommand("HACK");
61
* public static final NinjaCommand SLASH = new NinjaCommand("SLASH");
63
* public static final NinjaCommand BURN = new NinjaCommand("BURN");
67
* @author Andrew Cowie
72
* This implementation is identical to that used in our coverage GTK Dialogs
73
* and their ResponseTypes. See that class for lots of detail.
75
public class Command extends Constant
77
private static int response;
83
private Command(int ordinal, String nickname) {
84
super(ordinal, nickname);
88
* Constructor to let developer define their own Commands, if necessary.
91
* Used mainly for debugging purposes. The String supplied
92
* should match the name of the constant as declared in your
96
* An unique ordinal is assigned automatically
98
protected Command(String nickname) {
99
super(response++, nickname);
103
* It's not entirely necessary to have these here; we could just have
104
* Dialog call the static methods in UniqueCommandOverride directly, but
105
* the code seems a bit to have this as instance method here...
108
return UniqueCommandOverride.numOf(this);
112
* ... on the other hand, this is just clumsy, but it is at least
113
* consistent with getResponseId() and likewise a bit cleaner.
115
static Command constantFor(int ordinal) {
116
return UniqueCommandOverride.enumFor(ordinal);
120
* Generally interpreted to mean that the receiving instance should
121
* {@link org.gnome.gtk.Window#present() present()} itself.
125
public static final Command ACTIVATE = new Command(UniqueCommand.ACTIVATE, "ACTIVATE");
127
public static final Command NEW = new Command(UniqueCommand.NEW, "NEW");
129
public static final Command OPEN = new Command(UniqueCommand.OPEN, "OPEN");
131
public static final Command CLOSE = new Command(UniqueCommand.CLOSE, "CLOSE");