View Javadoc
1   /*
2    * Copyright (C) 2007-2012 Argeo GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.argeo.slc.client.ui.editors;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.eclipse.jface.resource.ImageDescriptor;
22  import org.eclipse.ui.IEditorInput;
23  import org.eclipse.ui.IMemento;
24  import org.eclipse.ui.IPersistableElement;
25  
26  public class ProcessEditorInput implements IEditorInput, IPersistableElement {
27  	private String processPath;
28  	private List<String> initialFlowPaths = new ArrayList<String>();
29  	private Boolean launchImmediately = false;
30  
31  	/** New empty process */
32  	public ProcessEditorInput() {
33  	}
34  
35  	/** New process with some flows */
36  	public ProcessEditorInput(List<String> initialFlowPaths,
37  			Boolean launchImmediately) {
38  		this.initialFlowPaths = initialFlowPaths;
39  		this.launchImmediately = launchImmediately;
40  	}
41  
42  	/** Existing process */
43  	public ProcessEditorInput(String processPath) {
44  		this.processPath = processPath;
45  	}
46  
47  	@SuppressWarnings("rawtypes")
48  	public Object getAdapter(Class arg0) {
49  		return null;
50  	}
51  
52  	public boolean exists() {
53  		return processPath != null;
54  	}
55  
56  	public ImageDescriptor getImageDescriptor() {
57  		return null;
58  	}
59  
60  	public String getName() {
61  		return processPath != null ? processPath : "<new process>";
62  	}
63  
64  	public IPersistableElement getPersistable() {
65  		return this;
66  	}
67  
68  	public String getToolTipText() {
69  		return "";
70  	}
71  
72  	public void saveState(IMemento memento) {
73  		memento.putString("processPath", processPath);
74  	}
75  
76  	public String getFactoryId() {
77  		return ProcessEditorInputFactory.ID;
78  	}
79  
80  	public String getProcessPath() {
81  		return processPath;
82  	}
83  
84  	public List<String> getInitialFlowPaths() {
85  		return initialFlowPaths;
86  	}
87  
88  	public Boolean getLaunchImmediately() {
89  		return launchImmediately;
90  	}
91  
92  	@Override
93  	public boolean equals(Object obj) {
94  		if (!(obj instanceof ProcessEditorInput))
95  			return false;
96  		ProcessEditorInput pei = (ProcessEditorInput) obj;
97  		if (processPath != null && pei.processPath != null)
98  			return processPath.equals(pei.processPath);
99  		return false;
100 	}
101 
102 }