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