/** * Copyright 2010 The University of North Carolina at Chapel Hill * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package unc.lib.cdr.workbench.capture; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IPersistableElement; /** * @author Gregory Jansen * */ public class OriginalFolderEditorInput implements IEditorInput { IPath platformPath = null; public OriginalFolderEditorInput(IFolder f) { this.platformPath = f.getFullPath(); } public IFolder getFolder() { return ResourcesPlugin.getWorkspace().getRoot().getFolder(platformPath); } @SuppressWarnings("unchecked") @Override public Object getAdapter(Class adapter) { return Platform.getAdapterManager().getAdapter(this, adapter); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final OriginalFolderEditorInput other = (OriginalFolderEditorInput) obj; if (this.platformPath == null) { if (other.platformPath != null) { return false; } } else if (!this.platformPath.equals(other.platformPath)) { return false; } return true; } /* * (non-Javadoc) * * @see org.eclipse.ui.IEditorInput#exists() */ @Override public boolean exists() { return false; } /* * (non-Javadoc) * * @see org.eclipse.ui.IEditorInput#getImageDescriptor() */ @Override public ImageDescriptor getImageDescriptor() { return null; } /* * (non-Javadoc) * * @see org.eclipse.ui.IEditorInput#getName() */ @Override public String getName() { return this.platformPath.lastSegment(); } /* * (non-Javadoc) * * @see org.eclipse.ui.IEditorInput#getPersistable() */ @Override public IPersistableElement getPersistable() { return null; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((this.platformPath == null) ? 0 : this.platformPath.hashCode()); return result; } /* * (non-Javadoc) * * @see org.eclipse.ui.IEditorInput#getToolTipText() */ @Override public String getToolTipText() { return ""; } }