| Edit a part context with an handler [message #833302] |
Sat, 31 March 2012 04:38  |
|
Goodmorning everyone,
I've got a problem.
I have an application with one Part who is linked to class editor.java
In this part there is a textarea and I'm trying to create a button menu who clean the textarea.
In editor.java there is this method:
@Inject
@Optional
public void setEditorTxt( @Named("setTxt") String text) {
txt.setText(text);
}
and in button's handler I've added this method:
@Execute
public <MApplication> void execute() {
MPart editor = partService.findPart("org.unifi.inf.tds.editorpart");
IEclipseContext cEditor = editor.getContext();
cEditor.set("setTxt", "");
}
First time I use the button, it works. Next time it doen't nothing.
Any suggestions?
Very thank you,
regards.
|
|
|
|
|
|
| Re: Edit a part context with an handler [message #834680 is a reply to message #833557] |
Mon, 02 April 2012 04:56   |
|
Sopot Cela wrote on Sat, 31 March 2012 19:52
Put this in the part class:
@Inject
public void clear(@Optional @UIEventTopic("CLEAR_IT") Object dummy){
if (txt!=null)
txt.setText("");
}
and this in the handler:
@Inject
IEventBroker eventBroker;
@Execute
public void execute() {
eventBroker.post("CLEAR_IT", null);
}
I've tried to do this but method clear not be executed. eventBroker.post("CLEAR_IT", null); returns true but nothing happens.
Thank you for your kind,
TDS.
|
|
|
|
|
|
| Re: Edit a part context with an handler [message #857450 is a reply to message #856125] |
Thu, 26 April 2012 10:49   |
|
I'm working again with part.
I want to create an infrastructure that opens part and gives them some information in a class called "EditorMaker".
I've seen this example on Vogella:
@Execute
public void open(
MyInput input
MApplication application,
EModelService modelService,
EPartService partService) {
// Assuming that all editors should open in the the stack with the
// ID "org.eclipse.e4.primaryDataStack"
MPartStack stack = (MPartStack) modelService.find("org.eclipse.e4.primaryDataStack", application);
MInputPart part = MBasicFactory.INSTANCE.createInputPart();
// Pointing to the contributing class
part.setContributionURI("bundleclass://de.vogella.rcp.e4.todo/de.vogella.rcp.e4.parts.Part1");
part.setInputURI(input.getInputURI());
part.setIconURI("platform:/plugin/de.vogella.rcp.e4.todo/icons/sample.gif");
part.setLabel(input.getName());
part.setTooltip(input.getTooltip());
part.setCloseable(true);
stack.getChildren().add(part);
partService.showPart(part, PartState.ACTIVATE);
}
so I've tryed to do a code like that in my part's class:
@PostConstruct
public void createControls(Composite parent, EditorMaker em) {
System.out.println(em!=null);
}
EditorMaker is created by the handler which open the part.
But I've got this error:
org.eclipse.e4.core.di.InjectionException: Unable to process "Editor#createControls()": no actual value was found for the argument "EditorMaker".
Where is the mistake?
Thank you.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02097 seconds