1 package org.simantics.scl.ui.editor2;
3 import org.eclipse.jface.resource.ImageDescriptor;
4 import org.eclipse.ui.IMemento;
5 import org.eclipse.ui.IPersistableElement;
6 import org.simantics.scl.compiler.source.ModuleSource;
7 import org.simantics.scl.osgi.SCLOsgi;
9 public class StandardSCLModuleEditorInput implements SCLModuleEditorInput, IPersistableElement {
11 private final String moduleName;
13 public StandardSCLModuleEditorInput(String moduleName) {
14 this.moduleName = moduleName;
18 public boolean exists() {
19 return SCLOsgi.SOURCE_REPOSITORY.getModuleSource(moduleName, null) != null;
23 public ImageDescriptor getImageDescriptor() {
28 public String getModuleName() {
33 public String getName() {
34 int p = moduleName.lastIndexOf('/');
36 return moduleName.substring(p+1);
42 public IPersistableElement getPersistable() {
47 public String getToolTipText() {
51 @SuppressWarnings("unchecked")
53 public <T> T getAdapter(Class<T> adapter) {
54 if(adapter.equals(ModuleSource.class))
55 return (T)SCLOsgi.SOURCE_REPOSITORY.getModuleSource(moduleName, null);
56 if(adapter.equals(IPersistableElement.class))
62 public int hashCode() {
65 result = prime * result + ((moduleName == null) ? 0 : moduleName.hashCode());
70 public boolean equals(Object obj) {
73 if (obj == null || getClass() != obj.getClass())
75 StandardSCLModuleEditorInput other = (StandardSCLModuleEditorInput) obj;
76 return moduleName.equals(other.moduleName);
80 public void saveState(IMemento memento) {
81 memento.putTextData(moduleName);
85 public String getFactoryId() {
86 return "org.simantics.scl.ui.editor.inputFactory";