]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/action/PriorityActionAdapter.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.ui / src / org / simantics / utils / ui / action / PriorityActionAdapter.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.utils.ui.action;
13
14 import org.eclipse.jface.action.IAction;
15
16 /**
17  * @author Tuukka Lehtonen
18  */
19 public class PriorityActionAdapter extends PriorityAction {
20
21     private IAction handler;
22     
23     /**
24      * @param handler
25      * @throws NullPointerException for null handlers
26      */
27     public PriorityActionAdapter(IAction handler) {
28         this(IPriorityAction.NORMAL, handler);
29     }
30
31     /**
32      * @param priority
33      * @param handler
34      * @throws NullPointerException for null handlers
35      */
36     public PriorityActionAdapter(int priority, IAction handler) {
37         super(priority, handler.getText(), handler.getStyle());
38         this.handler = handler;
39
40         setText(handler.getText());
41         setImageDescriptor(handler.getImageDescriptor());
42     }
43
44     @Override
45     public void run() {
46         if (handler != null) {
47             handler.run();
48         }
49     }
50 }