• About
Triona Weblog

Software Development and much more

Unresolved Eclipse Problem. Impossible: Unrelated (referring enablement-status) ContributionsItems for one command in multiple views

03.09.2009 by Holger Klatt

The Problem:
Two views in the workbench window. Both contain a toolbar with a CommmandContributionItem. Both CommandContributionItems belong to the same command. Each one should set its enablement-status independently according to its view context. BUT: You cannot have one CommmandContributionItem enabled and the other not at the same time.

That Problem is described in http://www.eclipsezone.com/eclipse/forums/t112307.html

Excerpt from that article:
As I see it, the problem is not directly related to the handlers, but to
the commands themselves, which (being typically defined in the plug-in’s
plugin.xml file) are instantiated by the platform only once. Thus, if
two command contribution items in two workbench windows are associated
with the same command ID, they are also referencing the same command
object. Since this command can, in turn, only be associated with (at
most) one handler at any one time, and this handler is responsible for
determining the commands enabled status, it is (as Mark says) impossible
to enable the command contribution item in one workbench window, whilst
keeping the command contribution using the same command ID in the other
workbench window disabled (or vice versa).

You can reproduce that wrong behaviour with Eclipse 3.4 or Eclipse 3.5 as follows (excerpt from the mentioned article):

  1. Start Eclipse IDE, specifying a workspace containing at least one file editable via the Text Editor.
  2. Close any editors. The “Print” toolbar item should now be disabled.
  3. Open a new workbench window via “Window > New Window”
  4. Open the Text Editor on a workspace file.
  5. Note that the “Print” toolbar item is now not only (correctly) enabled for the new workspace window, but is also (incorrectly) enabled for the original workspace window, even though there is nothing to print there.
Posted in: Development, Java Tagged: Eclipse, Eclipse RCP
October 2023
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
« Nov    

Tags

API Architecture CDI Collections Comparable Comparator Database EA Eclipse EJB Enterprise Architect Excel Hessian HTML Iteration Java Java 8 JavaEE Java EE Java Enterprise Development javascript Javascript Canvas HTML5 JEE JEE 6 JPA jQuery JSF linux Makro Map MariaDB Maven Oracle Plugins Relation relationship Richfaces Service Service Facade Set SOA Subversion Tutorial VBA XML

Recent Posts

  • Domain Driven Design und Event Storming
  • NESTJS BEYOND „HELLO WORLD“
  • Jakarta EE 9 – An upheaval with difficulties
  • Jakarta EE 9 – Ein Umbruch mit Schwierigkeiten
  • Erste Schritte mit Hibernate Spatial

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2023 Triona Weblog.

Impressum | Datenschutzerklärung