View Javadoc

1   /*
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2008, Ontotext Lab. / SIRMA Group
4   
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16   */
17  
18  /***
19   * <p>Title: WSMO Studio</p>
20   * <p>Description: Semantic Web Service Editor</p>
21   * <p>Copyright:  Copyright (c) 2004-2008</p>
22   * <p>Company: Ontotext Lab. / SIRMA </p>
23   */
24  
25  
26  package org.wsmostudio.bpmo.ui.editor;
27  
28  import org.wsmostudio.bpmo.model.WorkflowEntityNode;
29  
30  public class ClipboardManager {
31  
32      private static ClipboardManager _clipboard;
33      
34      private WorkflowEntityNode content = null;
35      
36      private ClipboardManager() {
37      }
38      
39      public static ClipboardManager getDefault() {
40          if (_clipboard == null) {
41              _clipboard = new ClipboardManager();
42          }
43          return _clipboard;
44      }
45  
46      public WorkflowEntityNode getContent() {
47          if (this.content == null) {
48              return null;
49          }
50          return copyContent(this.content);
51      }
52      
53      public void setContent(WorkflowEntityNode newContent) {
54          this.content = copyContent(newContent);
55      }
56      
57      public boolean hasContent() {
58          return this.content != null;
59      }
60      
61      @SuppressWarnings("unchecked")
62      public boolean checkContentType(Class type) {
63          return this.content != null 
64              && type.isInstance(this.content);
65      }
66      
67      public static WorkflowEntityNode copyContent(WorkflowEntityNode old) {
68          return old.cloneNode();
69  
70      }
71      
72  }