View Javadoc

1   /*
2    * Copyright 1999-2006 Faculty of Mathematics, Physics and Informatics, Comenius
3    * University, Bratislava. This file is protected by the Mozilla Public License
4    * version 1.1 (the License); you may not use this file except in compliance
5    * with the License. You may obtain a copy of the License at
6    * http://euromath2.sourceforge.net/license.html Unless required by applicable
7    * law or agreed to in writing, software distributed under the License is
8    * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9    * KIND, either express or implied. See the License for the specific language
10   * governing permissions and limitations under the License.
11   */
12  package sk.uniba.euromath.editor.textEditor.actions;
13  
14  import org.eclipse.swt.dnd.Clipboard;
15  import org.eclipse.ui.IWorkbenchPart;
16  
17  import sk.uniba.euromath.editor.textEditor.IClipboardProvider;
18  import sk.uniba.euromath.editor.xmlEditor.actions.XMLAccessModifyAction;
19  
20  /***
21   * Common clipboard action.
22   * 
23   * @author Tomáš Studva 8.7.2005
24   */
25  public class ClipboardAction extends XMLAccessModifyAction {
26  
27      /***
28       * System clipboard instance.
29       */
30      private Clipboard clipboard;
31  
32      /***
33       * Constructor.
34       * 
35       * @param part
36       *            workbench part to associate
37       */
38      public ClipboardAction(IWorkbenchPart part) {
39          super(part);
40      }
41  
42      /***
43       * Returns clipboard provider.
44       * 
45       * @return clipboard provider
46       */
47      protected IClipboardProvider getClipboardProvider() {
48          if (getWorkbenchPart() != null)
49              return (IClipboardProvider) (getWorkbenchPart()
50                      .getAdapter(IClipboardProvider.class));
51          return null;
52      }
53  
54      /***
55       * Returns system clipboard reference
56       * 
57       * @return clipboard
58       */
59      protected Clipboard getClipboard() {
60          if (this.clipboard != null)
61              return this.clipboard;
62          return getClipboardProvider().getClipboard();
63      }
64  
65  }