package org.jbpm.ui.common.action;
import org.eclipse.gef.commands.Command;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.jbpm.ui.JpdlVersionRegistry;
import org.jbpm.ui.common.command.UpdateJpdlVersionCommand;
import org.jbpm.ui.common.model.ProcessDefinition;
import org.jbpm.ui.editor.DesignerEditor;
public class UpdateJpdlVersionAction extends BaseActionDelegate {
public void run(IAction action) {
DesignerEditor editor = getActiveDesignerEditor();
Command command = new UpdateJpdlVersionCommand(editor, editor.getDefinitionFile(), editor.getDefinition());
executeCommand(command);
}
@Override
public void selectionChanged(IAction action, ISelection selection) {
super.selectionChanged(action, selection);
if (selectedPart != null) {
ProcessDefinition definition = (ProcessDefinition) selectedPart.getModel();
action.setEnabled(JpdlVersionRegistry.canBeUpdatedToNextVersion(definition));
} else {
action.setEnabled(false);
}
}
}