Hi Lars, Eric, Wim,
Many thank's for your answer!
> I think Angelo wants some base class which already implements dirty, focus, memento, save as, issaveasallowed, editor input, etcetera. An editor that is uniform to workbench requirements and that plays along well with the 3.x editor lifecycle.
Exactly!
>I'm not sure why you think it's necessary to have a base class though; we already handle focus and dirty etc through the model.
When you are newbie to develop some editor with E4 (as me), it's difficult to know how to start (except if you read tutorial of Lars:)). I think if E4 provides some framework by providing some base class, it should be easier.
Takes a basic sample of Lars tutorial :
------------------------------------------------------------------
public class MySavePart {
@Inject
MDirtyable dirty;
@PostConstruct
public void createControls(Composite parent) {
Button button = new Button(parent, SWT.PUSH);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dirty.setDirty(true);
}
});
}
}
------------------------------------------------------------------
In this sample you need to declare MDirtyable with @Inject and createControls with @PostConstruct. If you are newbie, you can forget to set the well annotation. If E4 provides a base class like this :
------------------------------------------------------------------
public abstract class BasePart {
@Inject
protected MDirtyable dirty;
@PostConstruct
public abstract void createControls(Composite parent);
}
------------------------------------------------------------------
After you could implement like this :
------------------------------------------------------------------
public class MySavePart extends BasePart {
public void createControls(Composite parent) {
Button button = new Button(parent, SWT.PUSH);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dirty.setDirty(true);
}
});
}
}
------------------------------------------------------------------
It's a basic example, but if E4 doesn't provide this BasePart class, I think each people will create that to avoid duplicate the code. But perhaps I'm wrong.
@Lars : it should be fantastic if you can send me the part about the editor of your chapter. I will follow you to buy it as soon as it will available (I have already the first edition).
Regards Angelo