diff --git a/src/main/java/ddtranslatorSoclib/toTopCell/Declaration.java b/src/main/java/ddtranslatorSoclib/toTopCell/Declaration.java index 642a2965e36d6ead017ba2232fc06869234333f3..89496affdf893126bc0c417ff71483fe3813972d 100755 --- a/src/main/java/ddtranslatorSoclib/toTopCell/Declaration.java +++ b/src/main/java/ddtranslatorSoclib/toTopCell/Declaration.java @@ -192,7 +192,7 @@ public class Declaration { //target address depends on number of TTYs and RAMs for (AvatarRAM ram : TopCellGenerator.avatardd.getAllRAM()) - if(ram.getNo_ram()==0){ + if(ram.getIndex()==0){ declaration += "soclib::caba::VciRam<vci_param>" + ram.getMemoryName()+ "(\"" + ram.getMemoryName()+ "\"" + ", IntTab(2), maptab);" + CR; } else{ @@ -364,16 +364,16 @@ int i=0; // for(AvatarChannel channel: ram.getChannels()){ //DG 27.06. for(AvatarRelation ar: avspec.getRelations()) { - - for(i=0; i<ar.nbOfSignals() ; i++) { - - AvatarSignal as1=ar.getSignal1(i); - AvatarSignal as2=ar.getSignal2(i); - //String chname = generateName(channel); - String chname = generateName(ar,as1,as2); - strArray=strArray+"\""+chname+"\","; - - } + // if ar.isMonitored(){//DG 29.06 per relation, all signals - how to make connection between channel and relation? + for(i=0; i<ar.nbOfSignals() ; i++) { + + AvatarSignal as1=ar.getSignal1(i); + AvatarSignal as2=ar.getSignal2(i); + //String chname = generateName(channel); + String chname = generateName(ar,as1,as2); + strArray=strArray+"\""+chname+"\","; + } + //} } // } diff --git a/src/main/java/ddtranslatorSoclib/toTopCell/Deployinfo.java b/src/main/java/ddtranslatorSoclib/toTopCell/Deployinfo.java index 9c5f9b58005de0368f2a27e762855fba3fa17590..9c55b3fd3a937c958939dbcf5e24f759cb9c4102 100755 --- a/src/main/java/ddtranslatorSoclib/toTopCell/Deployinfo.java +++ b/src/main/java/ddtranslatorSoclib/toTopCell/Deployinfo.java @@ -162,15 +162,15 @@ public class Deployinfo { String string_size_half = (Integer.toHexString(size/2)); //segments on this are half uram, half cram - deployinfo += "#define CACHED_RAM" + ram.getNo_ram() + "_NAME cram" + ram.getNo_ram() + CR; - deployinfo = deployinfo + "#define CACHED_RAM" + ram.getNo_ram() + "_ADDR 0x" + Integer.toHexString(address_start+i*CLUSTER_SIZE) + CR; + deployinfo += "#define CACHED_RAM" + ram.getIndex() + "_NAME cram" + ram.getIndex() + CR; + deployinfo = deployinfo + "#define CACHED_RAM" + ram.getIndex() + "_ADDR 0x" + Integer.toHexString(address_start+i*CLUSTER_SIZE) + CR; // 31.08. simplifie - deployinfo = deployinfo + "#define CACHED_RAM" + ram.getNo_ram() + "_SIZE 0x"+ string_size_half + CR; - deployinfo += "#define DEPLOY_RAM" + ram.getNo_ram() + "_NAME uram" + ram.getNo_ram() + CR; + deployinfo = deployinfo + "#define CACHED_RAM" + ram.getIndex() + "_SIZE 0x"+ string_size_half + CR; + deployinfo += "#define DEPLOY_RAM" + ram.getIndex() + "_NAME uram" + ram.getIndex() + CR; int cacheability_bit= 2097152; //0x00200000 - deployinfo = deployinfo + "#define DEPLOY_RAM" + ram.getNo_ram() + "_ADDR 0x" + Integer.toHexString(address_start+i*CLUSTER_SIZE+size/2+cacheability_bit) + CR; + deployinfo = deployinfo + "#define DEPLOY_RAM" + ram.getIndex() + "_ADDR 0x" + Integer.toHexString(address_start+i*CLUSTER_SIZE+size/2+cacheability_bit) + CR; // 31.08. simplifie - deployinfo = deployinfo + "#define DEPLOY_RAM" + ram.getNo_ram() + "_SIZE 0x"+ (string_size_half) + CR; + deployinfo = deployinfo + "#define DEPLOY_RAM" + ram.getIndex() + "_SIZE 0x"+ (string_size_half) + CR; i++; } @@ -196,7 +196,7 @@ System.out.println("@@@@@@@@ @@@@@@@@@@@@@@@@@"); deployinfo_map = deployinfo_map +"\n .channel"+nb_signals+" : { \\" + CR; deployinfo_map = deployinfo_map + "*(section_channel"+nb_signals+ ")\\"+ CR; - deployinfo_map=deployinfo_map+ "} > uram"+ram.getNo_ram()+"\\"+ CR; + deployinfo_map=deployinfo_map+ "} > uram"+ram.getIndex()+"\\"+ CR; i++;nb_signals++; } } @@ -232,26 +232,27 @@ System.out.println("@@@@@@@@ @@@@@@@@@@@@@@@@@"); try{ for (AvatarRAM ram : TopCellGenerator.avatardd.getAllRAM()) { // if (/*!*/(ram.getChannels().isEmpty())){ //"!" removed because it returned the wrong results. Logic is now incorrect but results are correct (needs further investigating) CD 20.6 - //if (!(ram.getChannels().isEmpty())){ + if (!(ram.getChannels().isEmpty())){ for(AvatarRelation ar: avspec.getRelations()){ for (j=0;j<ar.nbOfSignals();j++) { deployinfo_map = deployinfo_map + "\n .channel"+i+" : {"; deployinfo_map = deployinfo_map + "*(section_channel"+i+ ")"; - deployinfo_map = deployinfo_map + "} > uram" + ram.getNo_ram() + CR; //ram n° was incorrect (see above) + deployinfo_map = deployinfo_map + "} > uram" + ram.getIndex() + CR; //ram n° was incorrect (see above) i++; } } + i=0; for(AvatarRelation ar: avspec.getRelations()){ for (j=0;j<ar.nbOfSignals();j++) { //CD 15.06 dynamic to signal number deployinfo_map = deployinfo_map + "\n .lock"+i+" : { " ; deployinfo_map = deployinfo_map + "*(section_lock" + i + ")"; - deployinfo_map = deployinfo_map + "} > uram" + ram.getNo_ram() + CR; + deployinfo_map = deployinfo_map + "} > uram" + ram.getIndex() + CR; i++; } } } - // } + } }catch (Exception e){ e.printStackTrace(); } diff --git a/src/main/java/ddtranslatorSoclib/toTopCell/NetList.java b/src/main/java/ddtranslatorSoclib/toTopCell/NetList.java index 0282f60baae0295ed73b71691f07daa1115c275e..74870d23ee8af377e4bed015477f95024caafd69 100755 --- a/src/main/java/ddtranslatorSoclib/toTopCell/NetList.java +++ b/src/main/java/ddtranslatorSoclib/toTopCell/NetList.java @@ -178,12 +178,12 @@ public class NetList { netlist = netlist + ram.getMemoryName()+".p_clk(" + NAME_CLK + ");" + CR; netlist = netlist + ram.getMemoryName()+".p_resetn(" + NAME_RST + ");" + CR; - netlist = netlist + ram.getMemoryName()+".p_vci(signal_vci_vciram"+ram.getNo_ram()+");" + CR2; + netlist = netlist + ram.getMemoryName()+".p_vci(signal_vci_vciram"+ram.getIndex()+");" + CR2; if(icn=="vgmn"){ - netlist = netlist + "vgmn.p_to_target["+(ram.getNo_target())+"](signal_vci_vciram"+ram.getNo_ram()+");" + CR2; + netlist = netlist + "vgmn.p_to_target["+(ram.getNo_target())+"](signal_vci_vciram"+ram.getIndex()+");" + CR2; } else{ - netlist = netlist + "vgsb.p_to_target["+(ram.getNo_target())+"](signal_vci_vciram"+ram.getNo_ram()+");" + CR2; + netlist = netlist + "vgsb.p_to_target["+(ram.getNo_target())+"](signal_vci_vciram"+ram.getIndex()+");" + CR2; } } } @@ -197,9 +197,9 @@ public class NetList { netlist = netlist + ram.getMemoryName()+".p_clk(" + NAME_CLK + ");" + CR; netlist = netlist + ram.getMemoryName()+".p_resetn(" + NAME_RST + ");" + CR; - netlist = netlist + ram.getMemoryName()+".p_vci(signal_vci_vciram"+ram.getNo_ram()+");" + CR2; + netlist = netlist + ram.getMemoryName()+".p_vci(signal_vci_vciram"+ram.getIndex()+");" + CR2; //target number for local cluster: this is set at avatardd creation - netlist = netlist + "crossbar"+ram.getNo_cluster()+".p_to_target["+ram.getNo_target()+"](signal_vci_vciram"+ram.getNo_ram()+");" + CR2; + netlist = netlist + "crossbar"+ram.getNo_cluster()+".p_to_target["+ram.getNo_target()+"](signal_vci_vciram"+ram.getIndex()+");" + CR2; } //one mwmr ram and one mwmrdram per cluster are added transparently @@ -372,7 +372,7 @@ public class NetList { for (AvatarRAM ram : TopCellGenerator.avatardd.getAllRAM()) { if (ram.getMonitored()==1){ - int number = number = ram.getNo_ram(); + int number = number = ram.getIndex(); netlist += "logger"+i+".p_clk(signal_clk);" + CR; netlist += "logger"+i+".p_resetn(signal_resetn);" + CR; netlist += "logger"+i+".p_vci(signal_vci_vciram"+number+");" + CR2; @@ -381,7 +381,7 @@ public class NetList { else{ if (ram.getMonitored()==2){ - int number = number = ram.getNo_ram(); + int number = number = ram.getIndex(); netlist += "mwmr_stats"+j+".p_clk(signal_clk);" + CR; netlist += "mwmr_stats"+j+".p_resetn(signal_resetn);" + CR; netlist += "mwmr_stats"+j+".p_vci(signal_vci_vciram"+number+");" + CR2; @@ -429,7 +429,7 @@ public class NetList { for (AvatarRAM ram : TopCellGenerator.avatardd.getAllRAM()) { if (ram.getMonitored()==0){ - netlist += "sc_trace(tf,signal_vci_vciram"+ram.getNo_ram()+",\"Memory"+ram.getNo_ram()+"\");" + CR; + netlist += "sc_trace(tf,signal_vci_vciram"+ram.getIndex()+",\"Memory"+ram.getIndex()+"\");" + CR; } } } diff --git a/src/main/java/ddtranslatorSoclib/toTopCell/Signal.java b/src/main/java/ddtranslatorSoclib/toTopCell/Signal.java index 7efded56b5c227698c31d9d8c426046eeabce97f..73ecb81e10452be786ef97ad04e5a0191b506473 100755 --- a/src/main/java/ddtranslatorSoclib/toTopCell/Signal.java +++ b/src/main/java/ddtranslatorSoclib/toTopCell/Signal.java @@ -93,8 +93,8 @@ signal = signal +"caba::VciSignals<vci_param> signal_vci_vcilocks(\"signal_vci_v if(TopCellGenerator.avatardd.getAllCrossbar().size()==0){ for (AvatarRAM ram : TopCellGenerator.avatardd.getAllRAM()) - signal = signal + "soclib::caba::VciSignals<vci_param> signal_vci_vciram" + ram.getNo_ram() - + "(\"signal_vci_vciram" + ram.getNo_ram() + "\");" + CR2; + signal = signal + "soclib::caba::VciSignals<vci_param> signal_vci_vciram" + ram.getIndex() + + "(\"signal_vci_vciram" + ram.getIndex() + "\");" + CR2; i = 0; for (AvatarTTY tty : TopCellGenerator.avatardd.getAllTTY()){ @@ -109,8 +109,8 @@ i++; else{ for (AvatarRAM ram : TopCellGenerator.avatardd.getAllRAM()) - signal = signal + "soclib::caba::VciSignals<vci_param> signal_vci_vciram" + ram.getNo_ram() - + "(\"signal_vci_vciram" + ram.getNo_ram() + "\");" + CR2; i=0; + signal = signal + "soclib::caba::VciSignals<vci_param> signal_vci_vciram" + ram.getIndex() + + "(\"signal_vci_vciram" + ram.getIndex() + "\");" + CR2; i=0; for (AvatarTTY tty : TopCellGenerator.avatardd.getAllTTY()){ // signal = signal + "soclib::caba::VciSignals<vci_param> signal_vci_tty"+tty.getNo_tty()+"(\"signal_vci_tty"+tty.getNo_tty()+"\");" + CR2; signal = signal + "soclib::caba::VciSignals<vci_param> signal_vci_tty"+i+"(\"signal_vci_tty"+i+"\");" + CR2; diff --git a/src/main/java/ui/AvatarDeploymentPanelTranslator.java b/src/main/java/ui/AvatarDeploymentPanelTranslator.java index 98867ec02bd083f2c4760edb6b270560043952f0..918cb5fcc294c168e57a198ec16323f2f5b89851 100644 --- a/src/main/java/ui/AvatarDeploymentPanelTranslator.java +++ b/src/main/java/ui/AvatarDeploymentPanelTranslator.java @@ -75,8 +75,7 @@ public class AvatarDeploymentPanelTranslator { */ private int nb_target = 6; - private int no_proc = 0; - private int no_ram = 0; + private int no_tty = 0; private int nb_clusters = 0; @@ -112,26 +111,27 @@ public class AvatarDeploymentPanelTranslator { int dCacheSets = addCPUNode.getDCacheSets(); int dCacheWords = addCPUNode.getDCacheWords(); AvatarCPU avcpu; - int monitored = addCPUNode.getMonitored(); - -System.out.println("ADD CPU monitored "+ monitored); - - avcpu = new AvatarCPU(cpuName, nbOfIRQs, ICacheWays, ICacheSets, ICacheWords, dCacheWays, dCacheSets, dCacheWords, nb_init, no_proc, monitored); - nb_init++; - no_proc++; + //int monitored = addCPUNode.getMonitored(); + avcpu = new AvatarCPU(cpuName, nbOfIRQs, ICacheWays, ICacheSets, ICacheWords, dCacheWays, dCacheSets, dCacheWords, nb_init, addCPUNode.getIndex(), addCPUNode.getMonitored()); + + System.out.println("CPU name : "+ cpuName); + System.out.println("CPU index : "+ addCPUNode.getIndex()); Vector<ADDBlockArtifact> tasks = addCPUNode.getArtifactList(); - + for (int i = 0; i < tasks.size(); i++) { ADDBlockArtifact task = tasks.get(i); String taskName = task.getTaskName(); String referenceTaskName = task.getReferenceTaskName(); - + AvatarTask avtask = new AvatarTask(taskName, referenceTaskName, avcpu); + avcpu.addTask(avtask); avatarMappedObject.add(avtask); } + nb_init++; + avatarMap.put(dp, avcpu); avatarComponents.add(avcpu); @@ -141,7 +141,7 @@ System.out.println("ADD CPU monitored "+ monitored); int index = tty.getIndex(); String ttyName = tty.getNodeName(); - AvatarTTY avtty = new AvatarTTY(ttyName, index, no_tty, index); + AvatarTTY avtty = new AvatarTTY(ttyName, index, index, index);//DG 3.7. nb_target++; avatarMap.put(dp, avtty); @@ -256,12 +256,12 @@ System.out.println("ADD CPU monitored "+ monitored); int index = addRamNode.getIndex(); int byteDataSize = addRamNode.getDataSize(); - int monitored = addRamNode.getMonitored(); - System.out.println("ADD RAM monitored "+ monitored); - AvatarRAM avram = new AvatarRAM(name, index, byteDataSize, no_ram, index, monitored); + //int monitored = addRamNode.getMonitored(); + System.out.println("ADD RAM monitored "+ addRamNode.getMonitored()); + AvatarRAM avram = new AvatarRAM(name, index, byteDataSize, index, index, addRamNode.getMonitored());//DG 3.7. int cluster_index = avram.getIndex(); - no_ram++; + // no_ram++; nb_target++; Vector<ADDChannelArtifact> channels = addRamNode.getArtifactList(); @@ -271,7 +271,7 @@ System.out.println("ADD CPU monitored "+ monitored); String referenceDiagram = c.getReferenceDiagram(); String channelName = c.getChannelName(); //channel is inevitably on same cluster as RAM it is mapped on :) - AvatarChannel avcl = new AvatarChannel(referenceDiagram, channelName, avram, cluster_index, monitored); + AvatarChannel avcl = new AvatarChannel(referenceDiagram, channelName, avram, cluster_index, addRamNode.getMonitored()); avram.addChannel(avcl); avatarMappedObject.add(avcl); } @@ -308,22 +308,32 @@ System.out.println("ADD CPU monitored "+ monitored); // monitored = 2 MWMR stats boolean spy = connector.hasASpy(); int monitored = 0; + System.out.println("@@@ avowner "+ avowner_p1); + if (spy == true) { - monitored = 1; - } + monitored = 1; + System.out.println("@@@ owner "+ owner_p1.getName()+" monitored"); + System.out.println("@@@ avowner "+ avowner_p1+" monitored"); + + } AvatarConnector avconnector = new AvatarConnector(avConnectingPoint1, avConnectingPoint2, monitored); if (avowner_p1 instanceof AvatarRAM) { - //if stats mode selected beforehand in menu of component or spy + //if stats mode selected beforehand in menu of component or spy + AvatarRAM ram1=(AvatarRAM) avowner_p1; + System.out.println("@@@@@@@@@@@@@@ RAM no "+ram1.getNo_ram()+" @@@@@@@@@@@@@@@@@"); if ((((AvatarRAM)avowner_p1).getMonitored() == 2)||(spy == true)) //if (((AvatarRAM)avowner_p1).getMonitored() == 2) { monitored = 2; //monitored = 1; - } - - (((AvatarRAM) avowner_p1)).setMonitored(monitored); + //} + (((AvatarRAM) avowner_p1)).setMonitored(monitored); + System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); + System.out.println("@@@@@@@@@@@@@@ RAM no "+ram1.getNo_ram()+" monitored@@@@@@@@@@@@@@@@@"); + System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); + } } if (avowner_p1 instanceof AvatarCPU) { diff --git a/src/main/java/ui/tmldd/TMLArchiCommunicationNode.java b/src/main/java/ui/tmldd/TMLArchiCommunicationNode.java index 32ad0fef660b3eb90498e24240236b4421bc61bb..cdb035cad9bdc14c829878a993917de094598ec0 100755 --- a/src/main/java/ui/tmldd/TMLArchiCommunicationNode.java +++ b/src/main/java/ui/tmldd/TMLArchiCommunicationNode.java @@ -48,6 +48,7 @@ import ui.TGComponent; import ui.TGComponentManager; import java.util.ArrayList; +import java.util.List; /** * Class TMLArchiCommunicationNode @@ -102,9 +103,9 @@ public abstract class TMLArchiCommunicationNode extends TMLArchiNode implements } - public ArrayList<TMLArchiCommunicationArtifact> getChannelArtifactList() { + public List<TMLArchiCommunicationArtifact> getChannelArtifactList() { - ArrayList<TMLArchiCommunicationArtifact> v = new ArrayList<TMLArchiCommunicationArtifact>(); + List<TMLArchiCommunicationArtifact> v = new ArrayList<TMLArchiCommunicationArtifact>(); for( int i = 0; i < nbInternalTGComponent; i++ ) { if( tgcomponent[i] instanceof TMLArchiCommunicationArtifact ) { v.add( (TMLArchiCommunicationArtifact)( tgcomponent[i]) ); @@ -122,9 +123,9 @@ public abstract class TMLArchiCommunicationNode extends TMLArchiNode implements return v; } - public ArrayList<TMLArchiEventArtifact> getEventArtifactList() { + public List<TMLArchiEventArtifact> getEventArtifactList() { - ArrayList<TMLArchiEventArtifact> v = new ArrayList<TMLArchiEventArtifact>(); + List<TMLArchiEventArtifact> v = new ArrayList<TMLArchiEventArtifact>(); for( int i = 0; i < nbInternalTGComponent; i++ ) { if( tgcomponent[i] instanceof TMLArchiEventArtifact ) { v.add( (TMLArchiEventArtifact)(tgcomponent[i]) ); diff --git a/src/main/java/ui/tmlsd/TMLSDControllerInstance.java b/src/main/java/ui/tmlsd/TMLSDControllerInstance.java index a72f0040bc524399ade3cc5c17ab2630d6f2d40e..3af95fd7db1806a3fda79cdbc03f5019a149cb56 100755 --- a/src/main/java/ui/tmlsd/TMLSDControllerInstance.java +++ b/src/main/java/ui/tmlsd/TMLSDControllerInstance.java @@ -89,21 +89,19 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC myImageIcon = IconManager.imgic500; } + @Override public boolean editOndoubleClick(JFrame frame) { - - JDialogTMLCPControllerInstance jdab = new JDialogTMLCPControllerInstance( myAttributes, null, frame, - "Setting properties of " + name, "Attribute", name ); + JDialogTMLCPControllerInstance jdab = new JDialogTMLCPControllerInstance( myAttributes, + null, + frame, + "Setting properties of " + name, + "Attribute", + name ); setJDialogOptions(jdab); - // jdab.setSize(650, 575); - GraphicLib.centerOnParent(jdab, 650, 575 ); - jdab.setVisible(true); // blocked until dialog has been closed + GraphicLib.centerOnParent(jdab, 650, 500 ); + jdab.setVisible(true); // blocked until dialog has been closed name = jdab.getName(); - //makeValue(); - //if (oldValue.equals(value)) { - //return false; - //} - - //rescaled = true; + return true; } diff --git a/src/main/java/ui/tmlsd/TMLSDStorageInstance.java b/src/main/java/ui/tmlsd/TMLSDStorageInstance.java index 8cb25bc9af4738a01d0c35ab49ea46afc334606f..f639d69cb4be808624839a2bbad279ea0c1eb8f8 100755 --- a/src/main/java/ui/tmlsd/TMLSDStorageInstance.java +++ b/src/main/java/ui/tmlsd/TMLSDStorageInstance.java @@ -37,9 +37,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlsd; import myutil.GraphicLib; @@ -84,25 +81,24 @@ public class TMLSDStorageInstance extends TMLSDInstance implements SwallowTGComp value = "Storage instance name"; name = "StorageInstance"; - isActor = false; + isActor = false; myImageIcon = IconManager.imgic500; } + @Override public boolean editOndoubleClick(JFrame frame) { - JDialogTMLCPStorageInstance jdab = new JDialogTMLCPStorageInstance( myAttributes, null, frame, - "Setting properties of " + name, "Attribute", name ); + JDialogTMLCPStorageInstance jdab = new JDialogTMLCPStorageInstance( myAttributes, + null, + frame, + "Setting properties of " + name, + "Attribute", + name ); setJDialogOptions(jdab); - // jdab.setSize(650, 575); - GraphicLib.centerOnParent( jdab, 650, 575 ); + GraphicLib.centerOnParent( jdab, 650, 500 ); jdab.setVisible(true); // blocked until dialog has been closed name = jdab.getName(); - //makeValue(); - //if (oldValue.equals(value)) { - //return false; - //} - - //rescaled = true; + return true; } @@ -125,7 +121,8 @@ public class TMLSDStorageInstance extends TMLSDInstance implements SwallowTGComp //jda.enableTMLKeyword(false); } - @Override public int getType() { + @Override + public int getType() { return TGComponentManager.TMLSD_STORAGE_INSTANCE; } diff --git a/src/main/java/ui/tmlsd/TMLSDTransferInstance.java b/src/main/java/ui/tmlsd/TMLSDTransferInstance.java index ca1d38f68fe7f416ad28cd955ec67c54ea705ec1..fc475163781e079d7d585e5adbf28cbb38ea845a 100755 --- a/src/main/java/ui/tmlsd/TMLSDTransferInstance.java +++ b/src/main/java/ui/tmlsd/TMLSDTransferInstance.java @@ -37,9 +37,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.tmlsd; import myutil.GraphicLib; @@ -84,26 +81,24 @@ public class TMLSDTransferInstance extends TMLSDInstance implements SwallowTGCom value = "Transfer instance name"; name = "TransferInstance"; - isActor = false; + isActor = false; myImageIcon = IconManager.imgic500; } + @Override public boolean editOndoubleClick(JFrame frame) { - - JDialogTMLCPTransferInstance jdab = new JDialogTMLCPTransferInstance( myAttributes, null, frame, - "Setting properties of " + name, "Attribute", name ); + JDialogTMLCPTransferInstance jdab = new JDialogTMLCPTransferInstance( myAttributes, + null, + frame, + "Setting properties of " + name, + "Attribute", + name ); setJDialogOptions(jdab); - // jdab.setSize(650, 575); - GraphicLib.centerOnParent(jdab, 650, 575); + GraphicLib.centerOnParent(jdab, 650, 500); jdab.setVisible(true); // blocked until dialog has been closed name = jdab.getName(); - //makeValue(); - //if (oldValue.equals(value)) { - //return false; - //} - - //rescaled = true; + return true; } diff --git a/src/main/java/ui/window/JDialogCommPatternMapping.java b/src/main/java/ui/window/JDialogCommPatternMapping.java index a2e098d5df3e33906284fda1a70179d69d6ad77d..dc4ecb516dc521ef8c56126fad6b65b2df3f21d4 100644 --- a/src/main/java/ui/window/JDialogCommPatternMapping.java +++ b/src/main/java/ui/window/JDialogCommPatternMapping.java @@ -303,7 +303,7 @@ public class JDialogCommPatternMapping extends JDialog /* implements ActionListe //fifth line panel1 c1.insets = lblInsets; - pnlComPatternStruct.add( new JLabel( "Available Communication Patterns"), c1 ); + pnlComPatternStruct.add( new JLabel( "Available Communication Patterns" ), c1 ); communicationPatternsCB = new JComboBox<String>( communicationPatternsSL ); diff --git a/src/main/java/ui/window/JDialogTMLCPControllerInstance.java b/src/main/java/ui/window/JDialogTMLCPControllerInstance.java index 8775d592930acbbf20b8db585e4d48b3c2c72d8c..42282539d800820ef7fcc307536e766d9bf3ba16 100755 --- a/src/main/java/ui/window/JDialogTMLCPControllerInstance.java +++ b/src/main/java/ui/window/JDialogTMLCPControllerInstance.java @@ -42,14 +42,10 @@ package ui.window; -import ui.util.IconManager; -import ui.TAttribute; +import java.awt.Frame; +import java.util.List; -import javax.swing.*; -import javax.swing.event.ListSelectionListener; -import java.awt.*; -import java.awt.event.ActionListener; -import java.util.LinkedList; +import ui.TAttribute; /** @@ -59,186 +55,24 @@ import java.util.LinkedList; * @version 1.0 25/07/2014 * @author Ludovic APVRILLE, Andrea ENRICI */ -public class JDialogTMLCPControllerInstance extends JDialogTMLSDInstance implements ActionListener, ListSelectionListener { +public class JDialogTMLCPControllerInstance extends JDialogTMLSDInstance {//implements ActionListener, ListSelectionListener { /** Creates new form */ - public JDialogTMLCPControllerInstance( LinkedList<TAttribute> _attributes, LinkedList<TAttribute> _forbidden, Frame f, String title, String attrib, String _name ) { + public JDialogTMLCPControllerInstance( List<TAttribute> _attributes, List<TAttribute> _forbidden, Frame f, String title, String attrib, String _name ) { super(_attributes, _forbidden, f, title, attrib, _name ); } - @Override protected void initComponents() { - Container c = getContentPane(); - - JPanel namePanel = new JPanel(); - JPanel panelAttr = new JPanel(new BorderLayout()); - GridBagLayout gridbag0 = new GridBagLayout(); - GridBagLayout gridbag1 = new GridBagLayout(); - GridBagLayout gridbag2 = new GridBagLayout(); - GridBagConstraints c0 = new GridBagConstraints(); - GridBagConstraints c1 = new GridBagConstraints(); - GridBagConstraints c2 = new GridBagConstraints(); - - setFont(new Font("Helvetica", Font.PLAIN, 14)); - c.setLayout(gridbag0); - - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - - //Name panel - namePanel.add( new JLabel( "Name of controller instance:" ) ); - nameOfInstance = new JTextField( this.name, 30 ); - namePanel.add( nameOfInstance ); - - //Panel1 - - panel1 = new JPanel(); - panel1.setLayout(gridbag1); - panel1.setBorder(new javax.swing.border.TitledBorder("Adding " + attrib + "s")); - panel1.setPreferredSize(new Dimension(300, 250)); - - panel2 = new JPanel(); - panel2.setLayout(gridbag2); - panel2.setBorder(new javax.swing.border.TitledBorder("Managing " + attrib + "s")); - panel2.setPreferredSize(new Dimension(300, 250)); - - // first line panel1 - c1.gridwidth = 1; - c1.gridheight = 1; - c1.weighty = 1.0; - c1.weightx = 1.0; - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - c1.fill = GridBagConstraints.BOTH; - c1.gridheight = 3; - panel1.add(new JLabel(" "), c1); - - c1.gridwidth = 1; - c1.gridheight = 1; - c1.weighty = 1.0; - c1.weightx = 1.0; - c1.anchor = GridBagConstraints.CENTER; - panel1.add(new JLabel("access"), c1); - panel1.add(new JLabel("identifier"), c1); - if (attrib.equals("Attribute") || attrib.equals("Variable")) { - panel1.add(new JLabel(" "), c1); - panel1.add(new JLabel("initial value"), c1); - } - panel1.add(new JLabel(" "), c1); - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - panel1.add(new JLabel("type"), c1); - - // second line panel1 - c1.gridwidth = 1; - c1.fill = GridBagConstraints.HORIZONTAL; - c1.anchor = GridBagConstraints.CENTER; - accessBox = new JComboBox<>(); - panel1.add(accessBox, c1); - identifierText = new JTextField(); - identifierText.setColumns(15); - identifierText.setEditable(true); - panel1.add(identifierText, c1); - - initialValue = new JTextField(); - initialValue.setColumns(5); - initialValue.setEditable(true); - - if (attrib.equals("Attribute") || attrib.equals("Variable")) { - panel1.add(new JLabel(" = "), c1); - panel1.add(initialValue, c1); - } - - panel1.add(new JLabel(" : "), c1); - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - typeBox = new JComboBox<>(); - typeBox.addActionListener(this); - panel1.add(typeBox, c1); - - // third line panel1 - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - c1.fill = GridBagConstraints.BOTH; - c1.gridheight = 3; - panel1.add(new JLabel(" "), c1); - - // fourth line panel2 - c1.gridheight = 1; - c1.fill = GridBagConstraints.HORIZONTAL; - addButton = new JButton("Add / Modify " + attrib); - addButton.addActionListener(this); - panel1.add(addButton, c1); - - // 1st line panel2 - listAttribute = new JList<TAttribute> (attributes.toArray (new TAttribute[0])); - //listAttribute.setFixedCellWidth(150); - //listAttribute.setFixedCellHeight(20); - listAttribute.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - listAttribute.addListSelectionListener(this); - JScrollPane scrollPane = new JScrollPane(listAttribute); - scrollPane.setSize(300, 250); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - c2.fill = GridBagConstraints.BOTH; - c2.gridheight = 5; - c2.weighty = 10.0; - c2.weightx = 10.0; - panel2.add(scrollPane, c2); - - // 2nd line panel2 - c2.weighty = 1.0; - c2.weightx = 1.0; - c2.fill = GridBagConstraints.BOTH; - c2.gridheight = 1; - panel2.add(new JLabel(""), c2); - - // third line panel2 - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - c2.fill = GridBagConstraints.HORIZONTAL; - upButton = new JButton("Up"); - upButton.addActionListener(this); - panel2.add(upButton, c2); - - downButton = new JButton("Down"); - downButton.addActionListener(this); - panel2.add(downButton, c2); - - removeButton = new JButton("Remove " + attrib); - removeButton.addActionListener(this); - panel2.add(removeButton, c2); - - // main panel; - panelAttr.add(panel1, BorderLayout.WEST); - panelAttr.add(panel2, BorderLayout.EAST); - - - //c.add(panel1, c0); - //c.add(panel2, c0); - - c0.gridwidth = 1; - c0.gridheight = 10; - c0.weighty = 1.0; - c0.weightx = 1.0; - c0.gridwidth = GridBagConstraints.REMAINDER; //end row - - c.add(namePanel, c0); - c.add(panelAttr, c0); - - c0.gridwidth = 1; - c0.gridheight = 1; - c0.fill = GridBagConstraints.HORIZONTAL; - closeButton = new JButton("Save and Close", IconManager.imgic25); - //closeButton.setPreferredSize(new Dimension(600, 50)); - closeButton.addActionListener(this); - c.add(closeButton, c0); - c0.gridwidth = GridBagConstraints.REMAINDER; //end row - cancelButton = new JButton("Cancel", IconManager.imgic27); - cancelButton.addActionListener(this); - c.add(cancelButton, c0); - } - - @Override public void closeDialog() { - cancelled = false; - attributesPar.clear (); - for(int i=0; i<attributes.size(); i++) { - attributesPar.add (attributes.get (i)); - } - this.name = nameOfInstance.getText(); - dispose(); - } + // Issue #55: Components are now managed in the superclass + +// +// @Override +// public void closeDialog() { +// cancelled = false; +// attributesPar.clear (); +// for(int i=0; i<attributes.size(); i++) { +// attributesPar.add (attributes.get (i)); +// } +// this.name = nameOfInstance.getText(); +// dispose(); +// } } //End of class diff --git a/src/main/java/ui/window/JDialogTMLCPStorageInstance.java b/src/main/java/ui/window/JDialogTMLCPStorageInstance.java index c29c16b83661114cdf7005df0637237f0fef2ea8..38b39f5bc47b351c582848e450a82018fcdb3e46 100755 --- a/src/main/java/ui/window/JDialogTMLCPStorageInstance.java +++ b/src/main/java/ui/window/JDialogTMLCPStorageInstance.java @@ -37,19 +37,12 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.window; -import ui.util.IconManager; -import ui.TAttribute; +import java.awt.Frame; +import java.util.List; -import javax.swing.*; -import javax.swing.event.ListSelectionListener; -import java.awt.*; -import java.awt.event.ActionListener; -import java.util.LinkedList; +import ui.TAttribute; /** @@ -59,186 +52,188 @@ import java.util.LinkedList; * @version 1.0 25/07/2014 * @author Ludovic APVRILLE, Andrea ENRICI */ -public class JDialogTMLCPStorageInstance extends JDialogTMLSDInstance implements ActionListener, ListSelectionListener { +public class JDialogTMLCPStorageInstance extends JDialogTMLSDInstance {//implements ActionListener, ListSelectionListener { /** Creates new form */ - public JDialogTMLCPStorageInstance( LinkedList<TAttribute> _attributes, LinkedList<TAttribute> _forbidden, Frame f, String title, String attrib, String _name ) { + public JDialogTMLCPStorageInstance( List<TAttribute> _attributes, List<TAttribute> _forbidden, Frame f, String title, String attrib, String _name ) { super( _attributes, _forbidden, f, title, attrib, _name ); } - @Override protected void initComponents() { - Container c = getContentPane(); - - JPanel namePanel = new JPanel(); - JPanel panelAttr = new JPanel(new BorderLayout()); - GridBagLayout gridbag0 = new GridBagLayout(); - GridBagLayout gridbag1 = new GridBagLayout(); - GridBagLayout gridbag2 = new GridBagLayout(); - GridBagConstraints c0 = new GridBagConstraints(); - GridBagConstraints c1 = new GridBagConstraints(); - GridBagConstraints c2 = new GridBagConstraints(); - - setFont(new Font("Helvetica", Font.PLAIN, 14)); - c.setLayout(gridbag0); - - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - - //Name panel - namePanel.add( new JLabel( "Name of storage instance:" ) ); - nameOfInstance = new JTextField( this.name, 30 ); - namePanel.add( nameOfInstance ); - - //Panel1 - - panel1 = new JPanel(); - panel1.setLayout(gridbag1); - panel1.setBorder(new javax.swing.border.TitledBorder("Adding " + attrib + "s")); - panel1.setPreferredSize(new Dimension(300, 250)); - - panel2 = new JPanel(); - panel2.setLayout(gridbag2); - panel2.setBorder(new javax.swing.border.TitledBorder("Managing " + attrib + "s")); - panel2.setPreferredSize(new Dimension(300, 250)); - - // first line panel1 - c1.gridwidth = 1; - c1.gridheight = 1; - c1.weighty = 1.0; - c1.weightx = 1.0; - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - c1.fill = GridBagConstraints.BOTH; - c1.gridheight = 3; - panel1.add(new JLabel(" "), c1); - - c1.gridwidth = 1; - c1.gridheight = 1; - c1.weighty = 1.0; - c1.weightx = 1.0; - c1.anchor = GridBagConstraints.CENTER; - panel1.add(new JLabel("access"), c1); - panel1.add(new JLabel("identifier"), c1); - if (attrib.equals("Attribute") || attrib.equals("Variable")) { - panel1.add(new JLabel(" "), c1); - panel1.add(new JLabel("initial value"), c1); - } - panel1.add(new JLabel(" "), c1); - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - panel1.add(new JLabel("type"), c1); - - // second line panel1 - c1.gridwidth = 1; - c1.fill = GridBagConstraints.HORIZONTAL; - c1.anchor = GridBagConstraints.CENTER; - accessBox = new JComboBox<>(); - panel1.add(accessBox, c1); - identifierText = new JTextField(); - identifierText.setColumns(15); - identifierText.setEditable(true); - panel1.add(identifierText, c1); - - initialValue = new JTextField(); - initialValue.setColumns(5); - initialValue.setEditable(true); - - if (attrib.equals("Attribute") || attrib.equals("Variable")) { - panel1.add(new JLabel(" = "), c1); - panel1.add(initialValue, c1); - } - - panel1.add(new JLabel(" : "), c1); - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - typeBox = new JComboBox<>(); - typeBox.addActionListener(this); - panel1.add(typeBox, c1); - - // third line panel1 - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - c1.fill = GridBagConstraints.BOTH; - c1.gridheight = 3; - panel1.add(new JLabel(" "), c1); - - // fourth line panel2 - c1.gridheight = 1; - c1.fill = GridBagConstraints.HORIZONTAL; - addButton = new JButton("Add / Modify " + attrib); - addButton.addActionListener(this); - panel1.add(addButton, c1); - - // 1st line panel2 - listAttribute = new JList<TAttribute> (attributes.toArray (new TAttribute[0])); - //listAttribute.setFixedCellWidth(150); - //listAttribute.setFixedCellHeight(20); - listAttribute.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - listAttribute.addListSelectionListener(this); - JScrollPane scrollPane = new JScrollPane(listAttribute); - scrollPane.setSize(300, 250); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - c2.fill = GridBagConstraints.BOTH; - c2.gridheight = 5; - c2.weighty = 10.0; - c2.weightx = 10.0; - panel2.add(scrollPane, c2); - - // 2nd line panel2 - c2.weighty = 1.0; - c2.weightx = 1.0; - c2.fill = GridBagConstraints.BOTH; - c2.gridheight = 1; - panel2.add(new JLabel(""), c2); - - // third line panel2 - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - c2.fill = GridBagConstraints.HORIZONTAL; - upButton = new JButton("Up"); - upButton.addActionListener(this); - panel2.add(upButton, c2); - - downButton = new JButton("Down"); - downButton.addActionListener(this); - panel2.add(downButton, c2); - - removeButton = new JButton("Remove " + attrib); - removeButton.addActionListener(this); - panel2.add(removeButton, c2); - - // main panel; - panelAttr.add(panel1, BorderLayout.WEST); - panelAttr.add(panel2, BorderLayout.EAST); - - - //c.add(panel1, c0); - //c.add(panel2, c0); - - c0.gridwidth = 1; - c0.gridheight = 10; - c0.weighty = 1.0; - c0.weightx = 1.0; - c0.gridwidth = GridBagConstraints.REMAINDER; //end row - - c.add(namePanel, c0); - - c.add(panelAttr, c0); - - c0.gridwidth = 1; - c0.gridheight = 1; - c0.fill = GridBagConstraints.HORIZONTAL; - closeButton = new JButton("Save and Close", IconManager.imgic25); - //closeButton.setPreferredSize(new Dimension(600, 50)); - closeButton.addActionListener(this); - c.add(closeButton, c0); - c0.gridwidth = GridBagConstraints.REMAINDER; //end row - cancelButton = new JButton("Cancel", IconManager.imgic27); - cancelButton.addActionListener(this); - c.add(cancelButton, c0); - } - - @Override public void closeDialog() { - cancelled = false; - attributesPar.clear (); - for (TAttribute ta: attributes) - attributesPar.add (ta); - this.name = nameOfInstance.getText(); - dispose(); - } + // Issue #55: Components are now managed in the superclass +// +// @Override protected void initComponents() { +// Container c = getContentPane(); +// +// JPanel namePanel = new JPanel(); +// JPanel panelAttr = new JPanel(new BorderLayout()); +// GridBagLayout gridbag0 = new GridBagLayout(); +// GridBagLayout gridbag1 = new GridBagLayout(); +// GridBagLayout gridbag2 = new GridBagLayout(); +// GridBagConstraints c0 = new GridBagConstraints(); +// GridBagConstraints c1 = new GridBagConstraints(); +// GridBagConstraints c2 = new GridBagConstraints(); +// +// setFont(new Font("Helvetica", Font.PLAIN, 14)); +// c.setLayout(gridbag0); +// +// setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); +// +// +// //Name panel +// namePanel.add( new JLabel( "Name of storage instance:" ) ); +// nameOfInstance = new JTextField( this.name, 30 ); +// namePanel.add( nameOfInstance ); +// +// //Panel1 +// +// pnlAddingAtt = new JPanel(); +// pnlAddingAtt.setLayout(gridbag1); +// pnlAddingAtt.setBorder(new javax.swing.border.TitledBorder("Adding " + attrib + "s")); +// pnlAddingAtt.setPreferredSize(new Dimension(300, 250)); +// +// pnlManagingAtt = new JPanel(); +// pnlManagingAtt.setLayout(gridbag2); +// pnlManagingAtt.setBorder(new javax.swing.border.TitledBorder("Managing " + attrib + "s")); +// pnlManagingAtt.setPreferredSize(new Dimension(300, 250)); +// +// // first line panel1 +// c1.gridwidth = 1; +// c1.gridheight = 1; +// c1.weighty = 1.0; +// c1.weightx = 1.0; +// c1.gridwidth = GridBagConstraints.REMAINDER; //end row +// c1.fill = GridBagConstraints.BOTH; +// c1.gridheight = 3; +// pnlAddingAtt.add(new JLabel(" "), c1); +// +// c1.gridwidth = 1; +// c1.gridheight = 1; +// c1.weighty = 1.0; +// c1.weightx = 1.0; +// c1.anchor = GridBagConstraints.CENTER; +// pnlAddingAtt.add(new JLabel("access"), c1); +// pnlAddingAtt.add(new JLabel("identifier"), c1); +// if (attrib.equals("Attribute") || attrib.equals("Variable")) { +// pnlAddingAtt.add(new JLabel(" "), c1); +// pnlAddingAtt.add(new JLabel("initial value"), c1); +// } +// pnlAddingAtt.add(new JLabel(" "), c1); +// c1.gridwidth = GridBagConstraints.REMAINDER; //end row +// pnlAddingAtt.add(new JLabel("type"), c1); +// +// // second line panel1 +// c1.gridwidth = 1; +// c1.fill = GridBagConstraints.HORIZONTAL; +// c1.anchor = GridBagConstraints.CENTER; +// accessBox = new JComboBox<>(); +// pnlAddingAtt.add(accessBox, c1); +// identifierText = new JTextField(); +// identifierText.setColumns(15); +// identifierText.setEditable(true); +// pnlAddingAtt.add(identifierText, c1); +// +// initialValue = new JTextField(); +// initialValue.setColumns(5); +// initialValue.setEditable(true); +// +// if (attrib.equals("Attribute") || attrib.equals("Variable")) { +// pnlAddingAtt.add(new JLabel(" = "), c1); +// pnlAddingAtt.add(initialValue, c1); +// } +// +// pnlAddingAtt.add(new JLabel(" : "), c1); +// c1.gridwidth = GridBagConstraints.REMAINDER; //end row +// typeBox = new JComboBox<>(); +// typeBox.addActionListener(this); +// pnlAddingAtt.add(typeBox, c1); +// +// // third line panel1 +// c1.gridwidth = GridBagConstraints.REMAINDER; //end row +// c1.fill = GridBagConstraints.BOTH; +// c1.gridheight = 3; +// pnlAddingAtt.add(new JLabel(" "), c1); +// +// // fourth line panel2 +// c1.gridheight = 1; +// c1.fill = GridBagConstraints.HORIZONTAL; +// addButton = new JButton("Add / Modify " + attrib); +// addButton.addActionListener(this); +// pnlAddingAtt.add(addButton, c1); +// +// // 1st line panel2 +// listAttribute = new JList<TAttribute> (attributes.toArray (new TAttribute[0])); +// //listAttribute.setFixedCellWidth(150); +// //listAttribute.setFixedCellHeight(20); +// listAttribute.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); +// listAttribute.addListSelectionListener(this); +// JScrollPane scrollPane = new JScrollPane(listAttribute); +// scrollPane.setSize(300, 250); +// c2.gridwidth = GridBagConstraints.REMAINDER; //end row +// c2.fill = GridBagConstraints.BOTH; +// c2.gridheight = 5; +// c2.weighty = 10.0; +// c2.weightx = 10.0; +// pnlManagingAtt.add(scrollPane, c2); +// +// // 2nd line panel2 +// c2.weighty = 1.0; +// c2.weightx = 1.0; +// c2.fill = GridBagConstraints.BOTH; +// c2.gridheight = 1; +// pnlManagingAtt.add(new JLabel(""), c2); +// +// // third line panel2 +// c2.gridwidth = GridBagConstraints.REMAINDER; //end row +// c2.fill = GridBagConstraints.HORIZONTAL; +// upButton = new JButton("Up"); +// upButton.addActionListener(this); +// pnlManagingAtt.add(upButton, c2); +// +// downButton = new JButton("Down"); +// downButton.addActionListener(this); +// pnlManagingAtt.add(downButton, c2); +// +// removeButton = new JButton("Remove " + attrib); +// removeButton.addActionListener(this); +// pnlManagingAtt.add(removeButton, c2); +// +// // main panel; +// panelAttr.add(pnlAddingAtt, BorderLayout.WEST); +// panelAttr.add(pnlManagingAtt, BorderLayout.EAST); +// +// +// //c.add(panel1, c0); +// //c.add(panel2, c0); +// +// c0.gridwidth = 1; +// c0.gridheight = 10; +// c0.weighty = 1.0; +// c0.weightx = 1.0; +// c0.gridwidth = GridBagConstraints.REMAINDER; //end row +// +// c.add(namePanel, c0); +// +// c.add(panelAttr, c0); +// +// c0.gridwidth = 1; +// c0.gridheight = 1; +// c0.fill = GridBagConstraints.HORIZONTAL; +// closeButton = new JButton("Save and Close", IconManager.imgic25); +// //closeButton.setPreferredSize(new Dimension(600, 50)); +// closeButton.addActionListener(this); +// c.add(closeButton, c0); +// c0.gridwidth = GridBagConstraints.REMAINDER; //end row +// cancelButton = new JButton("Cancel", IconManager.imgic27); +// cancelButton.addActionListener(this); +// c.add(cancelButton, c0); +// } +// +// @Override public void closeDialog() { +// cancelled = false; +// attributesPar.clear (); +// for (TAttribute ta: attributes) +// attributesPar.add (ta); +// this.name = nameOfInstance.getText(); +// dispose(); +// } } //End of class diff --git a/src/main/java/ui/window/JDialogTMLCPTransferInstance.java b/src/main/java/ui/window/JDialogTMLCPTransferInstance.java index 386dc67fdbd6b4b72e9062a539a57786753e6739..2dba52df8636658eba85163867efc6937a91039e 100755 --- a/src/main/java/ui/window/JDialogTMLCPTransferInstance.java +++ b/src/main/java/ui/window/JDialogTMLCPTransferInstance.java @@ -42,15 +42,10 @@ package ui.window; -import ui.util.IconManager; -import ui.TAttribute; - -import javax.swing.*; -import javax.swing.event.ListSelectionListener; -import java.awt.*; -import java.awt.event.ActionListener; -import java.util.LinkedList; +import java.awt.Frame; +import java.util.List; +import ui.TAttribute; /** * Class JDialogTMLCPTransferInstance @@ -59,187 +54,190 @@ import java.util.LinkedList; * @version 1.0 25/07/2014 * @author Ludovic APVRILLE, Andrea ENRICI */ -public class JDialogTMLCPTransferInstance extends JDialogTMLSDInstance implements ActionListener, ListSelectionListener { +public class JDialogTMLCPTransferInstance extends JDialogTMLSDInstance {//implements ActionListener, ListSelectionListener { /** Creates new form */ - public JDialogTMLCPTransferInstance( LinkedList<TAttribute> _attributes, LinkedList<TAttribute> _forbidden, Frame f, String title, String attrib, String _name ) { + public JDialogTMLCPTransferInstance( List<TAttribute> _attributes, List<TAttribute> _forbidden, Frame f, String title, String attrib, String _name ) { super( _attributes, _forbidden, f, title, attrib, _name ); } - @Override protected void initComponents() { - Container c = getContentPane(); - - JPanel namePanel = new JPanel(); - JPanel panelAttr = new JPanel(new BorderLayout()); - GridBagLayout gridbag0 = new GridBagLayout(); - GridBagLayout gridbag1 = new GridBagLayout(); - GridBagLayout gridbag2 = new GridBagLayout(); - GridBagConstraints c0 = new GridBagConstraints(); - GridBagConstraints c1 = new GridBagConstraints(); - GridBagConstraints c2 = new GridBagConstraints(); - - setFont(new Font("Helvetica", Font.PLAIN, 14)); - c.setLayout(gridbag0); - - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - - //Name panel - namePanel.add( new JLabel( "Name of transfer instance:" ) ); - nameOfInstance = new JTextField( this.name, 30 ); - namePanel.add( nameOfInstance ); - - //Panel1 - - panel1 = new JPanel(); - panel1.setLayout(gridbag1); - panel1.setBorder(new javax.swing.border.TitledBorder("Adding " + attrib + "s")); - panel1.setPreferredSize(new Dimension(300, 250)); - - panel2 = new JPanel(); - panel2.setLayout(gridbag2); - panel2.setBorder(new javax.swing.border.TitledBorder("Managing " + attrib + "s")); - panel2.setPreferredSize(new Dimension(300, 250)); - - // first line panel1 - c1.gridwidth = 1; - c1.gridheight = 1; - c1.weighty = 1.0; - c1.weightx = 1.0; - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - c1.fill = GridBagConstraints.BOTH; - c1.gridheight = 3; - panel1.add(new JLabel(" "), c1); - - c1.gridwidth = 1; - c1.gridheight = 1; - c1.weighty = 1.0; - c1.weightx = 1.0; - c1.anchor = GridBagConstraints.CENTER; - panel1.add(new JLabel("access"), c1); - panel1.add(new JLabel("identifier"), c1); - if (attrib.equals("Attribute") || attrib.equals("Variable")) { - panel1.add(new JLabel(" "), c1); - panel1.add(new JLabel("initial value"), c1); - } - panel1.add(new JLabel(" "), c1); - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - panel1.add(new JLabel("type"), c1); - - // second line panel1 - c1.gridwidth = 1; - c1.fill = GridBagConstraints.HORIZONTAL; - c1.anchor = GridBagConstraints.CENTER; - accessBox = new JComboBox<>(); - panel1.add(accessBox, c1); - identifierText = new JTextField(); - identifierText.setColumns(15); - identifierText.setEditable(true); - panel1.add(identifierText, c1); - - initialValue = new JTextField(); - initialValue.setColumns(5); - initialValue.setEditable(true); - - if (attrib.equals("Attribute") || attrib.equals("Variable")) { - panel1.add(new JLabel(" = "), c1); - panel1.add(initialValue, c1); - } - - panel1.add(new JLabel(" : "), c1); - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - typeBox = new JComboBox<>(); - typeBox.addActionListener(this); - panel1.add(typeBox, c1); - - // third line panel1 - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - c1.fill = GridBagConstraints.BOTH; - c1.gridheight = 3; - panel1.add(new JLabel(" "), c1); - - // fourth line panel2 - c1.gridheight = 1; - c1.fill = GridBagConstraints.HORIZONTAL; - addButton = new JButton("Add / Modify " + attrib); - addButton.addActionListener(this); - panel1.add(addButton, c1); - - // 1st line panel2 - listAttribute = new JList<TAttribute> (attributes.toArray (new TAttribute[0])); - //listAttribute.setFixedCellWidth(150); - //listAttribute.setFixedCellHeight(20); - listAttribute.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - listAttribute.addListSelectionListener(this); - JScrollPane scrollPane = new JScrollPane(listAttribute); - scrollPane.setSize(300, 250); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - c2.fill = GridBagConstraints.BOTH; - c2.gridheight = 5; - c2.weighty = 10.0; - c2.weightx = 10.0; - panel2.add(scrollPane, c2); - - // 2nd line panel2 - c2.weighty = 1.0; - c2.weightx = 1.0; - c2.fill = GridBagConstraints.BOTH; - c2.gridheight = 1; - panel2.add(new JLabel(""), c2); - - // third line panel2 - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - c2.fill = GridBagConstraints.HORIZONTAL; - upButton = new JButton("Up"); - upButton.addActionListener(this); - panel2.add(upButton, c2); - - downButton = new JButton("Down"); - downButton.addActionListener(this); - panel2.add(downButton, c2); - - removeButton = new JButton("Remove " + attrib); - removeButton.addActionListener(this); - panel2.add(removeButton, c2); - - // main panel; - panelAttr.add(panel1, BorderLayout.WEST); - panelAttr.add(panel2, BorderLayout.EAST); - - - //c.add(panel1, c0); - //c.add(panel2, c0); - - c0.gridwidth = 1; - c0.gridheight = 10; - c0.weighty = 1.0; - c0.weightx = 1.0; - c0.gridwidth = GridBagConstraints.REMAINDER; //end row - - c.add(namePanel, c0); - - c.add( panelAttr, c0); - - c0.gridwidth = 1; - c0.gridheight = 1; - c0.fill = GridBagConstraints.HORIZONTAL; - closeButton = new JButton("Save and Close", IconManager.imgic25); - //closeButton.setPreferredSize(new Dimension(600, 50)); - closeButton.addActionListener(this); - c.add(closeButton, c0); - c0.gridwidth = GridBagConstraints.REMAINDER; //end row - cancelButton = new JButton("Cancel", IconManager.imgic27); - cancelButton.addActionListener(this); - c.add(cancelButton, c0); - } + + // Issue #55: Components are now managed in the superclass + + // @Override protected void initComponents() { +// Container c = getContentPane(); +// +// JPanel namePanel = new JPanel(); +// JPanel panelAttr = new JPanel(new BorderLayout()); +// GridBagLayout gridbag0 = new GridBagLayout(); +// GridBagLayout gridbag1 = new GridBagLayout(); +// GridBagLayout gridbag2 = new GridBagLayout(); +// GridBagConstraints c0 = new GridBagConstraints(); +// GridBagConstraints c1 = new GridBagConstraints(); +// GridBagConstraints c2 = new GridBagConstraints(); +// +// setFont(new Font("Helvetica", Font.PLAIN, 14)); +// c.setLayout(gridbag0); +// +// setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); +// +// +// //Name panel +// namePanel.add( new JLabel( "Name of transfer instance:" ) ); +// nameOfInstance = new JTextField( this.name, 30 ); +// namePanel.add( nameOfInstance ); +// +// //Panel1 +// +// pnlAddingAtt = new JPanel(); +// pnlAddingAtt.setLayout(gridbag1); +// pnlAddingAtt.setBorder(new javax.swing.border.TitledBorder("Adding " + attrib + "s")); +// pnlAddingAtt.setPreferredSize(new Dimension(300, 250)); +// +// pnlManagingAtt = new JPanel(); +// pnlManagingAtt.setLayout(gridbag2); +// pnlManagingAtt.setBorder(new javax.swing.border.TitledBorder("Managing " + attrib + "s")); +// pnlManagingAtt.setPreferredSize(new Dimension(300, 250)); +// +// // first line panel1 +// c1.gridwidth = 1; +// c1.gridheight = 1; +// c1.weighty = 1.0; +// c1.weightx = 1.0; +// c1.gridwidth = GridBagConstraints.REMAINDER; //end row +// c1.fill = GridBagConstraints.BOTH; +// c1.gridheight = 3; +// pnlAddingAtt.add(new JLabel(" "), c1); +// +// c1.gridwidth = 1; +// c1.gridheight = 1; +// c1.weighty = 1.0; +// c1.weightx = 1.0; +// c1.anchor = GridBagConstraints.CENTER; +// pnlAddingAtt.add(new JLabel("access"), c1); +// pnlAddingAtt.add(new JLabel("identifier"), c1); +// if (attrib.equals("Attribute") || attrib.equals("Variable")) { +// pnlAddingAtt.add(new JLabel(" "), c1); +// pnlAddingAtt.add(new JLabel("initial value"), c1); +// } +// pnlAddingAtt.add(new JLabel(" "), c1); +// c1.gridwidth = GridBagConstraints.REMAINDER; //end row +// pnlAddingAtt.add(new JLabel("type"), c1); +// +// // second line panel1 +// c1.gridwidth = 1; +// c1.fill = GridBagConstraints.HORIZONTAL; +// c1.anchor = GridBagConstraints.CENTER; +// accessBox = new JComboBox<>(); +// pnlAddingAtt.add(accessBox, c1); +// identifierText = new JTextField(); +// identifierText.setColumns(15); +// identifierText.setEditable(true); +// pnlAddingAtt.add(identifierText, c1); +// +// initialValue = new JTextField(); +// initialValue.setColumns(5); +// initialValue.setEditable(true); +// +// if (attrib.equals("Attribute") || attrib.equals("Variable")) { +// pnlAddingAtt.add(new JLabel(" = "), c1); +// pnlAddingAtt.add(initialValue, c1); +// } +// +// pnlAddingAtt.add(new JLabel(" : "), c1); +// c1.gridwidth = GridBagConstraints.REMAINDER; //end row +// typeBox = new JComboBox<>(); +// typeBox.addActionListener(this); +// pnlAddingAtt.add(typeBox, c1); +// +// // third line panel1 +// c1.gridwidth = GridBagConstraints.REMAINDER; //end row +// c1.fill = GridBagConstraints.BOTH; +// c1.gridheight = 3; +// pnlAddingAtt.add(new JLabel(" "), c1); +// +// // fourth line panel2 +// c1.gridheight = 1; +// c1.fill = GridBagConstraints.HORIZONTAL; +// addButton = new JButton("Add / Modify " + attrib); +// addButton.addActionListener(this); +// pnlAddingAtt.add(addButton, c1); +// +// // 1st line panel2 +// listAttribute = new JList<TAttribute> (attributes.toArray (new TAttribute[0])); +// //listAttribute.setFixedCellWidth(150); +// //listAttribute.setFixedCellHeight(20); +// listAttribute.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); +// listAttribute.addListSelectionListener(this); +// JScrollPane scrollPane = new JScrollPane(listAttribute); +// scrollPane.setSize(300, 250); +// c2.gridwidth = GridBagConstraints.REMAINDER; //end row +// c2.fill = GridBagConstraints.BOTH; +// c2.gridheight = 5; +// c2.weighty = 10.0; +// c2.weightx = 10.0; +// pnlManagingAtt.add(scrollPane, c2); +// +// // 2nd line panel2 +// c2.weighty = 1.0; +// c2.weightx = 1.0; +// c2.fill = GridBagConstraints.BOTH; +// c2.gridheight = 1; +// pnlManagingAtt.add(new JLabel(""), c2); +// +// // third line panel2 +// c2.gridwidth = GridBagConstraints.REMAINDER; //end row +// c2.fill = GridBagConstraints.HORIZONTAL; +// upButton = new JButton("Up"); +// upButton.addActionListener(this); +// pnlManagingAtt.add(upButton, c2); +// +// downButton = new JButton("Down"); +// downButton.addActionListener(this); +// pnlManagingAtt.add(downButton, c2); +// +// removeButton = new JButton("Remove " + attrib); +// removeButton.addActionListener(this); +// pnlManagingAtt.add(removeButton, c2); +// +// // main panel; +// panelAttr.add(pnlAddingAtt, BorderLayout.WEST); +// panelAttr.add(pnlManagingAtt, BorderLayout.EAST); +// +// +// //c.add(panel1, c0); +// //c.add(panel2, c0); +// +// c0.gridwidth = 1; +// c0.gridheight = 10; +// c0.weighty = 1.0; +// c0.weightx = 1.0; +// c0.gridwidth = GridBagConstraints.REMAINDER; //end row +// +// c.add(namePanel, c0); +// +// c.add( panelAttr, c0); +// +// c0.gridwidth = 1; +// c0.gridheight = 1; +// c0.fill = GridBagConstraints.HORIZONTAL; +// closeButton = new JButton("Save and Close", IconManager.imgic25); +// //closeButton.setPreferredSize(new Dimension(600, 50)); +// closeButton.addActionListener(this); +// c.add(closeButton, c0); +// c0.gridwidth = GridBagConstraints.REMAINDER; //end row +// cancelButton = new JButton("Cancel", IconManager.imgic27); +// cancelButton.addActionListener(this); +// c.add(cancelButton, c0); +// } - @Override public void closeDialog() { - cancelled = false; - attributesPar.clear (); - for(int i=0; i<attributes.size(); i++) { - attributesPar.add (attributes.get (i)); - } - this.name = nameOfInstance.getText(); - dispose(); - } +// @Override public void closeDialog() { +// cancelled = false; +// attributesPar.clear (); +// for(int i=0; i<attributes.size(); i++) { +// attributesPar.add (attributes.get (i)); +// } +// this.name = nameOfInstance.getText(); +// dispose(); +// } } //End of class diff --git a/src/main/java/ui/window/JDialogTMLSDInstance.java b/src/main/java/ui/window/JDialogTMLSDInstance.java index ffc3dd981a7bdf0575e690b8a31bfd2c7326afee..c7f641238dfb270eeb39721271c3fe66dfbf25e5 100755 --- a/src/main/java/ui/window/JDialogTMLSDInstance.java +++ b/src/main/java/ui/window/JDialogTMLSDInstance.java @@ -37,12 +37,10 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package ui.window; import ui.TAttribute; +import ui.util.IconManager; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -62,13 +60,15 @@ import java.util.LinkedList; */ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implements ActionListener, ListSelectionListener { - protected LinkedList<TAttribute> attributes, attributesPar, forbidden; - protected LinkedList<Boolean> initValues; + protected static final int DEFAULT_MARGIN_SIZE = 5; + + protected java.util.List<TAttribute> attributes, attributesPar, forbidden; + protected java.util.List<Boolean> initValues; protected boolean checkKeyword, checkJavaKeyword; protected boolean cancelled = false; - protected JPanel panel1, panel2; + protected JPanel pnlAddingAtt, pnlManagingAtt; protected Frame frame; protected int tab; @@ -91,7 +91,7 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement protected JButton removeButton; //Panel 3 - protected JComboBox referenceUnitsName; + //protected JComboBox<String> referenceUnitsName; // Main Panel protected JButton closeButton; @@ -100,7 +100,7 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement protected String name = ""; /** Creates new form */ - public JDialogTMLSDInstance( LinkedList<TAttribute> _attributes, LinkedList<TAttribute> _forbidden, Frame f, String title, String attrib, String _name ) { + public JDialogTMLSDInstance( java.util.List<TAttribute> _attributes, java.util.List<TAttribute> _forbidden, Frame f, String title, String attrib, String _name ) { super(f, title, true); frame = f; attributesPar = _attributes; @@ -111,8 +111,9 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement attributes = new LinkedList<TAttribute> (); - for (TAttribute attr: attributesPar) + for (TAttribute attr: attributesPar) { attributes.add (attr.makeClone()); + } initComponents(); myInitComponents(); @@ -125,8 +126,348 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement downButton.setEnabled(false); } - protected abstract void initComponents(); + // Issue #55 + protected JPanel createNamePanel() { + final JPanel pnlName = new JPanel(new GridBagLayout()); + + GridBagConstraints cstLblName = new GridBagConstraints(); + cstLblName.anchor = GridBagConstraints.NORTHEAST; + cstLblName.gridx = 0; + cstLblName.gridy = 0; + cstLblName.weightx = 0.0; + cstLblName.weighty = 0.0; + cstLblName.fill = GridBagConstraints.HORIZONTAL; + cstLblName.gridwidth = 1; + cstLblName.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0 ); + pnlName.add( new JLabel( "Name:" ), cstLblName ); + + nameOfInstance = new JTextField( this.name );//, 30 ); + GridBagConstraints cstTfdName = new GridBagConstraints(); + cstTfdName.anchor = GridBagConstraints.NORTHWEST; + cstTfdName.gridx = 1; + cstTfdName.gridy = 0; + cstTfdName.weightx = 1.0; + cstTfdName.weighty = 0.0; + cstTfdName.fill = GridBagConstraints.BOTH; + cstTfdName.gridwidth = GridBagConstraints.REMAINDER; //end row + cstTfdName.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE ); + pnlName.add( nameOfInstance, cstTfdName ); + + return pnlName; + } + + // Issue #55 + protected JPanel createAttributesPanel() { + JPanel pnlAttributes = new JPanel(new GridBagLayout()); + + pnlManagingAtt = new JPanel(); + pnlManagingAtt.setLayout( new GridBagLayout() ); + pnlManagingAtt.setBorder(new javax.swing.border.TitledBorder("Managing " + attrib + "s")); + + final GridBagConstraints cstMngAtt = new GridBagConstraints(); + cstMngAtt.anchor = GridBagConstraints.NORTHWEST; + cstMngAtt.gridx = 0; + cstMngAtt.gridy = 0; + cstMngAtt.weightx = 1.0; + cstMngAtt.weighty = 1.0; + cstMngAtt.fill = GridBagConstraints.BOTH; + cstMngAtt.gridwidth = GridBagConstraints.REMAINDER; //end row; + cstMngAtt.insets = new Insets( 0, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE ); + pnlAttributes.add(pnlManagingAtt, cstMngAtt );//BorderLayout.EAST); + + // 1st line panel2 + listAttribute = new JList<TAttribute>(attributes.toArray(new TAttribute[ attributes.size() ])); + listAttribute.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listAttribute.addListSelectionListener(this); + final GridBagConstraints cstLstAtt = new GridBagConstraints(); + cstLstAtt.anchor = GridBagConstraints.NORTHWEST; + cstLstAtt.gridx = 0; + cstLstAtt.gridy = 0; + cstLstAtt.weightx = 1.0; + cstLstAtt.weighty = 1.0; + cstLstAtt.fill = GridBagConstraints.BOTH; + cstLstAtt.gridwidth = GridBagConstraints.REMAINDER; + cstLstAtt.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0, DEFAULT_MARGIN_SIZE ); + JScrollPane scrollPane = new JScrollPane(listAttribute); + pnlManagingAtt.add(scrollPane, cstLstAtt); + + upButton = new JButton("Up"); + upButton.addActionListener(this); + final GridBagConstraints cstBtnUp = new GridBagConstraints(); + cstBtnUp.anchor = GridBagConstraints.NORTHWEST; + cstBtnUp.gridx = 0; + cstBtnUp.gridy = 1; + cstBtnUp.weightx = 1.0; + cstBtnUp.weighty = 0.0; + cstBtnUp.fill = GridBagConstraints.HORIZONTAL; + cstBtnUp.gridwidth = GridBagConstraints.REMAINDER; + cstBtnUp.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0, DEFAULT_MARGIN_SIZE ); + pnlManagingAtt.add(upButton, cstBtnUp ); + + downButton = new JButton("Down"); + downButton.addActionListener(this); + final GridBagConstraints cstBtnDown = new GridBagConstraints(); + cstBtnDown.anchor = GridBagConstraints.NORTHWEST; + cstBtnDown.gridx = 0; + cstBtnDown.gridy = 2; + cstBtnDown.weightx = 1.0; + cstBtnDown.weighty = 0.0; + cstBtnDown.fill = GridBagConstraints.HORIZONTAL; + cstBtnDown.gridwidth = GridBagConstraints.REMAINDER; + cstBtnDown.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0, DEFAULT_MARGIN_SIZE ); + pnlManagingAtt.add( downButton, cstBtnDown ); + + removeButton = new JButton("Remove " + attrib); + removeButton.addActionListener(this); + final GridBagConstraints cstBtnRem = new GridBagConstraints(); + cstBtnRem.anchor = GridBagConstraints.NORTHWEST; + cstBtnRem.gridx = 0; + cstBtnRem.gridy = 3; + cstBtnRem.weightx = 1.0; + cstBtnRem.weighty = 0.0; + cstBtnRem.fill = GridBagConstraints.HORIZONTAL; + cstBtnRem.gridwidth = GridBagConstraints.REMAINDER; + cstBtnRem.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE ); + pnlManagingAtt.add(removeButton, cstBtnRem); + + + pnlAddingAtt = new JPanel(); + pnlAddingAtt.setLayout( new GridBagLayout() ); + pnlAddingAtt.setBorder(new javax.swing.border.TitledBorder("Adding / Modifying " + attrib + "s")); + + GridBagConstraints cstPnlAddAtt = new GridBagConstraints(); + cstPnlAddAtt.anchor = GridBagConstraints.NORTHWEST; + cstPnlAddAtt.gridx = 0; + cstPnlAddAtt.gridy = 1; + cstPnlAddAtt.weightx = 1.0; + cstPnlAddAtt.weighty = 0.0; + cstPnlAddAtt.fill = GridBagConstraints.BOTH; + cstPnlAddAtt.gridwidth = 1; + cstPnlAddAtt.insets = new Insets( 0, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE ); + pnlAttributes.add( pnlAddingAtt, cstPnlAddAtt );//BorderLayout.WEST); + + int xPos = 0; + final GridBagConstraints cstLblAccess = new GridBagConstraints(); + cstLblAccess.anchor = GridBagConstraints.NORTHWEST; + cstLblAccess.gridx = xPos++; + cstLblAccess.gridy = 0; + cstLblAccess.weightx = 0.0; + cstLblAccess.weighty = 0.0; + cstLblAccess.fill = GridBagConstraints.HORIZONTAL; + cstLblAccess.gridwidth = 1; + cstLblAccess.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0, 0 ); + pnlAddingAtt.add( new JLabel("Access"), cstLblAccess ); + + final GridBagConstraints cstLblId = new GridBagConstraints(); + cstLblId.anchor = GridBagConstraints.NORTHWEST; + cstLblId.gridx = xPos++; + cstLblId.gridy = 0; + cstLblId.weightx = 0.0; + cstLblId.weighty = 0.0; + cstLblId.fill = GridBagConstraints.HORIZONTAL; + cstLblId.gridwidth = 1; + cstLblId.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0, 0 ); + pnlAddingAtt.add(new JLabel("Identifier"), cstLblId ); + + if (attrib.equals("Attribute") || attrib.equals("Variable")) { + + // For = label of row below + xPos++; + + final GridBagConstraints cstLblInVal = new GridBagConstraints(); + cstLblInVal.anchor = GridBagConstraints.NORTHWEST; + cstLblInVal.gridx = xPos++; + cstLblInVal.gridy = 0; + cstLblInVal.weightx = 0.0; + cstLblInVal.weighty = 0.0; + cstLblInVal.fill = GridBagConstraints.HORIZONTAL; + cstLblInVal.gridwidth = 1; + cstLblInVal.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0, 0 ); + pnlAddingAtt.add(new JLabel("Initial Value"), cstLblInVal ); + } + + // For = label of row below + xPos++; + + final GridBagConstraints cstLblType = new GridBagConstraints(); + cstLblType.anchor = GridBagConstraints.NORTHWEST; + cstLblType.gridx = xPos++; + cstLblType.gridy = 0; + cstLblType.weightx = 0.0; + cstLblType.weighty = 0.0; + cstLblType.fill = GridBagConstraints.HORIZONTAL; + cstLblType.gridwidth = GridBagConstraints.REMAINDER; + cstLblType.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0, DEFAULT_MARGIN_SIZE ); + pnlAddingAtt.add(new JLabel("Type"), cstLblType ); + + xPos = 0; + final GridBagConstraints cstCmbAccess = new GridBagConstraints(); + cstCmbAccess.anchor = GridBagConstraints.NORTHWEST; + cstCmbAccess.gridx = xPos++; + cstCmbAccess.gridy = 1; + cstCmbAccess.weightx = 0.0; + cstCmbAccess.weighty = 0.0; + cstCmbAccess.fill = GridBagConstraints.HORIZONTAL; + cstCmbAccess.gridwidth = 1; + cstCmbAccess.insets = new Insets( 0, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0 ); + accessBox = new JComboBox<String>(); + pnlAddingAtt.add(accessBox, cstCmbAccess ); + + identifierText = new JTextField(); + identifierText.setEditable(true); + final GridBagConstraints cstTfdId = new GridBagConstraints(); + cstTfdId.anchor = GridBagConstraints.NORTHWEST; + cstTfdId.gridx = xPos++; + cstTfdId.gridy = 1; + cstTfdId.weightx = 1.0; + cstTfdId.weighty = 0.0; + cstTfdId.fill = GridBagConstraints.BOTH; + cstTfdId.gridwidth = 1; + cstTfdId.insets = new Insets( 0, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0 ); + pnlAddingAtt.add(identifierText, cstTfdId ); + + if (attrib.equals("Attribute") || attrib.equals("Variable")) { + final GridBagConstraints cstLblEq = new GridBagConstraints(); + cstLblEq.anchor = GridBagConstraints.CENTER; + cstLblEq.gridx = xPos++; + cstLblEq.gridy = 1; + cstLblEq.weightx = 0.0; + cstLblEq.weighty = 0.0; + cstLblEq.fill = GridBagConstraints.BOTH; + cstLblEq.gridwidth = 1; + cstLblEq.insets = new Insets( 0, 0, DEFAULT_MARGIN_SIZE, 0 ); + pnlAddingAtt.add( new JLabel( " = " ), cstLblEq ); + initialValue = new JTextField(); + initialValue.setEditable(true); + final GridBagConstraints cstTfdInVal = new GridBagConstraints(); + cstTfdInVal.anchor = GridBagConstraints.NORTHWEST; + cstTfdInVal.gridx = xPos++; + cstTfdInVal.gridy = 1; + cstTfdInVal.weightx = 0.4; + cstTfdInVal.weighty = 0.0; + cstTfdInVal.fill = GridBagConstraints.BOTH; + cstTfdInVal.gridwidth = 1; + cstTfdInVal.insets = new Insets( 0, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0 ); + pnlAddingAtt.add(initialValue, cstTfdInVal ); + } + + final GridBagConstraints cstLblColumn = new GridBagConstraints(); + cstLblColumn.anchor = GridBagConstraints.CENTER; + cstLblColumn.gridx = xPos++; + cstLblColumn.gridy = 1; + cstLblColumn.weightx = 0.0; + cstLblColumn.weighty = 0.0; + cstLblColumn.fill = GridBagConstraints.BOTH; + cstLblColumn.gridwidth = 1; + cstLblColumn.insets = new Insets( 0, 0, DEFAULT_MARGIN_SIZE, 0 ); + pnlAddingAtt.add( new JLabel( " : " ), cstLblColumn ); + typeBox = new JComboBox<String>(); + typeBox.addActionListener(this); + final GridBagConstraints cstCmbType = new GridBagConstraints(); + cstCmbType.anchor = GridBagConstraints.NORTHWEST; + cstCmbType.gridx = xPos++; + cstCmbType.gridy = 1; + cstCmbType.weightx = 0.0; + cstCmbType.weighty = 0.0; + cstCmbType.fill = GridBagConstraints.HORIZONTAL; + cstCmbType.gridwidth = GridBagConstraints.REMAINDER; //end row + cstCmbType.insets = new Insets( 0, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE ); + pnlAddingAtt.add(typeBox, cstCmbType ); + + addButton = new JButton("Add / Modify " + attrib); + addButton.addActionListener(this); + final GridBagConstraints cstBtnAdd = new GridBagConstraints(); + cstBtnAdd.anchor = GridBagConstraints.NORTHWEST; + cstBtnAdd.gridx = 0; + cstBtnAdd.gridy = 2; + cstBtnAdd.weightx = 1.0; + cstBtnAdd.weighty = 0.0; + cstBtnAdd.fill = GridBagConstraints.HORIZONTAL; + cstBtnAdd.gridwidth = xPos; + cstBtnAdd.insets = new Insets( 0, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE ); + pnlAddingAtt.add(addButton, cstBtnAdd ); + + return pnlAttributes; + } + + // Issue #55 + protected JPanel createButtonsPanel() { + JPanel pnlButtons = new JPanel(new GridBagLayout()); + closeButton = new JButton("Save and Close", IconManager.imgic25 ); + closeButton.addActionListener(this); + GridBagConstraints cstBtnClose = new GridBagConstraints(); + cstBtnClose.anchor = GridBagConstraints.NORTHWEST; + cstBtnClose.gridx = 0; + cstBtnClose.gridy = 0; + cstBtnClose.weightx = 1.0; + cstBtnClose.weighty = 0.0; + cstBtnClose.fill = GridBagConstraints.HORIZONTAL; + cstBtnClose.gridwidth = 1; + cstBtnClose.insets = new Insets( 0, DEFAULT_MARGIN_SIZE, 0, DEFAULT_MARGIN_SIZE ); + pnlButtons.add(closeButton, cstBtnClose); + + cancelButton = new JButton("Cancel", IconManager.imgic27); + cancelButton.addActionListener(this); + GridBagConstraints cstBtnCancel = new GridBagConstraints(); + cstBtnCancel.anchor = GridBagConstraints.NORTHWEST; + cstBtnCancel.gridx = 1; + cstBtnCancel.gridy = 0; + cstBtnCancel.weightx = 1.0; + cstBtnCancel.weighty = 0.0; + cstBtnCancel.fill = GridBagConstraints.HORIZONTAL; + cstBtnCancel.gridwidth = GridBagConstraints.REMAINDER; + cstBtnCancel.insets = new Insets( 0, 0, 0, DEFAULT_MARGIN_SIZE ); + pnlButtons.add(cancelButton, cstBtnCancel); + + return pnlButtons; + } + protected void initComponents() { + setFont(new Font("Helvetica", Font.PLAIN, 14)); + setDefaultCloseOperation( DISPOSE_ON_CLOSE ); + + Container contentPane = getContentPane(); + contentPane.setLayout( new GridBagLayout() ); + + // Issue #55 + GridBagConstraints cstPnlName = new GridBagConstraints(); + cstPnlName.anchor = GridBagConstraints.NORTHWEST; + cstPnlName.gridx = 0; + cstPnlName.gridy = 0; + cstPnlName.weightx = 1.0; + cstPnlName.weighty = 0.0; + cstPnlName.fill = GridBagConstraints.HORIZONTAL; + cstPnlName.gridwidth = GridBagConstraints.REMAINDER; + cstPnlName.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0, DEFAULT_MARGIN_SIZE ); + final JPanel pnlName = createNamePanel(); + contentPane.add( pnlName, cstPnlName ); + + JPanel pnlAttr = createAttributesPanel(); + GridBagConstraints cstPnlAtt = new GridBagConstraints(); + cstPnlAtt.anchor = GridBagConstraints.NORTHWEST; + cstPnlAtt.gridx = 0; + cstPnlAtt.gridy = 1; + cstPnlAtt.weightx = 1.0; + cstPnlAtt.weighty = 1.0; + cstPnlAtt.fill = GridBagConstraints.BOTH; + cstPnlAtt.gridwidth = GridBagConstraints.REMAINDER; //end row + cstPnlAtt.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, 0, DEFAULT_MARGIN_SIZE ); + contentPane.add( pnlAttr, cstPnlAtt ); + + final JPanel pnlButtons = createButtonsPanel(); + GridBagConstraints cstPnlButtons = new GridBagConstraints(); + cstPnlButtons.anchor = GridBagConstraints.NORTHWEST; + cstPnlButtons.gridx = 0; + cstPnlButtons.gridy = 2; + cstPnlButtons.weightx = 1.0; + cstPnlButtons.weighty = 0.0; + cstPnlButtons.fill = GridBagConstraints.BOTH; + cstPnlButtons.gridwidth = GridBagConstraints.REMAINDER; + cstPnlButtons.insets = new Insets( DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE, DEFAULT_MARGIN_SIZE ); + contentPane.add( pnlButtons, cstPnlButtons ); + } + + @Override public void actionPerformed(ActionEvent evt) { if (evt.getSource() == typeBox) { boolean b = initValues.get (typeBox.getSelectedIndex()).booleanValue(); @@ -134,9 +475,6 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement return; } - - //String command = evt.getActionCommand(); - // Compare the action command to the known actions. if (evt.getSource() == closeButton) { closeDialog(); @@ -281,7 +619,7 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement } } - public abstract void closeDialog(); + // public abstract void closeDialog(); public boolean hasBeenCancelled() { return cancelled; @@ -308,7 +646,9 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement if (a.getType() == TAttribute.OTHER) { select(typeBox, a.getTypeOther()); } else { - select(typeBox, TAttribute.getStringAvatarType(a.getType())); + // Issue #55: The string type is used to populate the combo boxes not the avatar type. + select(typeBox, TAttribute.getStringType(a.getType())); +// select(typeBox, TAttribute.getStringAvatarType(a.getType())); } removeButton.setEnabled(true); if (i > 0) { @@ -338,4 +678,17 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement public String getName() { return this.name; } + + public void closeDialog() { + cancelled = false; + attributesPar.clear (); + + for(int i=0; i<attributes.size(); i++) { + attributesPar.add (attributes.get (i)); + } + + this.name = nameOfInstance.getText(); + + dispose(); + } } //End of class