]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.editors.win32/src/org/simantics/editors/win32/OLEEditorInput.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.editors.win32 / src / org / simantics / editors / win32 / OLEEditorInput.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.editors.win32;\r
13 \r
14 import java.io.File;\r
15 \r
16 import org.eclipse.jface.resource.ImageDescriptor;\r
17 import org.eclipse.ui.IEditorInput;\r
18 import org.eclipse.ui.IPersistableElement;\r
19 import org.simantics.editors.win32.ole.EditorDefinition;\r
20 \r
21 /**\r
22  * EditorInput for the OLEEditor component.\r
23  * Input can be configured in two ways: \r
24  * \r
25  * 1) giving an input file and the system tries to find proper ActiveX component for it.\r
26  * 2) giving both input file, and ActiveX component's progID.\r
27  * \r
28  * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>\r
29  *\r
30  */\r
31 public class OLEEditorInput implements IEditorInput {\r
32         \r
33         private String name;\r
34         private EditorDefinition factory;\r
35         private File file;\r
36         private boolean fullscreen;\r
37         \r
38         public OLEEditorInput(EditorDefinition factory, File file) {\r
39                 this(factory,file,false);\r
40         }\r
41         \r
42         public OLEEditorInput(EditorDefinition factory, File file, boolean fullscreen) {\r
43                 this(factory,file,file.getName(),fullscreen);\r
44         }\r
45         \r
46         public OLEEditorInput(EditorDefinition factory, File file, String name, boolean fullscreen) {\r
47                 if (file == null || factory == null || name == null)\r
48                         throw new NullPointerException();\r
49                 this.file = file;\r
50                 this.factory = factory;\r
51                 this.fullscreen = fullscreen;\r
52                 this.name = name;\r
53         }\r
54         \r
55 \r
56         @Override\r
57         public boolean exists() {\r
58                 return false;\r
59         }\r
60 \r
61         @Override\r
62         public ImageDescriptor getImageDescriptor() {\r
63                 return null;\r
64         }\r
65 \r
66         @Override\r
67         public String getName() {\r
68                 return name;\r
69         }\r
70 \r
71         @Override\r
72         public IPersistableElement getPersistable() {\r
73                 return null;\r
74         }\r
75 \r
76         @Override\r
77         public String getToolTipText() {\r
78                 return getName();\r
79         }\r
80 \r
81         @SuppressWarnings({ "rawtypes" })\r
82         @Override\r
83         public Object getAdapter(Class adapter) {\r
84                 return null;\r
85         }\r
86 \r
87         public File getFile() {\r
88                 return file;\r
89         }\r
90         \r
91         public EditorDefinition getFactory() {\r
92                 return factory;\r
93         }\r
94         \r
95         public boolean isFullscreen() {\r
96                 return fullscreen;\r
97         }\r
98         \r
99         @Override\r
100         public boolean equals(Object arg0) {\r
101                 if (arg0 == null)\r
102                         return false;\r
103                 if (arg0.getClass() != getClass())\r
104                         return false;\r
105                 OLEEditorInput other = (OLEEditorInput)arg0;\r
106                 return other.file.equals(file);\r
107                                         \r
108         }\r
109         \r
110         @Override\r
111         public int hashCode() {\r
112                 return file.hashCode();\r
113         }\r
114 \r
115         \r
116 \r
117 }\r