Changes

Jump to: navigation, search

Teams Winter 2011/team1/RCP/Define and use editors

842 bytes added, 18:14, 4 March 2011
3. Define and Use Editors
</source>
3.2 Add input editor
2.3. Editor Input
 
IEditorInput serves as the model for the editor and is supposed to be a light-weight representation of the model. For example the Eclipse IDE uses this concept to identify files without handling with the complete file. Based on the equals method the system will determine if the corresponding editor is already open or not therefore you should overwrite the method equals and hashcode in an implementation of IEditor.
Create the new class <code>''MyStudentEditorInput''</code> which implements <code>''IEditorInput''</code>.
<source lang=java>
 
package cs.ecl.rcp.simplercp.editor;
 
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
 
public class MyStudentEditorInput implements IEditorInput {
private final String id;
 
public MyStudentEditorInput(String id) {
this.id = id;
}
 
public String getId() {
return id;
}
 
@Override
public Object getAdapter(Class adapter) {
return null;
}
 
@Override
public boolean exists() {
return true;
}
 
@Override
public ImageDescriptor getImageDescriptor() {
return null;
}
 
@Override
public String getName() {
return String.valueOf(id);
}
 
@Override
public IPersistableElement getPersistable() {
return null;
}
 
@Override
public String getToolTipText() {
return "Displays a student";
}
 
 
}
 
</source>
1
edit

Navigation menu