1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.editors;
\r
14 import java.net.URL;
\r
16 import org.eclipse.jface.resource.ImageDescriptor;
\r
17 import org.eclipse.swt.SWT;
\r
18 import org.eclipse.ui.IEditorInput;
\r
19 import org.eclipse.ui.IPersistableElement;
\r
22 * EditorInput for the Browser component.
\r
25 * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>
\r
26 * @author Tuukka Lehtonen
\r
28 public class BrowserInput implements IEditorInput {
\r
31 private String name;
\r
32 private final boolean showControls;
\r
33 private final boolean fullscreen;
\r
34 private int browserStyle = SWT.NONE;
\r
37 * Creates an input for a browser that has visible controls.
\r
39 * @param url the url that browser opens.
\r
41 public BrowserInput(URL url) {
\r
43 this.showControls = true;
\r
44 this.fullscreen = false;
\r
48 * Creates an input for a browser that has visible controls.
\r
50 * @param url the url that browser opens.
\r
52 public BrowserInput(URL url, String name) {
\r
54 this.showControls = true;
\r
55 this.fullscreen = false;
\r
59 * Creates an input for a browser.
\r
61 * @param url the url that browser opens.
\r
62 * @param showControls visibility flag of controls
\r
64 public BrowserInput(URL url, boolean showControls) {
\r
66 this.showControls = showControls;
\r
67 this.fullscreen = false;
\r
70 public BrowserInput(URL url, boolean showControls, boolean fullscreen) {
\r
72 this.showControls = showControls;
\r
73 this.fullscreen = fullscreen;
\r
76 public BrowserInput(URL url, boolean showControls, boolean fullscreen, int style) {
\r
77 this(url, null, showControls, fullscreen, style);
\r
80 public BrowserInput(URL url, String name, boolean showControls, boolean fullscreen, int style) {
\r
83 this.showControls = showControls;
\r
84 this.fullscreen = fullscreen;
\r
85 this.browserStyle = style;
\r
88 public void setUrl(URL url) {
\r
92 public URL getUrl() {
\r
96 public boolean isShowControls() {
\r
97 return showControls;
\r
101 public boolean exists() {
\r
106 public ImageDescriptor getImageDescriptor() {
\r
110 public void setName(String name) {
\r
115 public String getName() {
\r
118 return url.toString();
\r
122 public IPersistableElement getPersistable() {
\r
127 public String getToolTipText() {
\r
128 //return getName();
\r
129 return getUrl().toString();
\r
132 public boolean isFullscreen() {
\r
136 public int getBrowserStyle() {
\r
137 return browserStyle;
\r
140 @SuppressWarnings({ "rawtypes" })
\r
142 public Object getAdapter(Class adapter) {
\r
147 public int hashCode() {
\r
148 final int prime = 31;
\r
150 result = prime * result + browserStyle;
\r
151 result = prime * result + (fullscreen ? 1231 : 1237);
\r
152 result = prime * result + (showControls ? 1231 : 1237);
\r
153 result = prime * result + ((url == null) ? 0 : url.hashCode());
\r
158 public boolean equals(Object obj) {
\r
163 if (getClass() != obj.getClass())
\r
165 BrowserInput other = (BrowserInput) obj;
\r
166 if (browserStyle != other.browserStyle)
\r
168 if (fullscreen != other.fullscreen)
\r
170 if (showControls != other.showControls)
\r
173 if (other.url != null)
\r
175 } else if (!url.equals(other.url))
\r