use of cbit.gui.graph.actions.GraphViewAction in project vcell by virtualcell.
the class ReactionCartoonTool method shapeHasMenuActionEnabled.
@Override
public boolean shapeHasMenuActionEnabled(Shape shape, String menuAction) {
if (menuAction.equals(CartoonToolMiscActions.Properties.MENU_ACTION)) {
if (shape instanceof CatalystShape) {
return false;
}
}
if (menuAction.equals(CartoonToolMiscActions.SearchReactions.MENU_ACTION)) {
if (!(shape instanceof ReactionContainerShape) || !getReactionCartoon().getStructureSuite().getStructures().contains(shape.getModelObject())) {
return false;
}
}
GraphViewAction paintingAction = ActionUtil.getAction(paintingActions, menuAction);
if (paintingAction != null) {
return paintingAction.isEnabledForShape(shape);
}
GraphViewAction groupAction = ActionUtil.getAction(groupActions, menuAction);
if (groupAction != null) {
return groupAction.isEnabledForShape(shape);
}
if (shape instanceof ReactionContainerShape) {
if (menuAction.equals(CartoonToolEditActions.PasteNew.MENU_ACTION)) {
ReactionSpeciesCopy reactionSpeciesCopy = (ReactionSpeciesCopy) VCellTransferable.getFromClipboard(VCellTransferable.REACTION_SPECIES_ARRAY_FLAVOR);
if (reactionSpeciesCopy != null) {
Structure targetStructure = ((ReactionContainerShape) shape).getStructure();
if (reactionSpeciesCopy.getReactStepArr() != null) {
for (int i = 0; i < reactionSpeciesCopy.getReactStepArr().length; i++) {
if (!reactionSpeciesCopy.getReactStepArr()[i].getStructure().getClass().equals(targetStructure.getClass())) {
return false;
}
}
}
return true;
} else {
return false;
}
} else if (menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
if (((ReactionContainerShape) shape).getStructureSuite().getStructures().size() == 1) {
return false;
}
}
}
return true;
}
use of cbit.gui.graph.actions.GraphViewAction in project vcell by virtualcell.
the class ReactionCartoonTool method shapeHasMenuAction.
@Override
public boolean shapeHasMenuAction(Shape shape, String menuAction) {
if (menuAction.equals(CartoonToolMiscActions.Annotate.MENU_ACTION)) {
if (shape instanceof ReactionStepShape) {
return true;
}
}
if (menuAction.equals(CartoonToolEditActions.Copy.MENU_ACTION)) {
if (shape instanceof SpeciesContextShape || shape instanceof ReactionStepShape || // rule participants don't make sense without their rule
shape instanceof RuleParticipantSignatureDiagramShape || shape instanceof ReactionRuleDiagramShape) {
return true;
}
}
if (/*menuAction.equals(CartoonToolEditActions.Paste.MENU_ACTION)
|| */
menuAction.equals(CartoonToolEditActions.PasteNew.MENU_ACTION)) {
if (shape instanceof ReactionContainerShape) {
return true;
}
}
if (menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
if (shape instanceof ReactionContainerShape || shape instanceof ReactionStepShape || shape instanceof SpeciesContextShape || shape instanceof ReactantShape || shape instanceof ProductShape || shape instanceof CatalystShape || shape instanceof ReactionRuleDiagramShape || shape instanceof RuleParticipantSignatureDiagramShape) {
return true;
}
}
if (menuAction.equals(CartoonToolMiscActions.AddSpecies.MENU_ACTION)) {
if (shape instanceof ReactionContainerShape) {
return true;
}
}
if (menuAction.equals(CartoonToolMiscActions.SearchReactions.MENU_ACTION)) {
if (shape instanceof ReactionContainerShape) {
return true;
}
}
if (menuAction.equals(CartoonToolSaveAsImageActions.MenuAction.MENU_ACTION)) {
if (shape instanceof ReactionContainerShape) {
return true;
}
}
if (menuAction.equals(CartoonToolMiscActions.Properties.MENU_ACTION)) {
if (shape instanceof ReactionStepShape || shape instanceof SpeciesContextShape || shape instanceof ReactantShape || shape instanceof ProductShape || shape instanceof CatalystShape || shape instanceof ReactionContainerShape) {
return true;
}
}
GraphViewAction paintingAction = ActionUtil.getAction(paintingActions, menuAction);
if (paintingAction != null) {
return paintingAction.canBeAppliedToShape(shape);
}
GraphViewAction groupAction = ActionUtil.getAction(groupActions, menuAction);
if (groupAction != null) {
return groupAction.canBeAppliedToShape(shape);
}
return false;
}
Aggregations