-/*******************************************************************************\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;\r
-\r
-import java.io.File;\r
-import java.net.URL;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.core.resources.IWorkspace;\r
-import org.eclipse.core.resources.ResourcesPlugin;\r
-import org.eclipse.ui.IEditorDescriptor;\r
-import org.eclipse.ui.IEditorPart;\r
-import org.eclipse.ui.IEditorRegistry;\r
-import org.eclipse.ui.IMemento;\r
-import org.eclipse.ui.IWorkbenchPage;\r
-import org.eclipse.ui.IWorkbenchWindow;\r
-import org.eclipse.ui.PartInitException;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.eclipse.ui.part.FileEditorInput;\r
-import org.simantics.editors.internal.SystemFile;\r
-import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
-\r
-public class Editors {\r
-\r
- public static IEditorPart openBrowser(URL url) throws PartInitException {\r
- return openBrowser(url, false);\r
- }\r
-\r
- public static IEditorPart openBrowser(URL url, boolean fullscreen) throws PartInitException {\r
- BrowserInput input = new BrowserInput(url, true, fullscreen);\r
- return WorkbenchUtils.openEditor("org.simantics.editors.browser", input);\r
- }\r
- \r
- public static IEditorPart openExternalEditor(File file) throws PartInitException {\r
- IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);\r
- IWorkspace ws = (IWorkspace) ResourcesPlugin.getWorkspace();\r
- FileEditorInput input = new ExternalFileEditorInput(new SystemFile(file, ws));\r
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\r
- IWorkbenchPage page = window.getActivePage();\r
- return page.openEditor(input, desc.getId());\r
- \r
- }\r
- \r
- private static class ExternalFileEditorInput extends FileEditorInput {\r
-\r
- public ExternalFileEditorInput(IFile file) {\r
- super(file);\r
- }\r
- \r
- @Override\r
- public void saveState(IMemento memento) {\r
- \r
- }\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;
+
+import java.io.File;
+import java.net.URL;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorRegistry;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.simantics.editors.internal.SystemFile;
+import org.simantics.utils.ui.workbench.WorkbenchUtils;
+
+public class Editors {
+
+ public static IEditorPart openBrowser(URL url) throws PartInitException {
+ return openBrowser(url, false);
+ }
+
+ public static IEditorPart openBrowser(URL url, boolean fullscreen) throws PartInitException {
+ BrowserInput input = new BrowserInput(url, true, fullscreen);
+ return WorkbenchUtils.openEditor("org.simantics.editors.browser", input);
+ }
+
+ public static IEditorPart openExternalEditor(File file) throws PartInitException {
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
+ IWorkspace ws = (IWorkspace) ResourcesPlugin.getWorkspace();
+ FileEditorInput input = new ExternalFileEditorInput(new SystemFile(file, ws));
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ return page.openEditor(input, desc.getId());
+
+ }
+
+ private static class ExternalFileEditorInput extends FileEditorInput {
+
+ public ExternalFileEditorInput(IFile file) {
+ super(file);
+ }
+
+ @Override
+ public void saveState(IMemento memento) {
+
+ }
+
+ }
+
+}