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