blob: 922fe5f0e337316ff408a9c4e6ca5d4ead106321 [file] [log] [blame]
/*
* Copyright (c) 2020 Eike Stepper (Loehne, Germany) and others.
* 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:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.emf.cdo.internal.ui.editor;
import org.eclipse.emf.cdo.eresource.CDOResourceLeaf;
import org.eclipse.emf.common.util.URI;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
/**
* A text editor will consult {@link CDOLobStorage} for this input.
*
* @author Eike Stepper
*/
public class CDOLobEditorInput extends PlatformObject implements IEditorInput
{
private final CDOResourceLeaf resource;
private final boolean commitOnSave;
private URI uri;
public CDOLobEditorInput(CDOResourceLeaf resource)
{
this(resource, false);
}
public CDOLobEditorInput(CDOResourceLeaf resource, boolean commitOnSave)
{
this.resource = resource;
this.commitOnSave = commitOnSave;
}
public final CDOResourceLeaf getResource()
{
return resource;
}
public final boolean isCommitOnSave()
{
return commitOnSave;
}
public final URI getURI()
{
return uri == null ? resource.getURI() : uri;
}
public final void setURI(URI uri)
{
this.uri = uri;
}
@Override
public boolean exists()
{
return true;
}
@Override
public ImageDescriptor getImageDescriptor()
{
return null;
}
@Override
public String getName()
{
return resource.getName();
}
@Override
public IPersistableElement getPersistable()
{
return null;
}
@Override
public String getToolTipText()
{
return resource.getURI().toString();
}
@Override
@SuppressWarnings("unchecked")
public <T> T getAdapter(Class<T> type)
{
T adapter = super.getAdapter(type);
if (adapter == null && type == URI.class)
{
adapter = (T)getURI();
}
return adapter;
}
}