Summary: | Selection state of ToggleSnapToGeometryAction and ToggleGridAction | ||||||
---|---|---|---|---|---|---|---|
Product: | [Tools] GEF | Reporter: | Sven Wende <s.wende> | ||||
Component: | GEF-Legacy GEF (MVC) | Assignee: | gef-inbox <gef-inbox> | ||||
Status: | NEW --- | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | andras | ||||
Version: | 3.1.1 | ||||||
Target Milestone: | --- | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Sven Wende
2006-03-07 07:51:52 EST
I agree. When I add ToggleSnapToGeometryAction to another place in the UI (e.g. into a context menu or toolbar), behaviour gets totally confused: checkmarks not consistent with each other and with the internal graphicalViewer state. Basically, the implementation of run() is incorrect: public void run() { diagramViewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(!isChecked())); } This never calls setChecked() on the action, which means the ActionContributionItems which control the menu and toolbar items won't get notified about the state change, and the checked state of other menu items won't get updated. setChecked() must be called because that' what fires the property change that causes ActionContributionItems to update themselves. The fix: run() method must call setChecked(): private void setSnapEnabled(boolean enabled) { diagramViewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(enabled)); } @Override public void run() { setSnapEnabled(!isSnapEnabled()); setChecked(isSnapEnabled()); } Created attachment 238065 [details]
Patch to track checked status correctly
The problem is not that run needs to call setChecked, it's that setChecked should be responsible for setting the appropriate state of the viewer.
The attached patch fixes ToggleSnapToGeometryAction, ToggleGridAction, and ToggleRulerVisibilityAction.
|