-/*******************************************************************************\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 org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.layout.FillLayout;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.ole.win32.OleAutomation;\r
-import org.eclipse.swt.ole.win32.OleClientSite;\r
-import org.eclipse.swt.ole.win32.OleFrame;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.IEditorInput;\r
-import org.eclipse.ui.IEditorSite;\r
-import org.eclipse.ui.PartInitException;\r
-import org.eclipse.ui.part.EditorPart;\r
-import org.simantics.editors.win32.ole.EditorDefinition;\r
-import org.simantics.editors.win32.ole.OleController;\r
-\r
-\r
-/**\r
- * OLEEditor is a wrapper for Windows ActiveX components.\r
- * \r
- * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>\r
- *\r
- */\r
-public class OLEEditor extends EditorPart {\r
-\r
- private OleFrame frame;\r
- private OleClientSite site;\r
- private OleAutomation auto;\r
- private OleController ctrl;\r
- \r
- private Shell fsShell;\r
- \r
- public OLEEditor() {\r
- super();\r
- }\r
-\r
- @Override\r
- public void doSave(IProgressMonitor monitor) {\r
-\r
- }\r
-\r
- @Override\r
- public void doSaveAs() {\r
-\r
- }\r
-\r
- @Override\r
- public void init(IEditorSite site, IEditorInput input)\r
- throws PartInitException {\r
- if (!(input instanceof OLEEditorInput))\r
- throw new PartInitException("Input must be OLEEditorInput");\r
- setInput(input);\r
- setSite(site);\r
-\r
- }\r
-\r
- @Override\r
- public boolean isDirty() {\r
- return false;\r
- }\r
-\r
- @Override\r
- public boolean isSaveAsAllowed() {\r
- return false;\r
- }\r
- \r
-\r
- @Override\r
- public void createPartControl(Composite parent) {\r
- OLEEditorInput input = (OLEEditorInput)getEditorInput();\r
- boolean fullscreen = input.isFullscreen();\r
- if (fullscreen) {\r
- fsShell = new Shell(parent.getDisplay());\r
- \r
- fsShell.setLayout(new GridLayout(1,false));\r
- fsShell.setLayout(new FillLayout());\r
- parent = new Composite(fsShell,SWT.NONE);\r
- fsShell.open();\r
- fsShell.setFullScreen(true);\r
- parent.setLayout(new FillLayout());\r
- }\r
- \r
- \r
- EditorDefinition factory = input.getFactory();\r
- frame = new OleFrame(parent, SWT.NONE);\r
- \r
- if (factory.getProgID() == null || factory.useFileInput()) {\r
- site = new OleClientSite(frame,SWT.NONE,input.getFile());\r
- } else {\r
- site = new OleClientSite(frame, SWT.NONE, factory.getProgID());\r
- auto = new OleAutomation(site);\r
- ctrl = factory.createController(frame, site, auto);\r
- ctrl.show(input);\r
- }\r
- \r
- setPartName(site.getProgramID() + " : " + input.getName());\r
- \r
- if (fullscreen) {\r
- fsShell.layout(true, true);\r
- }\r
- }\r
-\r
- @Override\r
- public void setFocus() {\r
- frame.setFocus();\r
- }\r
- \r
- /**\r
- * Returns OleController of embedded OLE component. May return null.\r
- * @return\r
- */\r
- public OleController getController() {\r
- return ctrl;\r
- }\r
- \r
- @Override\r
- public void dispose() {\r
- if (auto != null)\r
- auto.dispose();\r
- site.dispose();\r
- if (fsShell != null)\r
- fsShell.dispose();\r
- if (frame != null) {\r
- frame.dispose();\r
- }\r
- super.dispose();\r
-\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.editors.win32;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.ole.win32.OleAutomation;
+import org.eclipse.swt.ole.win32.OleClientSite;
+import org.eclipse.swt.ole.win32.OleFrame;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+import org.simantics.editors.win32.ole.EditorDefinition;
+import org.simantics.editors.win32.ole.OleController;
+
+
+/**
+ * OLEEditor is a wrapper for Windows ActiveX components.
+ *
+ * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>
+ *
+ */
+public class OLEEditor extends EditorPart {
+
+ private OleFrame frame;
+ private OleClientSite site;
+ private OleAutomation auto;
+ private OleController ctrl;
+
+ private Shell fsShell;
+
+ public OLEEditor() {
+ super();
+ }
+
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+
+ }
+
+ @Override
+ public void doSaveAs() {
+
+ }
+
+ @Override
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ if (!(input instanceof OLEEditorInput))
+ throw new PartInitException("Input must be OLEEditorInput");
+ setInput(input);
+ setSite(site);
+
+ }
+
+ @Override
+ public boolean isDirty() {
+ return false;
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+
+ @Override
+ public void createPartControl(Composite parent) {
+ OLEEditorInput input = (OLEEditorInput)getEditorInput();
+ boolean fullscreen = input.isFullscreen();
+ if (fullscreen) {
+ fsShell = new Shell(parent.getDisplay());
+
+ fsShell.setLayout(new GridLayout(1,false));
+ fsShell.setLayout(new FillLayout());
+ parent = new Composite(fsShell,SWT.NONE);
+ fsShell.open();
+ fsShell.setFullScreen(true);
+ parent.setLayout(new FillLayout());
+ }
+
+
+ EditorDefinition factory = input.getFactory();
+ frame = new OleFrame(parent, SWT.NONE);
+
+ if (factory.getProgID() == null || factory.useFileInput()) {
+ site = new OleClientSite(frame,SWT.NONE,input.getFile());
+ } else {
+ site = new OleClientSite(frame, SWT.NONE, factory.getProgID());
+ auto = new OleAutomation(site);
+ ctrl = factory.createController(frame, site, auto);
+ ctrl.show(input);
+ }
+
+ setPartName(site.getProgramID() + " : " + input.getName());
+
+ if (fullscreen) {
+ fsShell.layout(true, true);
+ }
+ }
+
+ @Override
+ public void setFocus() {
+ frame.setFocus();
+ }
+
+ /**
+ * Returns OleController of embedded OLE component. May return null.
+ * @return
+ */
+ public OleController getController() {
+ return ctrl;
+ }
+
+ @Override
+ public void dispose() {
+ if (auto != null)
+ auto.dispose();
+ site.dispose();
+ if (fsShell != null)
+ fsShell.dispose();
+ if (frame != null) {
+ frame.dispose();
+ }
+ super.dispose();
+
+ }
+
+}