Permalink
Browse files

radio buttons for setting container type now reflect current containe…

…r state (yay)
  • Loading branch information...
1 parent 9b462e5 commit ad92956696e57164fd139a847aa2a604e2a1fd06 @gregjan gregjan committed Mar 15, 2013
View
22 workbench_plugin/src/main/java/unc/lib/cdr/workbench/commands/SetDivTypeHandler.java
@@ -3,20 +3,24 @@
import gov.loc.mets.DivType;
import gov.loc.mets.MetsPackage;
+import java.util.Map;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.handlers.RadioState;
+import org.eclipse.ui.menus.UIElement;
import unc.lib.cdr.workbench.project.MetsProjectNature;
-public class SetDivTypeHandler extends AbstractHandler {
+public class SetDivTypeHandler extends AbstractHandler implements IElementUpdater {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
@@ -43,8 +47,20 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
// and finally update the current state
HandlerUtil.updateRadioState(event.getCommand(), currentState);
-
return null;
}
+ @Override
+ public void updateElement(UIElement element, Map parameters) {
+ String state = (String)parameters.get("org.eclipse.ui.commands.radioStateParameter");
+ IWorkbenchPartSite site = (IWorkbenchPartSite)parameters.get("org.eclipse.ui.part.IWorkbenchPartSite");
+ if(site.getId().equals("cdr-workbench.projectview")) {
+ IStructuredSelection s = (IStructuredSelection)site.getSelectionProvider().getSelection();
+ if(s.getFirstElement() instanceof DivType) {
+ DivType div = (DivType)s.getFirstElement();
+ element.setChecked(div.getTYPE() != null && div.getTYPE().equals(state));
+ }
+ }
+ }
+
}

0 comments on commit ad92956

Please sign in to comment.