--- /dev/null
+/*******************************************************************************\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.net.URL;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.ui.IPersistableElement;\r
+\r
+/**\r
+ * EditorInput for the Browser component.\r
+ * \r
+ * \r
+ * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class BrowserInput implements IEditorInput {\r
+\r
+ private URL url;\r
+ private String name;\r
+ private final boolean showControls;\r
+ private final boolean fullscreen;\r
+ private int browserStyle = SWT.NONE;\r
+\r
+ /**\r
+ * Creates an input for a browser that has visible controls.\r
+ * \r
+ * @param url the url that browser opens.\r
+ */\r
+ public BrowserInput(URL url) {\r
+ this.url = url;\r
+ this.showControls = true;\r
+ this.fullscreen = false;\r
+ }\r
+\r
+ /**\r
+ * Creates an input for a browser that has visible controls.\r
+ * \r
+ * @param url the url that browser opens.\r
+ */\r
+ public BrowserInput(URL url, String name) {\r
+ this.url = url;\r
+ this.showControls = true;\r
+ this.fullscreen = false;\r
+ }\r
+\r
+ /**\r
+ * Creates an input for a browser.\r
+ * \r
+ * @param url the url that browser opens.\r
+ * @param showControls visibility flag of controls\r
+ */\r
+ public BrowserInput(URL url, boolean showControls) {\r
+ this.url = url;\r
+ this.showControls = showControls;\r
+ this.fullscreen = false;\r
+ }\r
+\r
+ public BrowserInput(URL url, boolean showControls, boolean fullscreen) {\r
+ this.url = url;\r
+ this.showControls = showControls;\r
+ this.fullscreen = fullscreen;\r
+ }\r
+\r
+ public BrowserInput(URL url, boolean showControls, boolean fullscreen, int style) {\r
+ this(url, null, showControls, fullscreen, style);\r
+ }\r
+\r
+ public BrowserInput(URL url, String name, boolean showControls, boolean fullscreen, int style) {\r
+ this.url = url;\r
+ this.name = name;\r
+ this.showControls = showControls;\r
+ this.fullscreen = fullscreen;\r
+ this.browserStyle = style;\r
+ }\r
+\r
+ public void setUrl(URL url) {\r
+ this.url = url;\r
+ }\r
+\r
+ public URL getUrl() {\r
+ return url;\r
+ }\r
+\r
+ public boolean isShowControls() {\r
+ return showControls;\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
+ public void setName(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ @Override\r
+ public String getName() {\r
+ if (name != null)\r
+ return name;\r
+ return url.toString();\r
+ }\r
+\r
+ @Override\r
+ public IPersistableElement getPersistable() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getToolTipText() {\r
+ //return getName();\r
+ return getUrl().toString();\r
+ }\r
+\r
+ public boolean isFullscreen() {\r
+ return fullscreen;\r
+ }\r
+\r
+ public int getBrowserStyle() {\r
+ return browserStyle;\r
+ }\r
+\r
+ @SuppressWarnings({ "rawtypes" })\r
+ @Override\r
+ public Object getAdapter(Class adapter) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + browserStyle;\r
+ result = prime * result + (fullscreen ? 1231 : 1237);\r
+ result = prime * result + (showControls ? 1231 : 1237);\r
+ result = prime * result + ((url == null) ? 0 : url.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (obj == null)\r
+ return false;\r
+ if (getClass() != obj.getClass())\r
+ return false;\r
+ BrowserInput other = (BrowserInput) obj;\r
+ if (browserStyle != other.browserStyle)\r
+ return false;\r
+ if (fullscreen != other.fullscreen)\r
+ return false;\r
+ if (showControls != other.showControls)\r
+ return false;\r
+ if (url == null) {\r
+ if (other.url != null)\r
+ return false;\r
+ } else if (!url.equals(other.url))\r
+ return false;\r
+ return true;\r
+ }\r
+\r
+}\r