|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 package com.symbian.smt.gui.smtwidgets; |
|
19 |
|
20 import org.eclipse.jface.viewers.ISelectionProvider; |
|
21 import org.eclipse.jface.viewers.IStructuredSelection; |
|
22 import org.eclipse.swt.widgets.Button; |
|
23 import org.eclipse.ui.actions.SelectionProviderAction; |
|
24 |
|
25 /** |
|
26 * This is the parent of all actions that act on the command line options from |
|
27 * the list of assigned options. |
|
28 * <p> |
|
29 * It caches the Button that is the presentation proxy for the action and |
|
30 * manages the enabled state of the Button to be consistent with its own |
|
31 * enablement state. |
|
32 * </p> |
|
33 * |
|
34 * @author barbararosi-schwartz |
|
35 * |
|
36 */ |
|
37 public abstract class AbstractMultipleEntriesWidgetAction extends |
|
38 SelectionProviderAction { |
|
39 |
|
40 protected Button actionProxy; |
|
41 protected ISelectionProvider selectionProvider; |
|
42 |
|
43 /** |
|
44 * The constructor sets the text on the Button that is the visual proxy of |
|
45 * this action and caches the button for later usage. |
|
46 * |
|
47 * @param text |
|
48 * the text that represents both the name of the action and the |
|
49 * label on the corresponding Button |
|
50 * @param button |
|
51 * the Button that acts as the visual proxy of this action. |
|
52 */ |
|
53 public AbstractMultipleEntriesWidgetAction(ISelectionProvider provider, |
|
54 String text, Button button) { |
|
55 super(provider, text); |
|
56 |
|
57 if (provider == null) { |
|
58 throw new IllegalArgumentException( |
|
59 "ISelectionProvider cannot be null."); |
|
60 } |
|
61 |
|
62 if (button == null) { |
|
63 throw new IllegalArgumentException( |
|
64 "Button proxy object cannot be null."); |
|
65 } |
|
66 |
|
67 this.selectionProvider = provider; |
|
68 this.actionProxy = button; |
|
69 actionProxy.setText(text); |
|
70 } |
|
71 |
|
72 /** |
|
73 * The default implementation of this method does nothing. |
|
74 */ |
|
75 @Override |
|
76 public void dispose() { |
|
77 super.dispose(); |
|
78 } |
|
79 |
|
80 /** |
|
81 * The default implementation of this method does nothing. |
|
82 */ |
|
83 @Override |
|
84 public void run() { |
|
85 super.run(); |
|
86 }; |
|
87 |
|
88 /** |
|
89 * The default implementation of this method does nothing. |
|
90 */ |
|
91 @Override |
|
92 public void selectionChanged(IStructuredSelection selection) { |
|
93 super.selectionChanged(selection); |
|
94 } |
|
95 |
|
96 /** |
|
97 * Sets the enablement state of the proxy Button to be the same as the |
|
98 * enablement state of the action, the latter being managed by a call to |
|
99 * super.setEnabled(). |
|
100 */ |
|
101 @Override |
|
102 public final void setEnabled(boolean enabled) { |
|
103 actionProxy.setEnabled(enabled); |
|
104 super.setEnabled(enabled); |
|
105 } |
|
106 |
|
107 } |