|
|
|
|
|
|
|
|
|
|
|
|
Re: dynamically add part to partStack [message #988852 is a reply to message #988844] |
Mon, 03 December 2012 08:13   |
Eclipse User |
|
|
|
Why does you ModelViewer extend Composite? I can't imagine that any of
our tutorials shows such a structure?
I already answered how you can pass information to your Part-Bean in my
last response to you.
One solution is to store informations on the MPart instance when
creating it.
class MyModelViewer {
@PostConstruct
void init(Composite comp, MPart part) {
part.getPersistedData().get("myspecial data");
}
}
If you happen to have created an MInputPart you could have filled the
inputURI field with data and accessed in a similar way.
class MyModelViewer {
@PostConstruct
void init(Composite comp, MInputPart part) {
part.getInputURI()
}
}
Tom
Am 03.12.12 13:48, schrieb Aljoscha Steffens:
> Thanks a lot Sopot Cela! I'm not yet a 100% clear what you mean but
> about 90% :p It's all new stuff for me and I guess, I'll reach the 100%
> if I see some more Model Interfaces and remember what you said.
>
> But I still have no idea how to handle my problem. So there is this
> parstack which holds parts. When I add a part to this partstack, it
> needs a Class URI. Is this the correct class for the job?public class
> ModelViewer extends Composite {
>
> private ModelObject model;
> @Inject
> //controller is only injected so there is an instance of it somewhere
> public ModelViewer(Composite parent, Controller controller){
> super(parent, SWT.NONE);
> this.setLayout(new FillLayout());
> this.model = new ModelObject("new File");
>
> }
>
> @PostConstruct
> private void createContents(){
> TextViewer viewer = new TextViewer(this, SWT.V_SCROLL |
> SWT.H_SCROLL | SWT.WRAP | SWT.MULTI ) ;
> IDocument document = new Document();
> document.set(model.getContent());
> viewer.setDocument(document);
>
> }
>
> }
>
> Or would I set sth else for the Class URI, which then implements my
> ModelViewer?
> So in this tutorial:
> http://www.vogella.com/articles/Eclipse4Editor/article.html#eclipse4editor
> what would be my Contribution URI and what my Input URI?
|
|
|
Re: dynamically add part to partStack [message #989143 is a reply to message #988852] |
Tue, 04 December 2012 14:28   |
Eclipse User |
|
|
|
Hmm okay, extending a composite is not usefull. I read it in some other tutorial.
Sorry, but I still don't have any idea what to do. Actually it got worse.
First of all: MPart has not function called getPersistedData() (at least I can't find it).
But even if it did, I wouldn't know what to do since I don't understand the structure. And there literally 2 google entries when I look for 'MPart rcp'. Only thing usefull is this: http://www.vogella.com/articles/Eclipse4Services/article.html#selectedservices_partservice I'm very sorry, but I can't figure it out myself if I have barley any sources I can rely on.
So my idea of parts is, that they are basically views. A part would take something like a textedit (or my ModelViewer) and display it.
1.: So why would my ModelViewer need an instance of MPart or MInputPart?
public class NewModelHandler {
....
public void execute(EModelService modelService, MApplication app, EPartService partService) {
MInputPart part = MBasicFactory.INSTANCE.createInputPart();
part.setContributionURI("bundleclass://Test/Test.parts.ModelViewer");
part.setInputURI("bundleclass://Test/Test.parts.ModelViewer"); (same URIs)
part.setLabel("BLA");
part.setCloseable(true);
stack.getChildren().add(part);
partService.showPart(part, PartState.ACTIVATE);
}
This sounds logic to me. I create a part and set the source of the object that should be displayed. 2.: But what is the difference between the Contribution and the Input URI? 3.: For which would I take ModelViewer and what would I take for the other one? 4.: And when I set the Class URI in the Application model, would I choose the ModelViewer?
[Updated on: Tue, 04 December 2012 14:32] by Moderator
|
|
|
|
|
|
|
|
|
|
|
Re: dynamically add part to partStack [message #992313 is a reply to message #989700] |
Fri, 21 December 2012 05:32  |
Eclipse User |
|
|
|
Sorry for the late respond.
Sopot Cela wrote on Fri, 07 December 2012 05:472.Get access to the part (the ModelViewer) I have just created to modify the class?
like:
part.setContributionURI("bundleclass://Test/test.parts.ModelViewer");
part.setInputURI("fileName.txt");
part.getCreatedInstanceOfModelViewer().setModel(Model);
>>>>>>>>>>
part.getObject() and cast it to your class.
Ah okay. The crucial thing is to call the method after
partService.showPart(part, PartState.ACTIVATE);
otherwise it doesn't work.
Thanks a lot again!
|
|
|
Powered by
FUDForum. Page generated in 0.28058 seconds