~tapaal-contributor/tapaal/tikz-export-label-placement-1820528

« back to all changes in this revision

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

  • Committer: srba.jiri at gmail
  • Date: 2019-03-09 17:40:57 UTC
  • mfrom: (978.3.12 MakeMultiShared)
  • Revision ID: srba.jiri@gmail.com-20190309174057-qfotipidayci6qff
merged in branch lp:~tapaal-contributor/tapaal/places-with-same-name-shared-1801728 that allows to share places/transitions with names that appear in several components

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
import java.util.Collection;
14
14
import java.util.Collections;
15
15
import java.util.Comparator;
 
16
import java.util.HashMap;
16
17
import java.util.Set;
17
18
import java.util.Vector;
18
19
 
28
29
import javax.swing.event.ChangeEvent;
29
30
import javax.swing.event.ChangeListener;
30
31
 
 
32
import pipe.dataLayer.DataLayer;
31
33
import pipe.dataLayer.Template;
32
34
import pipe.gui.CreateGui;
33
35
import pipe.gui.Pipe;
 
36
import pipe.gui.graphicElements.PetriNetObject;
 
37
import pipe.gui.graphicElements.Place;
34
38
import pipe.gui.graphicElements.tapn.TimedPlaceComponent;
35
39
import dk.aau.cs.gui.Context;
36
40
import dk.aau.cs.gui.undo.ChangedInvariantCommand;
37
41
import dk.aau.cs.gui.undo.Command;
38
42
import dk.aau.cs.gui.undo.MakePlaceSharedCommand;
39
43
import dk.aau.cs.gui.undo.MakePlaceNewSharedCommand;
 
44
import dk.aau.cs.gui.undo.MakePlaceNewSharedMultiCommand;
40
45
import dk.aau.cs.gui.undo.RenameTimedPlaceCommand;
41
46
import dk.aau.cs.gui.undo.TimedPlaceMarkingEdit;
42
47
import dk.aau.cs.gui.undo.UnsharePlaceCommand;
47
52
import dk.aau.cs.model.tapn.LocalTimedPlace;
48
53
import dk.aau.cs.model.tapn.SharedPlace;
49
54
import dk.aau.cs.model.tapn.TimeInvariant;
 
55
import dk.aau.cs.model.tapn.TimedArcPetriNet;
50
56
import dk.aau.cs.model.tapn.TimedInhibitorArc;
51
57
import dk.aau.cs.model.tapn.TimedInputArc;
52
58
import dk.aau.cs.model.tapn.TimedOutputArc;
701
707
                        context.nameGenerator().updateIndices(context.activeModel(), newName);
702
708
                
703
709
                        if(makeNewShared){
704
 
                                Command command = new MakePlaceNewSharedCommand(context.activeModel(), newName, place.underlyingPlace(), place, context.tabContent());
 
710
                                Command command = new MakePlaceNewSharedCommand(context.activeModel(), newName, place.underlyingPlace(), place, context.tabContent(), false);
705
711
                                context.undoManager().addEdit(command);
706
712
                                try{
707
713
                                        command.redo();
708
714
                                }catch(RequireException e){
709
715
                                        context.undoManager().undo();
710
 
                                        JOptionPane.showMessageDialog(this, "A transition or place with the specified name already exists in this or another component, 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.ERROR_MESSAGE);
711
 
                                        return false;
 
716
                                        //This is checked as a place cannot be shared if there exists a transition with the same name
 
717
                                        if(context.activeModel().parentNetwork().isNameUsedForPlacesOnly(newName)) {
 
718
                                                int dialogResult = JOptionPane.showConfirmDialog(this, "A place with the specified name already exists in one or more components, or the specified name is invalid.\n\nAcceptable names for places 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 place name will be changed into shared one also in all other components.", "Error", JOptionPane.OK_CANCEL_OPTION);
 
719
                                                if(dialogResult == JOptionPane.OK_OPTION) {
 
720
                                                        Command cmd = new MakePlaceNewSharedMultiCommand(context, newName, place);      
 
721
                                                        cmd.redo();
 
722
                                                        context.undoManager().addNewEdit(cmd);
 
723
                                                } else {
 
724
                                                        return false;
 
725
                                                }
 
726
                                        } else {
 
727
                                                JOptionPane.showMessageDialog(this, "A transition with the specified name already exists in one or more components, or the specified name is invalid.\n\nAcceptable names for places 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);
 
728
                                                return false;
 
729
                                        }
712
730
                                }       
713
731
                        }
714
732
                }