1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.utils.ui.action;
\r
14 import org.eclipse.jface.action.Action;
\r
15 import org.eclipse.jface.resource.ImageDescriptor;
\r
18 * Extendable implementation of {@link IPriorityAction} based on {@link Action}.
\r
19 * PriorityActions are comparable by their priorities.
\r
21 * Note: this class has a natural ordering that is inconsistent with equals.
\r
23 * @author Tuukka Lehtonen
\r
25 public class PriorityAction extends Action implements IPriorityAction {
\r
27 private final int priority;
\r
29 public PriorityAction() {
\r
31 this.priority = IPriorityAction.NORMAL;
\r
34 public PriorityAction(String text, ImageDescriptor image) {
\r
36 this.priority = IPriorityAction.NORMAL;
\r
39 public PriorityAction(String text, int style) {
\r
41 this.priority = IPriorityAction.NORMAL;
\r
44 public PriorityAction(String text) {
\r
46 this.priority = IPriorityAction.NORMAL;
\r
49 public PriorityAction(int priority) {
\r
51 this.priority = priority;
\r
54 public PriorityAction(int priority, String text, ImageDescriptor image) {
\r
56 this.priority = priority;
\r
59 public PriorityAction(int priority, String text, int style) {
\r
61 this.priority = priority;
\r
64 public PriorityAction(int priority, String text) {
\r
66 this.priority = priority;
\r
70 * @see org.simantics.utils.ui.action.IPriorityAction#getPriority()
\r
72 public int getPriority() {
\r
76 public int compareTo(IPriorityAction o) {
\r
77 int op = o.getPriority();
\r
78 // delta < 0 when priority < op
\r
79 // delta > 0 when priority > op
\r
80 int delta = op - getPriority();
\r