SWT 中组件的动态加载
我正在开发一个RCP应用程序,其中我的视图有两个名为composite 1和composite 2的组件,它们是父composite的一部分,当然
我已经使用gridLayout 2相同大小的列并排放置composite。下面是这个的快照
确实如图所示,我希望在右侧的复合 2 动态地基于在复合 1 中的链接上执行的用户操作。
例如 link1 应该应用布局(Borderlayout) &在composite2中添加标签 link2 中的一些其他布局(rowLayout) 和composite2 中的文本
类似地,每个链接都必须对composite2 应用不同的样式, 我的解决方法包括以下内容, 对于那里的每个链接侦听器,我添加了相应的代码,如果它(composite2)不为空,则处理composite2的子级。
我正在寻找一个想法和想法在这种情况下编写友好代码的更好和更智能的编程实践是什么?有片段吗?
I'm working on an RCP application wherein my view has two components named composite 1 and composite 2 which are part of parent composite ofcourse
I've placed composites side by side using gridLayout 2 columns of equal size.Below is snapshot of this
indeed as shown in the figure, i wish to load/add some new components(technically widgets) in the composite 2 on right dynamically, based upon user actions performed on links in composite1.
Like for example link1 should apply a layout(Borderlayout) & add a label in composite2
link2 some other layout(rowLayout) and text in composite2
Similarly each link out there has to apply different styles to composite2,
My workaround includes the following,
for each listener of links over there, i have added the respective code that disposes children of the composite2 if it's(composite2) not null.
I'm looking for an ideas & what's the better and smart programming practice to write amicable code in such a scenario. Any snippets ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在大多数情况下,这是糟糕的 UI 设计。
如果您想根据选择向用户提供操作,您应该通过针对选择启用/禁用的菜单项或命令来执行此操作。或者,如果您想根据用户选择显示更复杂的数据,您应该使用第二个视图。
In most cases this is bad UI design.
If you want to provide actions to the user dependent on the selection you should either do this by menu items or commands which you enable/disable regarding to the selection. Or if you want to display more complex data accordingly to the user selection you should use a second view.
您的场景是 Eclipse Forms 中主详细信息部分的标准场景,有关详细信息,请参阅 http://www.eclipse.org/articles/Article-Forms/article.html。
总的来说:你的方法并不是糟糕的用户界面设计,而是典型的主从视图。不需要使用两个视图,您的方法很好,Eclipse 表单提供的 Master-Details-Implementation 可以让您了解如何实现它。
Your scenrao is the standard-scenario for Master-Details Sections in Eclipse Forms, for details see http://www.eclipse.org/articles/Article-Forms/article.html.
In general: Your approach is not bad ui-design, but a typical master-detail view. There is no need to use two views, your approach is fine and the Master-Details-Implementation provided by the Eclipse forms gives you an idea how to implement it.