21
21
import pipe.gui.graphicElements.tapn.TimedTransitionComponent;
22
22
import dk.aau.cs.gui.Context;
23
23
import dk.aau.cs.gui.undo.Command;
24
import dk.aau.cs.gui.undo.MakePlaceNewSharedMultiCommand;
24
25
import dk.aau.cs.gui.undo.MakeTransitionNewSharedCommand;
26
import dk.aau.cs.gui.undo.MakeTransitionNewSharedMultiCommand;
25
27
import dk.aau.cs.gui.undo.MakeTransitionSharedCommand;
26
28
import dk.aau.cs.gui.undo.RenameTimedTransitionCommand;
27
29
import dk.aau.cs.gui.undo.ToggleTransitionUrgent;
402
405
transition.underlyingTransition().unshare();
405
if(sharedCheckBox.isSelected()){
408
if(sharedCheckBox.isSelected()){
406
409
SharedTransition selectedTransition = (SharedTransition)sharedTransitionsComboBox.getSelectedItem();
407
Command command = new MakeTransitionSharedCommand(context.activeModel(), selectedTransition, transition.underlyingTransition(), context.tabContent());
410
Command command = new MakeTransitionSharedCommand(context.activeModel(), selectedTransition, transition.underlyingTransition(), context.tabContent());
408
411
context.undoManager().addEdit(command);
438
441
context.nameGenerator().updateIndices(transition.underlyingTransition().model(), newName);
440
444
if(makeNewShared){
441
Command command = new MakeTransitionNewSharedCommand(context.activeModel(), newName, transition.underlyingTransition(), context.tabContent());
445
Command command = new MakeTransitionNewSharedCommand(context.activeModel(), newName, transition.underlyingTransition(), context.tabContent(), false);
442
446
context.undoManager().addEdit(command);
445
449
}catch(RequireException e){
446
450
context.undoManager().undo();
447
JOptionPane.showMessageDialog(this,"A transition or place with the specified name already exists, or the specified name is invalid.\n\nAcceptable names are defined by the regular expression:\n[a-zA-Z][_a-zA-Z0-9]*", "Error", JOptionPane.ERROR_MESSAGE);
451
//This is checked as a transition cannot be shared if there exists a place with the same name
452
if(transition.underlyingTransition().model().parentNetwork().isNameUsedForTransitionsOnly(newName)) {
453
int dialogResult = JOptionPane.showConfirmDialog(this, "A transition with the specified name already exists in one or more components, or the specified name is invalid.\n\nAcceptable names for transitions are defined by the regular expression:\n[a-zA-Z][_a-zA-Z0-9]*\n\nNote that \"true\" and \"false\" are reserved keywords. \n\nThis transition name will be changed into shared one also in all other components.", "Error", JOptionPane.OK_CANCEL_OPTION);
454
if(dialogResult == JOptionPane.OK_OPTION) {
455
Command cmd = new MakeTransitionNewSharedMultiCommand(context, newName, transition);
457
context.undoManager().addEdit(cmd);
462
JOptionPane.showMessageDialog(this, "A place with the specified name already exists in one or more components, or the specified name is invalid.\n\nAcceptable names for transitions are defined by the regular expression:\n[a-zA-Z][_a-zA-Z0-9]*\n\nNote that \"true\" and \"false\" are reserved keywords.", "Error", JOptionPane.OK_OPTION);
450
466
transition.setUrgent(urgentCheckBox.isSelected());