package org.codefaces.ui.internal.editors;
import org.codefaces.core.models.RepoFile;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
public class RepoFileInput implements IEditorInput {
private RepoFile file;
public RepoFileInput(RepoFile file) {
this.file = file;
}
public RepoFile getFile() {
return file;
}
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class adapter) {
return file.getAdapter(adapter);
}
@Override
public boolean exists() {
return true;
}
@Override
public ImageDescriptor getImageDescriptor() {
return ImageDescriptor.getMissingImageDescriptor();
}
@Override
public String getName() {
return file.getName();
}
@Override
public IPersistableElement getPersistable() {
return null;
}
@Override
public String getToolTipText() {
return file.getPath().toString().substring(1);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((file == null) ? 0 : file.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
RepoFileInput other = (RepoFileInput) obj;
if (file == null) {
if (other.file != null)
return false;
} else if (!file.equals(other.file))
return false;
return true;
}
}