]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.editors.win32/src/org/simantics/editors/win32/OLEEditorInput.java b/bundles/org.simantics.editors.win32/src/org/simantics/editors/win32/OLEEditorInput.java
new file mode 100644 (file)
index 0000000..bef0f10
--- /dev/null
@@ -0,0 +1,117 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.editors.win32;\r
+\r
+import java.io.File;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.ui.IPersistableElement;\r
+import org.simantics.editors.win32.ole.EditorDefinition;\r
+\r
+/**\r
+ * EditorInput for the OLEEditor component.\r
+ * Input can be configured in two ways: \r
+ * \r
+ * 1) giving an input file and the system tries to find proper ActiveX component for it.\r
+ * 2) giving both input file, and ActiveX component's progID.\r
+ * \r
+ * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>\r
+ *\r
+ */\r
+public class OLEEditorInput implements IEditorInput {\r
+       \r
+       private String name;\r
+       private EditorDefinition factory;\r
+       private File file;\r
+       private boolean fullscreen;\r
+       \r
+       public OLEEditorInput(EditorDefinition factory, File file) {\r
+               this(factory,file,false);\r
+       }\r
+       \r
+       public OLEEditorInput(EditorDefinition factory, File file, boolean fullscreen) {\r
+               this(factory,file,file.getName(),fullscreen);\r
+       }\r
+       \r
+       public OLEEditorInput(EditorDefinition factory, File file, String name, boolean fullscreen) {\r
+               if (file == null || factory == null || name == null)\r
+                       throw new NullPointerException();\r
+               this.file = file;\r
+               this.factory = factory;\r
+               this.fullscreen = fullscreen;\r
+               this.name = name;\r
+       }\r
+       \r
+\r
+       @Override\r
+       public boolean exists() {\r
+               return false;\r
+       }\r
+\r
+       @Override\r
+       public ImageDescriptor getImageDescriptor() {\r
+               return null;\r
+       }\r
+\r
+       @Override\r
+       public String getName() {\r
+               return name;\r
+       }\r
+\r
+       @Override\r
+       public IPersistableElement getPersistable() {\r
+               return null;\r
+       }\r
+\r
+       @Override\r
+       public String getToolTipText() {\r
+               return getName();\r
+       }\r
+\r
+       @SuppressWarnings({ "rawtypes" })\r
+       @Override\r
+       public Object getAdapter(Class adapter) {\r
+               return null;\r
+       }\r
+\r
+       public File getFile() {\r
+               return file;\r
+       }\r
+       \r
+       public EditorDefinition getFactory() {\r
+               return factory;\r
+       }\r
+       \r
+       public boolean isFullscreen() {\r
+               return fullscreen;\r
+       }\r
+       \r
+       @Override\r
+       public boolean equals(Object arg0) {\r
+               if (arg0 == null)\r
+                       return false;\r
+               if (arg0.getClass() != getClass())\r
+                       return false;\r
+               OLEEditorInput other = (OLEEditorInput)arg0;\r
+               return other.file.equals(file);\r
+                                       \r
+       }\r
+       \r
+       @Override\r
+       public int hashCode() {\r
+               return file.hashCode();\r
+       }\r
+\r
+       \r
+\r
+}\r