Changes

Jump to: navigation, search

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

2,242 bytes added, 19:06, 4 March 2011
no edit summary
In class, enter <code>''cs.ecl.rcp.simplercp.MyStudentEditor''</code>.<br/>
[[Image: rcp_editor1.jpg | 700px]]<br/>
Here is the content of the class. Make sure the <code>ID</code> matches the ID of the editor extension.
 
<source lang=java>
 
public class MyStudentEditor extends EditorPart {
public static final String ID = "cs.ecl.rcp.simplercp.editor.studenteditor";
private Student student;
private MyStudentEditorInput input;
 
public MyStudentEditor() {
// TODO Auto-generated constructor stub
}
 
@Override
public void doSave(IProgressMonitor monitor) {
}
 
@Override
public void doSaveAs() {
}
 
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
if (!(input instanceof MyStudentEditorInput)) {
throw new RuntimeException("Wrong input");
}
 
MyStudentEditorInput new_name = (MyStudentEditorInput) input;
this.input = (MyStudentEditorInput) input;
setSite(site);
setInput(input);
student = ModelProvider.INSTANCE.getPersonById(this.input.getId());
setPartName("Student " + student.getLastName());
 
}
 
@Override
public boolean isDirty() {
return false;
}
 
@Override
public boolean isSaveAsAllowed() {
return false;
}
 
@Override
public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout();
layout.numColumns = 2;
parent.setLayout(layout);
Label label = new Label(parent, SWT.BORDER);
label.setText("ID");
Text text = new Text(parent, SWT.BORDER);
text.setText(student.getId());
text.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
Label label1 = new Label(parent, SWT.BORDER);
label1.setText("First Name");
Text text1 = new Text(parent, SWT.BORDER);
text1.setText(student.getFirstName());
text1.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
Label label2 = new Label(parent, SWT.BORDER);
label2.setText("Last Name");
Text text2 = new Text(parent, SWT.BORDER);
text2.setText(student.getLastName());
text2.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
Label label3 = new Label(parent, SWT.BORDER);
label3.setText("Program");
Text text3 = new Text(parent, SWT.BORDER);
text3.setText(student.getProgram());
text3.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
 
}
 
 
@Override
public void setFocus() {
 
}
 
}
</source>
1
edit

Navigation menu