~tapaal-contributor/tapaal/change-export-batch-shortcut-1820012

« back to all changes in this revision

Viewing changes to src/pipe/gui/widgets/TAPNTransitionEditor.java

  • Committer: Kenneth Yrke Jørgensen
  • Date: 2019-03-13 07:17:48 UTC
  • mfrom: (989 tapaal)
  • mto: This revision was merged to the branch mainline in revision 991.
  • Revision ID: kenneth@yrke.dk-20190313071748-fm6dc00yy27un3xd
Merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
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;
73
75
                
74
76
                
75
77
                
 
78
                
76
79
                sharedTransitionsComboBox = new WidthAdjustingComboBox(maxNumberOfTransitionsToShowAtOnce);
77
80
                sharedTransitionsComboBox.setPreferredSize(new Dimension(290,27));
78
81
                sharedTransitionsComboBox.addActionListener(new ActionListener() {
402
405
                        transition.underlyingTransition().unshare();
403
406
                }
404
407
                
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);
409
412
                        try{
410
413
                                command.redo();
436
439
                                return false;
437
440
                        }
438
441
                        context.nameGenerator().updateIndices(transition.underlyingTransition().model(), newName);
 
442
                
439
443
                        
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);
443
447
                                try{
444
448
                                        command.redo();
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);
448
 
                                        return false;
 
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);    
 
456
                                                        cmd.redo();
 
457
                                                        context.undoManager().addEdit(cmd);
 
458
                                                } else {
 
459
                                                        return false;
 
460
                                                }
 
461
                                        } else {
 
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);
 
463
                                                return false;
 
464
                                        }
449
465
                                }
450
466
                                transition.setUrgent(urgentCheckBox.isSelected());
451
467
                        }