lievendoclo / Valkyrie-RCP

A fork from http://www.gitorious.org/valkyrie-rcp
Apache License 2.0
23 stars 10 forks source link

Problem with same view multiple times #20

Open enavarrocu opened 9 years ago

enavarrocu commented 9 years ago

I'm trying to find a way to show the same view but with different input object at the same time to make comparisons. I can't find a way to do this. There is any way to do this?

Thanks in advance

cmadsen commented 9 years ago

Not as far as I know, you will have to create a "duplicate" view with a different view id.

enavarrocu commented 9 years ago

Thanks for the answer. Is exactly what I'm doing dynamic because can be two or more the same view with different data. But I have to register the descriptors in the bean pool to be able to open it. Maybe this is something that should be implemented.

Something like this:

public DefaultViewDescriptor createDynamicView(Class<? extends View> classz, String viewId) { try { AbstractBeanDefinition beanDef = BeanDefinitionReaderUtils.createBeanDefinition(null, DefaultViewDescriptor.class.getName(), ClassLoader.getSystemClassLoader()); ConstructorArgumentValues cArgs = new ConstructorArgumentValues(); cArgs.addIndexedArgumentValue(0, viewId); cArgs.addIndexedArgumentValue(1, classz); beanDef.setConstructorArgumentValues(cArgs); DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) applicationConfig.applicationContext().getAutowireCapableBeanFactory(); beanFactory.registerBeanDefinition(viewId, beanDef); return (DefaultViewDescriptor) beanFactory.getBean(viewId); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }

Do you think there is a better way to do this?

Thanks

cmadsen commented 9 years ago

Why not just declare the extra view statically?

enavarrocu commented 9 years ago

It's no just an extra view. Is the same view that the user can open every time he want.

cmadsen commented 9 years ago

I just can not see how you can do it without a copy assuming that you want to have to view/panels with the view open simultaneously. The Swing components hosted in the view can only have a single parent and createDynamicView also seems to create a new instance? But maybe I have misunderstood something.

enavarrocu commented 9 years ago

What do you mean with a copy? I have several views open somultaneously. The component hosted in the view need a new instance for each view because have different information inside. I will interact with this component simultaneously in each view. What createDynamicView is create a new instance of the view and in other method this view is open. It's a little complicated to explain. :(