From 8725e64b3ab60b9e980f9b47fbd51def6e1b5bb6 Mon Sep 17 00:00:00 2001 From: Lee <irina.lee@etu.upmc.fr> Date: Wed, 8 Aug 2018 16:49:42 +0200 Subject: [PATCH] Revert "Issue #69: Implemented components disabling for activity diagrams and" This reverts commit 88933719de3db52d5d89703ce0a0e40dd1bdc075. --- .../java/avatartranslator/AvatarState.java | 1 + src/main/java/ui/AbstractCDElement.java | 79 - .../ui/ActivityDiagram2TMLTranslator.java | 965 --------- .../java/ui/AvatarDesignPanelTranslator.java | 1293 +++++------- src/main/java/ui/CDElement.java | 22 +- src/main/java/ui/CanBeDisabled.java | 55 + src/main/java/ui/ColorManager.java | 102 +- src/main/java/ui/Expression.java | 69 - ...FindNextEnabledConnectingPointVisitor.java | 71 - .../ui/ForwardComponentsEnabledVisitor.java | 31 - src/main/java/ui/GNCModeling.java | 86 +- src/main/java/ui/GTMLModeling.java | 1833 ++++++++--------- src/main/java/ui/ICDElementVisitor.java | 6 - src/main/java/ui/MainGUI.java | 58 +- .../java/ui/MalformedModelingException.java | 20 +- .../java/ui/MalformedTMLDesignException.java | 42 +- src/main/java/ui/RangeExpression.java | 56 - src/main/java/ui/TDiagramMouseManager.java | 43 +- src/main/java/ui/TDiagramPanel.java | 79 +- src/main/java/ui/TGCNote.java | 12 +- src/main/java/ui/TGCOneLineText.java | 33 +- src/main/java/ui/TGCPointOfConnector.java | 9 - .../ui/TGCScalableWithInternalComponent.java | 11 +- .../java/ui/TGCWithInternalComponent.java | 11 +- .../java/ui/TGCWithoutInternalComponent.java | 6 +- src/main/java/ui/TGComponent.java | 191 +- src/main/java/ui/TGComponentManager.java | 32 +- src/main/java/ui/TGConnectingPoint.java | 83 +- .../java/ui/TGConnectingPointWidthHeight.java | 13 +- src/main/java/ui/TGConnector.java | 79 +- src/main/java/ui/TGConnectorComment.java | 11 +- src/main/java/ui/TGConnectorFullArrow.java | 17 +- src/main/java/ui/TGUIAction.java | 8 +- .../java/ui/TrackingCDElementVisitor.java | 18 - src/main/java/ui/UICheckingError.java | 15 +- .../ui/ad/CanBeDisabledADElementVisitor.java | 53 - .../java/ui/ad/EnablingADBranchVisitor.java | 30 - .../ui/ad/EnablingADConnectorVisitor.java | 51 - src/main/java/ui/ad/TADActionState.java | 34 +- src/main/java/ui/ad/TADArrayGetState.java | 17 +- src/main/java/ui/ad/TADArraySetState.java | 23 +- src/main/java/ui/ad/TADChoice.java | 186 +- .../ui/ad/TADComponentWithSubcomponents.java | 30 - .../ad/TADComponentWithoutSubcomponents.java | 30 - src/main/java/ui/ad/TADConnector.java | 74 - .../java/ui/ad/TADDeterministicDelay.java | 17 +- src/main/java/ui/ad/TADForLoop.java | 138 -- src/main/java/ui/ad/TADJunction.java | 20 +- .../java/ui/ad/TADNonDeterministicDelay.java | 18 +- src/main/java/ui/ad/TADOneLineText.java | 25 - src/main/java/ui/ad/TADParallel.java | 24 +- src/main/java/ui/ad/TADPreemption.java | 19 +- src/main/java/ui/ad/TADSequence.java | 77 +- src/main/java/ui/ad/TADStartState.java | 41 +- src/main/java/ui/ad/TADStopState.java | 51 +- src/main/java/ui/ad/TADTimeCapture.java | 20 +- src/main/java/ui/ad/TADTimeInterval.java | 21 +- src/main/java/ui/ad/TADTimeLimitedOffer.java | 25 +- .../ui/ad/TADTimeLimitedOfferWithLatency.java | 19 +- .../java/ui/ad/TActivityDiagramToolBar.java | 12 + src/main/java/ui/ad/TGConnectingPointAD.java | 14 +- src/main/java/ui/atd/ATDAttack.java | 54 +- src/main/java/ui/atd/ATDAttackConnector.java | 36 +- .../java/ui/atd/ATDCompositionConnector.java | 17 +- .../avatarad/AvatarADAcceptEventAction.java | 23 +- src/main/java/ui/avatarad/AvatarADAction.java | 12 +- .../java/ui/avatarad/AvatarADActivity.java | 64 +- .../AvatarADAssociationConnector.java | 29 +- .../AvatarADBasicCanBeDisabledComponent.java | 17 - .../ui/avatarad/AvatarADBasicComponent.java | 8 +- src/main/java/ui/avatarad/AvatarADChoice.java | 254 ++- .../ui/avatarad/AvatarADConnectingPoint.java | 8 +- .../java/ui/avatarad/AvatarADJunction.java | 13 +- src/main/java/ui/avatarad/AvatarADPanel.java | 43 +- .../java/ui/avatarad/AvatarADParallel.java | 57 +- .../java/ui/avatarad/AvatarADPartition.java | 31 +- .../ui/avatarad/AvatarADSendSignalAction.java | 19 +- .../java/ui/avatarad/AvatarADStartState.java | 18 +- .../java/ui/avatarad/AvatarADStopFlow.java | 17 +- .../java/ui/avatarad/AvatarADStopState.java | 16 +- .../java/ui/avatarad/AvatarADToolBar.java | 9 + .../avatarbd/AvatarBDPerformancePragma.java | 2 +- src/main/java/ui/avatarbd/AvatarBDPragma.java | 29 +- .../ui/avatarbd/AvatarBDSafetyPragma.java | 22 +- src/main/java/ui/avatardd/ADDArtifact.java | 20 +- .../java/ui/avatardd/ADDBlockArtifact.java | 20 +- src/main/java/ui/avatardd/ADDBridgeNode.java | 30 +- src/main/java/ui/avatardd/ADDBusNode.java | 24 +- src/main/java/ui/avatardd/ADDCPUNode.java | 30 +- .../java/ui/avatardd/ADDChannelArtifact.java | 17 +- .../AvatarMADCompositionConnector.java | 9 +- .../java/ui/avatarmad/AvatarMADConnector.java | 84 - .../avatarmad/AvatarMADImpactConnector.java | 76 +- .../ui/avatarmad/AvatarMADMeetConnector.java | 73 +- .../AvatarSMDBasicCanBeDisabledComponent.java | 25 - .../ui/avatarsmd/AvatarSMDBasicComponent.java | 14 +- .../java/ui/avatarsmd/AvatarSMDChoice.java | 29 +- .../java/ui/avatarsmd/AvatarSMDConnector.java | 191 +- .../ui/avatarsmd/AvatarSMDExpireTimer.java | 57 +- .../AvatarSMDLibraryFunctionCall.java | 47 +- .../java/ui/avatarsmd/AvatarSMDRandom.java | 38 +- .../ui/avatarsmd/AvatarSMDReceiveSignal.java | 54 +- .../ui/avatarsmd/AvatarSMDResetTimer.java | 32 +- .../ui/avatarsmd/AvatarSMDSendSignal.java | 72 +- .../java/ui/avatarsmd/AvatarSMDSetTimer.java | 45 +- .../ui/avatarsmd/AvatarSMDStartState.java | 28 +- .../java/ui/avatarsmd/AvatarSMDState.java | 214 +- .../java/ui/avatarsmd/AvatarSMDToolBar.java | 14 +- .../ui/avatarsmd/AvatarSMDTransitionInfo.java | 922 +++------ .../EnablingAvatarSMDConnectorVisitor.java | 31 - ...tarSMDComponentsToBeTranslatedVisitor.java | 105 - ...nabledAvatarSMDConnectingPointVisitor.java | 43 - src/main/java/ui/ftd/FTDFault.java | 69 +- src/main/java/ui/ncdd/NCDiagramPanel.java | 93 +- src/main/java/ui/ncdd/NCEqNode.java | 33 +- src/main/java/ui/ncdd/NCRouteArtifact.java | 27 +- .../java/ui/tmlad/TGConnectingPointTMLAD.java | 18 +- src/main/java/ui/tmlad/TGConnectorTMLAD.java | 18 +- src/main/java/ui/tmlad/TMLADActionState.java | 131 +- src/main/java/ui/tmlad/TMLADChoice.java | 312 ++- src/main/java/ui/tmlad/TMLADDecrypt.java | 17 +- src/main/java/ui/tmlad/TMLADDelay.java | 19 +- .../java/ui/tmlad/TMLADDelayInterval.java | 17 +- src/main/java/ui/tmlad/TMLADEncrypt.java | 19 +- src/main/java/ui/tmlad/TMLADExecC.java | 15 +- .../java/ui/tmlad/TMLADExecCInterval.java | 13 +- src/main/java/ui/tmlad/TMLADExecI.java | 14 +- .../java/ui/tmlad/TMLADExecIInterval.java | 14 +- src/main/java/ui/tmlad/TMLADForEverLoop.java | 99 +- src/main/java/ui/tmlad/TMLADForLoop.java | 137 +- .../java/ui/tmlad/TMLADForStaticLoop.java | 62 +- .../java/ui/tmlad/TMLADNotifiedEvent.java | 26 +- src/main/java/ui/tmlad/TMLADRandom.java | 28 +- src/main/java/ui/tmlad/TMLADReadChannel.java | 69 +- .../java/ui/tmlad/TMLADReadRequestArg.java | 19 +- src/main/java/ui/tmlad/TMLADSelectEvt.java | 24 +- src/main/java/ui/tmlad/TMLADSendEvent.java | 55 +- src/main/java/ui/tmlad/TMLADSendRequest.java | 41 +- src/main/java/ui/tmlad/TMLADSequence.java | 102 +- src/main/java/ui/tmlad/TMLADStartState.java | 89 +- src/main/java/ui/tmlad/TMLADStopState.java | 99 +- .../java/ui/tmlad/TMLADUnorderedSequence.java | 110 +- src/main/java/ui/tmlad/TMLADWaitEvent.java | 49 +- src/main/java/ui/tmlad/TMLADWriteChannel.java | 75 +- .../ui/tmlcompd/TMLCCompositeComponent.java | 85 +- .../TMLCRemoteCompositeComponent.java | 48 +- .../TMLComponentTaskDiagramPanel.java | 65 +- .../java/ui/tmlcp/TGConnectingPointTMLCP.java | 7 +- src/main/java/ui/tmlcp/TGConnectorTMLCP.java | 14 +- src/main/java/ui/tmlcp/TMLCPChoice.java | 295 ++- src/main/java/ui/tmlcp/TMLCPForLoop.java | 106 +- src/main/java/ui/tmlcp/TMLCPFork.java | 42 +- src/main/java/ui/tmlcp/TMLCPJoin.java | 26 +- src/main/java/ui/tmlcp/TMLCPPanel.java | 21 +- src/main/java/ui/tmlcp/TMLCPRefAD.java | 19 +- src/main/java/ui/tmlcp/TMLCPRefSD.java | 121 +- src/main/java/ui/tmlcp/TMLCPStartState.java | 81 +- src/main/java/ui/tmlcp/TMLCPStopState.java | 87 +- src/main/java/ui/tmlcp/TMLCPToolBar.java | 19 +- .../java/ui/tmldd/TMLArchiDiagramToolBar.java | 2 - src/main/java/ui/window/JBirdPanel.java | 28 +- .../java/ui/window/JDialogAvatarSignal.java | 14 +- .../ui/window/JDialogAvatarTransition.java | 718 ++----- .../java/ui/window/JDialogMultiString.java | 35 +- .../ui/window/JDialogMultiStringAndTabs.java | 41 +- src/main/java/ui/window/JDialogNCRoute.java | 42 +- .../ui/window/JDialogPerformancePragma.java | 7 +- src/main/java/ui/window/JDialogPragma.java | 8 +- .../java/ui/window/JDialogSafetyPragma.java | 3 +- .../ui/window/JDialogSelectAvatarBlock.java | 7 +- src/main/java/ui/window/TabInfo.java | 10 +- .../avatartranslator/AvatarPragmaTests.java | 44 +- 172 files changed, 4727 insertions(+), 8852 deletions(-) delete mode 100644 src/main/java/ui/AbstractCDElement.java delete mode 100644 src/main/java/ui/ActivityDiagram2TMLTranslator.java create mode 100755 src/main/java/ui/CanBeDisabled.java delete mode 100644 src/main/java/ui/Expression.java delete mode 100644 src/main/java/ui/FindNextEnabledConnectingPointVisitor.java delete mode 100644 src/main/java/ui/ForwardComponentsEnabledVisitor.java delete mode 100644 src/main/java/ui/ICDElementVisitor.java delete mode 100644 src/main/java/ui/RangeExpression.java delete mode 100644 src/main/java/ui/TrackingCDElementVisitor.java delete mode 100644 src/main/java/ui/ad/CanBeDisabledADElementVisitor.java delete mode 100644 src/main/java/ui/ad/EnablingADBranchVisitor.java delete mode 100644 src/main/java/ui/ad/EnablingADConnectorVisitor.java delete mode 100644 src/main/java/ui/ad/TADComponentWithSubcomponents.java delete mode 100644 src/main/java/ui/ad/TADComponentWithoutSubcomponents.java delete mode 100644 src/main/java/ui/ad/TADConnector.java delete mode 100644 src/main/java/ui/ad/TADForLoop.java delete mode 100644 src/main/java/ui/ad/TADOneLineText.java delete mode 100644 src/main/java/ui/avatarad/AvatarADBasicCanBeDisabledComponent.java delete mode 100644 src/main/java/ui/avatarmad/AvatarMADConnector.java delete mode 100644 src/main/java/ui/avatarsmd/AvatarSMDBasicCanBeDisabledComponent.java delete mode 100644 src/main/java/ui/avatarsmd/EnablingAvatarSMDConnectorVisitor.java delete mode 100644 src/main/java/ui/avatarsmd/FindAvatarSMDComponentsToBeTranslatedVisitor.java delete mode 100644 src/main/java/ui/avatarsmd/FindNextEnabledAvatarSMDConnectingPointVisitor.java diff --git a/src/main/java/avatartranslator/AvatarState.java b/src/main/java/avatartranslator/AvatarState.java index 13702fb6ca..3dc8238c19 100644 --- a/src/main/java/avatartranslator/AvatarState.java +++ b/src/main/java/avatartranslator/AvatarState.java @@ -89,6 +89,7 @@ public class AvatarState extends AvatarStateElement { checkLatency = b; } + public int hasEmptyTransitionsOnItself(AvatarStateMachine _asm) { AvatarTransition at; int cpt = 0; diff --git a/src/main/java/ui/AbstractCDElement.java b/src/main/java/ui/AbstractCDElement.java deleted file mode 100644 index afd37aeedc..0000000000 --- a/src/main/java/ui/AbstractCDElement.java +++ /dev/null @@ -1,79 +0,0 @@ -package ui; - -public abstract class AbstractCDElement implements CDElement { - - private boolean enabled; - - protected AbstractCDElement() { - enabled = true; - } - - /** - * Issue #69 - * @param _enabled - */ - @Override - public void setEnabled( final boolean _enabled ) { - doSetEnabled( _enabled ); - } - - /** - * Issue #69 - * @param _enabled - */ - @Override - public void doSetEnabled( final boolean _enabled ) { - enabled = _enabled; - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public boolean isEnabled( boolean checkBranch ) { - return isEnabled(); - } - - /** - * Issue #69 - * @return - */ - @Override - public boolean canBeDisabled() { - return false; - } - - /** - * Issue #69 - * @return - */ - @Override - public boolean canLabelBeDisabled( TGCOneLineText label ) { - return false; - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#acceptForward(ui.ICDElementVisitor) - */ - @Override - public void acceptForward( final ICDElementVisitor visitor ) { - visitor.visit( this ); - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#acceptBackward(ui.ICDElementVisitor) - */ - @Override - public void acceptBackward( final ICDElementVisitor visitor ) { - visitor.visit( this ); - } -// -// @Override -// public boolean isFullDisabler() { -// return false; -// } -} diff --git a/src/main/java/ui/ActivityDiagram2TMLTranslator.java b/src/main/java/ui/ActivityDiagram2TMLTranslator.java deleted file mode 100644 index 73dacbb477..0000000000 --- a/src/main/java/ui/ActivityDiagram2TMLTranslator.java +++ /dev/null @@ -1,965 +0,0 @@ -package ui; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - -import myutil.Conversion; -import myutil.TraceManager; -import tmltranslator.SecurityPattern; -import tmltranslator.TMLActionState; -import tmltranslator.TMLActivity; -import tmltranslator.TMLActivityElement; -import tmltranslator.TMLAttribute; -import tmltranslator.TMLChannel; -import tmltranslator.TMLCheckingError; -import tmltranslator.TMLChoice; -import tmltranslator.TMLDelay; -import tmltranslator.TMLEvent; -import tmltranslator.TMLExecC; -import tmltranslator.TMLExecCInterval; -import tmltranslator.TMLExecI; -import tmltranslator.TMLExecIInterval; -import tmltranslator.TMLForLoop; -import tmltranslator.TMLJunction; -import tmltranslator.TMLModeling; -import tmltranslator.TMLNotifiedEvent; -import tmltranslator.TMLRandom; -import tmltranslator.TMLRandomSequence; -import tmltranslator.TMLReadChannel; -import tmltranslator.TMLRequest; -import tmltranslator.TMLSelectEvt; -import tmltranslator.TMLSendEvent; -import tmltranslator.TMLSendRequest; -import tmltranslator.TMLSequence; -import tmltranslator.TMLStartState; -import tmltranslator.TMLStopState; -import tmltranslator.TMLTask; -import tmltranslator.TMLType; -import tmltranslator.TMLWaitEvent; -import tmltranslator.TMLWriteChannel; -import translator.CheckingError; -import ui.tmlad.TMLADActionState; -import ui.tmlad.TMLADChoice; -import ui.tmlad.TMLADDecrypt; -import ui.tmlad.TMLADDelay; -import ui.tmlad.TMLADDelayInterval; -import ui.tmlad.TMLADEncrypt; -import ui.tmlad.TMLADExecC; -import ui.tmlad.TMLADExecCInterval; -import ui.tmlad.TMLADExecI; -import ui.tmlad.TMLADExecIInterval; -import ui.tmlad.TMLADForEverLoop; -import ui.tmlad.TMLADForLoop; -import ui.tmlad.TMLADForStaticLoop; -import ui.tmlad.TMLADNotifiedEvent; -import ui.tmlad.TMLADRandom; -import ui.tmlad.TMLADReadChannel; -import ui.tmlad.TMLADReadRequestArg; -import ui.tmlad.TMLADSelectEvt; -import ui.tmlad.TMLADSendEvent; -import ui.tmlad.TMLADSendRequest; -import ui.tmlad.TMLADSequence; -import ui.tmlad.TMLADStartState; -import ui.tmlad.TMLADStopState; -import ui.tmlad.TMLADUnorderedSequence; -import ui.tmlad.TMLADWaitEvent; -import ui.tmlad.TMLADWriteChannel; -import ui.tmlad.TMLActivityDiagramPanel; - -public class ActivityDiagram2TMLTranslator { - - public static final ActivityDiagram2TMLTranslator INSTANCE = new ActivityDiagram2TMLTranslator(); - - private ActivityDiagram2TMLTranslator() { - } - - public void generateTaskActivityDiagrams( final TMLTask tmltask, - final List<CheckingError> checkingErrors, - final List<CheckingError> warnings, - final CorrespondanceTGElement corrTgElement, - final TMLModeling<TGComponent> tmlm, - final Map<String, SecurityPattern> securityPatterns, - final Map<String, String> table, - final List<String> removedChannels, - final List<String> removedEvents, - final List<String> removedRequests ) - throws MalformedTMLDesignException { - TMLActivity activity = tmltask.getActivityDiagram(); - TMLActivityDiagramPanel tadp = (TMLActivityDiagramPanel)(activity.getReferenceObject()); - - TraceManager.addDev( "Generating activity diagram of: " + tmltask.getName()); - - // search for start state - List<TGComponent> list = tadp.getComponentList(); - Iterator<TGComponent> iterator = list.listIterator(); - TGComponent tgc; - TMLADStartState tss = null; - int cptStart = 0; - // boolean rndAdded = false; - - while(iterator.hasNext()) { - tgc = iterator.next(); - - if (tgc instanceof TMLADStartState) { - tss = (TMLADStartState) tgc; - cptStart ++; - } - } - - if (tss == null) { - TMLCheckingError ce = new TMLCheckingError(CheckingError.BEHAVIOR_ERROR, "No start state in the TML activity diagram of " + tmltask.getName()); - ce.setTMLTask(tmltask); - checkingErrors.add(ce); - return; - } - - if (cptStart > 1) { - TMLCheckingError ce = new TMLCheckingError(CheckingError.BEHAVIOR_ERROR, "More than one start state in the TML activity diagram of " + tmltask.getName()); - ce.setTMLTask(tmltask); - checkingErrors.add(ce); - return; - } - - // Adding start state - TMLStartState tmlss = new TMLStartState("start", tss); - corrTgElement.addCor(tmlss, tss); - activity.setFirst(tmlss); - - // Creation of other elements - TMLChannel channel; - String [] channels; - TMLEvent event; - TMLRequest request; - - TMLADRandom tmladrandom; - TMLRandom tmlrandom; - TMLActionState tmlaction; - TMLChoice tmlchoice; - TMLExecI tmlexeci; - TMLExecIInterval tmlexecii; - TMLExecC tmlexecc; - TMLExecCInterval tmlexecci; - TMLForLoop tmlforloop; - TMLReadChannel tmlreadchannel; - TMLSendEvent tmlsendevent; - TMLSendRequest tmlsendrequest; - TMLStopState tmlstopstate; - TMLWaitEvent tmlwaitevent; - TMLNotifiedEvent tmlnotifiedevent; - TMLWriteChannel tmlwritechannel; - TMLSequence tmlsequence; - TMLRandomSequence tmlrsequence; - TMLSelectEvt tmlselectevt; - TMLDelay tmldelay; - int staticLoopIndex = 0; - String sl = "", tmp; - TMLType tt; - TMLAttribute tmlt; - - iterator = list.listIterator(); - while(iterator.hasNext()) { - tgc = iterator.next(); - // Issue #69: Manage component enablement - if ( tgc.isEnabled() ) { - if (tgc.getCheckLatency()){ - String name = tmltask.getName() + ":" + tgc.getName(); - name = name.replaceAll(" ",""); - //TraceManager.addDev("To check " + name); - if (tgc.getValue().contains("(")) { - tmlm.addCheckedActivity(tgc, name + ":" + tgc.getValue().split("\\(")[0]); - } else { - if (tgc instanceof TMLADExecI) { - tmlm.addCheckedActivity(tgc, ((TMLADExecI) tgc).getDelayValue()); - } - } - } - if (tgc instanceof TMLADActionState) { - tmlaction = new TMLActionState("action", tgc); - tmp = ((TMLADActionState)(tgc)).getAction(); - tmp = modifyActionString(tmp); - tmlaction.setAction(tmp); - activity.addElement(tmlaction); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlaction, tgc); - - } else if (tgc instanceof TMLADRandom) { - tmladrandom = (TMLADRandom)tgc; - tmlrandom = new TMLRandom("random" + tmladrandom.getValue(), tgc); - tmp = tmladrandom.getVariable(); - tmp = modifyActionString(tmp); - tmlrandom.setVariable(tmp); - tmp = tmladrandom.getMinValue(); - tmp = modifyActionString(tmp); - tmlrandom.setMinValue(tmp); - tmp = tmladrandom.getMaxValue(); - tmp = modifyActionString(tmp); - tmlrandom.setMaxValue(tmp); - tmlrandom.setFunctionId(tmladrandom.getFunctionId()); - activity.addElement(tmlrandom); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlrandom, tgc); - - } else if (tgc instanceof TMLADChoice) { - tmlchoice = new TMLChoice("choice", tgc); - // Guards are added at the same time as next activities - activity.addElement(tmlchoice); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlchoice, tgc); - - } else if (tgc instanceof TMLADSelectEvt) { - tmlselectevt = new TMLSelectEvt("select", tgc); - activity.addElement(tmlselectevt); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlselectevt, tgc); - - } else if (tgc instanceof TMLADExecI) { - tmlexeci = new TMLExecI("execi", tgc); - tmlexeci.setAction(modifyString(((TMLADExecI)tgc).getDelayValue())); - tmlexeci.setValue(((TMLADExecI)tgc).getDelayValue()); - activity.addElement(tmlexeci); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlexeci, tgc); - - } else if (tgc instanceof TMLADExecIInterval) { - tmlexecii = new TMLExecIInterval("execi", tgc); - tmlexecii.setValue(tgc.getValue()); - tmlexecii.setMinDelay(modifyString(((TMLADExecIInterval)tgc).getMinDelayValue())); - tmlexecii.setMaxDelay(modifyString(((TMLADExecIInterval)tgc).getMaxDelayValue())); - activity.addElement(tmlexecii); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlexecii, tgc); - - } else if (tgc instanceof TMLADEncrypt) { - tmlexecc = new TMLExecC("encrypt_"+((TMLADEncrypt)tgc).securityContext, tgc); - activity.addElement(tmlexecc); - SecurityPattern sp = securityPatterns.get(((TMLADEncrypt)tgc).securityContext); - if (sp ==null){ - //Throw error for missing security pattern - UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADEncrypt)tgc).securityContext + " not found"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } - else { - tmlexecc.securityPattern = sp; - tmlexecc.setAction(Integer.toString(sp.encTime)); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - tmlm.securityTaskMap.get(sp).add(tmltask); - corrTgElement.addCor(tmlexecc, tgc); - } - } else if (tgc instanceof TMLADDecrypt) { - tmlexecc = new TMLExecC("decrypt_"+((TMLADDecrypt)tgc).securityContext, tgc); - activity.addElement(tmlexecc); - SecurityPattern sp = securityPatterns.get(((TMLADDecrypt)tgc).securityContext); - if (sp ==null){ - //Throw error for missing security pattern - UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADDecrypt)tgc).securityContext + " not found"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } - else { - tmlexecc.securityPattern = sp; - tmlexecc.setAction(Integer.toString(sp.decTime)); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlexecc, tgc); - tmlm.securityTaskMap.get(sp).add(tmltask); - } - - } else if (tgc instanceof TMLADExecC) { - tmlexecc = new TMLExecC("execc", tgc); - tmlexecc.setValue(((TMLADExecC)tgc).getDelayValue()); - tmlexecc.setAction(modifyString(((TMLADExecC)tgc).getDelayValue())); - activity.addElement(tmlexecc); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlexecc, tgc); - - } else if (tgc instanceof TMLADExecCInterval) { - tmlexecci = new TMLExecCInterval("execci", tgc); - tmlexecci.setMinDelay(modifyString(((TMLADExecCInterval)tgc).getMinDelayValue())); - tmlexecci.setMaxDelay(modifyString(((TMLADExecCInterval)tgc).getMaxDelayValue())); - activity.addElement(tmlexecci); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlexecci, tgc); - - } else if (tgc instanceof TMLADDelay) { - tmldelay = new TMLDelay("d-delay", tgc); - tmldelay.setMinDelay(modifyString(((TMLADDelay)tgc).getDelayValue())); - tmldelay.setMaxDelay(modifyString(((TMLADDelay)tgc).getDelayValue())); - tmldelay.setUnit(((TMLADDelay)tgc).getUnit()); - activity.addElement(tmldelay); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmldelay, tgc); - - } else if (tgc instanceof TMLADDelayInterval) { - tmldelay = new TMLDelay("nd-delay", tgc); - tmldelay.setMinDelay(modifyString(((TMLADDelayInterval)tgc).getMinDelayValue())); - tmldelay.setMaxDelay(modifyString(((TMLADDelayInterval)tgc).getMaxDelayValue())); - tmldelay.setUnit(((TMLADDelayInterval)tgc).getUnit()); - activity.addElement(tmldelay); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmldelay, tgc); - - } else if (tgc instanceof TMLADForLoop) { - tmlforloop = new TMLForLoop("loop", tgc); - tmlforloop.setInit(modifyString(((TMLADForLoop)tgc).getInit())); - tmp = ((TMLADForLoop)tgc).getCondition(); - /*if (tmp.trim().length() == 0) { - tmp = "true"; - }*/ - tmlforloop.setCondition(modifyString(tmp)); - tmlforloop.setIncrement(modifyActionString(((TMLADForLoop)tgc).getIncrement())); - - activity.addElement(tmlforloop); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlforloop, tgc); - - } else if (tgc instanceof TMLADForStaticLoop) { - sl = "loop__" + staticLoopIndex; - tt = new TMLType(TMLType.NATURAL); - tmlt = new TMLAttribute(sl, tt); - tmlt.initialValue = "0"; - tmltask.addAttribute(tmlt); - tmlforloop = new TMLForLoop(sl, tgc); - tmlforloop.setInit(sl + " = 0"); - tmlforloop.setCondition(sl + "<" + modifyString(tgc.getValue())); - tmlforloop.setIncrement(sl + " = " + sl + " + 1"); - activity.addElement(tmlforloop); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlforloop, tgc); - staticLoopIndex++; - - } else if (tgc instanceof TMLADForEverLoop) { - /*sl = "loop__" + staticLoopIndex; - tt = new TMLType(TMLType.NATURAL); - tmlt = new TMLAttribute(sl, tt); - tmlt.initialValue = "0"; - tmltask.addAttribute(tmlt);*/ - tmlforloop = new TMLForLoop("infiniteloop", tgc); - tmlforloop.setInit(""); - tmlforloop.setCondition(""); - tmlforloop.setIncrement(""); - tmlforloop.setInfinite(true); - activity.addElement(tmlforloop); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlforloop, tgc); - staticLoopIndex++; - - tmlstopstate = new TMLStopState("Stop after infinite loop", null); - activity.addElement(tmlstopstate); - tmlforloop.addNext(tmlstopstate); - - } else if (tgc instanceof TMLADSequence) { - tmlsequence = new TMLSequence("seq", tgc); - activity.addElement(tmlsequence); - corrTgElement.addCor(tmlsequence, tgc); - - } else if (tgc instanceof TMLADUnorderedSequence) { - tmlrsequence = new TMLRandomSequence("rseq", tgc); - activity.addElement(tmlrsequence); - corrTgElement.addCor(tmlrsequence, tgc); - - } else if (tgc instanceof TMLADReadChannel) { - // Get the channel - //TMLADReadChannel rd = (TMLADReadChannel) tgc; - channel = tmlm.getChannelByName( getFromTable( tmltask, ((TMLADReadChannel)tgc).getChannelName(), table ) ); - /*if (rd.isAttacker()){ - channel = tmlm.getChannelByName(getAttackerChannel(((TMLADReadChannel)tgc).getChannelName())); - }*/ - if (channel == null) { - if (Conversion.containsStringInList(removedChannels, ((TMLADReadChannel)tgc).getChannelName())) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADReadChannel)tgc).getChannelName() + " has been removed because the corresponding channel is not taken into account"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - warnings.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - activity.addElement(new TMLJunction("void junction", tgc)); - } else { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADReadChannel)tgc).getChannelName() + " is an unknown channel"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - checkingErrors.add(ce); - } - - } else { - tmlreadchannel = new TMLReadChannel("read channel", tgc); - tmlreadchannel.setNbOfSamples(modifyString(((TMLADReadChannel)tgc).getSamplesValue())); - tmlreadchannel.setEncForm(((TMLADReadChannel) tgc).getEncForm()); - tmlreadchannel.addChannel(channel); - //security pattern - if (securityPatterns.get(((TMLADReadChannel)tgc).getSecurityContext())!=null){ - tmlreadchannel.securityPattern= securityPatterns.get(((TMLADReadChannel)tgc).getSecurityContext()); - //NbOfSamples will increase due to extra overhead from MAC - int cur=1; - try { - cur = Integer.valueOf(modifyString(((TMLADReadChannel)tgc).getSamplesValue())); - } catch(NumberFormatException e) { - } catch(NullPointerException e) { - } - int add = Integer.valueOf(tmlreadchannel.securityPattern.overhead); - if (!tmlreadchannel.securityPattern.nonce.equals("")){ - SecurityPattern nonce = securityPatterns.get(tmlreadchannel.securityPattern.nonce); - if (nonce!=null){ - add = Integer.valueOf(nonce.overhead); - } - } - cur = cur+ add; - tmlreadchannel.setNbOfSamples(Integer.toString(cur)); - } - else if (!((TMLADReadChannel)tgc).getSecurityContext().isEmpty()){ - //Throw error for missing security pattern - UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADReadChannel)tgc).getSecurityContext() + " not found"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } - if (tmltask.isAttacker()){ - tmlreadchannel.setAttacker(true); - } - activity.addElement(tmlreadchannel); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlreadchannel, tgc); - } - } else if (tgc instanceof TMLADSendEvent) { - event = tmlm.getEventByName(getFromTable(tmltask, ((TMLADSendEvent)tgc).getEventName(), table )); - if (event == null) { - if (Conversion.containsStringInList(removedEvents, ((TMLADSendEvent)tgc).getEventName())) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADSendEvent)tgc).getEventName() + " has been removed because the corresponding event is not taken into account"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - warnings.add(ce); - activity.addElement(new TMLJunction("void junction", tgc)); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } else { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendEvent)tgc).getEventName() + " is an unknown event"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } - } else { - tmlsendevent = new TMLSendEvent("send event", tgc); - tmlsendevent.setEvent(event); - - for(int i=0; i<((TMLADSendEvent)tgc).realNbOfParams(); i++) { - tmp = modifyString(((TMLADSendEvent)tgc).getRealParamValue(i)); - Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); - if (allVariables.size() > 0) { - for(int k=0; k<allVariables.size(); k++) { - //TraceManager.addDev("Adding record: " + allVariables.get(k)); - tmlsendevent.addParam(allVariables.get(k)); - } - } else { - //TraceManager.addDev("Adding param: " + tmp); - tmlsendevent.addParam(tmp); - } - } - if (event.getNbOfParams() != tmlsendevent.getNbOfParams()) { - TraceManager.addDev("ERROR : event#:" + event.getNbOfParams() + " sendevent#:" + tmlsendevent.getNbOfParams()); - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendEvent)tgc).getEventName() + ": wrong number of parameters"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } else { - activity.addElement(tmlsendevent); - corrTgElement.addCor(tmlsendevent, tgc); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - } - } - - } else if (tgc instanceof TMLADSendRequest) { - request = tmlm.getRequestByName(getFromTable(tmltask, ((TMLADSendRequest)tgc).getRequestName(), table ) ); - if (request == null) { - if (Conversion.containsStringInList(removedRequests, ((TMLADSendRequest)tgc).getRequestName())) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADSendRequest)tgc).getRequestName() + " has been removed because the corresponding request is not taken into account"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - warnings.add(ce); - activity.addElement(new TMLJunction("void junction", tgc)); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } else { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendRequest)tgc).getRequestName() + " is an unknown request"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } - } else { - tmlsendrequest = new TMLSendRequest("send request", tgc); - tmlsendrequest.setRequest(request); - for(int i=0; i<((TMLADSendRequest)tgc).realNbOfParams(); i++) { - tmp = modifyString(((TMLADSendRequest)tgc).getRealParamValue(i)); - Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); - if (allVariables.size() > 0) { - for(int k=0; k<allVariables.size(); k++) { - //TraceManager.addDev("Adding record: " + allVariables.get(k)); - tmlsendrequest.addParam(allVariables.get(k)); - request.addParamName(allVariables.get(k)); - } - } else { - //TraceManager.addDev("Adding param: " + tmp); - tmlsendrequest.addParam(tmp); - request.addParamName(tmp); - } - } - if (request.getNbOfParams() != tmlsendrequest.getNbOfParams()) { - TraceManager.addDev("ERROR : request#:" + request.getNbOfParams() + " sendrequest#:" + tmlsendrequest.getNbOfParams()); - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendRequest)tgc).getRequestName() + ": wrong number of parameters"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } else { - activity.addElement(tmlsendrequest); - corrTgElement.addCor(tmlsendrequest, tgc); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - } - } - - } else if (tgc instanceof TMLADReadRequestArg) { - request = tmlm.getRequestToMe(tmltask); - if (request == null) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "This task is not requested: cannot use \"reading request arg\" operator"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } else { - tmlaction = new TMLActionState("action reading args", tgc); - String act = ""; - int cpt = 1; - for(int i=0; i<((TMLADReadRequestArg)tgc).realNbOfParams(); i++) { - tmp = modifyString(((TMLADReadRequestArg)tgc).getRealParamValue(i)); - Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); - - if (allVariables.size() > 0) { - for(int k=0; k<allVariables.size(); k++) { - //TraceManager.addDev("Adding record: " + allVariables.get(k)); - if (cpt != 1) { - act += "$"; - } - act += allVariables.get(k) + " = arg" + cpt + "__req"; - cpt ++; - } - } else { - //TraceManager.addDev("Adding param: " + tmp); - if (cpt != 1) { - act += "$"; - } - act += tmp + " = arg" + cpt + "__req"; - cpt ++; - } - } - if (request.getNbOfParams() != (cpt-1)) { - //TraceManager.addDev("ERROR : request#:" + request.getNbOfParams() + " read request arg#:" + (cpt-1)); - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Wrong number of parameters in \"reading request arg\" operator"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } else { - //TraceManager.addDev("Adding action = " + act); - tmlaction.setAction(act); - activity.addElement(tmlaction); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlaction, tgc); - } - } - - } else if (tgc instanceof TMLADStopState) { - tmlstopstate = new TMLStopState("stop state", tgc); - activity.addElement(tmlstopstate); - corrTgElement.addCor(tmlstopstate, tgc); - - } else if (tgc instanceof TMLADNotifiedEvent) { - event = tmlm.getEventByName(getFromTable(tmltask, ((TMLADNotifiedEvent)tgc).getEventName(), table ) ); - if (event == null) { - if( removedEvents.size() > 0 ) { - if (Conversion.containsStringInList(removedEvents, ((TMLADNotifiedEvent)tgc).getEventName())) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADNotifiedEvent)tgc).getEventName() + " has been removed because the corresponding event is not taken into account"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - warnings.add(ce); - activity.addElement(new TMLJunction("void junction", tgc)); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } else { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADNotifiedEvent)tgc).getEventName() + " is an unknown event"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } - } else { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADNotifiedEvent)tgc).getEventName() + " is an unknown event"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } - } else { - event.setNotified(true); - tmlnotifiedevent = new TMLNotifiedEvent("notified event", tgc); - tmlnotifiedevent.setEvent(event); - tmlnotifiedevent.setVariable(modifyString(((TMLADNotifiedEvent)tgc).getVariable())); - activity.addElement(tmlnotifiedevent); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlnotifiedevent, tgc); - } - - } else if (tgc instanceof TMLADWaitEvent) { - event = tmlm.getEventByName(getFromTable(tmltask, ((TMLADWaitEvent)tgc).getEventName(), table ) ); - if (event == null) { - if( removedEvents.size() > 0 ) { - if (Conversion.containsStringInList(removedEvents, ((TMLADWaitEvent)tgc).getEventName())) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADWaitEvent)tgc).getEventName() + " has been removed because the corresponding event is not taken into account"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - warnings.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - activity.addElement(new TMLJunction("void junction", tgc)); - } else { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWaitEvent)tgc).getEventName() + " is an unknown event"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - checkingErrors.add(ce); - } - } else { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWaitEvent)tgc).getEventName() + " is an unknown event"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - checkingErrors.add(ce); - } - } else { - //TraceManager.addDev("Nb of param of event:" + event.getNbOfParams()); - tmlwaitevent = new TMLWaitEvent("wait event", tgc); - tmlwaitevent.setEvent(event); - for(int i=0; i<((TMLADWaitEvent)tgc).realNbOfParams(); i++) { - tmp = modifyString(((TMLADWaitEvent)tgc).getRealParamValue(i)); - Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); - if (allVariables.size() > 0) { - for(int k=0; k<allVariables.size(); k++) { - //TraceManager.addDev("Adding record: " + allVariables.get(k)); - tmlwaitevent.addParam(allVariables.get(k)); - } - } else { - //TraceManager.addDev("Adding param: " + tmp); - tmlwaitevent.addParam(tmp); - } - } - if (event.getNbOfParams() != tmlwaitevent.getNbOfParams()) { - //TraceManager.addDev("ERROR : event#:" + event.getNbOfParams() + " waitevent#:" + tmlwaitevent.getNbOfParams()); - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWaitEvent)tgc).getEventName() + ": wrong number of parameters"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - } else { - activity.addElement(tmlwaitevent); - corrTgElement.addCor(tmlwaitevent, tgc); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - } - - } - - } else if (tgc instanceof TMLADWriteChannel) { - // Get channels - //TMLADWriteChannel wr = (TMLADWriteChannel) tgc; - channels = ((TMLADWriteChannel)tgc).getChannelsByName(); - boolean error = false; - for(int i=0; i<channels.length; i++) { - //TraceManager.addDev("Getting from table " + tmltask.getName() + "/" +channels[i]); - channel = tmlm.getChannelByName(getFromTable(tmltask, channels[i], table ) ); - if (channel == null) { - if (Conversion.containsStringInList(removedChannels, ((TMLADWriteChannel)tgc).getChannelName(i))) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADWriteChannel)tgc).getChannelName(i) + " has been removed because the corresponding channel is not taken into account"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - warnings.add(ce); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - activity.addElement(new TMLJunction("void junction", tgc)); - } else { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWriteChannel)tgc).getChannelName(i) + " is an unknown channel"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.UNKNOWN); - checkingErrors.add(ce); - } - error = true; - - } - } - if (!error) { - tmlwritechannel = new TMLWriteChannel("write channel", tgc); - tmlwritechannel.setNbOfSamples(modifyString(((TMLADWriteChannel)tgc).getSamplesValue())); - tmlwritechannel.setEncForm(((TMLADWriteChannel) tgc).getEncForm()); - - for(int i=0; i<channels.length; i++) { - channel = tmlm.getChannelByName(getFromTable(tmltask, channels[i], table ) ); - tmlwritechannel.addChannel(channel); - } - //if (wr.isAttacker()){ - //channel = tmlm.getChannelByName(getAttackerChannel(channels[0])); - //tmlwritechannel.addChannel(channel); - //} - //add sec pattern - if (securityPatterns.get(((TMLADWriteChannel)tgc).getSecurityContext())!=null){ - tmlwritechannel.securityPattern= securityPatterns.get(((TMLADWriteChannel)tgc).getSecurityContext()); - int cur = Integer.valueOf(modifyString(((TMLADWriteChannel)tgc).getSamplesValue())); - int add = Integer.valueOf(tmlwritechannel.securityPattern.overhead); - if (!tmlwritechannel.securityPattern.nonce.equals("")){ - SecurityPattern nonce = securityPatterns.get(tmlwritechannel.securityPattern.nonce); - if (nonce!=null){ - add = Integer.valueOf(nonce.overhead); - } - } - cur = cur+ add; - tmlwritechannel.setNbOfSamples(Integer.toString(cur)); - } - else if (!((TMLADWriteChannel)tgc).getSecurityContext().isEmpty()){ - //Throw error for missing security pattern - UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADWriteChannel)tgc).getSecurityContext() + " not found"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } - if (tmltask.isAttacker()){ - tmlwritechannel.setAttacker(true); - } - activity.addElement(tmlwritechannel); - ((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK); - corrTgElement.addCor(tmlwritechannel, tgc); - } - } - } - } - - // Interconnection between elements - //TGConnectorTMLAD tgco; - //TGConnectingPoint p1, p2; - //TMLActivityElement ae1, ae2; - //TGComponent /*tgc1, tgc2,*/ tgc3; - //int j, index; - - final List<TGConnector> connectors = tadp.getConnectors(); - final Set<TGConnector> prunedConectors = new HashSet<TGConnector>(); - - for ( final TGConnector connector : connectors ) { - if ( !prunedConectors.contains( connector ) ) { - FindNextEnabledConnectingPointVisitor visitor = new FindNextEnabledConnectingPointVisitor( prunedConectors ); - connector.getTGConnectingPointP1().acceptBackward( visitor ); - final TGConnectingPoint conPoint1 = visitor.getEnabledComponentPoint(); - - if ( conPoint1 != null ) { - visitor = new FindNextEnabledConnectingPointVisitor( prunedConectors ); - connector.getTGConnectingPointP2().acceptForward( visitor ); - final TGConnectingPoint conPoint2 = visitor.getEnabledComponentPoint(); - - if ( conPoint2 != null ) { - final TGComponent compo1 = (TGComponent) conPoint1.getFather(); - final TGComponent compo2 = (TGComponent) conPoint2.getFather(); - - final TMLActivityElement ae1 = activity.findReferenceElement( compo1 ); - final TMLActivityElement ae2 = activity.findReferenceElement( compo2 ); - - //Special case if "for loop" or if "choice" - if (ae1 instanceof TMLForLoop) { - final int index = compo1.indexOf( conPoint1 ) - 1; - - if (index == 0) { - ae1.addNext( 0, ae2 ); - } - else { - ae1.addNext( ae2 ); - } - - } - else if (ae1 instanceof TMLChoice) { - //final int index = compo1.indexOf( conPoint1 ) - 1; - //TraceManager.addDev("Adding next:" + ae2); - ae1.addNext(ae2); - - final TMLADChoice choice = (TMLADChoice) compo1; - final TGCOneLineText guard = choice.getGuardForConnectingPoint( conPoint1 ); - ( (TMLChoice) ae1 ).addGuard( modifyString( choice.getEffectiveCondition( guard ) ) ); - } - else if (ae1 instanceof TMLSequence) { - final int index = compo1.indexOf( conPoint1 ) - 1; - ((TMLSequence)ae1).addIndex(index); - ae1.addNext(ae2); - //TraceManager.addDev("Adding " + ae2 + " at index " + index); - - } - else if (ae1 instanceof TMLRandomSequence) { - final int index = compo1.indexOf( conPoint1 ) - 1; - ((TMLRandomSequence)ae1).addIndex(index); - ae1.addNext(ae2); - } - else { - ae1.addNext(ae2); - } - } - } - } - } - - // Check that each "for" has two nexts - // Check that TMLChoice have compatible guards - // Check TML select evts - iterator = list.listIterator(); - while(iterator.hasNext()) { - tgc = iterator.next(); - - // Issue #69: Disabling of AD components - if ( tgc.isEnabled() ) { - if ((tgc instanceof TMLADForLoop) || (tgc instanceof TMLADForStaticLoop)) { - final TMLActivityElement ae1 = activity.findReferenceElement(tgc); - - if (ae1 != null) { - if (ae1.getNbNext() != 2) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formatted for loop: a loop must have an internal behavior, and an exit behavior "); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } - } - } - else if (tgc instanceof TMLADChoice) { - tmlchoice = (TMLChoice)(activity.findReferenceElement(tgc)); - tmlchoice.orderGuards(); - - int nbNonDeter = tmlchoice.nbOfNonDeterministicGuard(); - int nbStocha = tmlchoice.nbOfStochasticGuard(); - if ((nbNonDeter > 0) && (nbStocha > 0)) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formatted choice: it has both non-determinitic and stochastic guards"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } - int nb = Math.max(nbNonDeter, nbStocha); - if (nb > 0) { - nb = nb + tmlchoice.nbOfElseAndAfterGuards(); - if (nb != tmlchoice.getNbGuard()) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, UICheckingError.MESSAGE_CHOICE_BOTH_STOCHASTIC_DETERMINISTIC );//"Badly formatted choice: it has both non-determinitic/ stochastic and regular guards"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } - } - - //if (tmlchoice.nbOfNonDeterministicGuard() > 0) { - /*if (!rndAdded) { - TMLAttribute tmlt = new TMLAttribute("rnd__0", new TMLType(TMLType.NATURAL)); - tmlt.initialValue = ""; - tmltask.addAttribute(tmlt); - rndAdded = true; - }*/ - //} - if (tmlchoice.hasMoreThanOneElse()) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Choice should have only one [else] guard"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } else if ( tmlchoice.getElseGuard() > -1 ) { - final int index = tmlchoice.getElseGuard(); - - if (index == 0) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Choice should have a regular guard"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } - } - if (tmlchoice.hasMoreThanOneAfter()) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Choice should have only one [after] guard"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } - } - else if (tgc instanceof TMLADSelectEvt) { - tmlselectevt = (TMLSelectEvt)(activity.findReferenceElement(tgc)); - if (!tmlselectevt.isARealSelectEvt()) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "'Select events' should be followed by only event receiving operators"); - ce.setTDiagramPanel(tadp); - ce.setTGComponent(tgc); - checkingErrors.add(ce); - } - } - } - } - - // Sorting nexts elements of Sequence - for( int j=0; j<activity.nElements(); j++) { - final TMLActivityElement ae1 = activity.get(j); - - if (ae1 instanceof TMLSequence) { - ((TMLSequence)ae1).sortNexts(); - } - else if (ae1 instanceof TMLRandomSequence) { - ((TMLRandomSequence)ae1).sortNexts(); - } - } - - TraceManager.addDev( tmltask.getActivityDiagram().toXML() ); - } - - private String modifyActionString(String _input) { - int index = _input.indexOf("++"); - boolean b1, b2; - String tmp; - - if(index > -1) { - tmp = _input.substring(0, index).trim(); - - b1 = (tmp.substring(0,1)).matches("[a-zA-Z]"); - b2 = tmp.matches("\\w*"); - if (b1 && b2) { - return tmp + " = " + tmp + " + 1"; - } - } - - index = _input.indexOf("--"); - if(index > -1) { - tmp = _input.substring(0, index).trim(); - - b1 = (tmp.substring(0,1)).matches("[a-zA-Z]"); - b2 = tmp.matches("\\w*"); - if (b1 && b2) { - return tmp + " = " + tmp + " - 1"; - } - } - - return modifyString(_input); - } - - private String modifyString(String _input) { - return Conversion.replaceAllChar(_input, '.', "__"); - } - - private String getFromTable( final TMLTask task, - final String s, - final Map<String, String> table ) { - //TraceManager.addDev("TABLE GET: Getting from task=" + task.getName() + " element=" + s); - - if (table == null) { - return s; - } - - String ret = table.get(task.getName() + "/" + s); - //TraceManager.addDev("Returning=" + ret); - - if (ret == null) { - return s; - } - - return ret; - } -} diff --git a/src/main/java/ui/AvatarDesignPanelTranslator.java b/src/main/java/ui/AvatarDesignPanelTranslator.java index 19f86b72de..e440a89501 100644 --- a/src/main/java/ui/AvatarDesignPanelTranslator.java +++ b/src/main/java/ui/AvatarDesignPanelTranslator.java @@ -1267,61 +1267,51 @@ public class AvatarDesignPanelTranslator { ((ui.AvatarSignal) atas.getReferenceObject()).attachedToARelation = true; } } - final AvatarStateMachineElement element; - final String name = "action_on_signal"; - - if ( asmdss.isEnabled() ) { - element = new AvatarActionOnSignal( name, atas, asmdss ); - - final AvatarActionOnSignal aaos = (AvatarActionOnSignal) element; - if (asmdss.hasCheckedAccessibility()) - aaos.setCheckable(); - - if (asmdss.hasCheckedAccessibility()) - aaos.setChecked(); - - if (aaos.isReceiving ()) - throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "A receiving signal is used for sending: " + asmdss.getValue()); - - if (asmdss.getNbOfValues() == -1) - throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed signal: " + asmdss.getValue()); - - for(int i=0; i<asmdss.getNbOfValues(); i++) { - String tmp = asmdss.getValue(i); - if (tmp.isEmpty ()) - throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Empty parameter in signal expression: " + asmdss.getValue()); - - this.manageAttribute (tmp, _ab, aaos, tdp, asmdss, asmdss.getValue()); - } - - if (aaos.getNbOfValues () != atas.getListOfAttributes ().size ()) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Badly formed signal sending: " + asmdss.getValue() + " -> nb of parameters does not match definition"); - - // Checking expressions passed as parameter - for (int i=0; i<aaos.getNbOfValues(); i++) { - String theVal = aaos.getValue(i); - if (atas.getListOfAttributes ().get (i).isInt ()) { - if (AvatarSyntaxChecker.isAValidIntExpr (_as, _ab, theVal) < 0) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdss.getValue() + " -> value at index #" + i + " does not match definition"); - } else { - // We assume it is a bool attribute - if (AvatarSyntaxChecker.isAValidBoolExpr(_as, _ab, theVal) < 0) - throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdss.getValue() + " -> value at index #" + i + " does not match definition"); - } - } - - if (asmdss.getCheckLatency()){ - aaos.setCheckLatency( true ); - _as.checkedIDs.add(asmdss.getName()+"-"+ asmdss.getSignalName()+":"+aaos.getID()); - } - } - else { - element = new AvatarDummyState( name + ":" + atas.getName(), asmdss ); - } - listE.addCor(element, asmdss); - asmdss.setAVATARID (element.getID()); - asm.addElement(element); + AvatarActionOnSignal aaos = new AvatarActionOnSignal ("action_on_signal", atas, asmdss); + if (asmdss.hasCheckedAccessibility()) + aaos.setCheckable(); + + if (asmdss.hasCheckedAccessibility()) + aaos.setChecked(); + + if (aaos.isReceiving ()) + throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "A receiving signal is used for sending: " + asmdss.getValue()); + + if (asmdss.getNbOfValues() == -1) + throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed signal: " + asmdss.getValue()); + + for(int i=0; i<asmdss.getNbOfValues(); i++) { + String tmp = asmdss.getValue(i); + if (tmp.isEmpty ()) + throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Empty parameter in signal expression: " + asmdss.getValue()); + + this.manageAttribute (tmp, _ab, aaos, tdp, asmdss, asmdss.getValue()); + } + + if (aaos.getNbOfValues () != atas.getListOfAttributes ().size ()) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Badly formed signal sending: " + asmdss.getValue() + " -> nb of parameters does not match definition"); + + // Checking expressions passed as parameter + for (int i=0; i<aaos.getNbOfValues(); i++) { + String theVal = aaos.getValue(i); + if (atas.getListOfAttributes ().get (i).isInt ()) { + if (AvatarSyntaxChecker.isAValidIntExpr (_as, _ab, theVal) < 0) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdss.getValue() + " -> value at index #" + i + " does not match definition"); + } else { + // We assume it is a bool attribute + if (AvatarSyntaxChecker.isAValidBoolExpr(_as, _ab, theVal) < 0) + throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdss.getValue() + " -> value at index #" + i + " does not match definition"); + } + } + + this.listE.addCor (aaos, asmdss); + asmdss.setAVATARID (aaos.getID()); + if (asmdss.getCheckLatency()){ + aaos.setCheckLatency(true); + _as.checkedIDs.add(asmdss.getName()+"-"+ asmdss.getSignalName()+":"+aaos.getID()); + } + asm.addElement (aaos); } private void translateAvatarSMDLibraryFunctionCall (TDiagramPanel tdp, AvatarSpecification _as, AvatarStateMachineOwner _ab, AvatarSMDLibraryFunctionCall asmdlfc) throws CheckingError { @@ -1338,212 +1328,202 @@ public class AvatarDesignPanelTranslator { throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Unknown library function '" + libraryFunction.getFunctionName () + "'"); /* create Avatar representation of the function call */ - final AvatarStateMachineElement element; - final String name = "library_function_call"; - - if ( asmdlfc.isEnabled() ) { - /* create Avatar representation of the function call */ - element = new AvatarLibraryFunctionCall( name, aLibraryFunction, asmdlfc ); - AvatarLibraryFunctionCall alfc = (AvatarLibraryFunctionCall) element; -// AvatarLibraryFunctionCall alfc = new AvatarLibraryFunctionCall ("library_function_call", aLibraryFunction, asmdlfc); - - /* Get the list of parameters passed to the function */ - List<TAttribute> parameters = asmdlfc.getParameters (); - /* If the number of parameters does not match raise an error */ - if (parameters.size () != libraryFunction.getParameters ().size ()) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Calling library function " + libraryFunction.getFunctionName () + " requires " + libraryFunction.getParameters ().size () + "parameters (" + parameters.size () + " provided)"); - - /* Loop through the parameters */ - int i=0; - for (TAttribute ta: parameters) { - i ++; - /* If parameter has not be filled in raise an error */ - if (ta == null) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Missing parameter #" + i + " when calling library function " + libraryFunction.getFunctionName ()); - - /* Check if type of parameter matches what's expected */ - TAttribute returnTA = libraryFunction.getParameters ().get (i-1); - if (!ta.hasSameType (returnTA)) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Type of parameter #" + i + " when calling library function " + libraryFunction.getFunctionName () + " does not match"); - - /* Creates all the parameters corresponding to this parameter */ - List<String> parameterNames = new LinkedList<String> (); - if (ta.getType() == TAttribute.INTEGER - || ta.getType() == TAttribute.NATURAL - || ta.getType() == TAttribute.BOOLEAN - || ta.getType() == TAttribute.TIMER) - parameterNames.add (ta.getId ()); - else { - List<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (ta.getTypeOther ()); - if (types == null || types.isEmpty ()) - throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type: " + ta.getTypeOther () + " when calling " + libraryFunction.getFunctionName ()); - - for (TAttribute type: types) - parameterNames.add (ta.getId () + "__" + type.getId ()); - } - - /* Add flattened parameters */ - for (String parameterName: parameterNames) { - /* Try to get the corresponding attribute */ - AvatarAttribute attr = _ab.getAvatarAttributeWithName (parameterName); - /* If it does not exist raise an error */ - if (attr == null) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Parameter '" + ta.getId () + "' passed when calling library function " + libraryFunction.getFunctionName () + " does not exist"); - alfc.addParameter (attr); - } - } - - /* Get the list of signals mapped to the function's placeholders */ - List<ui.AvatarSignal> signals = asmdlfc.getSignals (); - /* If the number of signals does not match raise an error */ - if (signals.size () != libraryFunction.getSignals ().size ()) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Calling library function " + libraryFunction.getFunctionName () + " requires " + libraryFunction.getSignals ().size () + " signals (" + signals.size () + " mapped)"); - - /* Loop through the signals */ - i=0; - for (ui.AvatarSignal uias: signals) { - i ++; - /* If signal has not be filled in raise an error */ - if (uias == null) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Missing mapping for signal #" + i + " when calling library function " + libraryFunction.getFunctionName ()); - - /* Check if prototype of signal matches what's expected */ - ui.AvatarSignal expectedSig = libraryFunction.getSignals ().get (i-1); - if (!expectedSig.hasSamePrototype (uias)) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Prototype of signal #" + i + " when calling library function " + libraryFunction.getFunctionName () + " does not match"); - - /* Try to get the corresponding signal */ - avatartranslator.AvatarSignal sig = _ab.getAvatarSignalWithName (uias.getId ()); - /* If it does not exist raise an error */ - if (sig == null) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Signal '" + uias.getId () + "' mapped when calling library function " + libraryFunction.getFunctionName () + " does not exist"); - alfc.addSignal (sig); - } - - /* Get the list of return attributes passed to the function */ - List<TAttribute> returnAttributes = asmdlfc.getReturnAttributes (); - /* If the number of return attributes is greater that what the function can return raise an error */ - if (returnAttributes.size () > libraryFunction.getReturnAttributes ().size ()) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Calling library function " + libraryFunction.getFunctionName () + " can only return " + libraryFunction.getReturnAttributes ().size () + " values (" + returnAttributes.size () + " expected)"); - - /* Loop through the return attributes */ - i=0; - for (TAttribute ta: returnAttributes) { - List<AvatarAttribute> attrs = new LinkedList<AvatarAttribute> (); - /* If return attribute has not be filled in, add a dummy one */ - if (ta == null) { - TAttribute returnTA = libraryFunction.getReturnAttributes ().get (i); - String dummyName = "__dummy_return_attribute_" + returnTA.getId (); - - /* Creates all the attributes corresponding to this return attribute */ - if (returnTA.getType() == TAttribute.INTEGER - || returnTA.getType() == TAttribute.NATURAL - || returnTA.getType() == TAttribute.BOOLEAN - || returnTA.getType() == TAttribute.TIMER) { - AvatarAttribute attr = _ab.getAvatarAttributeWithName (dummyName); - if (attr == null) { - attr = this.createRegularAttribute (_ab, returnTA, "__dummy_return_attribute_"); - _ab.addAttribute (attr); - } - attrs.add (attr); - } else { - List<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (returnTA.getTypeOther ()); - if (types == null || types.isEmpty ()) - throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type: " + returnTA.getTypeOther () + " when calling " + libraryFunction.getFunctionName ()); - - for (TAttribute type: types) { - String attributeName = dummyName + "__" + type.getId (); - AvatarAttribute attr = _ab.getAvatarAttributeWithName (attributeName); - if (attr == null) { - attr = this.createRegularAttribute (_ab, type, dummyName + "__"); - _ab.addAttribute (attr); - } - attrs.add (attr); - } - } - } else { - /* Check if type of return attribute matches what's expected */ - TAttribute returnTA = libraryFunction.getReturnAttributes ().get (i); - if (!ta.hasSameType (returnTA)) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Type of return attribute #" + (i+1) + " when calling library function " + libraryFunction.getFunctionName () + " does not match"); - - /* Creates all the attributes corresponding to this return attribute */ - List<String> attributeNames = new LinkedList<String> (); - if (ta.getType() == TAttribute.INTEGER - || ta.getType() == TAttribute.NATURAL - || ta.getType() == TAttribute.BOOLEAN - || ta.getType() == TAttribute.TIMER) - attributeNames.add (ta.getId ()); - else { - List<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (ta.getTypeOther ()); - if (types == null || types.isEmpty ()) - throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type: " + ta.getTypeOther () + " when calling " + libraryFunction.getFunctionName ()); - - for (TAttribute type: types) - attributeNames.add (ta.getId () + "__" + type.getId ()); - } - - /* Add flattened parameters */ - for (String attributeName: attributeNames) { - AvatarAttribute attr = _ab.getAvatarAttributeWithName (attributeName); - /* If a return attribute was given but we can't find the corresponding one raise an error */ - if (attr == null) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Attribute '" + ta.getId () + "' expected to hold return value #" + (i+1) + " when calling library function " + libraryFunction.getFunctionName () + " does not exist"); - attrs.add (attr); - } - } - - for (AvatarAttribute attr: attrs) - alfc.addReturnAttribute (attr); - i ++; - } - - /* If there were missing return attributes, add dummies ones */ - for (; i<libraryFunction.getReturnAttributes ().size (); i++) { - TAttribute returnTA = libraryFunction.getReturnAttributes ().get (i); - String dummyName = "__dummy_return_attribute_" + returnTA.getId (); - - List<AvatarAttribute> attrs = new LinkedList<AvatarAttribute> (); - /* Creates all the attributes corresponding to this return attribute */ - if (returnTA.getType() == TAttribute.INTEGER - || returnTA.getType() == TAttribute.NATURAL - || returnTA.getType() == TAttribute.BOOLEAN - || returnTA.getType() == TAttribute.TIMER) { - AvatarAttribute attr = _ab.getAvatarAttributeWithName (dummyName); - if (attr == null) { - attr = this.createRegularAttribute (_ab, returnTA, "__dummy_return_attribute_"); - _ab.addAttribute (attr); - } - attrs.add (attr); - } else { - List<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (returnTA.getTypeOther ()); - if (types == null || types.isEmpty ()) - throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type: " + returnTA.getTypeOther () + " when calling " + libraryFunction.getFunctionName ()); - - for (TAttribute type: types) { - String attributeName = dummyName + "__" + type.getId (); - AvatarAttribute attr = _ab.getAvatarAttributeWithName (attributeName); - if (attr == null) { - attr = this.createRegularAttribute (_ab, type, dummyName + "__"); - _ab.addAttribute (attr); - } - attrs.add (attr); - } - } - - for (AvatarAttribute attr: attrs) - alfc.addReturnAttribute (attr); - } + AvatarLibraryFunctionCall alfc = new AvatarLibraryFunctionCall ("library_function_call", aLibraryFunction, asmdlfc); + + /* Get the list of parameters passed to the function */ + List<TAttribute> parameters = asmdlfc.getParameters (); + /* If the number of parameters does not match raise an error */ + if (parameters.size () != libraryFunction.getParameters ().size ()) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Calling library function " + libraryFunction.getFunctionName () + " requires " + libraryFunction.getParameters ().size () + "parameters (" + parameters.size () + " provided)"); + + /* Loop through the parameters */ + int i=0; + for (TAttribute ta: parameters) { + i ++; + /* If parameter has not be filled in raise an error */ + if (ta == null) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Missing parameter #" + i + " when calling library function " + libraryFunction.getFunctionName ()); + + /* Check if type of parameter matches what's expected */ + TAttribute returnTA = libraryFunction.getParameters ().get (i-1); + if (!ta.hasSameType (returnTA)) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Type of parameter #" + i + " when calling library function " + libraryFunction.getFunctionName () + " does not match"); + + /* Creates all the parameters corresponding to this parameter */ + List<String> parameterNames = new LinkedList<String> (); + if (ta.getType() == TAttribute.INTEGER + || ta.getType() == TAttribute.NATURAL + || ta.getType() == TAttribute.BOOLEAN + || ta.getType() == TAttribute.TIMER) + parameterNames.add (ta.getId ()); + else { + List<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (ta.getTypeOther ()); + if (types == null || types.isEmpty ()) + throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type: " + ta.getTypeOther () + " when calling " + libraryFunction.getFunctionName ()); + + for (TAttribute type: types) + parameterNames.add (ta.getId () + "__" + type.getId ()); + } + + /* Add flattened parameters */ + for (String parameterName: parameterNames) { + /* Try to get the corresponding attribute */ + AvatarAttribute attr = _ab.getAvatarAttributeWithName (parameterName); + /* If it does not exist raise an error */ + if (attr == null) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Parameter '" + ta.getId () + "' passed when calling library function " + libraryFunction.getFunctionName () + " does not exist"); + alfc.addParameter (attr); + } } - else { - element = new AvatarDummyState( name + ":" + aLibraryFunction.getName(), asmdlfc ); + + /* Get the list of signals mapped to the function's placeholders */ + List<ui.AvatarSignal> signals = asmdlfc.getSignals (); + /* If the number of signals does not match raise an error */ + if (signals.size () != libraryFunction.getSignals ().size ()) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Calling library function " + libraryFunction.getFunctionName () + " requires " + libraryFunction.getSignals ().size () + " signals (" + signals.size () + " mapped)"); + + /* Loop through the signals */ + i=0; + for (ui.AvatarSignal uias: signals) { + i ++; + /* If signal has not be filled in raise an error */ + if (uias == null) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Missing mapping for signal #" + i + " when calling library function " + libraryFunction.getFunctionName ()); + + /* Check if prototype of signal matches what's expected */ + ui.AvatarSignal expectedSig = libraryFunction.getSignals ().get (i-1); + if (!expectedSig.hasSamePrototype (uias)) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Prototype of signal #" + i + " when calling library function " + libraryFunction.getFunctionName () + " does not match"); + + /* Try to get the corresponding signal */ + avatartranslator.AvatarSignal sig = _ab.getAvatarSignalWithName (uias.getId ()); + /* If it does not exist raise an error */ + if (sig == null) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Signal '" + uias.getId () + "' mapped when calling library function " + libraryFunction.getFunctionName () + " does not exist"); + alfc.addSignal (sig); + } + + /* Get the list of return attributes passed to the function */ + List<TAttribute> returnAttributes = asmdlfc.getReturnAttributes (); + /* If the number of return attributes is greater that what the function can return raise an error */ + if (returnAttributes.size () > libraryFunction.getReturnAttributes ().size ()) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Calling library function " + libraryFunction.getFunctionName () + " can only return " + libraryFunction.getReturnAttributes ().size () + " values (" + returnAttributes.size () + " expected)"); + + /* Loop through the return attributes */ + i=0; + for (TAttribute ta: returnAttributes) { + List<AvatarAttribute> attrs = new LinkedList<AvatarAttribute> (); + /* If return attribute has not be filled in, add a dummy one */ + if (ta == null) { + TAttribute returnTA = libraryFunction.getReturnAttributes ().get (i); + String dummyName = "__dummy_return_attribute_" + returnTA.getId (); + + /* Creates all the attributes corresponding to this return attribute */ + if (returnTA.getType() == TAttribute.INTEGER + || returnTA.getType() == TAttribute.NATURAL + || returnTA.getType() == TAttribute.BOOLEAN + || returnTA.getType() == TAttribute.TIMER) { + AvatarAttribute attr = _ab.getAvatarAttributeWithName (dummyName); + if (attr == null) { + attr = this.createRegularAttribute (_ab, returnTA, "__dummy_return_attribute_"); + _ab.addAttribute (attr); + } + attrs.add (attr); + } else { + List<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (returnTA.getTypeOther ()); + if (types == null || types.isEmpty ()) + throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type: " + returnTA.getTypeOther () + " when calling " + libraryFunction.getFunctionName ()); + + for (TAttribute type: types) { + String attributeName = dummyName + "__" + type.getId (); + AvatarAttribute attr = _ab.getAvatarAttributeWithName (attributeName); + if (attr == null) { + attr = this.createRegularAttribute (_ab, type, dummyName + "__"); + _ab.addAttribute (attr); + } + attrs.add (attr); + } + } + } else { + /* Check if type of return attribute matches what's expected */ + TAttribute returnTA = libraryFunction.getReturnAttributes ().get (i); + if (!ta.hasSameType (returnTA)) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Type of return attribute #" + (i+1) + " when calling library function " + libraryFunction.getFunctionName () + " does not match"); + + /* Creates all the attributes corresponding to this return attribute */ + List<String> attributeNames = new LinkedList<String> (); + if (ta.getType() == TAttribute.INTEGER + || ta.getType() == TAttribute.NATURAL + || ta.getType() == TAttribute.BOOLEAN + || ta.getType() == TAttribute.TIMER) + attributeNames.add (ta.getId ()); + else { + List<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (ta.getTypeOther ()); + if (types == null || types.isEmpty ()) + throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type: " + ta.getTypeOther () + " when calling " + libraryFunction.getFunctionName ()); + + for (TAttribute type: types) + attributeNames.add (ta.getId () + "__" + type.getId ()); + } + + /* Add flattened parameters */ + for (String attributeName: attributeNames) { + AvatarAttribute attr = _ab.getAvatarAttributeWithName (attributeName); + /* If a return attribute was given but we can't find the corresponding one raise an error */ + if (attr == null) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Attribute '" + ta.getId () + "' expected to hold return value #" + (i+1) + " when calling library function " + libraryFunction.getFunctionName () + " does not exist"); + attrs.add (attr); + } + } + + for (AvatarAttribute attr: attrs) + alfc.addReturnAttribute (attr); + i ++; + } + + /* If there were missing return attributes, add dummies ones */ + for (; i<libraryFunction.getReturnAttributes ().size (); i++) { + TAttribute returnTA = libraryFunction.getReturnAttributes ().get (i); + String dummyName = "__dummy_return_attribute_" + returnTA.getId (); + + List<AvatarAttribute> attrs = new LinkedList<AvatarAttribute> (); + /* Creates all the attributes corresponding to this return attribute */ + if (returnTA.getType() == TAttribute.INTEGER + || returnTA.getType() == TAttribute.NATURAL + || returnTA.getType() == TAttribute.BOOLEAN + || returnTA.getType() == TAttribute.TIMER) { + AvatarAttribute attr = _ab.getAvatarAttributeWithName (dummyName); + if (attr == null) { + attr = this.createRegularAttribute (_ab, returnTA, "__dummy_return_attribute_"); + _ab.addAttribute (attr); + } + attrs.add (attr); + } else { + List<TAttribute> types = adp.getAvatarBDPanel ().getAttributesOfDataType (returnTA.getTypeOther ()); + if (types == null || types.isEmpty ()) + throw new CheckingError (CheckingError.STRUCTURE_ERROR, "Unknown data type: " + returnTA.getTypeOther () + " when calling " + libraryFunction.getFunctionName ()); + + for (TAttribute type: types) { + String attributeName = dummyName + "__" + type.getId (); + AvatarAttribute attr = _ab.getAvatarAttributeWithName (attributeName); + if (attr == null) { + attr = this.createRegularAttribute (_ab, type, dummyName + "__"); + _ab.addAttribute (attr); + } + attrs.add (attr); + } + } + + for (AvatarAttribute attr: attrs) + alfc.addReturnAttribute (attr); } - listE.addCor( element, asmdlfc ); - asmdlfc.setAVATARID( element.getID() ); - asm.addElement( element ); + this.listE.addCor (alfc, asmdlfc); + asmdlfc.setAVATARID (alfc.getID()); + asm.addElement (alfc); } + private void translateAvatarSMDReceiveSignal (TDiagramPanel tdp, AvatarSpecification _as, AvatarStateMachineOwner _ab, AvatarSMDReceiveSignal asmdrs) throws CheckingError { AvatarStateMachine asm = _ab.getStateMachine (); avatartranslator.AvatarSignal atas = _ab.getAvatarSignalWithName (asmdrs.getSignalName ()); @@ -1569,172 +1549,110 @@ public class AvatarDesignPanelTranslator { if (atas.getReferenceObject() instanceof ui.AvatarSignal) { ((ui.AvatarSignal) atas.getReferenceObject()).attachedToARelation = true; } - - final AvatarStateMachineElement element; - final String name = "action_on_signal"; - - if ( asmdrs.isEnabled() ) { - element = new AvatarActionOnSignal( name, atas, asmdrs ); - - final AvatarActionOnSignal aaos = (AvatarActionOnSignal) element; - if (asmdrs.hasCheckableAccessibility()) - aaos.setCheckable(); - - if (asmdrs.hasCheckedAccessibility()) - aaos.setChecked(); - - if (aaos.isSending()) - throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "A sending signal is used for receiving: " + asmdrs.getValue()); - - if (asmdrs.getNbOfValues() == -1) - throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed signal: " + asmdrs.getValue()); - - for(int i=0; i<asmdrs.getNbOfValues(); i++) { - String tmp = asmdrs.getValue(i); - if (tmp.isEmpty ()) - throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Empty parameter in signal expression: " + asmdrs.getValue()); - - this.manageAttribute (tmp, _ab, aaos, tdp, asmdrs, asmdrs.getValue()); - } - - if (aaos.getNbOfValues () != atas.getListOfAttributes ().size ()) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdrs.getValue() + " -> nb of parameters does not match definition"); - - // Checking expressions passed as parameter - for (int i=0; i<aaos.getNbOfValues(); i++) { - String theVal = aaos.getValue(i); - if (atas.getListOfAttributes ().get (i).isInt ()) { - if (AvatarSyntaxChecker.isAValidIntExpr (_as, _ab, theVal) < 0) - throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdrs.getValue() + " -> value at index #" + i + " does not match definition"); - } else { - // We assume it is a bool attribute - if (AvatarSyntaxChecker.isAValidBoolExpr(_as, _ab, theVal) < 0) - throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdrs.getValue() + " -> value at index #" + i + " does not match definition"); - } - } - - if (asmdrs.getCheckLatency()){ - aaos.setCheckLatency(true); - _as.checkedIDs.add(asmdrs.getName()+"-"+asmdrs.getSignalName()+":"+aaos.getID()); - } - } - else { - element = new AvatarDummyState( name + ":" + atas.getName(), asmdrs ); - } + AvatarActionOnSignal aaos = new AvatarActionOnSignal ("action_on_signal", atas, asmdrs); + if (asmdrs.hasCheckableAccessibility()) + aaos.setCheckable(); + + if (asmdrs.hasCheckedAccessibility()) + aaos.setChecked(); + + if (aaos.isSending()) + throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "A sending signal is used for receiving: " + asmdrs.getValue()); + + if (asmdrs.getNbOfValues() == -1) + throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed signal: " + asmdrs.getValue()); + + for(int i=0; i<asmdrs.getNbOfValues(); i++) { + String tmp = asmdrs.getValue(i); + if (tmp.isEmpty ()) + throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Empty parameter in signal expression: " + asmdrs.getValue()); + + this.manageAttribute (tmp, _ab, aaos, tdp, asmdrs, asmdrs.getValue()); + } + + if (aaos.getNbOfValues () != atas.getListOfAttributes ().size ()) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdrs.getValue() + " -> nb of parameters does not match definition"); + + // Checking expressions passed as parameter + for (int i=0; i<aaos.getNbOfValues(); i++) { + String theVal = aaos.getValue(i); + if (atas.getListOfAttributes ().get (i).isInt ()) { + if (AvatarSyntaxChecker.isAValidIntExpr (_as, _ab, theVal) < 0) + throw new CheckingError (CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdrs.getValue() + " -> value at index #" + i + " does not match definition"); + } else { + // We assume it is a bool attribute + if (AvatarSyntaxChecker.isAValidBoolExpr(_as, _ab, theVal) < 0) + throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdrs.getValue() + " -> value at index #" + i + " does not match definition"); + } + } - this.listE.addCor( element, asmdrs ); - asmdrs.setAVATARID( element.getID() ); - asm.addElement( element ); + this.listE.addCor (aaos, asmdrs); + asmdrs.setAVATARID (aaos.getID()); + asm.addElement (aaos); + if (asmdrs.getCheckLatency()){ + aaos.setCheckLatency(true); + _as.checkedIDs.add(asmdrs.getName()+"-"+asmdrs.getSignalName()+":"+aaos.getID()); + } } private void translateAvatarSMDState (TDiagramPanel tdp, AvatarSpecification _as, AvatarStateMachineOwner _ab, AvatarSMDState tgc) throws CheckingError { - AvatarStateMachine stateMachine = _ab.getStateMachine (); - AvatarStateElement stateElement = createState( stateMachine, tgc ); - //AvatarState astate = asm.getStateWithName(tgc.getValue()); -// if (astate == null) { -// astate = new AvatarState (tgc.getValue(), tgc); -// astate.setAsVerifiable(true); -// asm.addElement (astate); -// } + AvatarStateMachine asm = _ab.getStateMachine (); + AvatarState astate = asm.getStateWithName(tgc.getValue()); + if (astate == null) { + astate = new AvatarState (tgc.getValue(), tgc); + astate.setAsVerifiable(true); + asm.addElement (astate); + } if (tgc.hasCheckableAccessibility ()) - stateElement.setCheckable (); + astate.setCheckable (); if (tgc.hasCheckedAccessibility()) - stateElement.setChecked(); - - // Issue #69 - if ( tgc.isEnabled() ) { - final AvatarState state = (AvatarState) stateElement; - - // Executable code - state.addEntryCode(tgc.getEntryCode()); - - if (tgc.getCheckLatency()){ - state.setCheckLatency(true); - _as.checkedIDs.add(tgc.getName()+"-"+tgc.getValue()+":"+state.getID()); - } - } + astate.setChecked(); - listE.addCor(stateElement, tgc); - stateElement.addReferenceObject (tgc); - tgc.setAVATARID(stateElement.getID()); - } - - private AvatarStateElement createState( final AvatarStateMachine stateMachine, - final AvatarSMDState diagramState ) { - AvatarStateElement stateElement = stateMachine.getStateWithName( diagramState.getValue() ); - - if ( stateElement == null ) { - final String name = diagramState.getValue(); - - // Issue #69 - if ( diagramState.isEnabled() ) { - stateElement = new AvatarState( name, diagramState ); - stateElement.setAsVerifiable( true ); - } - else { - if ( diagramState.getOutputConnectors().isEmpty() ) { - stateElement = new AvatarStopState( name + "_state_converted_to_stop", diagramState ); - } - else { - stateElement = new AvatarDummyState( name, diagramState ); - } - } - - stateMachine.addElement( stateElement ); - } - - return stateElement; + // Executable code + astate.addEntryCode(tgc.getEntryCode()); + + this.listE.addCor (astate, tgc); + astate.addReferenceObject (tgc); + tgc.setAVATARID (astate.getID()); + if (tgc.getCheckLatency()){ + astate.setCheckLatency(true); + _as.checkedIDs.add(tgc.getName()+"-"+tgc.getValue()+":"+astate.getID()); + } } private void translateAvatarSMDRandom (TDiagramPanel tdp, AvatarSpecification _as, AvatarStateMachineOwner _ab, AvatarSMDRandom asmdrand) throws CheckingError { AvatarStateMachine asm = _ab.getStateMachine (); + AvatarRandom arandom = new AvatarRandom ("random", asmdrand); + String tmp1 = modifyString (asmdrand.getMinValue()); + int error = AvatarSyntaxChecker.isAValidIntExpr(_as, _ab, tmp1); + if (error < 0) + this.makeError (error, tdp, _ab, asmdrand, "min value of random", tmp1); - final AvatarStateMachineElement element; - final String name = "random"; - - if ( asmdrand.isEnabled() ) { - element = new AvatarRandom( name, asmdrand ); - - final AvatarRandom arandom = (AvatarRandom) element; + String tmp2 = modifyString(asmdrand.getMaxValue()); + error = AvatarSyntaxChecker.isAValidIntExpr(_as, _ab, tmp2); + if (error < 0) + this.makeError (error, tdp, _ab, asmdrand, "max value of random", tmp2); - String tmp1 = modifyString (asmdrand.getMinValue()); - int error = AvatarSyntaxChecker.isAValidIntExpr(_as, _ab, tmp1); - - if (error < 0) { - makeError (error, tdp, _ab, asmdrand, "min value of random", tmp1); - } + arandom.setValues (tmp1, tmp2); + arandom.setFunctionId (asmdrand.getFunctionId()); - String tmp2 = modifyString(asmdrand.getMaxValue()); - error = AvatarSyntaxChecker.isAValidIntExpr(_as, _ab, tmp2); - - if (error < 0) { - makeError (error, tdp, _ab, asmdrand, "max value of random", tmp2); - } + tmp1 = modifyString(asmdrand.getVariable()); + AvatarAttribute aa = _ab.getAvatarAttributeWithName (tmp1); - arandom.setValues (tmp1, tmp2); - arandom.setFunctionId (asmdrand.getFunctionId()); - - tmp1 = modifyString(asmdrand.getVariable()); - AvatarAttribute aa = _ab.getAvatarAttributeWithName (tmp1); - - if (aa == null) - this.makeError (-3, tdp, _ab, asmdrand, "random", tmp1); - // Checking type of variable -> must be an int - else if (!(aa.isInt())) - this.makeError (error, tdp, _ab, asmdrand, ": variable of random must be of type \"int\"", tmp2); - - arandom.setVariable(tmp1); - } - else { - element = new AvatarDummyState( name, asmdrand ); - } + if (aa == null) + this.makeError (-3, tdp, _ab, asmdrand, "random", tmp1); + // Checking type of variable -> must be an int + else if (!(aa.isInt())) + this.makeError (error, tdp, _ab, asmdrand, ": variable of random must be of type \"int\"", tmp2); + + arandom.setVariable (tmp1); - asm.addElement (element); - listE.addCor( element, asmdrand ); - asmdrand.setAVATARID( element.getID() ); + asm.addElement (arandom); + listE.addCor (arandom, asmdrand); + asmdrand.setAVATARID (arandom.getID()); } private void translateAvatarSMDSetTimer (TDiagramPanel tdp, AvatarSpecification _as, AvatarStateMachineOwner _ab, AvatarSMDSetTimer asmdst) throws CheckingError { @@ -1752,23 +1670,12 @@ public class AvatarDesignPanelTranslator { if (error < 0) this.makeError(error, tdp, _ab, asmdst, "value of the timer setting", tmp); - final AvatarStateMachineElement element; - final String name = "settimer__" + aa.getName(); - - if ( asmdst.isEnabled() ) { - element = new AvatarSetTimer( name, asmdst ); - - final AvatarSetTimer asettimer = (AvatarSetTimer) element; - asettimer.setTimer( aa ); - asettimer.setTimerValue( tmp ); - } - else { - element = new AvatarDummyState( name, asmdst ); - } - - asm.addElement(element); - listE.addCor(element, asmdst); - asmdst.setAVATARID(element.getID()); + AvatarSetTimer asettimer = new AvatarSetTimer("settimer__" + aa.getName(), asmdst); + asettimer.setTimer (aa); + asettimer.setTimerValue (tmp); + asm.addElement (asettimer); + this.listE.addCor (asettimer, asmdst); + asmdst.setAVATARID (asettimer.getID()); } private void translateAvatarSMDResetTimer (TDiagramPanel tdp, AvatarSpecification _as, AvatarStateMachineOwner _ab, AvatarSMDResetTimer asmdrt) throws CheckingError { @@ -1781,20 +1688,11 @@ public class AvatarDesignPanelTranslator { if (aa.getType() != AvatarType.TIMER) throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed parameter: " + tmp + " in timer reset: shall be a parameter of type \"Timer\""); - final AvatarStateMachineElement element; - final String name = "resettimer__" + aa.getName(); - - if ( asmdrt.isEnabled() ) { - element= new AvatarResetTimer( name, asmdrt ); - ( (AvatarResetTimer) element ).setTimer( aa ); - } - else { - element = new AvatarDummyState( name, asmdrt ); - } - - asm.addElement( element ); - listE.addCor( element, asmdrt ); - asmdrt.setAVATARID( element.getID() ); + AvatarResetTimer aresettimer = new AvatarResetTimer("resettimer__" + aa.getName(), asmdrt); + aresettimer.setTimer (aa); + asm.addElement(aresettimer); + this.listE.addCor (aresettimer, asmdrt); + asmdrt.setAVATARID (aresettimer.getID()); } private void translateAvatarSMDExpireTimer (TDiagramPanel tdp, AvatarSpecification _as, AvatarStateMachineOwner _ab, AvatarSMDExpireTimer asmdet) throws CheckingError { @@ -1807,178 +1705,14 @@ public class AvatarDesignPanelTranslator { if (aa.getType() != AvatarType.TIMER) throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed parameter: " + tmp + " in timer expiration: shall be a parameter of type \"Timer\""); - final AvatarStateMachineElement avatarElement; - final String name = "expiretimer__" + aa.getName(); - - if ( asmdet.isEnabled() ) { - avatarElement = new AvatarExpireTimer( name, asmdet ); - ( ( AvatarExpireTimer) avatarElement ).setTimer(aa); - } - else { - avatarElement = new AvatarDummyState( name, asmdet ); - } - - asm.addElement( avatarElement ); - this.listE.addCor( avatarElement, asmdet ); - asmdet.setAVATARID( avatarElement.getID() ); -// AvatarExpireTimer aexpiretimer = new AvatarExpireTimer("expiretimer__" + aa.getName(), asmdet); -// aexpiretimer.setTimer(aa); -// asm.addElement(aexpiretimer); -// this.listE.addCor(aexpiretimer, asmdet); -// asmdet.setAVATARID(aexpiretimer.getID()); - } - - private void createGuard( final AvatarTransition transition, - final AvatarSMDConnector connector ) { - final AvatarStateMachineOwner block = transition.getBlock(); - final String guardStr = modifyString( connector.getEffectiveGuard() ); - final AvatarGuard guard = AvatarGuard.createFromString( block, guardStr ); - final int error; - - if ( guard.isElseGuard() ) { - error = 0; - } - else { - error = AvatarSyntaxChecker.isAValidGuard( block.getAvatarSpecification(), block, guardStr ); - } - - if ( error < 0 ) { - makeError( error, connector.tdp, block, connector, "transition guard", guardStr ); - } - else { - transition.setGuard( guard ); - } - } - - private void createAfterDelay( final AvatarTransition transition, - final AvatarSMDConnector connector ) { - final AvatarStateMachineOwner block = transition.getBlock(); - final AvatarSpecification spec = block.getAvatarSpecification(); - - String afterMinDelayStr = modifyString( connector.getEffectiveAfterMinDelay() ); - int error = AvatarSyntaxChecker.isAValidIntExpr( spec, block, afterMinDelayStr ); - - if ( error < 0 ) { - makeError( error, connector.tdp, block, connector, "after min delay", afterMinDelayStr ); - afterMinDelayStr = null; - } - - String afterMaxDelayStr = modifyString( connector.getEffectiveAfterMaxDelay() ); - error = AvatarSyntaxChecker.isAValidIntExpr( spec, block, afterMaxDelayStr ); - - if ( error < 0 ) { - makeError(error, connector.tdp, block, connector, "after max delay", afterMaxDelayStr ); - afterMaxDelayStr = null; - } - - if ( afterMinDelayStr != null && afterMaxDelayStr != null ) { - transition.setDelays( afterMinDelayStr, afterMaxDelayStr ); - } - } - - private void createComputeDelay( final AvatarTransition transition, - final AvatarSMDConnector connector ) { - final AvatarStateMachineOwner block = transition.getBlock(); - final AvatarSpecification spec = block.getAvatarSpecification(); - - String computeMinDelayStr = modifyString( connector.getEffectiveComputeMinDelay() ); - int error = AvatarSyntaxChecker.isAValidIntExpr( spec, block, computeMinDelayStr ); - - if (error < 0) { - makeError( error, connector.tdp, block, connector, "compute min ", computeMinDelayStr ); - computeMinDelayStr = null; - } - - String computeMaxDelayStr = modifyString( connector.getEffectiveComputeMaxDelay() ); - error = AvatarSyntaxChecker.isAValidIntExpr( spec, block, computeMaxDelayStr ); - - if (error < 0) { - makeError( error, connector.tdp, block, connector, "compute max ", computeMaxDelayStr ); - computeMaxDelayStr = null; - } - - if ( computeMinDelayStr != null && computeMaxDelayStr != null) { - transition.setComputes( computeMinDelayStr, computeMaxDelayStr ); - } + AvatarExpireTimer aexpiretimer = new AvatarExpireTimer("expiretimer__" + aa.getName(), asmdet); + aexpiretimer.setTimer(aa); + asm.addElement(aexpiretimer); + this.listE.addCor(aexpiretimer, asmdet); + asmdet.setAVATARID(aexpiretimer.getID()); } - - private void createProbability( final AvatarTransition transition, - final AvatarSMDConnector connector ) { - final AvatarStateMachineOwner block = transition.getBlock(); - final AvatarSpecification spec = block.getAvatarSpecification(); - final String probabilityStr = modifyString( connector.getEffectiveProbability() ); - final int error = AvatarSyntaxChecker.isAValidProbabilityExpr( spec, block, probabilityStr ); - - if ( error < 0 ) { - makeError( error, connector.tdp, block, connector, "probability ", probabilityStr ); - } - if ( probabilityStr != null && !probabilityStr.isEmpty() ) { - transition.setProbability( Double.parseDouble( probabilityStr ) ); - } - } - - private void createActions( final AvatarTransition transition, - final AvatarSMDConnector connector ) { - final AvatarStateMachineOwner block = transition.getBlock(); - int error = 0; - - for( String actionText : connector.getEffectiveActions() ) { - if ( actionText.trim().length() > 0 ) { - actionText = modifyString( actionText.trim() ); - - // Variable assignment or method call? - if ( !isAVariableAssignation( actionText ) ) { - // Method call - int index2 = actionText.indexOf( ";" ); - - if ( index2 != -1 ) { - makeError( error, connector.tdp, block, connector, "transition action", actionText ); - } - - actionText = modifyStringMethodCall( actionText, block.getName() ); - - if ( !AvatarBlock.isAValidMethodCall( block, actionText ) ) { - UICheckingError ce = new UICheckingError( CheckingError.BEHAVIOR_ERROR, "Badly formed transition method call: " + actionText ); - // TODO: adapt - // ce.setAvatarBlock(_ab); - ce.setTDiagramPanel( connector.tdp ); - ce.setTGComponent( connector ); - addCheckingError(ce); - } - else { - transition.addAction( actionText ); - } - } - else { - // Variable assignment - error = AvatarSyntaxChecker.isAValidVariableExpr( block.getAvatarSpecification(), block, actionText); - - if ( error < 0 ) { - makeError( error, connector.tdp, block, connector, "transition action", actionText ); - } - else { - transition.addAction( actionText ); - } - } - } - } - } - - private void createTransitionInfo( final AvatarTransition transition, - final AvatarSMDConnector connector ) { - createGuard( transition,connector ); - - createAfterDelay( transition, connector); - - createComputeDelay( transition, connector ); - - createProbability( transition, connector ); - - createActions( transition, connector ); - } - - private void makeStateMachine (AvatarSpecification _as, AvatarStateMachineOwner _ab) { + public void makeStateMachine (AvatarSpecification _as, AvatarStateMachineOwner _ab) { AvatarBDStateMachineOwner block = (AvatarBDStateMachineOwner) listE.getTG (_ab); AvatarStateMachine asm = _ab.getStateMachine (); @@ -1999,7 +1733,7 @@ public class AvatarDesignPanelTranslator { int size = checkingErrors.size(); - //TDiagramPanel tdp = asmdp; + TDiagramPanel tdp = asmdp; // search for start state AvatarSMDStartState tss = null; @@ -2009,7 +1743,7 @@ public class AvatarDesignPanelTranslator { tss = (AvatarSMDStartState) tgc; else { UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "More than one start state in the state machine diagram of " + name); - ce.setTDiagramPanel( asmdp ); + ce.setTDiagramPanel(tdp); addCheckingError(ce); return; } @@ -2017,7 +1751,7 @@ public class AvatarDesignPanelTranslator { if (tss == null) { UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "No start state in the state machine diagram of " + name); - ce.setTDiagramPanel( asmdp ); + ce.setTDiagramPanel(tdp); addCheckingError(ce); return; } @@ -2025,32 +1759,27 @@ public class AvatarDesignPanelTranslator { // This shall also be true for all composite state: at most one start state! if (checkForStartStateOfCompositeStates (asmdp) != null) { UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "More than one start state in composite state"); - ce.setTDiagramPanel( asmdp ); + ce.setTDiagramPanel(tdp); addCheckingError(ce); return; } int choiceID = 0; // First pass: creating AVATAR components, but no interconnection between them - // Issue #69: - final FindAvatarSMDComponentsToBeTranslatedVisitor componentsToBeTranslatedVisitor = new FindAvatarSMDComponentsToBeTranslatedVisitor(); - tss.acceptForward( componentsToBeTranslatedVisitor ); - final Set<TGComponent> componentsToBeTranslated = componentsToBeTranslatedVisitor.getComponentsToBeTranslated(); - - for (TGComponent tgc: componentsToBeTranslated/*asmdp.getAllComponentList ()*/) + for (TGComponent tgc: asmdp.getAllComponentList ()) try { // Receive signal if (tgc instanceof AvatarSMDReceiveSignal) - this.translateAvatarSMDReceiveSignal ( asmdp, _as, _ab, (AvatarSMDReceiveSignal) tgc); + this.translateAvatarSMDReceiveSignal (tdp, _as, _ab, (AvatarSMDReceiveSignal) tgc); // Send signals else if (tgc instanceof AvatarSMDSendSignal) - this.translateAvatarSMDSendSignal ( asmdp, _as, _ab, (AvatarSMDSendSignal) tgc); + this.translateAvatarSMDSendSignal (tdp, _as, _ab, (AvatarSMDSendSignal) tgc); // Library Function Call else if (tgc instanceof AvatarSMDLibraryFunctionCall) - this.translateAvatarSMDLibraryFunctionCall ( asmdp, _as, _ab, (AvatarSMDLibraryFunctionCall) tgc); + this.translateAvatarSMDLibraryFunctionCall (tdp, _as, _ab, (AvatarSMDLibraryFunctionCall) tgc); // State else if (tgc instanceof AvatarSMDState) - this.translateAvatarSMDState ( asmdp, _as, _ab, (AvatarSMDState) tgc); + this.translateAvatarSMDState (tdp, _as, _ab, (AvatarSMDState) tgc); // Choice else if (tgc instanceof AvatarSMDChoice) { AvatarState astate = new AvatarState ("choice__" + choiceID, tgc); @@ -2061,16 +1790,16 @@ public class AvatarDesignPanelTranslator { } // Random else if (tgc instanceof AvatarSMDRandom) - this.translateAvatarSMDRandom ( asmdp, _as, _ab, (AvatarSMDRandom) tgc); + this.translateAvatarSMDRandom (tdp, _as, _ab, (AvatarSMDRandom) tgc); // Set timer else if (tgc instanceof AvatarSMDSetTimer) - this.translateAvatarSMDSetTimer ( asmdp, _as, _ab, (AvatarSMDSetTimer) tgc); + this.translateAvatarSMDSetTimer (tdp, _as, _ab, (AvatarSMDSetTimer) tgc); // Reset timer else if (tgc instanceof AvatarSMDResetTimer) - this.translateAvatarSMDResetTimer ( asmdp, _as, _ab, (AvatarSMDResetTimer) tgc); + this.translateAvatarSMDResetTimer (tdp, _as, _ab, (AvatarSMDResetTimer) tgc); // Expire timer else if (tgc instanceof AvatarSMDExpireTimer) - this.translateAvatarSMDExpireTimer ( asmdp, _as, _ab, (AvatarSMDExpireTimer) tgc); + this.translateAvatarSMDExpireTimer (tdp, _as, _ab, (AvatarSMDExpireTimer) tgc); // Start state else if (tgc instanceof AvatarSMDStartState) { AvatarStartState astart = new AvatarStartState("start", tgc); @@ -2092,7 +1821,7 @@ public class AvatarDesignPanelTranslator { // TODO: adapt // ce.setAvatarBlock (_ab); UICheckingError uice = new UICheckingError(ce); - uice.setTDiagramPanel ( asmdp ); + uice.setTDiagramPanel (tdp); uice.setTGComponent (tgc); uice.addMessagePrefix ("State Machine of " + name + ": "); this.addCheckingError (uice); @@ -2105,184 +1834,152 @@ public class AvatarDesignPanelTranslator { asm.removeAllInternalStartStates(); // Make hierachy between states and elements - for (TGComponent tgc: componentsToBeTranslated/*asmdp.getAllComponentList ()*/) { + for (TGComponent tgc: asmdp.getAllComponentList ()) if (tgc != null && tgc.getFather() != null) { AvatarStateMachineElement element1 = (AvatarStateMachineElement)(listE.getObject(tgc)); AvatarStateMachineElement element2 = (AvatarStateMachineElement)(listE.getObject(tgc.getFather())); - - if (element1 != null && /*element2 != null && */element2 instanceof AvatarState) { + if (element1 != null && element2 != null && element2 instanceof AvatarState) element1.setState ((AvatarState) element2); - } } - } // Make next: handle transitions - final Set<TGConnector> prunedConectors = componentsToBeTranslatedVisitor.getPrunedConnectors(); - - for ( final TGConnector connector : asmdp.getConnectors() ) { - // for (TGComponent tgc: asmdp.getAllComponentList ()) { - // if (tgc instanceof AvatarSMDConnector) { - // AvatarSMDConnector asmdco = (AvatarSMDConnector) tgc; - // Issue #69 - if ( !prunedConectors.contains( connector ) ) { - FindNextEnabledAvatarSMDConnectingPointVisitor visitor = new FindNextEnabledAvatarSMDConnectingPointVisitor( prunedConectors, componentsToBeTranslated ); - connector.getTGConnectingPointP1().acceptBackward( visitor ); - final TGConnectingPoint conPoint1 = visitor.getEnabledComponentPoint(); - - if ( conPoint1 != null ) { - visitor = new FindNextEnabledAvatarSMDConnectingPointVisitor( prunedConectors, componentsToBeTranslated ); - connector.getTGConnectingPointP2().acceptForward( visitor ); - final TGConnectingPoint conPoint2 = visitor.getEnabledComponentPoint(); - - if ( conPoint2 != null ) { - final TGComponent tgc1 = (TGComponent) conPoint1.getFather();//tdp.getComponentToWhichBelongs( connector.getTGConnectingPointP1() ); - final TGComponent tgc2 = (TGComponent) conPoint2.getFather();//tdp.getComponentToWhichBelongs( connector.getTGConnectingPointP2() ); - // TGComponent tgc1 = asmdp.getComponentToWhichBelongs (asmdco.getTGConnectingPointP1()); - // TGComponent tgc2 = asmdp.getComponentToWhichBelongs (asmdco.getTGConnectingPointP2()); - if (tgc1 == null || tgc2 == null) { - TraceManager.addDev("Tgcs null in Avatar translation"); - } - else { - final AvatarStateMachineElement element1 = (AvatarStateMachineElement)(listE.getObject(tgc1)); - final AvatarStateMachineElement element2 = (AvatarStateMachineElement)(listE.getObject(tgc2)); - - if ( element1 != null && element2 != null ) { - final AvatarSMDConnector avatarSmdConnector = (AvatarSMDConnector) connector; - - if ( asm.findEmptyTransition( element1, element2 ) == null ) { - final AvatarTransition at = new AvatarTransition( _ab, "avatar transition", connector ); - createTransitionInfo( at, avatarSmdConnector ); - // AvatarTransition at = new AvatarTransition (_ab, "avatar transition", tgc); - // - // // Guard - // String tmp = modifyString (asmdco.getGuard()); - // AvatarGuard guard = AvatarGuard.createFromString (_ab, tmp); - // if (guard.isElseGuard()) - // at.setGuard(guard); - // else { - // int error = AvatarSyntaxChecker.isAValidGuard (_as, _ab, tmp); - // if (error < 0) - // this.makeError (error, tdp, _ab, tgc, "transition guard", tmp); - // else - // at.setGuard (guard); - // } - // - // // Delays - // String tmp1 = modifyString (asmdco.getAfterMinDelay ()); - // int error = AvatarSyntaxChecker.isAValidIntExpr (_as, _ab, tmp1); - // if (error < 0) { - // this.makeError (error, tdp, _ab, tgc, "after min delay", tmp1); - // tmp1 = null; - // } - // String tmp2 = modifyString (asmdco.getAfterMaxDelay ()); - // error = AvatarSyntaxChecker.isAValidIntExpr (_as, _ab, tmp2); - // if (error < 0) { - // this.makeError(error, tdp, _ab, tgc, "after max delay", tmp2); - // tmp2 = null; - // } - // - // if (tmp1 != null && tmp2 != null) - // at.setDelays(tmp1, tmp2); - - // Compute min and max - // tmp1 = modifyString (asmdco.getComputeMinDelay ()); - // error = AvatarSyntaxChecker.isAValidIntExpr (_as, _ab, tmp1); - // if (error < 0) { - // this.makeError (error, tdp, _ab, tgc, "compute min ", tmp1); - // tmp1 = null; - // } - // tmp2 = modifyString(asmdco.getComputeMaxDelay()); - // error = AvatarSyntaxChecker.isAValidIntExpr(_as, _ab, tmp2); - // if (error < 0) { - // this.makeError (error, tdp, _ab, tgc, "compute max ", tmp2); - // tmp2 = null; - // } - // - // if (tmp1 != null && tmp2 != null) - // at.setComputes(tmp1, tmp2); - - // Probability - // tmp1 = asmdco.getProbability (); - // if ((tmp1 != null) && (tmp1.length()>0)) { - // error = AvatarSyntaxChecker.isAValidProbabilityExpr(_as, _ab, tmp1); - // if (error < 0) { - // this.makeError(error, tdp, _ab, tgc, "probability ", tmp1); - // tmp1 = null; - // } - // if (tmp1 != null) { - // at.setProbability(new Double(tmp1).doubleValue()); - // } - // } - // - // // Actions - // for(String s: asmdco.getActions()) - // if (s.trim().length() > 0) { - // s = modifyString(s.trim()); - // - // // Variable assignation or method call? - // if (!isAVariableAssignation(s)) { - // // Method call - // int index2 = s.indexOf(";"); - // if (index2 != -1) - // this.makeError(error, tdp, _ab, tgc, "transition action", s); - // - // s = modifyStringMethodCall(s, _ab.getName()); - // if (!AvatarBlock.isAValidMethodCall (_ab, s)) { - // UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed transition method call: " + s); - // // TODO: adapt - // // ce.setAvatarBlock(_ab); - // ce.setTDiagramPanel(tdp); - // ce.setTGComponent(tgc); - // addCheckingError(ce); - // } else - // at.addAction(s); - // } else { - // // Variable assignation - // error = AvatarSyntaxChecker.isAValidVariableExpr (_as, _ab, s); - // if (error < 0) - // this.makeError (error, tdp, _ab, tgc, "transition action", s); - // else - // at.addAction (s); - // } - // } - - element1.addNext( at ); - at.addNext( element2 ); - listE.addCor( at, connector ); - connector.setAVATARID( at.getID() ); - asm.addElement( at ); - - // Check for after on composite transitions - if (at.hasDelay() && element1 instanceof AvatarState && asm.isACompositeTransition(at)) { - UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "After clause cannot be used on composite transitions. Use timers instead."); - // TODO: adapt - // ce.setAvatarBlock(_ab); - ce.setTDiagramPanel( asmdp ); - ce.setTGComponent( connector ); - addCheckingError( ce ); - } - } - } - } - } - } - } - } + for (TGComponent tgc: asmdp.getAllComponentList ()) + if (tgc instanceof AvatarSMDConnector) { + AvatarSMDConnector asmdco = (AvatarSMDConnector) tgc; + TGComponent tgc1 = tdp.getComponentToWhichBelongs (asmdco.getTGConnectingPointP1()); + TGComponent tgc2 = tdp.getComponentToWhichBelongs (asmdco.getTGConnectingPointP2()); + if (tgc1 == null || tgc2 == null) + TraceManager.addDev("Tgcs null in Avatar translation"); + else { + AvatarStateMachineElement element1 = (AvatarStateMachineElement)(listE.getObject(tgc1)); + AvatarStateMachineElement element2 = (AvatarStateMachineElement)(listE.getObject(tgc2)); + if (element1 != null && element2 != null) { + AvatarTransition at = new AvatarTransition (_ab, "avatar transition", tgc); + + // Guard + String tmp = modifyString (asmdco.getGuard()); + AvatarGuard guard = AvatarGuard.createFromString (_ab, tmp); + if (guard.isElseGuard()) + at.setGuard(guard); + else { + int error = AvatarSyntaxChecker.isAValidGuard (_as, _ab, tmp); + if (error < 0) + this.makeError (error, tdp, _ab, tgc, "transition guard", tmp); + else + at.setGuard (guard); + } + + // Delays + String tmp1 = modifyString (asmdco.getAfterMinDelay ()); + int error = AvatarSyntaxChecker.isAValidIntExpr (_as, _ab, tmp1); + if (error < 0) { + this.makeError (error, tdp, _ab, tgc, "after min delay", tmp1); + tmp1 = null; + } + String tmp2 = modifyString (asmdco.getAfterMaxDelay ()); + error = AvatarSyntaxChecker.isAValidIntExpr (_as, _ab, tmp2); + if (error < 0) { + this.makeError(error, tdp, _ab, tgc, "after max delay", tmp2); + tmp2 = null; + } + + if (tmp1 != null && tmp2 != null) + at.setDelays(tmp1, tmp2); + + // Compute min and max +// tmp1 = modifyString (asmdco.getComputeMinDelay ()); +// error = AvatarSyntaxChecker.isAValidIntExpr (_as, _ab, tmp1); +// if (error < 0) { +// this.makeError (error, tdp, _ab, tgc, "compute min ", tmp1); +// tmp1 = null; +// } +// tmp2 = modifyString(asmdco.getComputeMaxDelay()); +// error = AvatarSyntaxChecker.isAValidIntExpr(_as, _ab, tmp2); +// if (error < 0) { +// this.makeError (error, tdp, _ab, tgc, "compute max ", tmp2); +// tmp2 = null; +// } +// +// if (tmp1 != null && tmp2 != null) +// at.setComputes(tmp1, tmp2); + + // Probability + tmp1 = asmdco.getProbability (); + if ((tmp1 != null) && (tmp1.length()>0)) { + error = AvatarSyntaxChecker.isAValidProbabilityExpr(_as, _ab, tmp1); + if (error < 0) { + this.makeError(error, tdp, _ab, tgc, "probability ", tmp1); + tmp1 = null; + } + if (tmp1 != null) { + at.setProbability(new Double(tmp1).doubleValue()); + } + } + + // Actions + for(String s: asmdco.getActions()) + if (s.trim().length() > 0) { + s = modifyString(s.trim()); + + // Variable assignation or method call? + if (!isAVariableAssignation(s)) { + // Method call + int index2 = s.indexOf(";"); + if (index2 != -1) + this.makeError(error, tdp, _ab, tgc, "transition action", s); + + s = modifyStringMethodCall(s, _ab.getName()); + if (!AvatarBlock.isAValidMethodCall (_ab, s)) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed transition method call: " + s); + // TODO: adapt + // ce.setAvatarBlock(_ab); + ce.setTDiagramPanel(tdp); + ce.setTGComponent(tgc); + addCheckingError(ce); + } else + at.addAction(s); + } else { + // Variable assignation + error = AvatarSyntaxChecker.isAValidVariableExpr (_as, _ab, s); + if (error < 0) + this.makeError (error, tdp, _ab, tgc, "transition action", s); + else + at.addAction (s); + } + } + + element1.addNext (at); + at.addNext (element2); + this.listE.addCor (at, tgc); + tgc.setAVATARID (at.getID()); + asm.addElement (at); + + // Check for after on composite transitions + if (at.hasDelay() && element1 instanceof AvatarState && asm.isACompositeTransition(at)) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "After clause cannot be used on composite transitions. Use timers instead."); + // TODO: adapt + // ce.setAvatarBlock(_ab); + ce.setTDiagramPanel(tdp); + ce.setTGComponent(tgc); + addCheckingError(ce); + } + } + } + } asm.handleUnfollowedStartState(_ab); // Investigate all states -> put warnings for all empty transitions from a state to the same one (infinite loop) // int nb; - for (AvatarStateMachineElement asmee: asm.getListOfElements()) { + for (AvatarStateMachineElement asmee: asm.getListOfElements()) if (asmee instanceof AvatarState && ((AvatarState)asmee).hasEmptyTransitionsOnItself(asm) > 0) { UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "State(s) " + asmee.getName() + " has empty transitions on itself"); // TODO: adapt // ce.setAvatarBlock(_ab); - ce.setTDiagramPanel( asmdp ); + ce.setTDiagramPanel(tdp); ce.setTGComponent((TGComponent)(asmee.getReferenceObject())); addWarning(ce); } - } } private void makeError(int _error, TDiagramPanel _tdp, AvatarStateMachineOwner _ab, TGComponent _tgc, String _info, String _element) { @@ -2361,23 +2058,23 @@ public class AvatarDesignPanelTranslator { //TraceManager.addDev("Searching signal with name " + name1 + " in block " + b1.getName()); atas1 = b1.getAvatarSignalWithName(name1); atas2 = b2.getAvatarSignalWithName(name2); - - if ((atas1 != null) && (atas2 != null)) { - if(atas1.isCompatibleWith(atas2)) { - //TraceManager.addDev("Signals " + atas1 + " and " + atas2 + " are compatible"); - r.addSignals(atas1, atas2); - } else { - //TraceManager.addDev("Signals " + atas1 + " and " + atas2 + " are NOT compatible"); - UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Wrong signal association betwen " + atas1 + " and " + atas2); - // TODO: adapt - // ce.setAvatarBlock(_ab); - ce.setTDiagramPanel(tgc.getTDiagramPanel()); - ce.setTGComponent(tgc); - addCheckingError(ce); - } - } else { - TraceManager.addDev("Null signals in AVATAR relation: " + name1 + " " + name2); - } + if ((atas1 != null) && (atas2 != null)) { + if(atas1.isCompatibleWith(atas2)) { + //TraceManager.addDev("Signals " + atas1 + " and " + atas2 + " are compatible"); + r.addSignals(atas1, atas2); + } else { + //TraceManager.addDev("Signals " + atas1 + " and " + atas2 + " are NOT compatible"); + UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Wrong signal association betwen " + atas1 + " and " + atas2); + // TODO: adapt + // ce.setAvatarBlock(_ab); + ce.setTDiagramPanel(tgc.getTDiagramPanel()); + ce.setTGComponent(tgc); + addCheckingError(ce); + } + } else { + TraceManager.addDev("Null signals in AVATAR relation: " + name1 + " " + name2); + } + } // Attribute of the relation diff --git a/src/main/java/ui/CDElement.java b/src/main/java/ui/CDElement.java index d87b8033e0..3458d8766a 100755 --- a/src/main/java/ui/CDElement.java +++ b/src/main/java/ui/CDElement.java @@ -35,9 +35,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ + + + + package ui; + /** * Interface CDElement * Creation : 22/12/2003 @@ -50,21 +55,4 @@ public interface CDElement { int getWidth(); int getHeight(); String getName(); - - // Issue #69 - void acceptForward( ICDElementVisitor visitor ); - - void acceptBackward( ICDElementVisitor visitor ); - - boolean canBeDisabled(); - - void setEnabled( boolean _enabled ); - - void doSetEnabled( boolean _enabled ); - - boolean isEnabled(); - - boolean isEnabled( boolean checkBranch ); - - boolean canLabelBeDisabled( TGCOneLineText label ); } diff --git a/src/main/java/ui/CanBeDisabled.java b/src/main/java/ui/CanBeDisabled.java new file mode 100755 index 0000000000..e7261314e7 --- /dev/null +++ b/src/main/java/ui/CanBeDisabled.java @@ -0,0 +1,55 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + + +package ui; + +/** + * Class CanBeDisabled + * Components that can be enabled/disabled with a mouse click + * Creation: 22/04/2015 + * @version 1.0 22/04/2015 + * @author Ludovic APVRILLE + */ +public interface CanBeDisabled { + boolean isEnabled(); + void setEnabled(boolean _enabled); +} diff --git a/src/main/java/ui/ColorManager.java b/src/main/java/ui/ColorManager.java index e4a49c55fa..a454f3a88d 100755 --- a/src/main/java/ui/ColorManager.java +++ b/src/main/java/ui/ColorManager.java @@ -36,12 +36,16 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui; import myutil.GraphicLib; import java.awt.*; + /** * Class IconManager * Creation: 15/12/2003 @@ -52,11 +56,6 @@ public class ColorManager { public static final Color DEFAULT = Color.black; public static final Color NORMAL_0 = Color.black; - - // Issue #69: Disabling components in diagram - public static Color DISABLED = new Color(214, 206, 198); - public static Color DISABLED_FILLING = Color.WHITE; - public static final Color POINTER_ON_ME_0 = Color.red; public static final Color ACCESSIBILITY = Color.red; public static final Color ACCESSIBILITY_UNKNOWN = Color.DARK_GRAY; @@ -150,20 +149,14 @@ public class ColorManager { //public static Color ATD_BLOCK = new Color(196, 232, 195); public static Color ATD_BLOCK = new Color(218, 218, 218); public static Color ATD_ATTACK = new Color(214, 187, 158); - - // Issue # 69: Using default disabled color - //public static Color ATD_ATTACK_DISABLED = new Color(214, 206, 198); - + public static Color ATD_ATTACK_DISABLED = new Color(214, 206, 198); public static Color ATD_ROOT_ATTACK = new Color(243, 131, 10); public static Color ATD_CONSTRAINT = new Color(191, 153, 161); public static Color ATD_COUNTERMEASURE = new Color(209, 218, 174); public static Color FTD_BLOCK = new Color(218, 218, 218); public static Color FTD_FAULT = new Color(214, 187, 158); - - // Issue # 69: Using default disabled color - // public static Color FTD_FAULT_DISABLED = new Color(214, 206, 198); - + public static Color FTD_FAULT_DISABLED = new Color(214, 206, 198); public static Color FTD_ROOT_FAULT = new Color(243, 131, 10); public static Color FTD_CONSTRAINT = new Color(191, 153, 161); public static Color FTD_COUNTERMEASURE = new Color(209, 218, 174); @@ -229,52 +222,37 @@ public class ColorManager { public static final Color InteractiveSimulationText_TERM = new Color(241, 6, 6); public static final Color InteractiveSimulationText_UNKNOWN = new Color(6, 6, 241); - // Issue #69: Managing color for disabled diagram components - public final static void setColor( Graphics g, - int state, - int type ) { - setColor( g, state, type, true ); - } - - public final static void setColor( Graphics g, - int state, - int type, - boolean enabled ) { + public final static void setColor(Graphics g, int state, int type) { if (type == 0) { - if ( !enabled ) { - g.setColor( DISABLED ); - } - else { - switch(state) { - case 0: - g.setColor(NORMAL_0); - break; - case 1: - g.setColor(POINTER_ON_ME_0); - GraphicLib.setMediumStroke(g); - break; - case 2: - g.setColor(SELECTED_0); - break; - case 3: - g.setColor(MOVING_0); - break; - case 4: - g.setColor(ADDING_0); - break; - case 5: - g.setColor(POINTED_0); - break; - case 6: - g.setColor(RESIZE_POINTED); - break; - case 7: - g.setColor(RESIZE_POINTED); - break; - default: - g.setColor(DEFAULT); - } - } + switch(state) { + case 0: + g.setColor(NORMAL_0); + break; + case 1: + g.setColor(POINTER_ON_ME_0); + GraphicLib.setMediumStroke(g); + break; + case 2: + g.setColor(SELECTED_0); + break; + case 3: + g.setColor(MOVING_0); + break; + case 4: + g.setColor(ADDING_0); + break; + case 5: + g.setColor(POINTED_0); + break; + case 6: + g.setColor(RESIZE_POINTED); + break; + case 7: + g.setColor(RESIZE_POINTED); + break; + default: + g.setColor(DEFAULT); + } } } @@ -320,8 +298,10 @@ public class ColorManager { AVATAR_RECEIVE_SIGNAL = Color.white; AVATAR_ASSUMPTION_ATTRIBUTES = Color.white; AVATAR_ASSUMPTION_TOP = Color.white; - SYSMLSEC_PARTITIONING = Color.white; - SYSMLSEC_SWDESIGN = Color.white; - SYSMLSEC_REQ = Color.white; + SYSMLSEC_PARTITIONING = Color.white; + SYSMLSEC_SWDESIGN = Color.white; + SYSMLSEC_REQ = Color.white; + } + } // Class Color diff --git a/src/main/java/ui/Expression.java b/src/main/java/ui/Expression.java deleted file mode 100644 index 08cf3df2c6..0000000000 --- a/src/main/java/ui/Expression.java +++ /dev/null @@ -1,69 +0,0 @@ -package ui; - -public class Expression { - - private String text; - - private final String nullText; - - private final String label; - - private boolean enabled; - - public Expression( final String text ) { - this( text, null, null ); - } - - public Expression( final String text, - final String nullText, - final String label ) { - this.text = text; - this.nullText = nullText; - this.label = label; - this.enabled = true; - } -// -// public Expression( final String text, -// final boolean enabled, -// final String nullText ) { -// } - - public String getText() { - return text; - } - - public void setText( String text ) { - this.text = text; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public String getEffectiveExpression( final String defaultExpr ) { - return isEnabled() ? getText() : defaultExpr; - } - - public boolean isNull() { - if ( nullText == null ) { - return getText() == null; - } - - return nullText.equals( getText() ); - } - - @Override - public String toString() { - final String text = isNull() ? "null" : getText(); - - return label == null ? text : String.format( label, text ); - } - - public String getLabel() { - return label; - } -} diff --git a/src/main/java/ui/FindNextEnabledConnectingPointVisitor.java b/src/main/java/ui/FindNextEnabledConnectingPointVisitor.java deleted file mode 100644 index 32c0a42e98..0000000000 --- a/src/main/java/ui/FindNextEnabledConnectingPointVisitor.java +++ /dev/null @@ -1,71 +0,0 @@ -package ui; - -import java.util.Set; - -public class FindNextEnabledConnectingPointVisitor extends TrackingCDElementVisitor { - - private final Set<TGConnector> disabledConnectors; - - private TGConnectingPoint enabledConnectingPoint; - - private TGConnectingPoint previousEnabledConnectingPoint; - - public FindNextEnabledConnectingPointVisitor( final Set<TGConnector> disabledConnectors ) { - super(); - - this.disabledConnectors = disabledConnectors; - enabledConnectingPoint = null; - } - - @Override - public boolean visit( final CDElement element ) { - if ( !super.visit( element ) ) { - return false; - } - - if ( element instanceof TGConnector ) { - final TGConnector connector = (TGConnector) element; - - if ( pruneConnector( connector ) ) { - disabledConnectors.add( (TGConnector) element ); - - return true; - } - - enabledConnectingPoint = previousEnabledConnectingPoint; - - return false; - } - - if ( element instanceof TGConnectingPoint ) { - final TGConnectingPoint point = (TGConnectingPoint) element; - final CDElement father = point.getFather(); - previousEnabledConnectingPoint = point; - - if ( !pruneElement( father ) ) { - enabledConnectingPoint = point; - - return false; - } - } - - return true; - } - - protected boolean pruneElement( final CDElement diagramElement ) { - return !diagramElement.isEnabled() || !( diagramElement instanceof TGComponent ) || diagramElement instanceof TGConnector; - } - - - protected boolean pruneConnector( final TGConnector connector ) { - return true; - } - - public TGConnectingPoint getEnabledComponentPoint() { - return enabledConnectingPoint; - } - - public Set<TGConnector> getDisabledConnectors() { - return disabledConnectors; - } -} diff --git a/src/main/java/ui/ForwardComponentsEnabledVisitor.java b/src/main/java/ui/ForwardComponentsEnabledVisitor.java deleted file mode 100644 index 21f28cb74f..0000000000 --- a/src/main/java/ui/ForwardComponentsEnabledVisitor.java +++ /dev/null @@ -1,31 +0,0 @@ -package ui; - -public class ForwardComponentsEnabledVisitor extends TrackingCDElementVisitor { - - private boolean enabled; - - public ForwardComponentsEnabledVisitor() { - super(); - - enabled = true; - } - - @Override - public boolean visit(CDElement element) { - if ( !super.visit( element ) ) { - return false; - } - - if ( element.canBeDisabled() && !( element instanceof TGConnector ) ) { - enabled = element.isEnabled(); - - return false; - } - - return true; - } - - public boolean isEnabled() { - return enabled; - } -} diff --git a/src/main/java/ui/GNCModeling.java b/src/main/java/ui/GNCModeling.java index e470accc10..368b47c251 100755 --- a/src/main/java/ui/GNCModeling.java +++ b/src/main/java/ui/GNCModeling.java @@ -36,6 +36,10 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + + package ui; import myutil.TreeCell; @@ -45,7 +49,6 @@ import ui.ncdd.*; import java.util.ArrayList; import java.util.LinkedList; -import java.util.List; import java.util.ListIterator; /** @@ -61,14 +64,16 @@ public class GNCModeling { private NCDiagramPanel ncdp; private LinkedList<CheckingError> checkingErrors, warnings; private CorrespondanceTGElement listE; - //private NCStructure nc; + private NCStructure nc; private static int PATH_INDEX = 0; - + + public GNCModeling(NCPanel _ncp) { ncp = _ncp; ncdp = ncp.ncdp; } + public NCStructure translateToNCStructure() { PATH_INDEX = 0; @@ -88,6 +93,8 @@ public class GNCModeling { manageParameters(); } + // + return ncs; } @@ -95,7 +102,8 @@ public class GNCModeling { return listE; } - public List<CheckingError> getCheckingErrors() { + + public LinkedList<CheckingError> getCheckingErrors() { return checkingErrors; } @@ -104,16 +112,16 @@ public class GNCModeling { } private void addEquipments() { - ListIterator<NCEqNode> iterator = ncdp.getListOfEqNode().listIterator(); + ListIterator iterator = ncdp.getListOfEqNode().listIterator(); NCEqNode node; NCEquipment eq; - // NCConnectorNode con; - //int cpt; + NCConnectorNode con; + int cpt; while(iterator.hasNext()) { - node = iterator.next(); + node = (NCEqNode)(iterator.next()); // Find the only interface of that Equipment // If more than one interface -> error @@ -155,13 +163,13 @@ public class GNCModeling { } private void addSwitches() { - ListIterator<NCSwitchNode> iterator = ncdp.getListOfSwitchNode().listIterator(); + ListIterator iterator = ncdp.getListOfSwitchNode().listIterator(); NCSwitchNode node; NCSwitch sw; NCCapacityUnit unit = new NCCapacityUnit(); while(iterator.hasNext()) { - node = iterator.next(); + node = (NCSwitchNode)(iterator.next()); sw= new NCSwitch(); sw.setName(node.getNodeName()); @@ -176,13 +184,13 @@ public class GNCModeling { } private void addTraffics() { - ListIterator<NCTrafficArtifact> iterator = ncdp.getTrafficArtifacts().listIterator(); + ListIterator iterator = ncdp.getTrafficArtifacts().listIterator(); NCTrafficArtifact arti; NCTraffic tr; NCTimeUnit unit; while(iterator.hasNext()) { - arti = iterator.next(); + arti = (NCTrafficArtifact)(iterator.next()); tr = new NCTraffic(); tr.setName(arti.getValue()); tr.setPeriodicType(arti.getPeriodicType()); @@ -202,9 +210,9 @@ public class GNCModeling { } private void addLinks() { - ListIterator<NCConnectorNode> iterator = ncdp.getListOfLinks().listIterator(); + ListIterator iterator = ncdp.getListOfLinks().listIterator(); NCConnectorNode nccn; - NCLink lk = null;//, lkr; + NCLink lk = null, lkr; boolean added; TGComponent tgc; TGConnectingPoint tp; @@ -215,7 +223,7 @@ public class GNCModeling { while(iterator.hasNext()) { added = false; - nccn = iterator.next(); + nccn = (NCConnectorNode)(iterator.next()); if (ncdp.isALinkBetweenEquipment(nccn)) { UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Link connected between two equipments: " + nccn.getInterfaceName()); @@ -297,24 +305,19 @@ public class GNCModeling { nccu.setUnit(nccn.getCapacityUnit()); lk.setCapacityUnit(nccu); } else { - if (switch1 == null && switch2 != null ) { + if (switch1 == null) { lk.setCapacity(switch2.getCapacity()); nccu = new NCCapacityUnit(); nccu.setUnit(switch2.getCapacityUnit()); lk.setCapacityUnit(nccu); } - // DB: Seems to be a bug... - else if (switch2 == null && switch1 != null ) { + if (switch2 == null) { lk.setCapacity(switch1.getCapacity()); nccu = new NCCapacityUnit(); - - // DB looks like a copy paste error - nccu.setUnit(switch1.getCapacityUnit()); -// nccu.setUnit(switch2.getCapacityUnit()); + nccu.setUnit(switch2.getCapacityUnit()); lk.setCapacityUnit(nccu); } - else { - //if ((switch1 != null) && (switch2 != null)) { + if ((switch1 != null) && (switch2 != null)) { if (switch1.getCapacity() != switch2.getCapacity()) { UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Link with no capacity between two switches of different capacity: " + nccn.getInterfaceName()); ce.setTDiagramPanel(ncdp); @@ -354,18 +357,18 @@ public class GNCModeling { // Consider each traffic // For each traffic, its builds a tree // Then, its generates the corresponding paths - ListIterator<NCTrafficArtifact> iterator = ncdp.getTrafficArtifacts().listIterator(); + ListIterator iterator = ncdp.getTrafficArtifacts().listIterator(); NCTrafficArtifact arti; NCTraffic tr; TreeCell tree; int ret; - //NCPath path; + NCPath path; NCEqNode node; NCEquipment eq; - List<String> list; + ArrayList<String> list; while(iterator.hasNext()) { - arti = iterator.next(); + arti = (NCTrafficArtifact)(iterator.next()); tr = ncs.getTrafficByName(arti.getValue()); if (tr == null) { @@ -396,7 +399,7 @@ public class GNCModeling { } } - private void exploreTree(TreeCell tree, List<String> list, NCEquipment origin, NCTraffic traffic) { + public void exploreTree(TreeCell tree, ArrayList<String> list, NCEquipment origin, NCTraffic traffic) { NCSwitchNode sw; NCSwitch ncsw; NCLinkedElement ncle; @@ -502,7 +505,7 @@ public class GNCModeling { // Find the only interface of that Equipment // If more than one interface -> error - List<NCSwitchNode> listsw = ncdp.getSwitchesOfEq(node); + ArrayList<NCSwitchNode> listsw = ncdp.getSwitchesOfEq(node); if (listsw.size() == 0) { UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Equipment " + node.getName() + " has non interface: traffic " + arti.getValue() + " cannot be sent over the network"); @@ -566,10 +569,10 @@ public class GNCModeling { TreeCell cell; NCConnectorNode nextArriving; - List<NCRoute> computed = new ArrayList<NCRoute>(); + ArrayList<NCRoute> computed = new ArrayList<NCRoute>(); // Get all routes concerning that traffic on that switch - List<NCRoute> routes = ncdp.getAllRoutesFor(sw, arti); + ArrayList<NCRoute> routes = ncdp.getAllRoutesFor(sw, arti); // @@ -700,9 +703,9 @@ public class GNCModeling { } public void manageParameters() { - //ListIterator iterator; + ListIterator iterator; NCEqNode node1, node2; - List<NCConnectorNode> cons1, cons2; + ArrayList<NCConnectorNode> cons1, cons2; NCConnectorNode con1, con2; int i; int parameter1, parameter2; @@ -713,14 +716,14 @@ public class GNCModeling { //NCPath path1; //ArrayList<NCEquipment> newEquipments = new ArrayList<NCEquipment>(); - //List<NCTraffic> newTraffics = new ArrayList<NCTraffic>(); - //List<NCLink> newLinks = new ArrayList<NCLink>(); - List<NCPath> newPaths = new ArrayList<NCPath>(); + ArrayList<NCTraffic> newTraffics = new ArrayList<NCTraffic>(); + ArrayList<NCLink> newLinks = new ArrayList<NCLink>(); + ArrayList<NCPath> newPaths = new ArrayList<NCPath>(); - List<NCEquipment> oldEquipments = new ArrayList<NCEquipment>(); - List<NCTraffic> oldTraffics = new ArrayList<NCTraffic>(); - List<NCLink> oldLinks = new ArrayList<NCLink>(); - List<NCPath> oldPaths = new ArrayList<NCPath>(); + ArrayList<NCEquipment> oldEquipments = new ArrayList<NCEquipment>(); + ArrayList<NCTraffic> oldTraffics = new ArrayList<NCTraffic>(); + ArrayList<NCLink> oldLinks = new ArrayList<NCLink>(); + ArrayList<NCPath> oldPaths = new ArrayList<NCPath>(); // Are there any path to duplicate? for(NCPath path: ncs.paths) { @@ -859,4 +862,5 @@ public class GNCModeling { cpt ++; } } + } diff --git a/src/main/java/ui/GTMLModeling.java b/src/main/java/ui/GTMLModeling.java index f3d8a5b441..ea8fa2e367 100755 --- a/src/main/java/ui/GTMLModeling.java +++ b/src/main/java/ui/GTMLModeling.java @@ -38,103 +38,35 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui; -import java.awt.Point; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Vector; +package ui; import avatartranslator.AvatarSpecification; +import myutil.Conversion; import myutil.TraceManager; -import tmltranslator.HwA; -import tmltranslator.HwBridge; -import tmltranslator.HwBus; -import tmltranslator.HwCPU; -import tmltranslator.HwCommunicationNode; -import tmltranslator.HwCrossbar; -import tmltranslator.HwDMA; -import tmltranslator.HwExecutionNode; -import tmltranslator.HwFPGA; -import tmltranslator.HwLink; -import tmltranslator.HwMemory; -import tmltranslator.HwNode; -import tmltranslator.HwVGMN; -import tmltranslator.SecurityPattern; -import tmltranslator.TMLActivity; -import tmltranslator.TMLActivityElement; -import tmltranslator.TMLActivityElementChannel; -import tmltranslator.TMLArchitecture; -import tmltranslator.TMLAttribute; -import tmltranslator.TMLCP; -import tmltranslator.TMLCPError; -import tmltranslator.TMLCPLib; -import tmltranslator.TMLCPLibArtifact; -import tmltranslator.TMLCPSyntaxChecking; -import tmltranslator.TMLChannel; -import tmltranslator.TMLCheckingError; -import tmltranslator.TMLElement; -import tmltranslator.TMLError; -import tmltranslator.TMLEvent; -import tmltranslator.TMLExecI; -import tmltranslator.TMLMapping; -import tmltranslator.TMLModeling; -import tmltranslator.TMLPort; -import tmltranslator.TMLRequest; -import tmltranslator.TMLSyntaxChecking; -import tmltranslator.TMLTask; -import tmltranslator.TMLType; +import tmltranslator.*; import tmltranslator.modelcompiler.ArchUnitMEC; import tmltranslator.tmlcp.TMLCPElement; import tmltranslator.tmlcp.TMLSDAction; import tmltranslator.tmlcp.TMLSDEvent; import tmltranslator.tmlcp.TMLSDMessage; import translator.CheckingError; -import ui.tmlad.TMLADEncrypt; -import ui.tmlad.TMLADReadChannel; -import ui.tmlad.TMLADWriteChannel; -import ui.tmlad.TMLActivityDiagramPanel; +import ui.tmlad.*; import ui.tmlcd.TMLChannelOperator; import ui.tmlcd.TMLEventOperator; import ui.tmlcd.TMLRequestOperator; import ui.tmlcd.TMLTaskOperator; -import ui.tmlcompd.TMLCChannelOutPort; -import ui.tmlcompd.TMLCFork; -import ui.tmlcompd.TMLCJoin; -import ui.tmlcompd.TMLCPath; -import ui.tmlcompd.TMLCPortConnector; -import ui.tmlcompd.TMLCPrimitiveComponent; -import ui.tmlcompd.TMLCPrimitivePort; -import ui.tmlcompd.TMLCRecordComponent; -import ui.tmldd.TMLArchiArtifact; -import ui.tmldd.TMLArchiBUSNode; -import ui.tmldd.TMLArchiBridgeNode; -import ui.tmldd.TMLArchiCPNode; -import ui.tmldd.TMLArchiCPUNode; -import ui.tmldd.TMLArchiCommunicationArtifact; -import ui.tmldd.TMLArchiCommunicationNode; -import ui.tmldd.TMLArchiConnectorNode; -import ui.tmldd.TMLArchiCrossbarNode; -import ui.tmldd.TMLArchiDMANode; -import ui.tmldd.TMLArchiEventArtifact; -import ui.tmldd.TMLArchiFPGANode; -import ui.tmldd.TMLArchiFirewallNode; -import ui.tmldd.TMLArchiHWANode; -import ui.tmldd.TMLArchiKey; -import ui.tmldd.TMLArchiMemoryNode; -import ui.tmldd.TMLArchiNode; -import ui.tmldd.TMLArchiPortArtifact; -import ui.tmldd.TMLArchiVGMNNode; +import ui.tmlcompd.*; +import ui.tmldd.*; import ui.tmlsd.TGConnectorMessageTMLSD; import ui.tmlsd.TMLSDControllerInstance; import ui.tmlsd.TMLSDStorageInstance; import ui.tmlsd.TMLSDTransferInstance; +import java.awt.*; +import java.util.*; +import java.util.List; + /** * Class GTMLModeling * Use to translate graphical TML modeling to "tmlmodeling" @@ -1663,7 +1595,7 @@ public class GTMLModeling { } else { // Adding all elements of record //TraceManager.addDev("Found a record named: " + rc.getValue()); - List<TAttribute> attr = rc.getAttributes(); + LinkedList<TAttribute> attr = rc.getAttributes(); for (TAttribute tat : attr) { if (tat.getType() == TAttribute.NATURAL) { tt = new TMLType(TMLType.NATURAL); @@ -1722,873 +1654,860 @@ public class GTMLModeling { while (iterator.hasNext()) { tmltask = iterator.next(); - - // Issue #69: Component disabling - ActivityDiagram2TMLTranslator.INSTANCE.generateTaskActivityDiagrams( tmltask, - checkingErrors, - warnings, - listE, - tmlm, - securityPatterns, - table, - removedChannels, - removedEvents, - removedRequests ); -// generateTaskActivityDiagrams(tmltask); + generateTaskActivityDiagrams(tmltask); } //TraceManager.addDev( "errors: " + checkingErrors.size() ); if (checkingErrors.size() > 0) { throw new MalformedTMLDesignException("Error(s) found in activity diagrams"); } } -// -// private String modifyActionString(String _input) { -// int index = _input.indexOf("++"); -// boolean b1, b2; -// String tmp; -// -// if (index > -1) { -// tmp = _input.substring(0, index).trim(); -// -// b1 = (tmp.substring(0, 1)).matches("[a-zA-Z]"); -// b2 = tmp.matches("\\w*"); -// if (b1 && b2) { -// return tmp + " = " + tmp + " + 1"; -// } -// } -// -// index = _input.indexOf("--"); -// if (index > -1) { -// tmp = _input.substring(0, index).trim(); -// -// b1 = (tmp.substring(0, 1)).matches("[a-zA-Z]"); -// b2 = tmp.matches("\\w*"); -// if (b1 && b2) { -// return tmp + " = " + tmp + " - 1"; -// } -// } -// -// return modifyString(_input); -// } -// -// private String modifyString(String _input) { -// return Conversion.replaceAllChar(_input, '.', "__"); -// } - - // Issue #69: Moved to class ActivityDiagram2TMLTranslator -// private void generateTaskActivityDiagrams(TMLTask tmltask) throws MalformedTMLDesignException { -// TMLActivity activity = tmltask.getActivityDiagram(); -// TMLActivityDiagramPanel tadp = (TMLActivityDiagramPanel) (activity.getReferenceObject()); -// -// //TraceManager.addDev("Generating activity diagram of:" + tmltask.getName()); -// -// // search for start state -// List<TGComponent> list = tadp.getComponentList(); -// Iterator<TGComponent> iterator = list.listIterator(); -// TGComponent tgc; -// TMLADStartState tss = null; -// int cptStart = 0; -// // boolean rndAdded = false; -// -// while (iterator.hasNext()) { -// tgc = iterator.next(); -// -// if (tgc instanceof TMLADStartState) { -// tss = (TMLADStartState) tgc; -// cptStart++; -// } -// } -// -// if (tss == null) { -// TMLCheckingError ce = new TMLCheckingError(CheckingError.BEHAVIOR_ERROR, "No start state in the TML activity diagram of " + tmltask.getName()); -// ce.setTMLTask(tmltask); -// checkingErrors.add(ce); -// return; -// } -// -// if (cptStart > 1) { -// TMLCheckingError ce = new TMLCheckingError(CheckingError.BEHAVIOR_ERROR, "More than one start state in the TML activity diagram of " + tmltask.getName()); -// ce.setTMLTask(tmltask); -// checkingErrors.add(ce); -// return; -// } -// -// // Adding start state -// TMLStartState tmlss = new TMLStartState("start", tss); -// listE.addCor(tmlss, tss); -// activity.setFirst(tmlss); -// -// // Creation of other elements -// TMLChannel channel; -// String[] channels; -// TMLEvent event; -// TMLRequest request; -// -// TMLADRandom tmladrandom; -// TMLRandom tmlrandom; -// TMLActionState tmlaction; -// TMLChoice tmlchoice; -// TMLExecI tmlexeci; -// TMLExecIInterval tmlexecii; -// TMLExecC tmlexecc; -// TMLExecCInterval tmlexecci; -// TMLForLoop tmlforloop; -// TMLReadChannel tmlreadchannel; -// TMLSendEvent tmlsendevent; -// TMLSendRequest tmlsendrequest; -// TMLStopState tmlstopstate; -// TMLWaitEvent tmlwaitevent; -// TMLNotifiedEvent tmlnotifiedevent; -// TMLWriteChannel tmlwritechannel; -// TMLSequence tmlsequence; -// TMLRandomSequence tmlrsequence; -// TMLSelectEvt tmlselectevt; -// TMLDelay tmldelay; -// int staticLoopIndex = 0; -// String sl = "", tmp; -// TMLType tt; -// TMLAttribute tmlt; -// -// iterator = list.listIterator(); -// while (iterator.hasNext()) { -// tgc = iterator.next(); -// if (tgc.getCheckLatency()) { -// String name = tmltask.getName() + ":" + tgc.getName(); -// name = name.replaceAll(" ", ""); -// //TraceManager.addDev("To check " + name); -// if (tgc.getValue().contains("(")) { -// tmlm.addCheckedActivity(tgc, name + ":" + tgc.getValue().split("\\(")[0]); -// } else { -// if (tgc instanceof TMLADExecI) { -// tmlm.addCheckedActivity(tgc, ((TMLADExecI) tgc).getDelayValue()); -// } -// } -// } -// if (tgc instanceof TMLADActionState) { -// tmlaction = new TMLActionState("action", tgc); -// tmp = ((TMLADActionState) (tgc)).getAction(); -// tmp = modifyActionString(tmp); -// tmlaction.setAction(tmp); -// activity.addElement(tmlaction); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlaction, tgc); -// -// } else if (tgc instanceof TMLADRandom) { -// tmladrandom = (TMLADRandom) tgc; -// tmlrandom = new TMLRandom("random" + tmladrandom.getValue(), tgc); -// tmp = tmladrandom.getVariable(); -// tmp = modifyActionString(tmp); -// tmlrandom.setVariable(tmp); -// tmp = tmladrandom.getMinValue(); -// tmp = modifyActionString(tmp); -// tmlrandom.setMinValue(tmp); -// tmp = tmladrandom.getMaxValue(); -// tmp = modifyActionString(tmp); -// tmlrandom.setMaxValue(tmp); -// tmlrandom.setFunctionId(tmladrandom.getFunctionId()); -// activity.addElement(tmlrandom); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlrandom, tgc); -// -// } else if (tgc instanceof TMLADChoice) { -// tmlchoice = new TMLChoice("choice", tgc); -// // Guards are added at the same time as next activities -// activity.addElement(tmlchoice); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlchoice, tgc); -// -// } else if (tgc instanceof TMLADSelectEvt) { -// tmlselectevt = new TMLSelectEvt("select", tgc); -// activity.addElement(tmlselectevt); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlselectevt, tgc); -// -// } else if (tgc instanceof TMLADExecI) { -// tmlexeci = new TMLExecI("execi", tgc); -// tmlexeci.setAction(modifyString(((TMLADExecI) tgc).getDelayValue())); -// tmlexeci.setValue(((TMLADExecI) tgc).getDelayValue()); -// activity.addElement(tmlexeci); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlexeci, tgc); -// -// } else if (tgc instanceof TMLADExecIInterval) { -// tmlexecii = new TMLExecIInterval("execi", tgc); -// tmlexecii.setValue(tgc.getValue()); -// tmlexecii.setMinDelay(modifyString(((TMLADExecIInterval) tgc).getMinDelayValue())); -// tmlexecii.setMaxDelay(modifyString(((TMLADExecIInterval) tgc).getMaxDelayValue())); -// activity.addElement(tmlexecii); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlexecii, tgc); -// -// } else if (tgc instanceof TMLADEncrypt) { -// tmlexecc = new TMLExecC("encrypt_" + ((TMLADEncrypt) tgc).securityContext, tgc); -// activity.addElement(tmlexecc); -// SecurityPattern sp = securityPatterns.get(((TMLADEncrypt) tgc).securityContext); -// if (sp == null) { -// //Throw error for missing security pattern -// UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADEncrypt) tgc).securityContext + " not found"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } else { -// tmlexecc.securityPattern = sp; -// tmlexecc.setAction(Integer.toString(sp.encTime)); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// tmlm.securityTaskMap.get(sp).add(tmltask); -// listE.addCor(tmlexecc, tgc); -// } -// } else if (tgc instanceof TMLADDecrypt) { -// tmlexecc = new TMLExecC("decrypt_" + ((TMLADDecrypt) tgc).securityContext, tgc); -// activity.addElement(tmlexecc); -// SecurityPattern sp = securityPatterns.get(((TMLADDecrypt) tgc).securityContext); -// if (sp == null) { -// //Throw error for missing security pattern -// UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADDecrypt) tgc).securityContext + " not found"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } else { -// tmlexecc.securityPattern = sp; -// tmlexecc.setAction(Integer.toString(sp.decTime)); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlexecc, tgc); -// tmlm.securityTaskMap.get(sp).add(tmltask); -// } -// -// } else if (tgc instanceof TMLADExecC) { -// tmlexecc = new TMLExecC("execc", tgc); -// tmlexecc.setValue(((TMLADExecC) tgc).getDelayValue()); -// tmlexecc.setAction(modifyString(((TMLADExecC) tgc).getDelayValue())); -// activity.addElement(tmlexecc); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlexecc, tgc); -// -// } else if (tgc instanceof TMLADExecCInterval) { -// tmlexecci = new TMLExecCInterval("execci", tgc); -// tmlexecci.setMinDelay(modifyString(((TMLADExecCInterval) tgc).getMinDelayValue())); -// tmlexecci.setMaxDelay(modifyString(((TMLADExecCInterval) tgc).getMaxDelayValue())); -// activity.addElement(tmlexecci); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlexecci, tgc); -// -// } else if (tgc instanceof TMLADDelay) { -// tmldelay = new TMLDelay("d-delay", tgc); -// tmldelay.setMinDelay(modifyString(((TMLADDelay) tgc).getDelayValue())); -// tmldelay.setMaxDelay(modifyString(((TMLADDelay) tgc).getDelayValue())); -// tmldelay.setUnit(((TMLADDelay) tgc).getUnit()); -// activity.addElement(tmldelay); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmldelay, tgc); -// -// } else if (tgc instanceof TMLADDelayInterval) { -// tmldelay = new TMLDelay("nd-delay", tgc); -// tmldelay.setMinDelay(modifyString(((TMLADDelayInterval) tgc).getMinDelayValue())); -// tmldelay.setMaxDelay(modifyString(((TMLADDelayInterval) tgc).getMaxDelayValue())); -// tmldelay.setUnit(((TMLADDelayInterval) tgc).getUnit()); -// activity.addElement(tmldelay); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmldelay, tgc); -// -// } else if (tgc instanceof TMLADForLoop) { -// tmlforloop = new TMLForLoop("loop", tgc); -// tmlforloop.setInit(modifyString(((TMLADForLoop) tgc).getInit())); -// tmp = ((TMLADForLoop) tgc).getCondition(); -// /*if (tmp.trim().length() == 0) { -// tmp = "true"; -// }*/ -// tmlforloop.setCondition(modifyString(tmp)); -// tmlforloop.setIncrement(modifyActionString(((TMLADForLoop) tgc).getIncrement())); -// -// activity.addElement(tmlforloop); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlforloop, tgc); -// -// } else if (tgc instanceof TMLADForStaticLoop) { -// sl = "loop__" + staticLoopIndex; -// tt = new TMLType(TMLType.NATURAL); -// tmlt = new TMLAttribute(sl, tt); -// tmlt.initialValue = "0"; -// tmltask.addAttribute(tmlt); -// tmlforloop = new TMLForLoop(sl, tgc); -// tmlforloop.setInit(sl + " = 0"); -// tmlforloop.setCondition(sl + "<" + modifyString(tgc.getValue())); -// tmlforloop.setIncrement(sl + " = " + sl + " + 1"); -// activity.addElement(tmlforloop); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlforloop, tgc); -// staticLoopIndex++; -// -// } else if (tgc instanceof TMLADForEverLoop) { -// /*sl = "loop__" + staticLoopIndex; -// tt = new TMLType(TMLType.NATURAL); -// tmlt = new TMLAttribute(sl, tt); -// tmlt.initialValue = "0"; -// tmltask.addAttribute(tmlt);*/ -// tmlforloop = new TMLForLoop("infiniteloop", tgc); -// tmlforloop.setInit(""); -// tmlforloop.setCondition(""); -// tmlforloop.setIncrement(""); -// tmlforloop.setInfinite(true); -// activity.addElement(tmlforloop); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlforloop, tgc); -// staticLoopIndex++; -// -// tmlstopstate = new TMLStopState("Stop after infinite loop", null); -// activity.addElement(tmlstopstate); -// tmlforloop.addNext(tmlstopstate); -// -// } else if (tgc instanceof TMLADSequence) { -// tmlsequence = new TMLSequence("seq", tgc); -// activity.addElement(tmlsequence); -// listE.addCor(tmlsequence, tgc); -// -// } else if (tgc instanceof TMLADUnorderedSequence) { -// tmlrsequence = new TMLRandomSequence("rseq", tgc); -// activity.addElement(tmlrsequence); -// listE.addCor(tmlrsequence, tgc); -// -// } else if (tgc instanceof TMLADReadChannel) { -// // Get the channel -// //TMLADReadChannel rd = (TMLADReadChannel) tgc; -// channel = tmlm.getChannelByName(getFromTable(tmltask, ((TMLADReadChannel) tgc).getChannelName())); -// /*if (rd.isAttacker()){ -// channel = tmlm.getChannelByName(getAttackerChannel(((TMLADReadChannel)tgc).getChannelName())); -// }*/ -// if (channel == null) { -// if (Conversion.containsStringInList(removedChannels, ((TMLADReadChannel) tgc).getChannelName())) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADReadChannel) tgc).getChannelName() + " has been removed because the corresponding channel is not taken into account"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// warnings.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// activity.addElement(new TMLJunction("void junction", tgc)); -// } else { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADReadChannel) tgc).getChannelName() + " is an unknown channel"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// checkingErrors.add(ce); -// } -// -// } else { -// tmlreadchannel = new TMLReadChannel("read channel", tgc); -// tmlreadchannel.setNbOfSamples(modifyString(((TMLADReadChannel) tgc).getSamplesValue())); -// tmlreadchannel.setEncForm(((TMLADReadChannel) tgc).getEncForm()); -// tmlreadchannel.addChannel(channel); -// //security pattern -// if (securityPatterns.get(((TMLADReadChannel) tgc).getSecurityContext()) != null) { -// tmlreadchannel.securityPattern = securityPatterns.get(((TMLADReadChannel) tgc).getSecurityContext()); -// //NbOfSamples will increase due to extra overhead from MAC -// int cur = 1; -// try { -// cur = Integer.valueOf(modifyString(((TMLADReadChannel) tgc).getSamplesValue())); -// } catch (NumberFormatException e) { -// } catch (NullPointerException e) { -// } -// int add = Integer.valueOf(tmlreadchannel.securityPattern.overhead); -// if (!tmlreadchannel.securityPattern.nonce.equals("")) { -// SecurityPattern nonce = securityPatterns.get(tmlreadchannel.securityPattern.nonce); -// if (nonce != null) { -// add = Integer.valueOf(nonce.overhead); -// } -// } -// cur = cur + add; -// tmlreadchannel.setNbOfSamples(Integer.toString(cur)); -// } else if (!((TMLADReadChannel) tgc).getSecurityContext().isEmpty()) { -// //Throw error for missing security pattern -// UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADReadChannel) tgc).getSecurityContext() + " not found"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } -// if (tmltask.isAttacker()) { -// tmlreadchannel.setAttacker(true); -// } -// activity.addElement(tmlreadchannel); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlreadchannel, tgc); -// } -// } else if (tgc instanceof TMLADSendEvent) { -// event = tmlm.getEventByName(getFromTable(tmltask, ((TMLADSendEvent) tgc).getEventName())); -// if (event == null) { -// if (Conversion.containsStringInList(removedEvents, ((TMLADSendEvent) tgc).getEventName())) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADSendEvent) tgc).getEventName() + " has been removed because the corresponding event is not taken into account"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// warnings.add(ce); -// activity.addElement(new TMLJunction("void junction", tgc)); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } else { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendEvent) tgc).getEventName() + " is an unknown event"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } -// } else { -// tmlsendevent = new TMLSendEvent("send event", tgc); -// tmlsendevent.setEvent(event); -// -// for (int i = 0; i < ((TMLADSendEvent) tgc).realNbOfParams(); i++) { -// tmp = modifyString(((TMLADSendEvent) tgc).getRealParamValue(i)); -// Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); -// if (allVariables.size() > 0) { -// for (int k = 0; k < allVariables.size(); k++) { -// //TraceManager.addDev("Adding record: " + allVariables.get(k)); -// tmlsendevent.addParam(allVariables.get(k)); -// } -// } else { -// //TraceManager.addDev("Adding param: " + tmp); -// tmlsendevent.addParam(tmp); -// } -// } -// if (event.getNbOfParams() != tmlsendevent.getNbOfParams()) { -// //TraceManager.addDev("ERROR : event#:" + event.getNbOfParams() + " sendevent#:" + tmlsendevent.getNbOfParams()); -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendEvent) tgc).getEventName() + ": wrong number of parameters"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } else { -// activity.addElement(tmlsendevent); -// listE.addCor(tmlsendevent, tgc); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// } -// } -// -// } else if (tgc instanceof TMLADSendRequest) { -// request = tmlm.getRequestByName(getFromTable(tmltask, ((TMLADSendRequest) tgc).getRequestName())); -// if (request == null) { -// if (Conversion.containsStringInList(removedRequests, ((TMLADSendRequest) tgc).getRequestName())) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADSendRequest) tgc).getRequestName() + " has been removed because the corresponding request is not taken into account"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// warnings.add(ce); -// activity.addElement(new TMLJunction("void junction", tgc)); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } else { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendRequest) tgc).getRequestName() + " is an unknown request"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } -// } else { -// tmlsendrequest = new TMLSendRequest("send request", tgc); -// tmlsendrequest.setRequest(request); -// for (int i = 0; i < ((TMLADSendRequest) tgc).realNbOfParams(); i++) { -// tmp = modifyString(((TMLADSendRequest) tgc).getRealParamValue(i)); -// Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); -// if (allVariables.size() > 0) { -// for (int k = 0; k < allVariables.size(); k++) { -// TraceManager.addDev("Adding record: " + allVariables.get(k)); -// tmlsendrequest.addParam(allVariables.get(k)); -// request.addParamName(allVariables.get(k)); -// } -// } else { -// //TraceManager.addDev("Adding param: " + tmp); -// tmlsendrequest.addParam(tmp); -// request.addParamName(tmp); -// } -// } -// if (request.getNbOfParams() != tmlsendrequest.getNbOfParams()) { -// //TraceManager.addDev("ERROR : request#:" + request.getNbOfParams() + " sendrequest#:" + tmlsendrequest.getNbOfParams()); -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendRequest) tgc).getRequestName() + ": wrong number of parameters"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } else { -// activity.addElement(tmlsendrequest); -// listE.addCor(tmlsendrequest, tgc); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// } -// } -// -// } else if (tgc instanceof TMLADReadRequestArg) { -// request = tmlm.getRequestToMe(tmltask); -// if (request == null) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "This task is not requested: cannot use \"reading request arg\" operator"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } else { -// tmlaction = new TMLActionState("action reading args", tgc); -// String act = ""; -// int cpt = 1; -// for (int i = 0; i < ((TMLADReadRequestArg) tgc).realNbOfParams(); i++) { -// tmp = modifyString(((TMLADReadRequestArg) tgc).getRealParamValue(i)); -// Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); -// -// if (allVariables.size() > 0) { -// for (int k = 0; k < allVariables.size(); k++) { -// //TraceManager.addDev("Adding record: " + allVariables.get(k)); -// if (cpt != 1) { -// act += "$"; -// } -// act += allVariables.get(k) + " = arg" + cpt + "__req"; -// cpt++; -// } -// } else { -// //TraceManager.addDev("Adding param: " + tmp); -// if (cpt != 1) { -// act += "$"; -// } -// act += tmp + " = arg" + cpt + "__req"; -// cpt++; -// } -// } -// if (request.getNbOfParams() != (cpt - 1)) { -// //TraceManager.addDev("ERROR : request#:" + request.getNbOfParams() + " read request arg#:" + (cpt-1)); -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Wrong number of parameters in \"reading request arg\" operator"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } else { -// //TraceManager.addDev("Adding action = " + act); -// tmlaction.setAction(act); -// activity.addElement(tmlaction); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlaction, tgc); -// } -// -// -// } -// -// } else if (tgc instanceof TMLADStopState) { -// tmlstopstate = new TMLStopState("stop state", tgc); -// activity.addElement(tmlstopstate); -// listE.addCor(tmlstopstate, tgc); -// -// } else if (tgc instanceof TMLADNotifiedEvent) { -// event = tmlm.getEventByName(getFromTable(tmltask, ((TMLADNotifiedEvent) tgc).getEventName())); -// if (event == null) { -// if (removedEvents.size() > 0) { -// if (Conversion.containsStringInList(removedEvents, ((TMLADNotifiedEvent) tgc).getEventName())) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADNotifiedEvent) tgc).getEventName() + " has been removed because the corresponding event is not taken into account"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// warnings.add(ce); -// activity.addElement(new TMLJunction("void junction", tgc)); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } else { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADNotifiedEvent) tgc).getEventName() + " is an unknown event"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } -// } else { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADNotifiedEvent) tgc).getEventName() + " is an unknown event"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } -// } else { -// event.setNotified(true); -// tmlnotifiedevent = new TMLNotifiedEvent("notified event", tgc); -// tmlnotifiedevent.setEvent(event); -// tmlnotifiedevent.setVariable(modifyString(((TMLADNotifiedEvent) tgc).getVariable())); -// activity.addElement(tmlnotifiedevent); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlnotifiedevent, tgc); -// } -// -// } else if (tgc instanceof TMLADWaitEvent) { -// event = tmlm.getEventByName(getFromTable(tmltask, ((TMLADWaitEvent) tgc).getEventName())); -// if (event == null) { -// if (removedEvents.size() > 0) { -// if (Conversion.containsStringInList(removedEvents, ((TMLADWaitEvent) tgc).getEventName())) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADWaitEvent) tgc).getEventName() + " has been removed because the corresponding event is not taken into account"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// warnings.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// activity.addElement(new TMLJunction("void junction", tgc)); -// } else { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWaitEvent) tgc).getEventName() + " is an unknown event"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// checkingErrors.add(ce); -// } -// } else { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWaitEvent) tgc).getEventName() + " is an unknown event"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// checkingErrors.add(ce); -// } -// } else { -// //TraceManager.addDev("Nb of param of event:" + event.getNbOfParams()); -// tmlwaitevent = new TMLWaitEvent("wait event", tgc); -// tmlwaitevent.setEvent(event); -// for (int i = 0; i < ((TMLADWaitEvent) tgc).realNbOfParams(); i++) { -// tmp = modifyString(((TMLADWaitEvent) tgc).getRealParamValue(i)); -// Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); -// if (allVariables.size() > 0) { -// for (int k = 0; k < allVariables.size(); k++) { -// //TraceManager.addDev("Adding record: " + allVariables.get(k)); -// tmlwaitevent.addParam(allVariables.get(k)); -// } -// } else { -// //TraceManager.addDev("Adding param: " + tmp); -// tmlwaitevent.addParam(tmp); -// } -// } -// if (event.getNbOfParams() != tmlwaitevent.getNbOfParams()) { -// //TraceManager.addDev("ERROR : event#:" + event.getNbOfParams() + " waitevent#:" + tmlwaitevent.getNbOfParams()); -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWaitEvent) tgc).getEventName() + ": wrong number of parameters"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// } else { -// activity.addElement(tmlwaitevent); -// listE.addCor(tmlwaitevent, tgc); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// } -// -// } -// -// } else if (tgc instanceof TMLADWriteChannel) { -// // Get channels -// //TMLADWriteChannel wr = (TMLADWriteChannel) tgc; -// channels = ((TMLADWriteChannel) tgc).getChannelsByName(); -// boolean error = false; -// for (int i = 0; i < channels.length; i++) { -// //TraceManager.addDev("Getting from table " + tmltask.getName() + "/" +channels[i]); -// channel = tmlm.getChannelByName(getFromTable(tmltask, channels[i])); -// if (channel == null) { -// if (Conversion.containsStringInList(removedChannels, ((TMLADWriteChannel) tgc).getChannelName(i))) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADWriteChannel) tgc).getChannelName(i) + " has been removed because the corresponding channel is not taken into account"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// warnings.add(ce); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// activity.addElement(new TMLJunction("void junction", tgc)); -// } else { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWriteChannel) tgc).getChannelName(i) + " is an unknown channel"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); -// checkingErrors.add(ce); -// } -// error = true; -// -// } -// } -// if (!error) { -// tmlwritechannel = new TMLWriteChannel("write channel", tgc); -// tmlwritechannel.setNbOfSamples(modifyString(((TMLADWriteChannel) tgc).getSamplesValue())); -// tmlwritechannel.setEncForm(((TMLADWriteChannel) tgc).getEncForm()); -// for (int i = 0; i < channels.length; i++) { -// channel = tmlm.getChannelByName(getFromTable(tmltask, channels[i])); -// tmlwritechannel.addChannel(channel); -// } -// //if (wr.isAttacker()){ -// //channel = tmlm.getChannelByName(getAttackerChannel(channels[0])); -// //tmlwritechannel.addChannel(channel); -// //} -// //add sec pattern -// if (securityPatterns.get(((TMLADWriteChannel) tgc).getSecurityContext()) != null) { -// tmlwritechannel.securityPattern = securityPatterns.get(((TMLADWriteChannel) tgc).getSecurityContext()); -// int cur = Integer.valueOf(modifyString(((TMLADWriteChannel) tgc).getSamplesValue())); -// int add = Integer.valueOf(tmlwritechannel.securityPattern.overhead); -// if (!tmlwritechannel.securityPattern.nonce.equals("")) { -// SecurityPattern nonce = securityPatterns.get(tmlwritechannel.securityPattern.nonce); -// if (nonce != null) { -// add = Integer.valueOf(nonce.overhead); -// } -// } -// cur = cur + add; -// tmlwritechannel.setNbOfSamples(Integer.toString(cur)); -// } else if (!((TMLADWriteChannel) tgc).getSecurityContext().isEmpty()) { -// //Throw error for missing security pattern -// UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADWriteChannel) tgc).getSecurityContext() + " not found"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } -// if (tmltask.isAttacker()) { -// tmlwritechannel.setAttacker(true); -// } -// activity.addElement(tmlwritechannel); -// ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); -// listE.addCor(tmlwritechannel, tgc); -// } -// } -// } -// -// // Interconnection between elements -// TGConnectorTMLAD tgco; -// TGConnectingPoint p1, p2; -// TMLActivityElement ae1, ae2; -// TGComponent tgc1, tgc2, tgc3; -// int j, index; -// -// iterator = list.listIterator(); -// while (iterator.hasNext()) { -// tgc = iterator.next(); -// if (tgc instanceof TGConnectorTMLAD) { -// tgco = (TGConnectorTMLAD) tgc; -// p1 = tgco.getTGConnectingPointP1(); -// p2 = tgco.getTGConnectingPointP2(); -// -// // Identification of connected components -// tgc1 = null; -// tgc2 = null; -// for (j = 0; j < list.size(); j++) { -// tgc3 = list.get(j); -// if (tgc3.belongsToMe(p1)) { -// tgc1 = tgc3; -// } -// if (tgc3.belongsToMe(p2)) { -// tgc2 = tgc3; -// } -// } -// -// // Connecting tml modeling components -// if ((tgc1 != null) && (tgc2 != null)) { -// //ADComponent ad1, ad2; -// ae1 = activity.findReferenceElement(tgc1); -// ae2 = activity.findReferenceElement(tgc2); -// -// if ((ae1 != null) && (ae2 != null)) { -// //Special case if "for loop" or if "choice" -// -// if (ae1 instanceof TMLForLoop) { -// index = tgc1.indexOf(p1) - 1; -// if (index == 0) { -// ae1.addNext(0, ae2); -// } else { -// ae1.addNext(ae2); -// } -// -// } else if (ae1 instanceof TMLChoice) { -// index = tgc1.indexOf(p1) - 1; -// //TraceManager.addDev("Adding next:" + ae2); -// ae1.addNext(ae2); -// //TraceManager.addDev("Adding guard:" + ((TMLADChoice)tgc1).getGuard(index)); -// ((TMLChoice) ae1).addGuard(modifyString(((TMLADChoice) tgc1).getGuard(index))); -// -// } else if (ae1 instanceof TMLSequence) { -// index = tgc1.indexOf(p1) - 1; -// ((TMLSequence) ae1).addIndex(index); -// ae1.addNext(ae2); -// //TraceManager.addDev("Adding " + ae2 + " at index " + index); -// -// } else if (ae1 instanceof TMLRandomSequence) { -// index = tgc1.indexOf(p1) - 1; -// ((TMLRandomSequence) ae1).addIndex(index); -// ae1.addNext(ae2); -// //TraceManager.addDev("Adding " + ae2 + " at index " + index); -// -// } else { -// ae1.addNext(ae2); -// } -// } -// } -// } -// } -// -// -// // Check that each "for" has two nexts -// // Check that TMLChoice have compatible guards -// // Check TML select evts -// iterator = list.listIterator(); -// while (iterator.hasNext()) { -// tgc = iterator.next(); -// -// if ((tgc instanceof TMLADForLoop) || (tgc instanceof TMLADForStaticLoop)) { -// ae1 = activity.findReferenceElement(tgc); -// if (ae1 != null) { -// if (ae1.getNbNext() != 2) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formatted for loop: a loop must have an internal behavior, and an exit behavior "); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } -// } -// } else if (tgc instanceof TMLADChoice) { -// tmlchoice = (TMLChoice) (activity.findReferenceElement(tgc)); -// tmlchoice.orderGuards(); -// -// int nbNonDeter = tmlchoice.nbOfNonDeterministicGuard(); -// int nbStocha = tmlchoice.nbOfStochasticGuard(); -// if ((nbNonDeter > 0) && (nbStocha > 0)) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formatted choice: it has both non-determinitic and stochastic guards"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } -// int nb = Math.max(nbNonDeter, nbStocha); -// if (nb > 0) { -// nb = nb + tmlchoice.nbOfElseAndAfterGuards(); -// if (nb != tmlchoice.getNbGuard()) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formatted choice: it has both non-determinitic/ stochastic and regular guards)"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } -// } -// -// if (tmlchoice.nbOfNonDeterministicGuard() > 0) { -// /*if (!rndAdded) { -// TMLAttribute tmlt = new TMLAttribute("rnd__0", new TMLType(TMLType.NATURAL)); -// tmlt.initialValue = ""; -// tmltask.addAttribute(tmlt); -// rndAdded = true; -// }*/ -// } -// if (tmlchoice.hasMoreThanOneElse()) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Choice should have only one [else] guard"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } else if ((index = tmlchoice.getElseGuard()) > -1) { -// index = tmlchoice.getElseGuard(); -// if (index == 0) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Choice should have a regular guard"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } -// } -// if (tmlchoice.hasMoreThanOneAfter()) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Choice should have only one [after] guard"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } -// } -// if (tgc instanceof TMLADSelectEvt) { -// tmlselectevt = (TMLSelectEvt) (activity.findReferenceElement(tgc)); -// if (!tmlselectevt.isARealSelectEvt()) { -// UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "'Select events' should be followed by only event receiving operators"); -// ce.setTDiagramPanel(tadp); -// ce.setTGComponent(tgc); -// checkingErrors.add(ce); -// } -// } -// -// } -// -// // Sorting nexts elements of Sequence -// for (j = 0; j < activity.nElements(); j++) { -// ae1 = activity.get(j); -// if (ae1 instanceof TMLSequence) { -// ((TMLSequence) ae1).sortNexts(); -// } -// if (ae1 instanceof TMLRandomSequence) { -// ((TMLRandomSequence) ae1).sortNexts(); -// } -// } -// } + + private String modifyActionString(String _input) { + int index = _input.indexOf("++"); + boolean b1, b2; + String tmp; + + if (index > -1) { + tmp = _input.substring(0, index).trim(); + + b1 = (tmp.substring(0, 1)).matches("[a-zA-Z]"); + b2 = tmp.matches("\\w*"); + if (b1 && b2) { + return tmp + " = " + tmp + " + 1"; + } + } + + index = _input.indexOf("--"); + if (index > -1) { + tmp = _input.substring(0, index).trim(); + + b1 = (tmp.substring(0, 1)).matches("[a-zA-Z]"); + b2 = tmp.matches("\\w*"); + if (b1 && b2) { + return tmp + " = " + tmp + " - 1"; + } + } + + return modifyString(_input); + } + + private String modifyString(String _input) { + return Conversion.replaceAllChar(_input, '.', "__"); + } + + private void generateTaskActivityDiagrams(TMLTask tmltask) throws MalformedTMLDesignException { + TMLActivity activity = tmltask.getActivityDiagram(); + TMLActivityDiagramPanel tadp = (TMLActivityDiagramPanel) (activity.getReferenceObject()); + + //TraceManager.addDev("Generating activity diagram of:" + tmltask.getName()); + + // search for start state + List<TGComponent> list = tadp.getComponentList(); + Iterator<TGComponent> iterator = list.listIterator(); + TGComponent tgc; + TMLADStartState tss = null; + int cptStart = 0; + // boolean rndAdded = false; + + while (iterator.hasNext()) { + tgc = iterator.next(); + + if (tgc instanceof TMLADStartState) { + tss = (TMLADStartState) tgc; + cptStart++; + } + } + + if (tss == null) { + TMLCheckingError ce = new TMLCheckingError(CheckingError.BEHAVIOR_ERROR, "No start state in the TML activity diagram of " + tmltask.getName()); + ce.setTMLTask(tmltask); + checkingErrors.add(ce); + return; + } + + if (cptStart > 1) { + TMLCheckingError ce = new TMLCheckingError(CheckingError.BEHAVIOR_ERROR, "More than one start state in the TML activity diagram of " + tmltask.getName()); + ce.setTMLTask(tmltask); + checkingErrors.add(ce); + return; + } + + // Adding start state + TMLStartState tmlss = new TMLStartState("start", tss); + listE.addCor(tmlss, tss); + activity.setFirst(tmlss); + + // Creation of other elements + TMLChannel channel; + String[] channels; + TMLEvent event; + TMLRequest request; + + TMLADRandom tmladrandom; + TMLRandom tmlrandom; + TMLActionState tmlaction; + TMLChoice tmlchoice; + TMLExecI tmlexeci; + TMLExecIInterval tmlexecii; + TMLExecC tmlexecc; + TMLExecCInterval tmlexecci; + TMLForLoop tmlforloop; + TMLReadChannel tmlreadchannel; + TMLSendEvent tmlsendevent; + TMLSendRequest tmlsendrequest; + TMLStopState tmlstopstate; + TMLWaitEvent tmlwaitevent; + TMLNotifiedEvent tmlnotifiedevent; + TMLWriteChannel tmlwritechannel; + TMLSequence tmlsequence; + TMLRandomSequence tmlrsequence; + TMLSelectEvt tmlselectevt; + TMLDelay tmldelay; + int staticLoopIndex = 0; + String sl = "", tmp; + TMLType tt; + TMLAttribute tmlt; + + iterator = list.listIterator(); + while (iterator.hasNext()) { + tgc = iterator.next(); + if (tgc.getCheckLatency()) { + String name = tmltask.getName() + ":" + tgc.getName(); + name = name.replaceAll(" ", ""); + //TraceManager.addDev("To check " + name); + if (tgc.getValue().contains("(")) { + tmlm.addCheckedActivity(tgc, name + ":" + tgc.getValue().split("\\(")[0]); + } else { + if (tgc instanceof TMLADExecI) { + tmlm.addCheckedActivity(tgc, ((TMLADExecI) tgc).getDelayValue()); + } + } + } + if (tgc instanceof TMLADActionState) { + tmlaction = new TMLActionState("action", tgc); + tmp = ((TMLADActionState) (tgc)).getAction(); + tmp = modifyActionString(tmp); + tmlaction.setAction(tmp); + activity.addElement(tmlaction); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlaction, tgc); + + } else if (tgc instanceof TMLADRandom) { + tmladrandom = (TMLADRandom) tgc; + tmlrandom = new TMLRandom("random" + tmladrandom.getValue(), tgc); + tmp = tmladrandom.getVariable(); + tmp = modifyActionString(tmp); + tmlrandom.setVariable(tmp); + tmp = tmladrandom.getMinValue(); + tmp = modifyActionString(tmp); + tmlrandom.setMinValue(tmp); + tmp = tmladrandom.getMaxValue(); + tmp = modifyActionString(tmp); + tmlrandom.setMaxValue(tmp); + tmlrandom.setFunctionId(tmladrandom.getFunctionId()); + activity.addElement(tmlrandom); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlrandom, tgc); + + } else if (tgc instanceof TMLADChoice) { + tmlchoice = new TMLChoice("choice", tgc); + // Guards are added at the same time as next activities + activity.addElement(tmlchoice); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlchoice, tgc); + + } else if (tgc instanceof TMLADSelectEvt) { + tmlselectevt = new TMLSelectEvt("select", tgc); + activity.addElement(tmlselectevt); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlselectevt, tgc); + + } else if (tgc instanceof TMLADExecI) { + tmlexeci = new TMLExecI("execi", tgc); + tmlexeci.setAction(modifyString(((TMLADExecI) tgc).getDelayValue())); + tmlexeci.setValue(((TMLADExecI) tgc).getDelayValue()); + activity.addElement(tmlexeci); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlexeci, tgc); + + } else if (tgc instanceof TMLADExecIInterval) { + tmlexecii = new TMLExecIInterval("execi", tgc); + tmlexecii.setValue(tgc.getValue()); + tmlexecii.setMinDelay(modifyString(((TMLADExecIInterval) tgc).getMinDelayValue())); + tmlexecii.setMaxDelay(modifyString(((TMLADExecIInterval) tgc).getMaxDelayValue())); + activity.addElement(tmlexecii); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlexecii, tgc); + + } else if (tgc instanceof TMLADEncrypt) { + tmlexecc = new TMLExecC("encrypt_" + ((TMLADEncrypt) tgc).securityContext, tgc); + activity.addElement(tmlexecc); + SecurityPattern sp = securityPatterns.get(((TMLADEncrypt) tgc).securityContext); + if (sp == null) { + //Throw error for missing security pattern + UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADEncrypt) tgc).securityContext + " not found"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } else { + tmlexecc.securityPattern = sp; + tmlexecc.setAction(Integer.toString(sp.encTime)); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + tmlm.securityTaskMap.get(sp).add(tmltask); + listE.addCor(tmlexecc, tgc); + } + } else if (tgc instanceof TMLADDecrypt) { + tmlexecc = new TMLExecC("decrypt_" + ((TMLADDecrypt) tgc).securityContext, tgc); + activity.addElement(tmlexecc); + SecurityPattern sp = securityPatterns.get(((TMLADDecrypt) tgc).securityContext); + if (sp == null) { + //Throw error for missing security pattern + UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADDecrypt) tgc).securityContext + " not found"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } else { + tmlexecc.securityPattern = sp; + tmlexecc.setAction(Integer.toString(sp.decTime)); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlexecc, tgc); + tmlm.securityTaskMap.get(sp).add(tmltask); + } + + } else if (tgc instanceof TMLADExecC) { + tmlexecc = new TMLExecC("execc", tgc); + tmlexecc.setValue(((TMLADExecC) tgc).getDelayValue()); + tmlexecc.setAction(modifyString(((TMLADExecC) tgc).getDelayValue())); + activity.addElement(tmlexecc); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlexecc, tgc); + + } else if (tgc instanceof TMLADExecCInterval) { + tmlexecci = new TMLExecCInterval("execci", tgc); + tmlexecci.setMinDelay(modifyString(((TMLADExecCInterval) tgc).getMinDelayValue())); + tmlexecci.setMaxDelay(modifyString(((TMLADExecCInterval) tgc).getMaxDelayValue())); + activity.addElement(tmlexecci); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlexecci, tgc); + + } else if (tgc instanceof TMLADDelay) { + tmldelay = new TMLDelay("d-delay", tgc); + tmldelay.setMinDelay(modifyString(((TMLADDelay) tgc).getDelayValue())); + tmldelay.setMaxDelay(modifyString(((TMLADDelay) tgc).getDelayValue())); + tmldelay.setUnit(((TMLADDelay) tgc).getUnit()); + activity.addElement(tmldelay); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmldelay, tgc); + + } else if (tgc instanceof TMLADDelayInterval) { + tmldelay = new TMLDelay("nd-delay", tgc); + tmldelay.setMinDelay(modifyString(((TMLADDelayInterval) tgc).getMinDelayValue())); + tmldelay.setMaxDelay(modifyString(((TMLADDelayInterval) tgc).getMaxDelayValue())); + tmldelay.setUnit(((TMLADDelayInterval) tgc).getUnit()); + activity.addElement(tmldelay); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmldelay, tgc); + + } else if (tgc instanceof TMLADForLoop) { + tmlforloop = new TMLForLoop("loop", tgc); + tmlforloop.setInit(modifyString(((TMLADForLoop) tgc).getInit())); + tmp = ((TMLADForLoop) tgc).getCondition(); + /*if (tmp.trim().length() == 0) { + tmp = "true"; + }*/ + tmlforloop.setCondition(modifyString(tmp)); + tmlforloop.setIncrement(modifyActionString(((TMLADForLoop) tgc).getIncrement())); + + activity.addElement(tmlforloop); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlforloop, tgc); + + } else if (tgc instanceof TMLADForStaticLoop) { + sl = "loop__" + staticLoopIndex; + tt = new TMLType(TMLType.NATURAL); + tmlt = new TMLAttribute(sl, tt); + tmlt.initialValue = "0"; + tmltask.addAttribute(tmlt); + tmlforloop = new TMLForLoop(sl, tgc); + tmlforloop.setInit(sl + " = 0"); + tmlforloop.setCondition(sl + "<" + modifyString(tgc.getValue())); + tmlforloop.setIncrement(sl + " = " + sl + " + 1"); + activity.addElement(tmlforloop); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlforloop, tgc); + staticLoopIndex++; + + } else if (tgc instanceof TMLADForEverLoop) { + /*sl = "loop__" + staticLoopIndex; + tt = new TMLType(TMLType.NATURAL); + tmlt = new TMLAttribute(sl, tt); + tmlt.initialValue = "0"; + tmltask.addAttribute(tmlt);*/ + tmlforloop = new TMLForLoop("infiniteloop", tgc); + tmlforloop.setInit(""); + tmlforloop.setCondition(""); + tmlforloop.setIncrement(""); + tmlforloop.setInfinite(true); + activity.addElement(tmlforloop); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlforloop, tgc); + staticLoopIndex++; + + tmlstopstate = new TMLStopState("Stop after infinite loop", null); + activity.addElement(tmlstopstate); + tmlforloop.addNext(tmlstopstate); + + } else if (tgc instanceof TMLADSequence) { + tmlsequence = new TMLSequence("seq", tgc); + activity.addElement(tmlsequence); + listE.addCor(tmlsequence, tgc); + + } else if (tgc instanceof TMLADUnorderedSequence) { + tmlrsequence = new TMLRandomSequence("rseq", tgc); + activity.addElement(tmlrsequence); + listE.addCor(tmlrsequence, tgc); + + } else if (tgc instanceof TMLADReadChannel) { + // Get the channel + //TMLADReadChannel rd = (TMLADReadChannel) tgc; + channel = tmlm.getChannelByName(getFromTable(tmltask, ((TMLADReadChannel) tgc).getChannelName())); + /*if (rd.isAttacker()){ + channel = tmlm.getChannelByName(getAttackerChannel(((TMLADReadChannel)tgc).getChannelName())); + }*/ + if (channel == null) { + if (Conversion.containsStringInList(removedChannels, ((TMLADReadChannel) tgc).getChannelName())) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADReadChannel) tgc).getChannelName() + " has been removed because the corresponding channel is not taken into account"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + warnings.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + activity.addElement(new TMLJunction("void junction", tgc)); + } else { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADReadChannel) tgc).getChannelName() + " is an unknown channel"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + checkingErrors.add(ce); + } + + } else { + tmlreadchannel = new TMLReadChannel("read channel", tgc); + tmlreadchannel.setNbOfSamples(modifyString(((TMLADReadChannel) tgc).getSamplesValue())); + tmlreadchannel.setEncForm(((TMLADReadChannel) tgc).getEncForm()); + tmlreadchannel.addChannel(channel); + //security pattern + if (securityPatterns.get(((TMLADReadChannel) tgc).getSecurityContext()) != null) { + tmlreadchannel.securityPattern = securityPatterns.get(((TMLADReadChannel) tgc).getSecurityContext()); + //NbOfSamples will increase due to extra overhead from MAC + int cur = 1; + try { + cur = Integer.valueOf(modifyString(((TMLADReadChannel) tgc).getSamplesValue())); + } catch (NumberFormatException e) { + } catch (NullPointerException e) { + } + int add = Integer.valueOf(tmlreadchannel.securityPattern.overhead); + if (!tmlreadchannel.securityPattern.nonce.equals("")) { + SecurityPattern nonce = securityPatterns.get(tmlreadchannel.securityPattern.nonce); + if (nonce != null) { + add = Integer.valueOf(nonce.overhead); + } + } + cur = cur + add; + tmlreadchannel.setNbOfSamples(Integer.toString(cur)); + } else if (!((TMLADReadChannel) tgc).getSecurityContext().isEmpty()) { + //Throw error for missing security pattern + UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADReadChannel) tgc).getSecurityContext() + " not found"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } + if (tmltask.isAttacker()) { + tmlreadchannel.setAttacker(true); + } + activity.addElement(tmlreadchannel); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlreadchannel, tgc); + } + } else if (tgc instanceof TMLADSendEvent) { + event = tmlm.getEventByName(getFromTable(tmltask, ((TMLADSendEvent) tgc).getEventName())); + if (event == null) { + if (Conversion.containsStringInList(removedEvents, ((TMLADSendEvent) tgc).getEventName())) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADSendEvent) tgc).getEventName() + " has been removed because the corresponding event is not taken into account"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + warnings.add(ce); + activity.addElement(new TMLJunction("void junction", tgc)); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } else { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendEvent) tgc).getEventName() + " is an unknown event"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } + } else { + tmlsendevent = new TMLSendEvent("send event", tgc); + tmlsendevent.setEvent(event); + + for (int i = 0; i < ((TMLADSendEvent) tgc).realNbOfParams(); i++) { + tmp = modifyString(((TMLADSendEvent) tgc).getRealParamValue(i)); + Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); + if (allVariables.size() > 0) { + for (int k = 0; k < allVariables.size(); k++) { + //TraceManager.addDev("Adding record: " + allVariables.get(k)); + tmlsendevent.addParam(allVariables.get(k)); + } + } else { + //TraceManager.addDev("Adding param: " + tmp); + tmlsendevent.addParam(tmp); + } + } + if (event.getNbOfParams() != tmlsendevent.getNbOfParams()) { + //TraceManager.addDev("ERROR : event#:" + event.getNbOfParams() + " sendevent#:" + tmlsendevent.getNbOfParams()); + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendEvent) tgc).getEventName() + ": wrong number of parameters"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } else { + activity.addElement(tmlsendevent); + listE.addCor(tmlsendevent, tgc); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + } + } + + } else if (tgc instanceof TMLADSendRequest) { + request = tmlm.getRequestByName(getFromTable(tmltask, ((TMLADSendRequest) tgc).getRequestName())); + if (request == null) { + if (Conversion.containsStringInList(removedRequests, ((TMLADSendRequest) tgc).getRequestName())) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADSendRequest) tgc).getRequestName() + " has been removed because the corresponding request is not taken into account"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + warnings.add(ce); + activity.addElement(new TMLJunction("void junction", tgc)); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } else { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendRequest) tgc).getRequestName() + " is an unknown request"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } + } else { + tmlsendrequest = new TMLSendRequest("send request", tgc); + tmlsendrequest.setRequest(request); + for (int i = 0; i < ((TMLADSendRequest) tgc).realNbOfParams(); i++) { + tmp = modifyString(((TMLADSendRequest) tgc).getRealParamValue(i)); + Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); + if (allVariables.size() > 0) { + for (int k = 0; k < allVariables.size(); k++) { + TraceManager.addDev("Adding record: " + allVariables.get(k)); + tmlsendrequest.addParam(allVariables.get(k)); + request.addParamName(allVariables.get(k)); + } + } else { + //TraceManager.addDev("Adding param: " + tmp); + tmlsendrequest.addParam(tmp); + request.addParamName(tmp); + } + } + if (request.getNbOfParams() != tmlsendrequest.getNbOfParams()) { + //TraceManager.addDev("ERROR : request#:" + request.getNbOfParams() + " sendrequest#:" + tmlsendrequest.getNbOfParams()); + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADSendRequest) tgc).getRequestName() + ": wrong number of parameters"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } else { + activity.addElement(tmlsendrequest); + listE.addCor(tmlsendrequest, tgc); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + } + } + + } else if (tgc instanceof TMLADReadRequestArg) { + request = tmlm.getRequestToMe(tmltask); + if (request == null) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "This task is not requested: cannot use \"reading request arg\" operator"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } else { + tmlaction = new TMLActionState("action reading args", tgc); + String act = ""; + int cpt = 1; + for (int i = 0; i < ((TMLADReadRequestArg) tgc).realNbOfParams(); i++) { + tmp = modifyString(((TMLADReadRequestArg) tgc).getRealParamValue(i)); + Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); + + if (allVariables.size() > 0) { + for (int k = 0; k < allVariables.size(); k++) { + //TraceManager.addDev("Adding record: " + allVariables.get(k)); + if (cpt != 1) { + act += "$"; + } + act += allVariables.get(k) + " = arg" + cpt + "__req"; + cpt++; + } + } else { + //TraceManager.addDev("Adding param: " + tmp); + if (cpt != 1) { + act += "$"; + } + act += tmp + " = arg" + cpt + "__req"; + cpt++; + } + } + if (request.getNbOfParams() != (cpt - 1)) { + //TraceManager.addDev("ERROR : request#:" + request.getNbOfParams() + " read request arg#:" + (cpt-1)); + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Wrong number of parameters in \"reading request arg\" operator"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } else { + //TraceManager.addDev("Adding action = " + act); + tmlaction.setAction(act); + activity.addElement(tmlaction); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlaction, tgc); + } + + + } + + } else if (tgc instanceof TMLADStopState) { + tmlstopstate = new TMLStopState("stop state", tgc); + activity.addElement(tmlstopstate); + listE.addCor(tmlstopstate, tgc); + + } else if (tgc instanceof TMLADNotifiedEvent) { + event = tmlm.getEventByName(getFromTable(tmltask, ((TMLADNotifiedEvent) tgc).getEventName())); + if (event == null) { + if (removedEvents.size() > 0) { + if (Conversion.containsStringInList(removedEvents, ((TMLADNotifiedEvent) tgc).getEventName())) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADNotifiedEvent) tgc).getEventName() + " has been removed because the corresponding event is not taken into account"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + warnings.add(ce); + activity.addElement(new TMLJunction("void junction", tgc)); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } else { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADNotifiedEvent) tgc).getEventName() + " is an unknown event"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } + } else { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADNotifiedEvent) tgc).getEventName() + " is an unknown event"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } + } else { + event.setNotified(true); + tmlnotifiedevent = new TMLNotifiedEvent("notified event", tgc); + tmlnotifiedevent.setEvent(event); + tmlnotifiedevent.setVariable(modifyString(((TMLADNotifiedEvent) tgc).getVariable())); + activity.addElement(tmlnotifiedevent); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlnotifiedevent, tgc); + } + + } else if (tgc instanceof TMLADWaitEvent) { + event = tmlm.getEventByName(getFromTable(tmltask, ((TMLADWaitEvent) tgc).getEventName())); + if (event == null) { + if (removedEvents.size() > 0) { + if (Conversion.containsStringInList(removedEvents, ((TMLADWaitEvent) tgc).getEventName())) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADWaitEvent) tgc).getEventName() + " has been removed because the corresponding event is not taken into account"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + warnings.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + activity.addElement(new TMLJunction("void junction", tgc)); + } else { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWaitEvent) tgc).getEventName() + " is an unknown event"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + checkingErrors.add(ce); + } + } else { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWaitEvent) tgc).getEventName() + " is an unknown event"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + checkingErrors.add(ce); + } + } else { + //TraceManager.addDev("Nb of param of event:" + event.getNbOfParams()); + tmlwaitevent = new TMLWaitEvent("wait event", tgc); + tmlwaitevent.setEvent(event); + for (int i = 0; i < ((TMLADWaitEvent) tgc).realNbOfParams(); i++) { + tmp = modifyString(((TMLADWaitEvent) tgc).getRealParamValue(i)); + Vector<String> allVariables = tmltask.getAllAttributesStartingWith(tmp + "__"); + if (allVariables.size() > 0) { + for (int k = 0; k < allVariables.size(); k++) { + //TraceManager.addDev("Adding record: " + allVariables.get(k)); + tmlwaitevent.addParam(allVariables.get(k)); + } + } else { + //TraceManager.addDev("Adding param: " + tmp); + tmlwaitevent.addParam(tmp); + } + } + if (event.getNbOfParams() != tmlwaitevent.getNbOfParams()) { + //TraceManager.addDev("ERROR : event#:" + event.getNbOfParams() + " waitevent#:" + tmlwaitevent.getNbOfParams()); + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWaitEvent) tgc).getEventName() + ": wrong number of parameters"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + } else { + activity.addElement(tmlwaitevent); + listE.addCor(tmlwaitevent, tgc); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + } + + } + + } else if (tgc instanceof TMLADWriteChannel) { + // Get channels + //TMLADWriteChannel wr = (TMLADWriteChannel) tgc; + channels = ((TMLADWriteChannel) tgc).getChannelsByName(); + boolean error = false; + for (int i = 0; i < channels.length; i++) { + //TraceManager.addDev("Getting from table " + tmltask.getName() + "/" +channels[i]); + channel = tmlm.getChannelByName(getFromTable(tmltask, channels[i])); + if (channel == null) { + if (Conversion.containsStringInList(removedChannels, ((TMLADWriteChannel) tgc).getChannelName(i))) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A call to " + ((TMLADWriteChannel) tgc).getChannelName(i) + " has been removed because the corresponding channel is not taken into account"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + warnings.add(ce); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + activity.addElement(new TMLJunction("void junction", tgc)); + } else { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, ((TMLADWriteChannel) tgc).getChannelName(i) + " is an unknown channel"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.UNKNOWN); + checkingErrors.add(ce); + } + error = true; + + } + } + if (!error) { + tmlwritechannel = new TMLWriteChannel("write channel", tgc); + tmlwritechannel.setNbOfSamples(modifyString(((TMLADWriteChannel) tgc).getSamplesValue())); + tmlwritechannel.setEncForm(((TMLADWriteChannel) tgc).getEncForm()); + for (int i = 0; i < channels.length; i++) { + channel = tmlm.getChannelByName(getFromTable(tmltask, channels[i])); + tmlwritechannel.addChannel(channel); + } + //if (wr.isAttacker()){ + //channel = tmlm.getChannelByName(getAttackerChannel(channels[0])); + //tmlwritechannel.addChannel(channel); + //} + //add sec pattern + if (securityPatterns.get(((TMLADWriteChannel) tgc).getSecurityContext()) != null) { + tmlwritechannel.securityPattern = securityPatterns.get(((TMLADWriteChannel) tgc).getSecurityContext()); + int cur = Integer.valueOf(modifyString(((TMLADWriteChannel) tgc).getSamplesValue())); + int add = Integer.valueOf(tmlwritechannel.securityPattern.overhead); + if (!tmlwritechannel.securityPattern.nonce.equals("")) { + SecurityPattern nonce = securityPatterns.get(tmlwritechannel.securityPattern.nonce); + if (nonce != null) { + add = Integer.valueOf(nonce.overhead); + } + } + cur = cur + add; + tmlwritechannel.setNbOfSamples(Integer.toString(cur)); + } else if (!((TMLADWriteChannel) tgc).getSecurityContext().isEmpty()) { + //Throw error for missing security pattern + UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Security Pattern " + ((TMLADWriteChannel) tgc).getSecurityContext() + " not found"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } + if (tmltask.isAttacker()) { + tmlwritechannel.setAttacker(true); + } + activity.addElement(tmlwritechannel); + ((BasicErrorHighlight) tgc).setStateAction(ErrorHighlight.OK); + listE.addCor(tmlwritechannel, tgc); + } + } + } + + // Interconnection between elements + TGConnectorTMLAD tgco; + TGConnectingPoint p1, p2; + TMLActivityElement ae1, ae2; + TGComponent tgc1, tgc2, tgc3; + int j, index; + + iterator = list.listIterator(); + while (iterator.hasNext()) { + tgc = iterator.next(); + if (tgc instanceof TGConnectorTMLAD) { + tgco = (TGConnectorTMLAD) tgc; + p1 = tgco.getTGConnectingPointP1(); + p2 = tgco.getTGConnectingPointP2(); + + // Identification of connected components + tgc1 = null; + tgc2 = null; + for (j = 0; j < list.size(); j++) { + tgc3 = list.get(j); + if (tgc3.belongsToMe(p1)) { + tgc1 = tgc3; + } + if (tgc3.belongsToMe(p2)) { + tgc2 = tgc3; + } + } + + // Connecting tml modeling components + if ((tgc1 != null) && (tgc2 != null)) { + //ADComponent ad1, ad2; + ae1 = activity.findReferenceElement(tgc1); + ae2 = activity.findReferenceElement(tgc2); + + if ((ae1 != null) && (ae2 != null)) { + //Special case if "for loop" or if "choice" + + if (ae1 instanceof TMLForLoop) { + index = tgc1.indexOf(p1) - 1; + if (index == 0) { + ae1.addNext(0, ae2); + } else { + ae1.addNext(ae2); + } + + } else if (ae1 instanceof TMLChoice) { + index = tgc1.indexOf(p1) - 1; + //TraceManager.addDev("Adding next:" + ae2); + ae1.addNext(ae2); + //TraceManager.addDev("Adding guard:" + ((TMLADChoice)tgc1).getGuard(index)); + ((TMLChoice) ae1).addGuard(modifyString(((TMLADChoice) tgc1).getGuard(index))); + + } else if (ae1 instanceof TMLSequence) { + index = tgc1.indexOf(p1) - 1; + ((TMLSequence) ae1).addIndex(index); + ae1.addNext(ae2); + //TraceManager.addDev("Adding " + ae2 + " at index " + index); + + } else if (ae1 instanceof TMLRandomSequence) { + index = tgc1.indexOf(p1) - 1; + ((TMLRandomSequence) ae1).addIndex(index); + ae1.addNext(ae2); + //TraceManager.addDev("Adding " + ae2 + " at index " + index); + + } else { + ae1.addNext(ae2); + } + } + } + } + } + + + // Check that each "for" has two nexts + // Check that TMLChoice have compatible guards + // Check TML select evts + iterator = list.listIterator(); + while (iterator.hasNext()) { + tgc = iterator.next(); + + if ((tgc instanceof TMLADForLoop) || (tgc instanceof TMLADForStaticLoop)) { + ae1 = activity.findReferenceElement(tgc); + if (ae1 != null) { + if (ae1.getNbNext() != 2) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formatted for loop: a loop must have an internal behavior, and an exit behavior "); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } + } + } else if (tgc instanceof TMLADChoice) { + tmlchoice = (TMLChoice) (activity.findReferenceElement(tgc)); + tmlchoice.orderGuards(); + + int nbNonDeter = tmlchoice.nbOfNonDeterministicGuard(); + int nbStocha = tmlchoice.nbOfStochasticGuard(); + if ((nbNonDeter > 0) && (nbStocha > 0)) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formatted choice: it has both non-determinitic and stochastic guards"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } + int nb = Math.max(nbNonDeter, nbStocha); + if (nb > 0) { + nb = nb + tmlchoice.nbOfElseAndAfterGuards(); + if (nb != tmlchoice.getNbGuard()) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formatted choice: it has both non-determinitic/ stochastic and regular guards)"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } + } + + if (tmlchoice.nbOfNonDeterministicGuard() > 0) { + /*if (!rndAdded) { + TMLAttribute tmlt = new TMLAttribute("rnd__0", new TMLType(TMLType.NATURAL)); + tmlt.initialValue = ""; + tmltask.addAttribute(tmlt); + rndAdded = true; + }*/ + } + if (tmlchoice.hasMoreThanOneElse()) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Choice should have only one [else] guard"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } else if ((index = tmlchoice.getElseGuard()) > -1) { + index = tmlchoice.getElseGuard(); + if (index == 0) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Choice should have a regular guard"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } + } + if (tmlchoice.hasMoreThanOneAfter()) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Choice should have only one [after] guard"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } + } + if (tgc instanceof TMLADSelectEvt) { + tmlselectevt = (TMLSelectEvt) (activity.findReferenceElement(tgc)); + if (!tmlselectevt.isARealSelectEvt()) { + UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "'Select events' should be followed by only event receiving operators"); + ce.setTDiagramPanel(tadp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + } + } + + } + + // Sorting nexts elements of Sequence + for (j = 0; j < activity.nElements(); j++) { + ae1 = activity.get(j); + if (ae1 instanceof TMLSequence) { + ((TMLSequence) ae1).sortNexts(); + } + if (ae1 instanceof TMLRandomSequence) { + ((TMLRandomSequence) ae1).sortNexts(); + } + } + } public TMLMapping<TGComponent> translateToTMLMapping() { tmlm = new TMLModeling<>(true); @@ -3931,23 +3850,23 @@ public class GTMLModeling { } return ""; } -// -// public String getFromTable(TMLTask task, String s) { -// //TraceManager.addDev("TABLE GET: Getting from task=" + task.getName() + " element=" + s); -// -// if (table == null) { -// return s; -// } -// -// String ret = table.get(task.getName() + "/" + s); -// //TraceManager.addDev("Returning=" + ret); -// -// if (ret == null) { -// return s; -// } -// -// return ret; -// } + + public String getFromTable(TMLTask task, String s) { + //TraceManager.addDev("TABLE GET: Getting from task=" + task.getName() + " element=" + s); + + if (table == null) { + return s; + } + + String ret = table.get(task.getName() + "/" + s); + //TraceManager.addDev("Returning=" + ret); + + if (ret == null) { + return s; + } + + return ret; + } public void removeActionsWithRecords() { //TraceManager.addDev("Reworking actions with records"); diff --git a/src/main/java/ui/ICDElementVisitor.java b/src/main/java/ui/ICDElementVisitor.java deleted file mode 100644 index 2ccfa5f361..0000000000 --- a/src/main/java/ui/ICDElementVisitor.java +++ /dev/null @@ -1,6 +0,0 @@ -package ui; - -public interface ICDElementVisitor { - - boolean visit( CDElement element ); -} diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index 86f6693074..1024449f09 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -8054,7 +8054,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per return false; } - public boolean newSysCAMSComponentTaskName(TURTLEPanel tp, String old, String niou) { + public boolean newSysCAMSComponentTaskName(TURTLEPanel tp, String old, String niou) { JTabbedPane jtp = tp.tabbedPane; for (int i = 0; i < jtp.getTabCount(); i++) { if (jtp.getTitleAt(i).equals(niou)) { @@ -8075,7 +8075,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per tdp.setName(niou); } } - + return true; } } @@ -8439,33 +8439,33 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per //tofile.extracParamToFile(); } -// public void avatarToSoclib() { -// //DG 6.2. appelee nulle part? -// -// ADDDiagramPanel deploymentDiagramPanel = getDeploymentPanel(); -// AvatarDesignPanel designDiagramPanel = getFirstAvatarDesignPanelFound(); -// -// AvatarDeploymentPanelTranslator avdeploymenttranslator = new AvatarDeploymentPanelTranslator(deploymentDiagramPanel); -// AvatarddSpecification avddspec = avdeploymenttranslator.getAvatarddSpecification(); -// -// -// AvatarDesignPanelTranslator avdesigntranslator = new AvatarDesignPanelTranslator(designDiagramPanel); -// -// List<AvatarBDStateMachineOwner> adp = designDiagramPanel.getAvatarBDPanel().getFullStateMachineOwnerList(); -// AvatarSpecification avaspec = avdesigntranslator.generateAvatarSpecification(adp); -// -// // Generator for block tasks and application main file -// -// TasksAndMainGenerator gene = new TasksAndMainGenerator(avddspec, avaspec); -// gene.generateSoclib(false, false); -// try { -// //System.err.println("ok"); -// gene.saveInFiles(TasksAndMainGenerator.getGeneratedPath()); -// } catch (FileException e) { -// System.err.println("FileException : MainGUI.avatarToSoclib()"); -// } -// -// } + public void avatarToSoclib() { + //DG 6.2. appelee nulle part? + + ADDDiagramPanel deploymentDiagramPanel = getDeploymentPanel(); + AvatarDesignPanel designDiagramPanel = getFirstAvatarDesignPanelFound(); + + AvatarDeploymentPanelTranslator avdeploymenttranslator = new AvatarDeploymentPanelTranslator(deploymentDiagramPanel); + AvatarddSpecification avddspec = avdeploymenttranslator.getAvatarddSpecification(); + + + AvatarDesignPanelTranslator avdesigntranslator = new AvatarDesignPanelTranslator(designDiagramPanel); + + List<AvatarBDStateMachineOwner> adp = designDiagramPanel.getAvatarBDPanel().getFullStateMachineOwnerList(); + AvatarSpecification avaspec = avdesigntranslator.generateAvatarSpecification(adp); + + // Generator for block tasks and application main file + + TasksAndMainGenerator gene = new TasksAndMainGenerator(avddspec, avaspec); + gene.generateSoclib(false, false); + try { + //System.err.println("ok"); + gene.saveInFiles(TasksAndMainGenerator.getGeneratedPath()); + } catch (FileException e) { + System.err.println("FileException : MainGUI.avatarToSoclib()"); + } + + } //--------------------end DDD------------------------------------------------ public Vector<SysCAMSComponentTaskDiagramPanel> getListSysCAMSPanel() { diff --git a/src/main/java/ui/MalformedModelingException.java b/src/main/java/ui/MalformedModelingException.java index 809732ad48..c656bb59ba 100755 --- a/src/main/java/ui/MalformedModelingException.java +++ b/src/main/java/ui/MalformedModelingException.java @@ -36,8 +36,12 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui; + /** * Class MalformedModelingException * Creation: 15/12/2003 @@ -46,22 +50,10 @@ package ui; */ public class MalformedModelingException extends Exception { - /** - * - */ - private static final long serialVersionUID = 7411903139644480309L; - public MalformedModelingException() { - this( (Throwable) null ); - } - - public MalformedModelingException( final String message ) { - super( message ); - } - - public MalformedModelingException( final Throwable th ) { - super( "Modeling does not follow the TTool format", th ); + super("Modeling does not follows the TTool format"); } + } // Class \ No newline at end of file diff --git a/src/main/java/ui/MalformedTMLDesignException.java b/src/main/java/ui/MalformedTMLDesignException.java index 725d68f6eb..45952af48e 100755 --- a/src/main/java/ui/MalformedTMLDesignException.java +++ b/src/main/java/ui/MalformedTMLDesignException.java @@ -36,12 +36,11 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui; -import java.util.ArrayList; -import java.util.List; -import translator.CheckingError; + +package ui; + /** * Class MalformedTMLDesigngException @@ -51,43 +50,10 @@ import translator.CheckingError; */ public class MalformedTMLDesignException extends Exception { - /** - * - */ - private static final long serialVersionUID = -379782523139636075L; - - private final List<CheckingError> errors; - public MalformedTMLDesignException(String msg) { - this( msg, new ArrayList<CheckingError>() ); + super(msg); } - public MalformedTMLDesignException( final String msg, - final List<CheckingError> errors ) { - super( msg ); - - this.errors = errors; - } - - public List<CheckingError> getErrors() { - return errors; - } - - @Override - public String toString() { - final StringBuilder message = new StringBuilder( super.toString() ); - - if ( !getErrors().isEmpty() ) { - message.append( "Errors are:" ); - } - - for ( final CheckingError error : getErrors() ) { - message.append( System.lineSeparator() + error ); - } - - return message.toString(); - } - } // Class \ No newline at end of file diff --git a/src/main/java/ui/RangeExpression.java b/src/main/java/ui/RangeExpression.java deleted file mode 100644 index 58ee809ada..0000000000 --- a/src/main/java/ui/RangeExpression.java +++ /dev/null @@ -1,56 +0,0 @@ -package ui; - -public class RangeExpression extends Expression { - - private final Expression minExpression; - - private final Expression maxExpression; - - - public RangeExpression( final String minExpressionText, - final String maxExpressionText, - final String nullText, - final String labelGlobal, - final String labelValues ) { - super( null, nullText, labelGlobal ); - - - minExpression = new Expression( minExpressionText, nullText, labelValues ); - maxExpression = new Expression( maxExpressionText, nullText, labelValues ); - } - - public Expression getMinExpression() { - return minExpression; - } - - public Expression getMaxExpression() { - return maxExpression; - } - - @Override - public void setEnabled( final boolean enabled ) { - getMinExpression().setEnabled( enabled ); - getMaxExpression().setEnabled( enabled ); - } - - @Override - public boolean isEnabled() { - return minExpression.isEnabled() || maxExpression.isEnabled(); - } - - @Override - public boolean isNull() { - return minExpression.isNull() && maxExpression.isNull(); - } - - @Override - public String toString() { - if ( getLabel() == null ) { - return "[" + getMinExpression().toString() + ", " + getMaxExpression().toString() + "]"; - } - - final Object[] values = new String[] { getMinExpression().toString(), getMaxExpression().toString() }; - - return String.format( getLabel(), values ); - } -} diff --git a/src/main/java/ui/TDiagramMouseManager.java b/src/main/java/ui/TDiagramMouseManager.java index 48895b01a3..0f589acc15 100755 --- a/src/main/java/ui/TDiagramMouseManager.java +++ b/src/main/java/ui/TDiagramMouseManager.java @@ -38,13 +38,13 @@ package ui; -import java.awt.Cursor; -import java.awt.Point; +import ui.window.JDialogSearchBox; + +import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; - -import ui.window.JDialogSearchBox; +import myutil.*; /** * Class TDiagramMouseManager @@ -58,7 +58,7 @@ public class TDiagramMouseManager extends MouseAdapter {//implements MouseListen private TDiagramPanel tdp; private TGComponent tgc; - // private TGComponent lastSelectedComponent = null; + private TGComponent lastSelectedComponent = null; private int oldx; private int oldy; @@ -75,7 +75,7 @@ public class TDiagramMouseManager extends MouseAdapter {//implements MouseListen private int resizeInfo; - // private boolean selectedComponent = false; + private boolean selectedComponent = false; //private Point p; private TGConnectingPoint cp; @@ -496,14 +496,14 @@ public class TDiagramMouseManager extends MouseAdapter {//implements MouseListen else tdp.getGUI().setMode(MainGUI.OPENED); - //lastSelectedComponent = tgc; + lastSelectedComponent = tgc; tdp.setSelect(true); tgc.singleClick(tdp.getGUI().getFrame(), x, y); } else { tdp.getGUI().setMode(MainGUI.OPENED); tdp.setSelect(false); - // lastSelectedComponent = null; + lastSelectedComponent = null; tdp.componentPointed = null; } tdp.getGUI().changeMade(tdp, TDiagramPanel.CHANGE_VALUE_COMPONENT); @@ -581,22 +581,19 @@ public class TDiagramMouseManager extends MouseAdapter {//implements MouseListen tdp.repaint(); } } - - // Issue #69 Always repaint. Needed for displaying the transition element in Avatar state machine diagram -// -// if ((selected == TGComponentManager.CONNECTOR) && (tdp.mode == TDiagramPanel.NORMAL)) { // is connectingPointShow selected -// if(tdp.highlightOutAndFreeConnectingPoint(e.getX(), e.getY(), tdp.getMGUI().getIdButtonSelected())) { -// tdp.repaint(); -// } -// } -// -// if ((selected == TGComponentManager.CONNECTOR) && (tdp.mode == TDiagramPanel.ADDING_CONNECTOR)) { -// tdp.highlightInAndFreeConnectingPoint(e.getX(), e.getY(), tdp.getMGUI().getIdButtonSelected()); -// tdp.setAddingTGConnector(e.getX(), e.getY()); -// tdp.repaint(); -// } - tdp.repaint(); + if ((selected == TGComponentManager.CONNECTOR) && (tdp.mode == TDiagramPanel.NORMAL)) { // is connectingPointShow selected + if(tdp.highlightOutAndFreeConnectingPoint(e.getX(), e.getY(), tdp.getMGUI().getIdButtonSelected())) { + tdp.repaint(); + } + } + + if ((selected == TGComponentManager.CONNECTOR) && (tdp.mode == TDiagramPanel.ADDING_CONNECTOR)) { + tdp.highlightInAndFreeConnectingPoint(e.getX(), e.getY(), tdp.getMGUI().getIdButtonSelected()); + tdp.setAddingTGConnector(e.getX(), e.getY()); + tdp.repaint(); + } + } @Override diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java index 187a537778..e23b07fe9c 100755 --- a/src/main/java/ui/TDiagramPanel.java +++ b/src/main/java/ui/TDiagramPanel.java @@ -1702,10 +1702,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } if (e.getSource() == enableDisable) { - - // Issue #69 - componentPopup.setEnabled( !componentPopup.isEnabled( true ) ); -// componentPopup.setEnabled(!componentPopup.isEnabled()); + componentPopup.setEnabled(!componentPopup.isEnabled()); getGUI().changeMade(this, CHANGE_VALUE_COMPONENT); repaint(); return; @@ -2035,17 +2032,15 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { clone.setEnabled(false); } - // Issue #69 - enableDisable.setEnabled( componentPointed.canBeDisabled() ); -// if (componentPointed instanceof CanBeDisabled) { -// /*if (componentPointed.hasFather()) { -// clone.setEnabled(false); -// } else {*/ -// enableDisable.setEnabled(true); -// //} -// } else { -// enableDisable.setEnabled(false); -// } + if (componentPointed instanceof CanBeDisabled) { + /*if (componentPointed.hasFather()) { + clone.setEnabled(false); + } else {*/ + enableDisable.setEnabled(true); + //} + } else { + enableDisable.setEnabled(false); + } if (componentPointed instanceof SwallowedTGComponent) { if (componentPointed.getFather() == null) { @@ -2554,18 +2549,6 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } return null; } - - public List<TGConnector> getConnectors() { - final List<TGConnector> connectors = new ArrayList<TGConnector>(); - - for( final TGComponent compo : componentList ) { - if ( compo instanceof TGConnector ) { - connectors.add( (TGConnector) compo ); - } - } - - return connectors; - } public TGComponent getComponentToWhichBelongs(TGConnectingPoint p) { for (TGComponent tgc1 : this.componentList) { @@ -2587,7 +2570,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { return null; } - public void getAllLatencyChecks(List<TGComponent> _list) { + public void getAllLatencyChecks(ArrayList<TGComponent> _list) { for (TGComponent tgc : this.componentList) { if (tgc.getCheckLatency()) { _list.add(tgc); @@ -2595,13 +2578,13 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } } - public void getAllCheckedTGComponent( List<TGComponent> _list) { + public void getAllCheckedTGComponent(ArrayList<TGComponent> _list) { for (TGComponent tgc : this.componentList) if (tgc.hasCheckedAccessibility()) _list.addAll(tgc.getAllCheckedAccessibility()); } - public void getAllCheckableTGComponent(List<TGComponent> _list) { + public void getAllCheckableTGComponent(ArrayList<TGComponent> _list) { for (TGComponent tgc : this.componentList) { //if (tgc instanceof CheckableAccessibility) { _list.addAll(tgc.getAllCheckableAccessibility()); @@ -2612,7 +2595,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } - public void getAllCheckableInvariantTGComponent(List<TGComponent> _list) { + public void getAllCheckableInvariantTGComponent(ArrayList<TGComponent> _list) { for (TGComponent tgc : this.componentList) if (tgc.hasCheckableInvariant()) _list.addAll(tgc.getAllCheckableInvariant()); @@ -3752,7 +3735,8 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { ; } - public void getListOfBreakPoints(List<Point> points, int taskID) { + + public void getListOfBreakPoints(java.util.List<Point> points, int taskID) { for (TGComponent tgc : this.componentList) if (tgc.getBreakpoint() && (tgc.getDIPLOID() != -1)) { boolean found = false; @@ -3912,7 +3896,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { select = b; } - protected void upComponent() { + public void upComponent() { TGComponent tgc = componentPointed; if (tgc != null && tgc.moveable) { tgc.setMoveCd(tgc.x, tgc.y - MOVE_SPEED); @@ -3920,7 +3904,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } } - protected void downComponent() { + public void downComponent() { TGComponent tgc = componentPointed; if (tgc != null && tgc.moveable) { tgc.setMoveCd(tgc.x, tgc.y + MOVE_SPEED); @@ -3928,7 +3912,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } } - protected void leftComponent() { + public void leftComponent() { TGComponent tgc = componentPointed; if (tgc != null && tgc.moveable) { tgc.setMoveCd(tgc.x - MOVE_SPEED, tgc.y); @@ -3936,7 +3920,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } } - protected void rightComponent() { + public void rightComponent() { TGComponent tgc = componentPointed; if (tgc != null && tgc.moveable) { tgc.setMoveCd(tgc.x + MOVE_SPEED, tgc.y); @@ -3944,22 +3928,22 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } } - protected void upComponents() { + public void upComponents() { moveSelected(xSel, ySel - MOVE_SPEED); repaint(); } - protected void downComponents() { + public void downComponents() { moveSelected(xSel, ySel + MOVE_SPEED); repaint(); } - protected void leftComponents() { + public void leftComponents() { moveSelected(xSel - MOVE_SPEED, ySel); repaint(); } - protected void rightComponents() { + public void rightComponents() { moveSelected(xSel + MOVE_SPEED, ySel); repaint(); } @@ -3971,21 +3955,6 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { public TDiagramMouseManager getMouseManager() { return tdmm; } - - /** - * Check if newvalue is already a name of a component. - * - * @param newvalue - * @return true if the name is used - * @author Fabien Tessier - */ - public boolean isCompositeNameUsed(String newvalue) { - for (TGComponent tgc : this.componentList) { - if (tgc.getValue().equals(newvalue)) - return true; - } - return false; - } } diff --git a/src/main/java/ui/TGCNote.java b/src/main/java/ui/TGCNote.java index 0cb5986d14..069995457b 100755 --- a/src/main/java/ui/TGCNote.java +++ b/src/main/java/ui/TGCNote.java @@ -36,6 +36,7 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui; import myutil.*; @@ -118,7 +119,7 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { return this.values; } - @Override + public void internalDrawing(Graphics graph) { if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; @@ -177,10 +178,10 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { graph.fillPolygon(px, py, 4); graph.setColor(c); - // Graphics2D g2 = (Graphics2D)graph; + Graphics2D g2 = (Graphics2D)graph; for (int i = 0; i < this.values.length; i++) { //TraceManager.addDev("Value #" + i + " = " + this.values[i]); - graph.drawString(this.values[i], this.x + this.textX, this.y + this.textY + (i + 1) * this.currentFontSize); + g2.drawString(this.values[i], this.x + this.textX, this.y + this.textY + (i + 1) * this.currentFontSize); } } @@ -188,7 +189,6 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { values = Conversion.wrapText(value); } - @Override public boolean editOndoubleClick(JFrame frame) { String oldValue = this.value; @@ -205,7 +205,6 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { return false; } - @Override public TGComponent isOnMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -213,7 +212,6 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { return null; } - @Override public void rescale(double scaleFactor) { /*dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; lineHeight = (int)(dlineHeight); @@ -225,12 +223,10 @@ public class TGCNote extends TGCScalableWithoutInternalComponent { super.rescale(scaleFactor); } - @Override public int getType() { return TGComponentManager.UML_NOTE; } - @Override protected String translateExtraParam() { if (values == null) this.makeValue(); diff --git a/src/main/java/ui/TGCOneLineText.java b/src/main/java/ui/TGCOneLineText.java index d9db3c6569..26ee5a0803 100755 --- a/src/main/java/ui/TGCOneLineText.java +++ b/src/main/java/ui/TGCOneLineText.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui; import myutil.Conversion; @@ -45,6 +48,8 @@ import ui.util.IconManager; import javax.swing.*; import java.awt.*; +//import java.awt.geom.*; + /** * Class TGCOneLineText * Internal component that is a onle line text @@ -53,8 +58,8 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class TGCOneLineText extends TGCWithoutInternalComponent{ + protected boolean emptyText; - protected boolean emptyText; public TGCOneLineText(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -74,7 +79,6 @@ public class TGCOneLineText extends TGCWithoutInternalComponent{ myImageIcon = IconManager.imgic302; } - @Override public void internalDrawing(Graphics g) { if (!tdp.isScaled()) { width = g.getFontMetrics().stringWidth(value); @@ -86,7 +90,6 @@ public class TGCOneLineText extends TGCWithoutInternalComponent{ } } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y - height, Math.max(width, minWidth), height)) { return this; @@ -94,7 +97,6 @@ public class TGCOneLineText extends TGCWithoutInternalComponent{ return null; } - @Override public boolean editOndoubleClick(JFrame frame) { String oldValue = value; String text = getName() + ": "; @@ -122,12 +124,21 @@ public class TGCOneLineText extends TGCWithoutInternalComponent{ return false; } - /* Issue #69 - * (non-Javadoc) - * @see ui.TGComponent#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - return getFather() != null && getFather().canLabelBeDisabled( this ); + public void renameTab(String s) { + TURTLEPanel tp = this.tdp.tp; + for (TDiagramPanel tdpTmp: tp.panels) { + if (tdpTmp.name.equals(name)) { + if (!tp.nameInUse(s)) { + tp.tabbedPane.setTitleAt(tp.getIndexOfChild(tdpTmp), s); + tp.panels.elementAt(tp.getIndexOfChild(tdpTmp)).setName(s); + tp.mgui.changeMade(null, -1); + } + break; + } + } } + + public boolean nameUsed(String s) { + return this.tdp.tp.refNameUsed(s); + } } diff --git a/src/main/java/ui/TGCPointOfConnector.java b/src/main/java/ui/TGCPointOfConnector.java index 5d8608d4fb..253517696f 100755 --- a/src/main/java/ui/TGCPointOfConnector.java +++ b/src/main/java/ui/TGCPointOfConnector.java @@ -109,13 +109,4 @@ public class TGCPointOfConnector extends TGCScalableWithoutInternalComponent { public int getCurrentMaxY() { return getY() + getHeight(); } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - return false; - } } diff --git a/src/main/java/ui/TGCScalableWithInternalComponent.java b/src/main/java/ui/TGCScalableWithInternalComponent.java index e292b8944c..a5c9f992f7 100755 --- a/src/main/java/ui/TGCScalableWithInternalComponent.java +++ b/src/main/java/ui/TGCScalableWithInternalComponent.java @@ -38,6 +38,8 @@ package ui; +import myutil.TraceManager; + /** * Class TGCScalableWithInternalComponent * Graphical component that contains one or more internal components, and which is scalable @@ -46,10 +48,8 @@ package ui; * @author Ludovic APVRILLE */ public abstract class TGCScalableWithInternalComponent extends TGCWithInternalComponent implements ScalableTGComponent { - - protected boolean rescaled = false; - - protected double oldScaleFactor; + protected boolean rescaled = false; + protected double oldScaleFactor; public TGCScalableWithInternalComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -114,7 +114,7 @@ public abstract class TGCScalableWithInternalComponent extends TGCWithInternalCo hasBeenResized(); } - protected void initScaling(int w, int h) { + public void initScaling(int w, int h) { oldScaleFactor = tdp.getZoom(); dx = 0; @@ -139,4 +139,5 @@ public abstract class TGCScalableWithInternalComponent extends TGCWithInternalCo rescaled = true; } + } diff --git a/src/main/java/ui/TGCWithInternalComponent.java b/src/main/java/ui/TGCWithInternalComponent.java index 833bc50b1d..1b2d6e71a1 100755 --- a/src/main/java/ui/TGCWithInternalComponent.java +++ b/src/main/java/ui/TGCWithInternalComponent.java @@ -36,8 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui; +//import java.awt.*; + /** * Class TGCWithInternalComponent * Graphical component that contains one or more internal components @@ -45,13 +50,13 @@ package ui; * @version 1.0 22/12/2003 * @author Ludovic APVRILLE */ -public abstract class TGCWithInternalComponent extends TGComponent { +public abstract class TGCWithInternalComponent extends TGComponent{ + public TGCWithInternalComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); } - @Override public void setState(int s) { state = s; if (s != TGState.POINTER_ON_ME) { @@ -71,7 +76,6 @@ public abstract class TGCWithInternalComponent extends TGComponent { } } - @Override public final TGComponent isOnMe(int x1, int y1) { selectedInternalComponent = isOnAnInternalTGComponent(x1, y1); @@ -83,4 +87,5 @@ public abstract class TGCWithInternalComponent extends TGComponent { } public abstract TGComponent isOnOnlyMe(int x1, int y1); + } diff --git a/src/main/java/ui/TGCWithoutInternalComponent.java b/src/main/java/ui/TGCWithoutInternalComponent.java index 8689b45193..cfbf1548ae 100755 --- a/src/main/java/ui/TGCWithoutInternalComponent.java +++ b/src/main/java/ui/TGCWithoutInternalComponent.java @@ -36,8 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui; +//import java.awt.*; + /** * Class TGCWithoutInternalComponent * Graphical component which contains no internal component @@ -54,7 +59,6 @@ public abstract class TGCWithoutInternalComponent extends TGComponent{ nbInternalTGComponent = 0; } - @Override public void setState(int s) { if ((s == TGState.POINTED) && (father == null)) { state = TGState.POINTER_ON_ME; diff --git a/src/main/java/ui/TGComponent.java b/src/main/java/ui/TGComponent.java index 644262db99..3d48762e9b 100755 --- a/src/main/java/ui/TGComponent.java +++ b/src/main/java/ui/TGComponent.java @@ -68,7 +68,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.geom.Point2D; import java.util.ArrayList; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Vector; @@ -82,7 +81,7 @@ import java.util.Vector; * @version 1.0 21/12/2003 */ -public abstract class TGComponent extends AbstractCDElement implements /*CDElement,*/ GenericTree { +public abstract class TGComponent implements CDElement, GenericTree { protected final static String XML_HEAD = "<COMPONENT type=\""; protected final static String XML_ID = "\" id=\""; @@ -157,7 +156,7 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem protected TGComponent selectedInternalComponent; // characteristics - //protected boolean enabled = true; + protected boolean enabled = true; protected boolean moveable; protected boolean removable; protected boolean multieditable = false; @@ -169,7 +168,7 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem //Associated transactions public String transaction = ""; - public List<SimulationTransaction> transactions = new ArrayList<SimulationTransaction>(); + public java.util.List<SimulationTransaction> transactions = new ArrayList<SimulationTransaction>(); //If task public String runningStatus = ""; @@ -246,14 +245,14 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem public abstract void setState(int s); -// -// public void setEnabled(boolean _enabled) { -// enabled = _enabled; -// } -// -// public boolean isEnabled() { -// return enabled; -// } + + public void setEnabled(boolean _enabled) { + enabled = _enabled; + } + + public boolean isEnabled() { + return enabled; + } // Internal component operations public void setFather(TGComponent _father) { @@ -388,14 +387,14 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem return false; } - public List<TGComponent> getAllCheckedAccessibility() { - List<TGComponent> list = new LinkedList<TGComponent>(); + public java.util.List<TGComponent> getAllCheckedAccessibility() { + java.util.List<TGComponent> list = new LinkedList<TGComponent>(); getAllCheckedAccessibility(list); return list; } - public void getAllCheckedAccessibility(List<TGComponent> _list) { + public void getAllCheckedAccessibility(java.util.List<TGComponent> _list) { if (accessibility) { _list.add(this); } @@ -407,14 +406,14 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem } } - public List<TGComponent> getAllCheckableAccessibility() { - List<TGComponent> list = new LinkedList<TGComponent>(); + public java.util.List<TGComponent> getAllCheckableAccessibility() { + java.util.List<TGComponent> list = new LinkedList<TGComponent>(); getAllCheckableAccessibility(list); return list; } - public void getAllCheckableAccessibility(List<TGComponent> _list) { + public void getAllCheckableAccessibility(java.util.List<TGComponent> _list) { TraceManager.addDev("Investigating accessibility of " + this); if (this instanceof CheckableAccessibility) { _list.add(this); @@ -613,7 +612,7 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem GraphicLib.dashedRect(g, x + width + s2 + s3, y + s3, w + 15, h - 12); } - protected void drawAttributes(Graphics g, String attr) { + public void drawAttributes(Graphics g, String attr) { if (attr == null) { return; } @@ -631,9 +630,11 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem int w = p1.x; int h = p1.y - y + s3; GraphicLib.dashedRect(g, x + width + s2 + s3, y + s3, w + 15, h - 12); + } - protected Point drawCode(Graphics g, String s, int x1, int y1, boolean pre, boolean java, int dec) { + public Point drawCode(Graphics g, String s, int x1, int y1, boolean pre, boolean java, int dec) { + Point p = new Point(0, y1); String info; @@ -1021,14 +1022,11 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem } + public void draw(Graphics g) { RunningInfo ri; LoadInfo li; - - // Issue #69: Disabling of components - ColorManager.setColor(g, state, 0, isEnabled() ); -// ColorManager.setColor(g, state, 0); - + ColorManager.setColor(g, state, 0); Font font = new Font(Font.SANS_SERIF, Font.PLAIN, this.tdp.getFontSize()); g.setFont(font); internalDrawing(g); @@ -1155,7 +1153,7 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem if (li != null) { drawLoadDiploID(g, li); } - List<SimulationTransaction> ts = tdp.getMGUI().getTransactions(getDIPLOID()); + java.util.List<SimulationTransaction> ts = tdp.getMGUI().getTransactions(getDIPLOID()); if (ts != null && ts.size() > 0) { transactions = new ArrayList<SimulationTransaction>(ts); transaction = transactions.get(transactions.size() - 1).taskName + ":" + transactions.get(transactions.size() - 1).command; @@ -1629,8 +1627,8 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem return tgcomponent[index]; } - public List<TGComponent> getRecursiveAllInternalComponent() { - List<TGComponent> ll = new LinkedList<TGComponent>(); + public LinkedList<TGComponent> getRecursiveAllInternalComponent() { + LinkedList<TGComponent> ll = new LinkedList<TGComponent>(); for (int i = 0; i < nbInternalTGComponent; i++) { ll.add(tgcomponent[i]); @@ -3049,7 +3047,7 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem return saveInXML(true); } - protected StringBuffer saveInXML(boolean saveSubComponents) { + public StringBuffer saveInXML(boolean saveSubComponents) { StringBuffer sb = null; boolean b = (father == null); if (b) { @@ -3070,10 +3068,7 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem sb.append(translateCDParam()); sb.append(translateSizeParam()); sb.append(translateHidden()); - - // Issue #69 - if ( canBeDisabled() ) { - //if (this instanceof CanBeDisabled) { + if (this instanceof CanBeDisabled) { sb.append(translateEnabled()); } sb.append(translateCDRectangleParam()); @@ -3124,7 +3119,7 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem } protected String translateEnabled() { - return "<enabled value=\"" + isEnabled() + "\" />\n"; + return "<enabled value=\"" + enabled + "\" />\n"; } protected String translateHidden() { @@ -3284,7 +3279,6 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem public void postLoading(int decId) throws MalformedModelingException { } - @Override public String toString() { String s1 = getName(); String s2 = getValue(); @@ -3347,131 +3341,4 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDElem public void clickSelect(boolean b) { isSelect = b; } - - /** - * Issue #69 - * @param point - * @return - */ - public TGConnector getConnectorConnectedTo( final TGConnectingPoint point ) { - return tdp.getConnectorConnectedTo( point ); - } - - /** - * Issue #69 - * @return - */ - public List<TGConnector> getConnectors() { - return tdp.getConnectors(); - } - - /** - * Issue #69 - * @return - */ - public List<TGConnector> getInputConnectors() { - final List<TGConnector> connectors = new ArrayList<TGConnector>(); - final List<TGConnectingPoint> points = Arrays.asList( getConnectingPoints() ); - - for ( final TGConnector connector : getConnectors() ) { - if ( points.contains( connector.getTGConnectingPointP2() ) ) { - connectors.add( connector ); - } - } - - return connectors; - } - - /** - * Issue #69 - * @return - */ - public List<TGConnector> getOutputConnectors() { - final List<TGConnector> connectors = new ArrayList<TGConnector>(); - final List<TGConnectingPoint> points = Arrays.asList( getConnectingPoints() ); - - for ( final TGConnector connector : getConnectors() ) { - if ( points.contains( connector.getTGConnectingPointP1() ) ) { - connectors.add( connector ); - } - } - - return connectors; - } - - /** - * Issue #69 - * @return - */ - public TGConnectingPoint[] getConnectingPoints() { - return connectingPoint; - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#acceptForward(ui.ICDElementVisitor) - */ - @Override - public void acceptForward( final ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - if ( tgcomponent != null ) { - for ( final TGComponent subCompo : tgcomponent ) { - subCompo.acceptForward( visitor ); - } - } - - if ( connectingPoint != null ) { - for ( final TGConnectingPoint point : connectingPoint ) { - final TGConnector connector = getConnectorConnectedTo( point ); - - if ( connector != null && point == connector.getTGConnectingPointP1() ) { - point.acceptForward( visitor ); - } - } - } - } - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#acceptBackward(ui.ICDElementVisitor) - */ - @Override - public void acceptBackward( final ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - if ( tgcomponent != null ) { - for ( final TGComponent subCompo : tgcomponent ) { - subCompo.acceptBackward( visitor ); - } - } - - if ( connectingPoint != null ) { - for ( final TGConnectingPoint point : connectingPoint ) { - final TGConnector connector = getConnectorConnectedTo( point ); - - if ( connector != null && point == connector.getTGConnectingPointP2() ) { - point.acceptBackward( visitor ); - } - } - } - } - } - - public void renameTab(String s) { - TURTLEPanel tp = this.tdp.tp; - for (TDiagramPanel tdpTmp: tp.panels) { - if (tdpTmp.name.equals(name)) { - if (!tp.nameInUse(s)) { - tp.tabbedPane.setTitleAt(tp.getIndexOfChild(tdpTmp), s); - tp.panels.elementAt(tp.getIndexOfChild(tdpTmp)).setName(s); - tp.mgui.changeMade(null, -1); - } - break; - } - } - } - - public boolean nameUsed(String s) { - return this.tdp.tp.refNameUsed(s); - } } diff --git a/src/main/java/ui/TGComponentManager.java b/src/main/java/ui/TGComponentManager.java index 00855a1cd4..ffa0c80975 100644 --- a/src/main/java/ui/TGComponentManager.java +++ b/src/main/java/ui/TGComponentManager.java @@ -37,8 +37,11 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui; +//import java.awt.*; + import ui.ad.*; import ui.atd.*; import ui.avatarad.*; @@ -325,9 +328,7 @@ public class TGComponentManager { public static final int TMLCP_REF_SD = 1505; public static final int TMLCP_START_STATE = 1506; public static final int TMLCP_STOP_STATE = 1507; - - // Issue #69 - // public static final int TMLCP_JUNCTION = 1508; + public static final int TMLCP_JUNCTION = 1508; public static final int TMLCP_FOR_LOOP = 1510; public static final int TMLSD_STORAGE_INSTANCE = 1520; @@ -432,10 +433,7 @@ public class TGComponentManager { public static final int AVATARSMD_CONNECTOR = 5102; public static final int AVATARSMD_SEND_SIGNAL = 5103; public static final int AVATARSMD_RECEIVE_SIGNAL = 5104; - - // Issue #69 - //public static final int AVATARSMD_PARALLEL = 5105; - + public static final int AVATARSMD_PARALLEL = 5105; public static final int AVATARSMD_STATE = 5106; public static final int AVATARSMD_CHOICE = 5107; public static final int AVATARSMD_RANDOM = 5108; @@ -604,9 +602,9 @@ public class TGComponentManager { case AVATARSMD_RECEIVE_SIGNAL: tgc = new AvatarSMDReceiveSignal(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; -// case AVATARSMD_PARALLEL: Issue #69 -// tgc = new AvatarSMDParallel(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); -// break; + case AVATARSMD_PARALLEL: + tgc = new AvatarSMDParallel(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; case AVATARSMD_STATE: tgc = new AvatarSMDState(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; @@ -1404,9 +1402,9 @@ public class TGComponentManager { case TMLCP_STOP_STATE: tgc = new TMLCPStopState(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; -// case TMLCP_JUNCTION: // Issue #69 -// tgc = new TMLCPJunction(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); -// break; + case TMLCP_JUNCTION: + tgc = new TMLCPJunction(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; case TMLCP_FOR_LOOP: tgc = new TMLCPForLoop(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; @@ -1559,8 +1557,8 @@ public class TGComponentManager { return AVATARSMD_RECEIVE_SIGNAL; } else if (tgc instanceof AvatarSMDLibraryFunctionCall) { return AVATARSMD_LIBRARY_FUNCTION_CALL; -// } else if (tgc instanceof AvatarSMDParallel) { // Issue #69 -// return AVATARSMD_PARALLEL; + } else if (tgc instanceof AvatarSMDParallel) { + return AVATARSMD_PARALLEL; } else if (tgc instanceof AvatarSMDState) { return AVATARSMD_STATE; } else if (tgc instanceof AvatarSMDChoice) { @@ -2202,8 +2200,8 @@ public class TGComponentManager { return TMLCP_START_STATE; } else if (tgc instanceof TMLCPStopState) { return TMLCP_STOP_STATE; -// } else if (tgc instanceof TMLCPJunction) { Issue #69 -// return TMLCP_JUNCTION; + } else if (tgc instanceof TMLCPJunction) { + return TMLCP_JUNCTION; } else if (tgc instanceof TMLCPForLoop) { return TMLCP_FOR_LOOP; } else if (tgc instanceof TGConnectorTMLCP) { diff --git a/src/main/java/ui/TGConnectingPoint.java b/src/main/java/ui/TGConnectingPoint.java index 1ac1d98c38..8943e41030 100755 --- a/src/main/java/ui/TGConnectingPoint.java +++ b/src/main/java/ui/TGConnectingPoint.java @@ -37,6 +37,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui; import myutil.GraphicLib; @@ -50,9 +53,9 @@ import java.awt.*; * @version 1.0 22/12/2003 * @author Ludovic APVRILLE, Andrea Enrici */ -public class TGConnectingPoint extends AbstractCDElement /*implements CDElement*/ { +public class TGConnectingPoint implements CDElement { - //protected TGComponent father; + protected TGComponent father; //private static int ID = 0; @@ -120,7 +123,6 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* public void draw(Graphics g) { int mx = getX(); int my = getY(); - if (state == SELECTED) { mx = mx - width / 2; my = my - height / 2; @@ -131,6 +133,7 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* g.setColor(myColor); g.fillRect(mx - width/4, my - width/4, width/2, height/2); GraphicLib.doubleColorRect(g, mx - width/4, my - width/4, width/2, height/2, Color.lightGray, Color.black); + } } @@ -217,6 +220,8 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* TGComponent.setGeneralId(id + 1); } + + // return true if state _s is different from the previous one public boolean setState(int _s){ boolean b = false; @@ -291,9 +296,9 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* }*/ //DG 27.02. -// public TGComponent getOwner() { -// return father; -// } + public TGComponent getOwner() { + return father; + } //fin DG public void setReferenceToConnector( TGConnector _ref ) { @@ -320,70 +325,4 @@ public class TGConnectingPoint extends AbstractCDElement /*implements CDElement* public int getCurrentMaxY() { return getY() + getHeight(); } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - return false; - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#isEnabled() - */ - @Override - public boolean isEnabled() { - return true; - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#acceptForward(ui.ICDElementVisitor) - */ - @Override - public void acceptForward( final ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - if ( getFather() instanceof TGComponent ) { - final TGConnector connector = ( (TGComponent) getFather() ).getConnectorConnectedTo( this ); - - if ( connector != null ) { - - // Traverse the graph in its direction - if ( this == connector.getTGConnectingPointP2() ) { - getFather().acceptForward( visitor ); - } - else { - connector.acceptForward( visitor ); - } - } - } - } - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#acceptBackward(ui.ICDElementVisitor) - */ - @Override - public void acceptBackward( final ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - if ( getFather() instanceof TGComponent ) { - final TGConnector connector = ( (TGComponent) getFather() ).getConnectorConnectedTo( this ); - - if ( connector != null ) { - - // Traverse the graph in its direction - if ( this == connector.getTGConnectingPointP1() ) { - getFather().acceptBackward( visitor ); - } - else { - connector.acceptBackward( visitor ); - } - } - } - } - } } diff --git a/src/main/java/ui/TGConnectingPointWidthHeight.java b/src/main/java/ui/TGConnectingPointWidthHeight.java index 46d95a7615..2aa5eab134 100755 --- a/src/main/java/ui/TGConnectingPointWidthHeight.java +++ b/src/main/java/ui/TGConnectingPointWidthHeight.java @@ -36,8 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui; +//import java.awt.*; + /** * Class TGConnectingPointWidthHeight * Connecting points of TClasses @@ -46,10 +51,8 @@ package ui; * @author Ludovic APVRILLE */ public class TGConnectingPointWidthHeight extends TGConnectingPoint{ - - protected double w; - - protected double h; + protected double w; + protected double h; public TGConnectingPointWidthHeight(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out); @@ -57,12 +60,10 @@ public class TGConnectingPointWidthHeight extends TGConnectingPoint{ h = _h; } - @Override public int getX() { return x + container.getX() + (int)(container.getWidth() * w); } - @Override public int getY() { return y + container.getY() + (int)(container.getHeight() * h); } diff --git a/src/main/java/ui/TGConnector.java b/src/main/java/ui/TGConnector.java index c8cfd70edf..0166e22e6b 100755 --- a/src/main/java/ui/TGConnector.java +++ b/src/main/java/ui/TGConnector.java @@ -37,6 +37,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui; import myutil.*; @@ -56,7 +59,7 @@ import java.util.Vector; * @version 1.0 22/12/2003 * @author Ludovic APVRILLE, Andrea ENRICI */ -public abstract class TGConnector extends TGCScalableWithInternalComponent { +public abstract class TGConnector extends TGCScalableWithInternalComponent { protected final static String XML_CONNECTOR_HEAD = "<CONNECTOR type=\""; protected final static String XML_ID = "\" id=\""; @@ -185,9 +188,10 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { //TraceManager.addDev("Index=" + index); return index; } + public int getFirstIndexOfOtherInternalComponents() { - return getIndexOfLastTGCPointOfConnector() + 1; + return getIndexOfLastTGCPointOfConnector() + 1; } public boolean hasTGCPointOfConnector() { @@ -205,25 +209,24 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { return -1; }*/ - @Override public void internalDrawing(Graphics g) { + TGComponent p3, p4; + if (hasTGCPointOfConnector()) { p3 = tgcomponent[0]; p4 = tgcomponent[0]; //TraceManager.addDev("p3.x " + p3.getX() + " p3.y " + p3.getY()); //drawMiddleSegment(g, p1.getX(), p1.getY(), p3.getXZoom(), p3.getYZoom()); - drawMiddleSegment(g, p1.getX(), p1.getY(), p3.getX(), p3.getY()); + drawMiddleSegment(g, p1.getX(), p1.getY(), p3.getX(), p3.getY()); - TGCPointOfConnector[] pts = listOfPointsToArray(); - + TGCPointOfConnector[] pts = listOfPointsToArray(); for(int i=0; i<pts.length-1; i++) { p3 = tgcomponent[i]; p4 = tgcomponent[i+1]; drawMiddleSegment(g, p3.getX(), p3.getY(), p4.getX(), p4.getY()); } - drawLastSegment(g, p4.getX(), p4.getY(), p2.getX(), p2.getY()); } else { drawLastSegment(g, p1.getX(), p1.getY(), p2.getX(), p2.getY()); @@ -444,12 +447,12 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { } private int indexOf(TGComponent pt) { - for(int i=0; i<tgcomponent.length; i++) { - if (tgcomponent[i] == pt) { - return i; - } - } - return -1; + for(int i=0; i<tgcomponent.length; i++) { + if (tgcomponent[i] == pt) { + return i; + } + } + return -1; } public int indexPointedSegment(int x1, int y1) { @@ -462,7 +465,7 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { return 0; } - TGCPointOfConnector []points = listOfPointsToArray(); + TGCPointOfConnector []points = listOfPointsToArray(); for(int i=0; i<points.length-1; i++) { p3 = points[i]; p4 = points[i+1]; @@ -618,7 +621,6 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { return true; } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { TGComponent p3, p4; int i; @@ -772,7 +774,6 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { } - @Override public StringBuffer saveInXML() { StringBuffer sb = new StringBuffer(XML_CONNECTOR_HEAD); sb.append(getType()); @@ -827,7 +828,6 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { } } - @Override public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { popupx = x; popupy = y; @@ -863,7 +863,6 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { } } - @Override public boolean eventOnPopup(ActionEvent e) { if (e.getActionCommand().equals("Add Point")) { return addTGCPointOfConnector(popupx, popupy); @@ -909,8 +908,8 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { tgcomponent = tgcomponentnew; } + // Middle of the last segment - @Override public void drawAttributes(Graphics g, String attr) { int s0=4, s1=9, s2=30, s3=10; int x1, y1; @@ -976,46 +975,4 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { return maxValue; } - - /* Issue #69 - * (non-Javadoc) - * @see ui.TGComponent#acceptForward(ui.ICDElementVisitor) - */ - @Override - public void acceptForward( ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - - // Traverse the graph in the direction of the connector - getTGConnectingPointP2().acceptForward( visitor ); - } - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.TGComponent#acceptBackward(ui.ICDElementVisitor) - */ - @Override - public void acceptBackward( ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - - // Traverse the graph in the direction of the connector - getTGConnectingPointP1().acceptBackward( visitor ); - } - } - - public boolean isContainedBy( final TGComponent component ) { - if ( p2 != null ) { - if ( p2.getFather() instanceof TGComponent && ( (TGComponent) p2.getFather() ).getFather() == component ) { - return true; - } - } - - if ( p1 != null ) { - if ( p1.getFather() instanceof TGComponent && ( (TGComponent) p1.getFather() ).getFather() == component ) { - return true; - } - } - - return false; - } }//End of class diff --git a/src/main/java/ui/TGConnectorComment.java b/src/main/java/ui/TGConnectorComment.java index dc15f63d6e..9f17561d41 100755 --- a/src/main/java/ui/TGConnectorComment.java +++ b/src/main/java/ui/TGConnectorComment.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui; import myutil.GraphicLib; @@ -44,6 +47,8 @@ import ui.util.IconManager; import java.awt.*; import java.util.Vector; +//import java.awt.geom.*; + /** * Class TGConnectorComment * Connects a UML note to a component @@ -55,23 +60,21 @@ public class TGConnectorComment extends TGConnector { public TGConnectorComment(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); - myImageIcon = IconManager.imgic108; automaticDrawing = false; } - @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ GraphicLib.dashedLine(g, x1, y1, x2, y2); + } - @Override protected void drawMiddleSegment(Graphics g, int x1, int y1, int x2, int y2) { GraphicLib.dashedLine(g, x1, y1, x2, y2); } - @Override public int getType() { return TGComponentManager.CONNECTOR_COMMENT; } + } diff --git a/src/main/java/ui/TGConnectorFullArrow.java b/src/main/java/ui/TGConnectorFullArrow.java index 4b356be0e5..3e95702904 100755 --- a/src/main/java/ui/TGConnectorFullArrow.java +++ b/src/main/java/ui/TGConnectorFullArrow.java @@ -35,6 +35,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui; @@ -53,16 +56,13 @@ import java.util.Vector; * @author Ludovic APVRILLE */ public class TGConnectorFullArrow extends TGConnector implements TGConnectorBetweenElementsInterface { - protected int arrowLength = 10; public TGConnectorFullArrow(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); - myImageIcon = IconManager.imgic202; } - @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { g.drawLine(x1, y1, x2, y2); @@ -71,8 +71,15 @@ public class TGConnectorFullArrow extends TGConnector implements TGConnectorBet } } - @Override public int getType() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; + // + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } } + + + + + + + diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java index 44f4c64ee8..a7e8d1b31e 100644 --- a/src/main/java/ui/TGUIAction.java +++ b/src/main/java/ui/TGUIAction.java @@ -425,7 +425,7 @@ public class TGUIAction extends AbstractAction { public static final int ASMD_SEND_SIGNAL = 296; public static final int ASMD_RECEIVE_SIGNAL = 297; public static final int ASMD_LIBRARY_FUNCTION_CALL = 432; - //public static final int ASMD_PARALLEL = 298; Issue #69 + public static final int ASMD_PARALLEL = 298; public static final int ASMD_STATE = 299; public static final int ASMD_CHOICE = 325; public static final int ASMD_RANDOM = 326; @@ -1301,7 +1301,7 @@ public class TGUIAction extends AbstractAction { actions[ASMD_RECEIVE_SIGNAL] = new TAction("add-asmd-receivesignal", "Receive signal", IconManager.imgic2016, IconManager.imgic2016, "Receive signal", "Add a receive signal operator to the currently opened AVATAR state machine diagram", 0); // TODO: change icon actions[ASMD_LIBRARY_FUNCTION_CALL] = new TAction("add-asmd-libraryfunctioncall", "Library function call", IconManager.imgic2018, IconManager.imgic2018, "Library function call", "Add a library function call to the currently opened AVATAR state machine diagram", 0); - //actions[ASMD_PARALLEL] = new TAction("add-asmd-parallel", "Parallel", IconManager.imgic206, IconManager.imgic206, "Parallel", "Add a parallel operator to the currently opened AVATAR state machine diagram", 0); + actions[ASMD_PARALLEL] = new TAction("add-asmd-parallel", "Parallel", IconManager.imgic206, IconManager.imgic206, "Parallel", "Add a parallel operator to the currently opened AVATAR state machine diagram", 0); actions[ASMD_STATE] = new TAction("add-asmd-state", "State", IconManager.imgic5036, IconManager.imgic5036, "State", "Add a new state to the currently opened AVATAR state machine diagram", 0); actions[ASMD_CHOICE] = new TAction("add-asmd-choice", "Add Choice", IconManager.imgic208, IconManager.imgic208, "Choice", "Add a choice - non-deterministic or guarded - to the currently opened AVATAR state machine diagram", 0); actions[ASMD_RANDOM] = new TAction("add-asmd-random", "Add random", IconManager.imgic924, IconManager.imgic924, "Select random", "Add a random operator to the currently opened AVATAR State Machine diagram", 0); @@ -1382,9 +1382,10 @@ public class TGUIAction extends AbstractAction { actions[ACT_GENERATE_ONTOLOGIES_ALL_DIAGRAMS] = new TAction("generate-ontology-all-diagrams", "Generate ontology (all diagrams)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (all diagrams)", "Generate the ontology for the diagrams under edition", 0); actions[MOVE_ENABLED] = new TAction("Move", "Move enabled", IconManager.imgic780, IconManager.imgic780, "Move enabled (shift + arrow)", "Move", 0); - actions[FIRST_DIAGRAM] = new TAction("FirstDiagram", "First Diagram", IconManager.imgic142, IconManager.imgic142, "Switch the the first diagram", "Switch to the first diagram", 0); + actions[FIRST_DIAGRAM] = new TAction("FirstDiagram", "First Diagram", IconManager.imgic142, IconManager.imgic142, "Switch the the first diagram", "Switch to the first diagram", 0); } + public String getActionCommand() { return (String)getValue(Action.ACTION_COMMAND_KEY); } @@ -1397,7 +1398,6 @@ public class TGUIAction extends AbstractAction { return (String)getValue(Action.LONG_DESCRIPTION); } - @Override public void actionPerformed(ActionEvent evt) { if (listeners != null) { Object[] listenerList = listeners.getListenerList(); diff --git a/src/main/java/ui/TrackingCDElementVisitor.java b/src/main/java/ui/TrackingCDElementVisitor.java deleted file mode 100644 index 5dbfd6a684..0000000000 --- a/src/main/java/ui/TrackingCDElementVisitor.java +++ /dev/null @@ -1,18 +0,0 @@ -package ui; - -import java.util.HashSet; -import java.util.Set; - -public abstract class TrackingCDElementVisitor implements ICDElementVisitor { - - private final Set<CDElement> visitedElements; - - protected TrackingCDElementVisitor() { - visitedElements = new HashSet<CDElement>(); - } - - @Override - public boolean visit(CDElement element) { - return visitedElements.add( element ); - } -} diff --git a/src/main/java/ui/UICheckingError.java b/src/main/java/ui/UICheckingError.java index b03b7feeba..bbbb281e7e 100755 --- a/src/main/java/ui/UICheckingError.java +++ b/src/main/java/ui/UICheckingError.java @@ -36,10 +36,16 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + + package ui; import translator.CheckingError; + + /** * Class UICheckingError * Creation: 07/06/2017 @@ -48,14 +54,7 @@ import translator.CheckingError; */ public class UICheckingError extends CheckingError { - /** - * - */ - private static final long serialVersionUID = -6532490783339577084L; - - public static final String MESSAGE_CHOICE_BOTH_STOCHASTIC_DETERMINISTIC = "Badly formatted choice: it has both non-determinitic/ stochastic and regular guards"; - - private TDiagramPanel tdp; + private TDiagramPanel tdp; private TGComponent tgc; public UICheckingError(int _type, String _message) { diff --git a/src/main/java/ui/ad/CanBeDisabledADElementVisitor.java b/src/main/java/ui/ad/CanBeDisabledADElementVisitor.java deleted file mode 100644 index 19c9172844..0000000000 --- a/src/main/java/ui/ad/CanBeDisabledADElementVisitor.java +++ /dev/null @@ -1,53 +0,0 @@ -package ui.ad; - -import ui.TrackingCDElementVisitor; -import ui.CDElement; -import ui.TGConnectingPoint; - -public class CanBeDisabledADElementVisitor extends TrackingCDElementVisitor { - - private boolean canBeDisabled; - - public CanBeDisabledADElementVisitor() { - super(); - - canBeDisabled = true; - } - - /* Check that the element is not part of the inside loop of a for loop - * (non-Javadoc) - * @see ui.ICDElementVisitor#visit(ui.CDElement) - */ - @Override - public boolean visit( final CDElement element ) { - if ( !super.visit( element ) ) { - return false; - } - - if ( element instanceof TGConnectingPoint ) { - final CDElement father = ( (TGConnectingPoint) element ).getFather(); - - if ( father instanceof TADForLoop ) { - if ( element == ( (TADForLoop) father ).getInsideLoopConnectingPoint() && !father.isEnabled() ) { - canBeDisabled = false; - - return false; - } - } - -// if ( father instanceof TADSequence ) { -// if ( element != ( (TADSequence) father ).getEnterSequenceConnectionPoint() && !father.isEnabled() ) { -// canBeDisabled = false; -// -// return false; -// } -// } - } - - return true; - } - - public boolean isCanBeDisabled() { - return canBeDisabled; - } -} diff --git a/src/main/java/ui/ad/EnablingADBranchVisitor.java b/src/main/java/ui/ad/EnablingADBranchVisitor.java deleted file mode 100644 index 592367a684..0000000000 --- a/src/main/java/ui/ad/EnablingADBranchVisitor.java +++ /dev/null @@ -1,30 +0,0 @@ -package ui.ad; - -import ui.CDElement; -import ui.TrackingCDElementVisitor; - -public class EnablingADBranchVisitor extends TrackingCDElementVisitor { - - private final boolean enabled; - - public EnablingADBranchVisitor( final boolean enabled ) { - super(); - - this.enabled = enabled; - } - - /* Disable everything of the branch - * (non-Javadoc) - * @see ui.ICDElementVisitor#visit(ui.CDElement) - */ - @Override - public boolean visit( final CDElement element ) { - if ( !super.visit( element ) ) { - return false; - } - - element.doSetEnabled( enabled ); - - return true; - } -} diff --git a/src/main/java/ui/ad/EnablingADConnectorVisitor.java b/src/main/java/ui/ad/EnablingADConnectorVisitor.java deleted file mode 100644 index 60a190a350..0000000000 --- a/src/main/java/ui/ad/EnablingADConnectorVisitor.java +++ /dev/null @@ -1,51 +0,0 @@ -package ui.ad; - -import ui.CDElement; -import ui.TGConnectingPoint; -import ui.TGConnector; -import ui.TrackingCDElementVisitor; - -public class EnablingADConnectorVisitor extends TrackingCDElementVisitor { - - private final boolean enabled; - - public EnablingADConnectorVisitor( final boolean enabled ) { - super(); - - this.enabled = enabled; - } - - @Override - public boolean visit( final CDElement element ) { - if ( !super.visit( element ) ) { - return false; - } - - // Do not disable the stop - if ( element instanceof TADStopState ) { - return false; - } - - if ( element.canBeDisabled() && !( element instanceof TGConnector ) ) { - element.setEnabled( enabled ); - } - - if ( element instanceof TGConnectingPoint ) { - final TGConnectingPoint point = (TGConnectingPoint) element; - final CDElement father = point.getFather(); - - // Only continue if the point does not belongs to the inside of the loop because it is managed by - // the For itself - if ( father instanceof TADForLoop ) { - return point != ( (TADForLoop) father ).getInsideLoopConnectingPoint(); - } - - // Disabling a sequence results in disabling all its branches so only continue if we are at entrance -// if ( father instanceof TADSequence ) { -// return point == ( (TADSequence) father ).getEnterSequenceConnectionPoint(); -// } - } - - return true; - } -} diff --git a/src/main/java/ui/ad/TADActionState.java b/src/main/java/ui/ad/TADActionState.java index a99752dca2..6188b2dcd4 100755 --- a/src/main/java/ui/ad/TADActionState.java +++ b/src/main/java/ui/ad/TADActionState.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -52,7 +55,7 @@ import java.awt.geom.Line2D; * @version 1.0 12/08/2003 * @author Ludovic APVRILLE */ -public class TADActionState extends TADOneLineText/* Issue #69 TGCOneLineText*/ implements PreJavaCode, PostJavaCode, CheckableAccessibility, ActionStateErrorHighlight { +public class TADActionState extends TGCOneLineText implements PreJavaCode, PostJavaCode, CheckableAccessibility, ActionStateErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -68,12 +71,11 @@ public class TADActionState extends TADOneLineText/* Issue #69 TGCOneLineText*/ height = 20; minWidth = 30; - createConnectingPoints(); -// nbConnectingPoint = 2; -// connectingPoint = new TGConnectingPoint[2]; -// connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); -// addTGConnectingPointsComment(); + nbConnectingPoint = 2; + connectingPoint = new TGConnectingPoint[2]; + connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); + addTGConnectingPointsComment(); moveable = true; editable = true; @@ -85,16 +87,6 @@ public class TADActionState extends TADOneLineText/* Issue #69 TGCOneLineText*/ myImageIcon = IconManager.imgic204; } - protected void createConnectingPoints() { - nbConnectingPoint = 2; - connectingPoint = new TGConnectingPoint[ nbConnectingPoint ]; - connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); - - addTGConnectingPointsComment(); - } - - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -135,7 +127,6 @@ public class TADActionState extends TADOneLineText/* Issue #69 TGCOneLineText*/ } } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -184,18 +175,19 @@ public class TADActionState extends TADOneLineText/* Issue #69 TGCOneLineText*/ return ret; } - @Override public int getType() { return TGComponentManager.TAD_ACTION_STATE; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_AD_DIAGRAM; } - @Override public void setStateAction(int _stateAction) { stateAction = _stateAction; } + + + + } diff --git a/src/main/java/ui/ad/TADArrayGetState.java b/src/main/java/ui/ad/TADArrayGetState.java index 47e708e4ac..96138a63e5 100755 --- a/src/main/java/ui/ad/TADArrayGetState.java +++ b/src/main/java/ui/ad/TADArrayGetState.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -57,7 +60,7 @@ import java.awt.geom.Line2D; * @version 1.0 20/03/2009 * @author Ludovic APVRILLE */ -public class TADArrayGetState extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements BasicErrorHighlight { +public class TADArrayGetState extends TGCWithoutInternalComponent implements BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -95,7 +98,8 @@ public class TADArrayGetState extends TADComponentWithoutSubcomponents/* Issue # myImageIcon = IconManager.imgic230; } - @Override + + public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -132,8 +136,8 @@ public class TADArrayGetState extends TADComponentWithoutSubcomponents/* Issue # }*/ } - @Override public boolean editOndoubleClick(JFrame frame) { + String oldValue = value; JDialogArrayGet jdag = new JDialogArrayGet(frame, variable, array, index, "Getting value from an array"); @@ -157,7 +161,6 @@ public class TADArrayGetState extends TADComponentWithoutSubcomponents/* Issue # value = variable + " = " + array + "[" + index + "]"; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Prop variable=\""); @@ -210,7 +213,6 @@ public class TADArrayGetState extends TADComponentWithoutSubcomponents/* Issue # makeValue(); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -240,18 +242,17 @@ public class TADArrayGetState extends TADComponentWithoutSubcomponents/* Issue # return index; } - @Override public int getType() { return TGComponentManager.TAD_ARRAY_GET; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_AD_DIAGRAM; } - @Override public void setStateAction(int _stateAction) { stateAction = _stateAction; } + + } diff --git a/src/main/java/ui/ad/TADArraySetState.java b/src/main/java/ui/ad/TADArraySetState.java index 4e0060f2fc..80517ed993 100755 --- a/src/main/java/ui/ad/TADArraySetState.java +++ b/src/main/java/ui/ad/TADArraySetState.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -57,7 +60,7 @@ import java.awt.geom.Line2D; * @version 1.0 20/03/2009 * @author Ludovic APVRILLE */ -public class TADArraySetState extends TADComponentWithoutSubcomponents/* Issue #69TGCWithoutInternalComponent */ implements BasicErrorHighlight { +public class TADArraySetState extends TGCWithoutInternalComponent implements BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -69,6 +72,7 @@ public class TADArraySetState extends TADComponentWithoutSubcomponents/* Issue # protected String expr = "x"; protected int stateAction = 0; // 0: unchecked 1: ok; 2:unknown + public TADArraySetState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -93,7 +97,8 @@ public class TADArraySetState extends TADComponentWithoutSubcomponents/* Issue # myImageIcon = IconManager.imgic232; } - @Override + + public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -121,10 +126,11 @@ public class TADArraySetState extends TADComponentWithoutSubcomponents/* Issue # g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); g.drawString(value, x + (width - w) / 2 , y + textY); + } - - @Override + public boolean editOndoubleClick(JFrame frame) { + String oldValue = value; JDialogArraySet jdas = new JDialogArraySet(frame, array, index, expr, "Setting value of an array location"); @@ -148,7 +154,6 @@ public class TADArraySetState extends TADComponentWithoutSubcomponents/* Issue # value = array + "[" + index + "] = " + expr; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Prop expr=\""); @@ -201,7 +206,6 @@ public class TADArraySetState extends TADComponentWithoutSubcomponents/* Issue # makeValue(); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -231,18 +235,17 @@ public class TADArraySetState extends TADComponentWithoutSubcomponents/* Issue # return index; } - @Override public int getType() { return TGComponentManager.TAD_ARRAY_SET; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } - @Override public void setStateAction(int _stateAction) { stateAction = _stateAction; } + + } diff --git a/src/main/java/ui/ad/TADChoice.java b/src/main/java/ui/ad/TADChoice.java index 67361b576a..ab65e5b211 100755 --- a/src/main/java/ui/ad/TADChoice.java +++ b/src/main/java/ui/ad/TADChoice.java @@ -36,18 +36,18 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; import ui.*; import ui.util.IconManager; -import java.awt.Color; -import java.awt.Graphics; +import java.awt.*; import java.awt.geom.Line2D; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; + /** * Class TADChoice @@ -56,19 +56,11 @@ import java.util.List; * @version 1.0 21/12/2003 * @author Ludovic APVRILLE */ -public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWithInternalComponent */ { - - public static final String EMPTY_GUARD_TEXT = "[ ]"; - - private static final String TRUE_GUARD_TEXT = "[ true ]"; - - protected int lineLength = 10; - - protected int lineOutLength = 25; +public class TADChoice extends TGCWithInternalComponent { + private int lineLength = 10; + private int lineOutLength = 25; + private int textX1, textY1, textX2, textY2, textX3, textY3; - private int textX1, textY1, textX2, textY2, textX3, textY3; - - protected int stateOfError = 0; public TADChoice(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -82,45 +74,6 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit textX3 = width /2 + 5; textY3 = height + 15; - createConnectingPoints(); -// nbConnectingPoint = 4; -// connectingPoint = new TGConnectingPoint[nbConnectingPoint]; -// connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new TGConnectingPointAD(this, -lineOutLength, 0, false, true, 0.0, 0.5); -// connectingPoint[2] = new TGConnectingPointAD(this, lineOutLength, 0, false, true, 1.0, 0.5); -// connectingPoint[3] = new TGConnectingPointAD(this, 0, lineOutLength, false, true, 0.5, 1.0); -// addTGConnectingPointsComment(); - - nbInternalTGComponent = 3; - tgcomponent = new TGComponent[nbInternalTGComponent]; - - createGuards(); - -// TGCOneLineText tgc = new TGCOneLineText(x+textX1-50, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 1"); -// tgcomponent[0] = tgc; -// -// tgc = new TGCOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 2"); -// tgcomponent[1] = tgc; -// -// tgc = new TGCOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 3"); -// tgcomponent[2] = tgc; - - moveable = true; - editable = false; - removable = true; - - name = "choice"; - - myImageIcon = IconManager.imgic208; - } - - protected void createConnectingPoints() { nbConnectingPoint = 4; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); @@ -128,44 +81,36 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit connectingPoint[2] = new TGConnectingPointAD(this, lineOutLength, 0, false, true, 1.0, 0.5); connectingPoint[3] = new TGConnectingPointAD(this, 0, lineOutLength, false, true, 0.5, 1.0); addTGConnectingPointsComment(); - } - - protected void createGuards() { - TGCOneLineText tgc = new TGCOneLineText(x+textX1, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, tdp); - tgc.setValue( EMPTY_GUARD_TEXT ); + + nbInternalTGComponent = 3; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGCOneLineText tgc = new TGCOneLineText(x+textX1-50, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, _tdp); + tgc.setValue("[ ]"); tgc.setName("guard 1"); - tgcomponent[ 0 ] = tgc; + tgcomponent[0] = tgc; - tgc = new TGCOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, tdp); - tgc.setValue( EMPTY_GUARD_TEXT ); + tgc = new TGCOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, _tdp); + tgc.setValue("[ ]"); tgc.setName("guard 2"); - tgcomponent[ 1 ] = tgc; + tgcomponent[1] = tgc; - tgc = new TGCOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, tdp); - tgc.setValue( EMPTY_GUARD_TEXT ); + tgc = new TGCOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, _tdp); + tgc.setValue("[ ]"); tgc.setName("guard 3"); - tgcomponent[ 2 ] = tgc; + tgcomponent[2] = tgc; + + moveable = true; + editable = false; + removable = true; + + name = "choice"; + + myImageIcon = IconManager.imgic208; } - @Override public void internalDrawing(Graphics g) { - if (stateOfError > 0) { - Color c = g.getColor(); - switch(stateOfError) { - case ErrorHighlight.OK: - g.setColor(ColorManager.CHOICE); - break; - default: - g.setColor(ColorManager.UNKNOWN_BOX_ACTION); - } - // Making the polygon - int [] px1 = {x+(width/2), x+width+2, x + (width/2), x}; - int [] py1 = {y, y + height/2, y+height+2, y+height/2}; - g.fillPolygon(px1, py1, 4); - g.setColor(c); - } - - g.drawLine(x+(width/2), y, x+width, y + height/2); + g.drawLine(x+(width/2), y, x+width, y + height/2); g.drawLine(x, y + height / 2, x+width/2, y + height); g.drawLine(x + width/2, y, x, y + height/2); g.drawLine(x + width, y + height/2, x + width/2, y + height); @@ -176,7 +121,6 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit g.drawLine(x+(width/2), y + height, x+(width/2), y + height + lineOutLength); } - @Override public TGComponent isOnOnlyMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -214,72 +158,20 @@ public class TADChoice extends TADComponentWithSubcomponents/* Issue #69 TGCWit tgcomponent[i].setValue(guard); } } - - public List<String> getGuards() { - List<String> guards = new ArrayList<String>(); - for( int i = 0; i < nbInternalTGComponent; i++ ) { - guards.add( getGuard(i) ); - } - return guards; - } - - /** - * Issue #69 - * @param point - * @return - */ - public TGCOneLineText getGuardForConnectingPoint( final TGConnectingPoint point ) { - final int index = Arrays.asList( connectingPoint ).indexOf( point ); - - if ( index < 0 ) { - throw new IllegalArgumentException( "No guard found for connecting point " + point ); - } - - return (TGCOneLineText) tgcomponent[ index - 1 ]; - } - - @Override + public int getType() { return TGComponentManager.TAD_CHOICE; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_AD_DIAGRAM; } - - public void setStateAction(int _stateAction) { - stateOfError = _stateAction; - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.AbstractCDElement#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - return false; - } - /** - * Issue #69 - * @return - */ - @Override - public boolean canLabelBeDisabled( final TGCOneLineText label ) { - return label.getValue() != null && !label.getValue().isEmpty() && !EMPTY_GUARD_TEXT.equals( label.getValue() ); - } - - /** - * Issue #69 - * @param guard - * @return - */ - public String getEffectiveCondition( final TGCOneLineText guard ) { - if ( guard.isEnabled() ) { - return guard.getValue(); - } - - return TRUE_GUARD_TEXT; - } } + + + + + + + diff --git a/src/main/java/ui/ad/TADComponentWithSubcomponents.java b/src/main/java/ui/ad/TADComponentWithSubcomponents.java deleted file mode 100644 index 7faa2ecd2c..0000000000 --- a/src/main/java/ui/ad/TADComponentWithSubcomponents.java +++ /dev/null @@ -1,30 +0,0 @@ -package ui.ad; - -import ui.TDiagramPanel; -import ui.TGCScalableWithInternalComponent; -import ui.TGComponent; - -/** - * Issue #69 - * @author dblouin - * - */ -public abstract class TADComponentWithSubcomponents extends TGCScalableWithInternalComponent /*TGCWithInternalComponent*/ { - - public TADComponentWithSubcomponents(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, - boolean _pos, TGComponent _father, TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - } - - /** - * Issue #69 - * @return - */ - @Override - public boolean canBeDisabled() { - final CanBeDisabledADElementVisitor visitor = new CanBeDisabledADElementVisitor(); - acceptBackward( visitor ); - - return visitor.isCanBeDisabled(); - } -} diff --git a/src/main/java/ui/ad/TADComponentWithoutSubcomponents.java b/src/main/java/ui/ad/TADComponentWithoutSubcomponents.java deleted file mode 100644 index 2317c348b6..0000000000 --- a/src/main/java/ui/ad/TADComponentWithoutSubcomponents.java +++ /dev/null @@ -1,30 +0,0 @@ -package ui.ad; - -import ui.TDiagramPanel; -import ui.TGCWithoutInternalComponent; -import ui.TGComponent; - -/** - * Issue #69 - * @author dblouin - * - */ -public abstract class TADComponentWithoutSubcomponents extends TGCWithoutInternalComponent { - - public TADComponentWithoutSubcomponents(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, - boolean _pos, TGComponent _father, TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - } - - /** - * Issue #69 - * @return - */ - @Override - public boolean canBeDisabled() { - final CanBeDisabledADElementVisitor visitor = new CanBeDisabledADElementVisitor(); - acceptBackward( visitor ); - - return visitor.isCanBeDisabled(); - } -} diff --git a/src/main/java/ui/ad/TADConnector.java b/src/main/java/ui/ad/TADConnector.java deleted file mode 100644 index 8fc2736a95..0000000000 --- a/src/main/java/ui/ad/TADConnector.java +++ /dev/null @@ -1,74 +0,0 @@ -package ui.ad; - -import java.awt.Point; -import java.util.Vector; - -import ui.ForwardComponentsEnabledVisitor; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGConnectingPoint; -import ui.TGConnector; - -/** - * Issue #69 - * @author dblouin - * - */ -public abstract class TADConnector extends TGConnector { - - public TADConnector( int _x, - int _y, - int _minX, - int _maxX, - int _minY, - int _maxY, - boolean _pos, - TGComponent _father, - TDiagramPanel _tdp, - TGConnectingPoint _p1, - TGConnectingPoint _p2, - Vector<Point> _listPoint ) { - super( _x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint ); - } - - /** - * Issue #69 - * @param _enabled - */ - @Override - public void setEnabled( final boolean _enabled ) { - if ( p2 != null ) { - p2.acceptForward( new EnablingADConnectorVisitor( _enabled ) ); - } - } - - /** - * Issue #69 - * @return - */ - @Override - public boolean canBeDisabled() { - if ( p2 != null && p2.getFather() instanceof TADStopState ) { - return false; - } - - final CanBeDisabledADElementVisitor visitor = new CanBeDisabledADElementVisitor(); - acceptBackward( visitor ); - - return visitor.isCanBeDisabled(); - } - - /** Issue #69 - * @return - */ - public boolean isEnabled( boolean checkBranch ) { - if ( checkBranch && p2 != null ) { - final ForwardComponentsEnabledVisitor visitor = new ForwardComponentsEnabledVisitor(); - p2.acceptForward( visitor ); - - return visitor.isEnabled(); - } - - return super.isEnabled(); - } -} diff --git a/src/main/java/ui/ad/TADDeterministicDelay.java b/src/main/java/ui/ad/TADDeterministicDelay.java index a326f06ad7..f37a5a603d 100755 --- a/src/main/java/ui/ad/TADDeterministicDelay.java +++ b/src/main/java/ui/ad/TADDeterministicDelay.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -52,11 +55,9 @@ import java.awt.geom.Line2D; * @version 1.0 21/12/2003 * @author Ludovic APVRILLE */ -public class TADDeterministicDelay extends TADComponentWithSubcomponents/* Issue #69 TGCWithInternalComponent */{ - - private int lineLength = 5; - - private int textX, textY; +public class TADDeterministicDelay extends TGCWithInternalComponent { + private int lineLength = 5; + private int textX, textY; public TADDeterministicDelay(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -89,14 +90,12 @@ public class TADDeterministicDelay extends TADComponentWithSubcomponents/* Issue myImageIcon = IconManager.imgic214; } - @Override public void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -117,13 +116,13 @@ public class TADDeterministicDelay extends TADComponentWithSubcomponents/* Issue tgcomponent[0].setValue(value); } - @Override public int getType() { return TGComponentManager.TAD_DETERMINISTIC_DELAY; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_AD_DIAGRAM; } + } + diff --git a/src/main/java/ui/ad/TADForLoop.java b/src/main/java/ui/ad/TADForLoop.java deleted file mode 100644 index ebb66cde88..0000000000 --- a/src/main/java/ui/ad/TADForLoop.java +++ /dev/null @@ -1,138 +0,0 @@ -package ui.ad; - -import java.awt.geom.Line2D; - -import myutil.GraphicLib; -import ui.BasicErrorHighlight; -import ui.EmbeddedComment; -import ui.ICDElementVisitor; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGConnectingPoint; -import ui.util.IconManager; - -/** - * Issue #69 - * @author dblouin - * - */ -public abstract class TADForLoop extends TADComponentWithoutSubcomponents implements EmbeddedComment, BasicErrorHighlight { - - protected final static String IN_LOOP = "inside loop"; - protected final static String EXIT_LOOP = "exit loop"; - - protected static final int INDEX_ENTER_LOOP = 0; - protected static final int INDEX_INSIDE_LOOP = 1; - protected static final int INDEX_EXIT_LOOP = 2; - - protected int lineLength = 5; - protected int textX = 5; - protected int textY = 15; - protected int arc = 5; - - protected int stateOfError = 0; - - public TADForLoop( int _x, - int _y, - int _minX, - int _maxX, - int _minY, - int _maxY, - boolean _pos, - TGComponent _father, - TDiagramPanel _tdp ) { - super( _x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp ); - - width = 30; - height = 20; - minWidth = 30; - - moveable = true; - editable = true; - removable = true; - - myImageIcon = IconManager.imgic912; - } - - @Override - public TGComponent isOnMe(int _x, int _y) { - if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { - return this; - } - - if ((int)(Line2D.ptSegDistSq(x+(width/2), y-lineLength, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { - return this; - } - - if ((int)(Line2D.ptSegDistSq(x+width, y+height/2, x+width +lineLength, y+height/2, _x, _y)) < distanceSelected) { - return this; - } - - return null; - } - - @Override - public void setStateAction(int _stateAction) { - stateOfError = _stateAction; - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.TGComponent#acceptForward(ui.ICDElementVisitor) - */ - @Override - public void acceptForward( ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - final TGConnectingPoint insideLoopPoint = getInsideLoopConnectingPoint(); - - if ( insideLoopPoint != null ) { - insideLoopPoint.acceptForward( visitor ); - } - - final TGConnectingPoint exitPoint = getExitLoopConnectingPoint(); - - if ( exitPoint != null ) { - exitPoint.acceptForward( visitor ); - } - } - } - - - /* Issue #69 - * (non-Javadoc) - * @see ui.TGComponent#acceptBackward(ui.ICDElementVisitor) - */ - @Override - public void acceptBackward( ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - final TGConnectingPoint enterLoopPoint = getEnterLoopConnectingPoint(); - - if ( enterLoopPoint != null ) { - enterLoopPoint.acceptBackward( visitor ); - } - } - } - - /** - * Issue #69 - * @param _enabled - */ - @Override - public void setEnabled( final boolean _enabled ) { - super.setEnabled( _enabled ); - - getInsideLoopConnectingPoint().acceptForward( new EnablingADBranchVisitor( _enabled ) ); - } - - public TGConnectingPoint getEnterLoopConnectingPoint() { - return connectingPoint[ INDEX_ENTER_LOOP ]; - } - - public TGConnectingPoint getInsideLoopConnectingPoint() { - return connectingPoint[ INDEX_INSIDE_LOOP ]; - } - - public TGConnectingPoint getExitLoopConnectingPoint() { - return connectingPoint[ INDEX_EXIT_LOOP ]; - } -} diff --git a/src/main/java/ui/ad/TADJunction.java b/src/main/java/ui/ad/TADJunction.java index 7fed85cbf3..7990e48101 100755 --- a/src/main/java/ui/ad/TADJunction.java +++ b/src/main/java/ui/ad/TADJunction.java @@ -35,6 +35,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; @@ -44,6 +47,7 @@ import ui.util.IconManager; import java.awt.*; import java.awt.geom.Line2D; + /** * Class TADJunction * Junction between several activities, without any synchronization. To be used in activity diagrams @@ -51,7 +55,7 @@ import java.awt.geom.Line2D; * @version 1.0 28/12/2003 * @author Ludovic APVRILLE */ -public class TADJunction extends TADComponentWithoutSubcomponents /* Issue #69 TGCWithoutInternalComponent*/ { +public class TADJunction extends TGCWithoutInternalComponent { protected int range = 5; @@ -104,7 +108,6 @@ public class TADJunction extends TADComponentWithoutSubcomponents /* Issue #69 T myImageIcon = IconManager.imgic212; } - @Override public void internalDrawing(Graphics g) { //g.drawLine(x +width/2, y, x+width/2, y + height); //g.drawLine(x, y + (height/2), x+width, y + (height/2)); @@ -120,7 +123,6 @@ public class TADJunction extends TADComponentWithoutSubcomponents /* Issue #69 T g.drawLine(x+width/2+range, y + height / 2, x+width/2, y+height/2+range); } - @Override public TGComponent isOnMe(int _x, int _y) { // vertical line if ((int)(Line2D.ptSegDistSq(x +width/2, y, x+width/2, y + height, _x, _y)) < distanceSelected) { @@ -133,13 +135,19 @@ public class TADJunction extends TADComponentWithoutSubcomponents /* Issue #69 T return null; } - @Override public int getType() { return TGComponentManager.TAD_JUNCTION; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } + } + + + + + + + diff --git a/src/main/java/ui/ad/TADNonDeterministicDelay.java b/src/main/java/ui/ad/TADNonDeterministicDelay.java index 6eff783dcd..89b4f98895 100755 --- a/src/main/java/ui/ad/TADNonDeterministicDelay.java +++ b/src/main/java/ui/ad/TADNonDeterministicDelay.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -52,7 +55,7 @@ import java.awt.geom.Line2D; * @version 1.0 10/12/2003 * @author Ludovic APVRILLE */ -public class TADNonDeterministicDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ { +public class TADNonDeterministicDelay extends TGCWithInternalComponent{ private int lineLength = 5; private int textX = 5; private int textY = 5; @@ -88,7 +91,6 @@ public class TADNonDeterministicDelay extends TADComponentWithSubcomponents /* I myImageIcon = IconManager.imgic216; } - @Override public void internalDrawing(Graphics g) { int y1 = y; @@ -106,7 +108,6 @@ public class TADNonDeterministicDelay extends TADComponentWithSubcomponents /* I } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -127,13 +128,18 @@ public class TADNonDeterministicDelay extends TADComponentWithSubcomponents /* I tgcomponent[0].setValue(value); } - @Override public int getType() { return TGComponentManager.TAD_NON_DETERMINISTIC_DELAY; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } } + + + + + + + diff --git a/src/main/java/ui/ad/TADOneLineText.java b/src/main/java/ui/ad/TADOneLineText.java deleted file mode 100644 index ffdc4a483f..0000000000 --- a/src/main/java/ui/ad/TADOneLineText.java +++ /dev/null @@ -1,25 +0,0 @@ -package ui.ad; - -import ui.TDiagramPanel; -import ui.TGCOneLineText; -import ui.TGComponent; - -public abstract class TADOneLineText extends TGCOneLineText { - - public TADOneLineText(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, - TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - } - - /** - * Issue #69 - * @return - */ - @Override - public boolean canBeDisabled() { - final CanBeDisabledADElementVisitor visitor = new CanBeDisabledADElementVisitor(); - acceptBackward( visitor ); - - return visitor.isCanBeDisabled(); - } -} diff --git a/src/main/java/ui/ad/TADParallel.java b/src/main/java/ui/ad/TADParallel.java index 530ebc3c7a..7ab9862e24 100755 --- a/src/main/java/ui/ad/TADParallel.java +++ b/src/main/java/ui/ad/TADParallel.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -52,11 +55,9 @@ import java.awt.*; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TADParallel extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ { - - private int lineLength = 0; - - private int textX, textY; +public class TADParallel extends TGCWithInternalComponent{ + private int lineLength = 0; + private int textX, textY; public TADParallel(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -99,13 +100,11 @@ public class TADParallel extends TADComponentWithSubcomponents /* Issue #69 TGCW myImageIcon = IconManager.imgic206; } - @Override public void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -121,13 +120,18 @@ public class TADParallel extends TADComponentWithSubcomponents /* Issue #69 TGCW tgcomponent[0].setValue(val); } - @Override public int getType() { return TGComponentManager.TAD_PARALLEL; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } } + + + + + + + diff --git a/src/main/java/ui/ad/TADPreemption.java b/src/main/java/ui/ad/TADPreemption.java index 8f601cb484..c38308f225 100755 --- a/src/main/java/ui/ad/TADPreemption.java +++ b/src/main/java/ui/ad/TADPreemption.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -52,11 +55,9 @@ import java.awt.*; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TADPreemption extends TADComponentWithSubcomponents/* Issue #69 TGCWithInternalComponent*/ { - - private int lineLength = 0; - - private int textX, textY; +public class TADPreemption extends TGCWithInternalComponent{ + private int lineLength = 0; + private int textX, textY; public TADPreemption(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -97,13 +98,11 @@ public class TADPreemption extends TADComponentWithSubcomponents/* Issue #69 TGC myImageIcon = IconManager.imgic206; } - @Override public void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -111,13 +110,11 @@ public class TADPreemption extends TADComponentWithSubcomponents/* Issue #69 TGC return null; } - @Override public int getType() { return TGComponentManager.TAD_PREEMPTION; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } -} +} \ No newline at end of file diff --git a/src/main/java/ui/ad/TADSequence.java b/src/main/java/ui/ad/TADSequence.java index 158a67935d..99eabaf2fd 100755 --- a/src/main/java/ui/ad/TADSequence.java +++ b/src/main/java/ui/ad/TADSequence.java @@ -36,16 +36,17 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.ad; -import java.awt.Graphics; -import java.util.Arrays; -import java.util.List; + + +package ui.ad; import myutil.GraphicLib; import ui.*; import ui.util.IconManager; +import java.awt.*; + /** * Class TADSequence * Sequence operator. Activities are executed in sequence from left to right @@ -54,11 +55,9 @@ import ui.util.IconManager; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TADSequence extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ { - - protected int lineLength = 0; - - private int textX, textY; +public class TADSequence extends TGCWithInternalComponent{ + private int lineLength = 0; + private int textX, textY; public TADSequence(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -70,16 +69,15 @@ public class TADSequence extends TADComponentWithSubcomponents /* Issue #69 TGCW textX = width - 6; textY = height + 2; - createConnectingPoints(); -// nbConnectingPoint = 6; -// connectingPoint = new TGConnectingPoint[6]; -// connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.167, 1.0); -// connectingPoint[2] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.333, 1.0); -// connectingPoint[3] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); -// connectingPoint[4] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.667, 1.0); -// connectingPoint[5] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.833, 1.0); -// addTGConnectingPointsCommentCorner(); + nbConnectingPoint = 6; + connectingPoint = new TGConnectingPoint[6]; + connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.167, 1.0); + connectingPoint[2] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.333, 1.0); + connectingPoint[3] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); + connectingPoint[4] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.667, 1.0); + connectingPoint[5] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.833, 1.0); + addTGConnectingPointsCommentCorner(); nbInternalTGComponent = 1; tgcomponent = new TGComponent[nbInternalTGComponent]; @@ -100,25 +98,11 @@ public class TADSequence extends TADComponentWithSubcomponents /* Issue #69 TGCW myImageIcon = IconManager.imgic206; } - protected void createConnectingPoints() { - nbConnectingPoint = 6; - connectingPoint = new TGConnectingPoint[6]; - connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.167, 1.0); - connectingPoint[2] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.333, 1.0); - connectingPoint[3] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); - connectingPoint[4] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.667, 1.0); - connectingPoint[5] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.833, 1.0); - addTGConnectingPointsCommentCorner(); - } - - @Override public void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -126,36 +110,11 @@ public class TADSequence extends TADComponentWithSubcomponents /* Issue #69 TGCW return null; } - @Override public int getType() { return TGComponentManager.TAD_SEQUENCE; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; - } - - public TGConnectingPoint getEnterConnectingPoint() { - return connectingPoint[ 0 ]; - } - - public List<TGConnectingPoint> getExitConnectingPoints() { - return Arrays.asList( Arrays.copyOfRange( connectingPoint, 1, connectingPoint.length ) ); - } - - /** - * Issue #69 - * @param _enabled - */ - @Override - public void setEnabled( final boolean _enabled ) { - super.setEnabled( _enabled ); - - for ( final TGConnectingPoint point : connectingPoint ) { - if ( point != getEnterConnectingPoint() ) { - point.acceptForward( new EnablingADConnectorVisitor( _enabled ) ); - } - } + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } } diff --git a/src/main/java/ui/ad/TADStartState.java b/src/main/java/ui/ad/TADStartState.java index b4d21f778e..0bf11c61a6 100755 --- a/src/main/java/ui/ad/TADStartState.java +++ b/src/main/java/ui/ad/TADStartState.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -52,9 +55,8 @@ import java.awt.geom.Line2D; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TADStartState extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ { - - protected int lineLength = 5; +public class TADStartState extends TGCWithoutInternalComponent{ + private int lineLength = 5; public TADStartState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -62,10 +64,9 @@ public class TADStartState extends TADComponentWithoutSubcomponents/* Issue #69 width = 15; height = 15; - createConnectingPoints(); -// nbConnectingPoint = 1; -// connectingPoint = new TGConnectingPoint[1]; -// connectingPoint[0] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); + nbConnectingPoint = 1; + connectingPoint = new TGConnectingPoint[1]; + connectingPoint[0] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); nbInternalTGComponent = 0; @@ -78,19 +79,11 @@ public class TADStartState extends TADComponentWithoutSubcomponents/* Issue #69 myImageIcon = IconManager.imgic222; } - protected void createConnectingPoints() { - nbConnectingPoint = 1; - connectingPoint = new TGConnectingPoint[1]; - connectingPoint[0] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); - } - - @Override public void internalDrawing(Graphics g) { g.fillOval(x, y, width, height); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -100,25 +93,19 @@ public class TADStartState extends TADComponentWithoutSubcomponents/* Issue #69 return this; } + + return null; } - @Override public int getType() { return TGComponentManager.TAD_START_STATE; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.AbstractCDElement#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - return false; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } + } + + diff --git a/src/main/java/ui/ad/TADStopState.java b/src/main/java/ui/ad/TADStopState.java index 04dc7556e0..a92f665a91 100755 --- a/src/main/java/ui/ad/TADStopState.java +++ b/src/main/java/ui/ad/TADStopState.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -51,11 +54,9 @@ import java.awt.*; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TADStopState extends TADComponentWithoutSubcomponents /* Issue #69 TGCWithoutInternalComponent*/ { - +public class TADStopState extends TGCWithoutInternalComponent{ private int internalCircleSize = 16; - - protected int lineLength = 5; + private int lineLength = 5; public TADStopState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -63,10 +64,9 @@ public class TADStopState extends TADComponentWithoutSubcomponents /* Issue #69 width = 20; height = 20; - createConnectingPoints(); -// nbConnectingPoint = 1; -// connectingPoint = new TGConnectingPoint[1]; -// connectingPoint[0] = new TGConnectingPointAD(this, 0, - lineLength, true, false, 0.5, 0.0); + nbConnectingPoint = 1; + connectingPoint = new TGConnectingPoint[1]; + connectingPoint[0] = new TGConnectingPointAD(this, 0, - lineLength, true, false, 0.5, 0.0); nbInternalTGComponent = 0; @@ -79,24 +79,14 @@ public class TADStopState extends TADComponentWithoutSubcomponents /* Issue #69 myImageIcon = IconManager.imgic210; } - protected void createConnectingPoints() { - nbConnectingPoint = 1; - connectingPoint = new TGConnectingPoint[1]; - connectingPoint[0] = new TGConnectingPointAD(this, 0, - lineLength, true, false, 0.5, 0.0); - } - - @Override public void internalDrawing(Graphics g) { - - // Issue #69 - ColorManager.setColor( g, state, 0, isEnabled() ); -// ColorManager.setColor(g, state, 0); + ColorManager.setColor(g, state, 0); g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); g.drawOval(x, y, width, height); g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); } - @Override + public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -104,22 +94,19 @@ public class TADStopState extends TADComponentWithoutSubcomponents /* Issue #69 return null; } - @Override public int getType() { return TGComponentManager.TAD_STOP_STATE; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.AbstractCDElement#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - return false; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } + } + + + + + + + diff --git a/src/main/java/ui/ad/TADTimeCapture.java b/src/main/java/ui/ad/TADTimeCapture.java index 5197e73575..128a81da1a 100755 --- a/src/main/java/ui/ad/TADTimeCapture.java +++ b/src/main/java/ui/ad/TADTimeCapture.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -52,13 +55,14 @@ import java.awt.geom.Line2D; * @version 1.0 23/07/2009 * @author Ludovic APVRILLE */ -public class TADTimeCapture extends TADOneLineText/* Issue #69 TGCOneLineText*/ implements ActionStateErrorHighlight { +public class TADTimeCapture extends TGCOneLineText implements ActionStateErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; protected int arc = 5; protected int stateAction = 0; // 0: unchecked 1: attribute; 3:unknown + public TADTimeCapture(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -83,7 +87,6 @@ public class TADTimeCapture extends TADOneLineText/* Issue #69 TGCOneLineText*/ myImageIcon = IconManager.imgic204; } - @Override public void internalDrawing(Graphics g) { String myVal = "time -> " + value; int w = g.getFontMetrics().stringWidth(myVal); @@ -107,16 +110,15 @@ public class TADTimeCapture extends TADOneLineText/* Issue #69 TGCOneLineText*/ g.fillRoundRect(x, y, width, height, arc, arc); g.setColor(c); } - - g.drawRoundRect(x, y, width, height, arc, arc); + g.drawRoundRect(x, y, width, height, arc, arc); g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); g.drawString(myVal, x + (width - w) / 2 , y + textY); + } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -125,22 +127,22 @@ public class TADTimeCapture extends TADOneLineText/* Issue #69 TGCOneLineText*/ if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, _x, _y)) < distanceSelected) { return this; } + return null; } - @Override + public int getType() { return TGComponentManager.TAD_TIME_CAPTURE; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } - @Override public void setStateAction(int _stateAction) { stateAction = _stateAction; } + } diff --git a/src/main/java/ui/ad/TADTimeInterval.java b/src/main/java/ui/ad/TADTimeInterval.java index fea95ac151..2b87cea962 100755 --- a/src/main/java/ui/ad/TADTimeInterval.java +++ b/src/main/java/ui/ad/TADTimeInterval.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -52,7 +55,7 @@ import java.awt.geom.Line2D; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TADTimeInterval extends TADComponentWithSubcomponents/* Issue #69 TGCWithInternalComponent */{ +public class TADTimeInterval extends TGCWithInternalComponent{ private int lineLength = 5; private int textX, textY; private int incrementY = 3; @@ -67,7 +70,7 @@ public class TADTimeInterval extends TADComponentWithSubcomponents/* Issue #69 T textY = height/2 + 5; nbConnectingPoint = 2; - connectingPoint = new TGConnectingPoint[ nbConnectingPoint ]; + connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointAD(this, 0, + lineLength, false, true, 0.5, 1.0); addTGConnectingPointsComment(); @@ -89,7 +92,6 @@ public class TADTimeInterval extends TADComponentWithSubcomponents/* Issue #69 T myImageIcon = IconManager.imgic224; } - @Override public void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); @@ -107,7 +109,6 @@ public class TADTimeInterval extends TADComponentWithSubcomponents/* Issue #69 T } } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -136,13 +137,19 @@ public class TADTimeInterval extends TADComponentWithSubcomponents/* Issue #69 T ((TGCTimeInterval)(tgcomponent[0])).setMaxDelay(val); } - @Override public int getType() { return TGComponentManager.TAD_DELAY_NON_DETERMINISTIC_DELAY; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } + } + + + + + + + diff --git a/src/main/java/ui/ad/TADTimeLimitedOffer.java b/src/main/java/ui/ad/TADTimeLimitedOffer.java index 1298580e5d..02785ec46b 100755 --- a/src/main/java/ui/ad/TADTimeLimitedOffer.java +++ b/src/main/java/ui/ad/TADTimeLimitedOffer.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -54,7 +57,7 @@ import java.awt.geom.Line2D; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TADTimeLimitedOffer extends TADComponentWithSubcomponents/* Issue #69 TGCWithInternalComponent*/ implements ActionStateErrorHighlight { +public class TADTimeLimitedOffer extends TGCWithInternalComponent implements ActionStateErrorHighlight { protected int lineLength = 25; protected int lineDistance = 10; protected int textX = 5; @@ -78,7 +81,7 @@ public class TADTimeLimitedOffer extends TADComponentWithSubcomponents/* Issue connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); connectingPoint[2] = new TGConnectingPointAD(this, distanceTwoLines, lineLength, false, true, 0.5, 1.0); - addTGConnectingPointsComment(); + addTGConnectingPointsComment(); nbInternalTGComponent = 1; tgcomponent = new TGComponent[nbInternalTGComponent]; @@ -98,7 +101,6 @@ public class TADTimeLimitedOffer extends TADComponentWithSubcomponents/* Issue myImageIcon = IconManager.imgic218; } - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -140,7 +142,6 @@ public class TADTimeLimitedOffer extends TADComponentWithSubcomponents/* Issue } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -174,7 +175,7 @@ public class TADTimeLimitedOffer extends TADComponentWithSubcomponents/* Issue connectingPoint[2].setCdX(width / 2 + distanceTwoLines); }*/ - protected void updateInternalComponents(int diffWidth, int diffX) { + public void updateInternalComponents(int diffWidth, int diffX) { int x1 = tgcomponent[0].getX(); int y1 = tgcomponent[0].getY(); tgcomponent[0].setCdRectangle(width + distanceStateLine + 2, width + distanceStateLine + 10, textY - 10, textY + 10); @@ -183,7 +184,6 @@ public class TADTimeLimitedOffer extends TADComponentWithSubcomponents/* Issue // } - @Override public boolean editOndoubleClick(JFrame frame) { String oldValue = value; String text = getName() + ": "; @@ -209,18 +209,23 @@ public class TADTimeLimitedOffer extends TADComponentWithSubcomponents/* Issue return tgcomponent[0].getValue(); } - @Override public int getType() { return TGComponentManager.TAD_TIME_LIMITED_OFFER; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } - @Override public void setStateAction(int _stateAction) { stateAction = _stateAction; } + } + + + + + + + diff --git a/src/main/java/ui/ad/TADTimeLimitedOfferWithLatency.java b/src/main/java/ui/ad/TADTimeLimitedOfferWithLatency.java index c775d61df2..bc0cb533f7 100755 --- a/src/main/java/ui/ad/TADTimeLimitedOfferWithLatency.java +++ b/src/main/java/ui/ad/TADTimeLimitedOfferWithLatency.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import myutil.GraphicLib; @@ -54,7 +57,7 @@ import java.awt.geom.Line2D; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TADTimeLimitedOfferWithLatency extends TADComponentWithSubcomponents/* Issue #69 TGCWithInternalComponent*/ implements ActionStateErrorHighlight { +public class TADTimeLimitedOfferWithLatency extends TGCWithInternalComponent implements ActionStateErrorHighlight { protected int lineLength = 25; protected int lineLengthLatency = 5; protected int lineDistance = 10; @@ -113,9 +116,9 @@ public class TADTimeLimitedOfferWithLatency extends TADComponentWithSubcomponent minWidth = 30; myImageIcon = IconManager.imgic220; + } - @Override public void internalDrawing(Graphics g) { // int w = g.getFontMetrics().stringWidth(value); @@ -167,7 +170,6 @@ public class TADTimeLimitedOfferWithLatency extends TADComponentWithSubcomponent } } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { // state if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -208,7 +210,7 @@ public class TADTimeLimitedOfferWithLatency extends TADComponentWithSubcomponent connectingPoint[2].setCdX(width / 2 + distanceTwoLines); }*/ - protected void updateInternalComponents(int diffWidth, int diffX) { + public void updateInternalComponents(int diffWidth, int diffX) { int x1 = tgcomponent[0].getX(); int y1 = tgcomponent[0].getY(); @@ -221,7 +223,6 @@ public class TADTimeLimitedOfferWithLatency extends TADComponentWithSubcomponent tgcomponent[1].setCdRectangle(posx, posx+10, posy - 10, posy + 10); } - @Override public boolean editOndoubleClick(JFrame frame) { String oldValue = value; String text = getName() + ": "; @@ -263,18 +264,16 @@ public class TADTimeLimitedOfferWithLatency extends TADComponentWithSubcomponent tgcomponent[0].setValue(delay); } - @Override public int getType() { return TGComponentManager.TAD_TIME_LIMITED_OFFER_WITH_LATENCY; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_AD_DIAGRAM; + return TGComponentManager.CONNECTOR_AD_DIAGRAM; } - @Override public void setStateAction(int _stateAction) { stateAction = _stateAction; } - } + +} diff --git a/src/main/java/ui/ad/TActivityDiagramToolBar.java b/src/main/java/ui/ad/TActivityDiagramToolBar.java index 02d83a32ba..5f84487b9c 100755 --- a/src/main/java/ui/ad/TActivityDiagramToolBar.java +++ b/src/main/java/ui/ad/TActivityDiagramToolBar.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; import ui.MainGUI; @@ -44,6 +47,9 @@ import ui.TToolBar; import javax.swing.*; +//import java.awt.*; +//import java.awt.event.*; + /** * Class TActivityDiagramToolBar * Toolbar associated with activity diagrams @@ -53,6 +59,7 @@ import javax.swing.*; */ public class TActivityDiagramToolBar extends TToolBar { + public TActivityDiagramToolBar(MainGUI _mgui) { super(_mgui); } @@ -178,3 +185,8 @@ public class TActivityDiagramToolBar extends TToolBar { button.addMouseListener(mgui.mouseHandler); } } // Class + + + + + diff --git a/src/main/java/ui/ad/TGConnectingPointAD.java b/src/main/java/ui/ad/TGConnectingPointAD.java index df8f136712..bffd4f9663 100755 --- a/src/main/java/ui/ad/TGConnectingPointAD.java +++ b/src/main/java/ui/ad/TGConnectingPointAD.java @@ -35,6 +35,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ad; @@ -49,14 +52,21 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 12/12/2003 * @author Ludovic APVRILLE */ -public class TGConnectingPointAD extends TGConnectingPointWidthHeight{ +public class TGConnectingPointAD extends TGConnectingPointWidthHeight{ public TGConnectingPointAD(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } - @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_AD_DIAGRAM; } + } + + + + + + + diff --git a/src/main/java/ui/atd/ATDAttack.java b/src/main/java/ui/atd/ATDAttack.java index ab9cc1a828..e81ba2822b 100644 --- a/src/main/java/ui/atd/ATDAttack.java +++ b/src/main/java/ui/atd/ATDAttack.java @@ -59,7 +59,7 @@ import java.awt.*; * @author Ludovic APVRILLE * @version 1.0 09/12/2009 */ -public class ATDAttack extends TGCScalableWithInternalComponent implements SwallowedTGComponent, WithAttributes, CheckableAccessibility/*, CanBeDisabled*/ { +public class ATDAttack extends TGCScalableWithInternalComponent implements SwallowedTGComponent, WithAttributes, CheckableAccessibility, CanBeDisabled { private int textY1 = 3; // private int textY2 = 3; @@ -127,7 +127,6 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall myImageIcon = IconManager.imgic702; } - @Override public void internalDrawing(Graphics g) { String ster; if (isRootAttack) { @@ -197,20 +196,14 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall // Core of the attack Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); - if (isEnabled()) { if (isRootAttack) { g.setColor(ColorManager.ATD_ROOT_ATTACK); } else { g.setColor(ColorManager.ATD_ATTACK); } - } - else { - // Issue #69: Disabled color now managed in TGComponent / ColorManager - // For filled shapes ensure background color is white so that text is - // readable - g.setColor( ColorManager.DISABLED_FILLING ); -// g.setColor(ColorManager.ATD_ATTACK_DISABLED); + } else { + g.setColor(ColorManager.ATD_ATTACK_DISABLED); } g.fill3DRect(x + 1, y + 1, width - 1, height - 1, true); @@ -261,14 +254,13 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall } } - // Issue #69: Use the same disabling UI as other components -// if (!isEnabled()) { -// String val = "disabled"; -// w = g.getFontMetrics().stringWidth(val); -// //int h = currentFontSize + (int)(textY1 * tdp.getZoom()); -// g.setFont(f.deriveFont(Font.ITALIC)); -// g.drawString(val, x + (width - w - 5), y + height - 2); -// } + if (!isEnabled()) { + String val = "disabled"; + w = g.getFontMetrics().stringWidth(val); + //int h = currentFontSize + (int)(textY1 * tdp.getZoom()); + g.setFont(f.deriveFont(Font.ITALIC)); + g.drawString(val, x + (width - w - 5), y + height - 2); + } } else { @@ -279,7 +271,7 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall } - private void setValue(String val, Graphics g) { + public void setValue(String val, Graphics g) { oldValue = value; String ster; if (isRootAttack) { @@ -307,9 +299,10 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall g.setFont(f0); + + // } - @Override public void resizeWithFather() { if ((father != null) && (father instanceof ATDBlock)) { // @@ -319,7 +312,7 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall } } - @Override + public boolean editOndoubleClick(JFrame frame) { String tmp; boolean error = false; @@ -363,7 +356,6 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall return !error; } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -372,12 +364,10 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall return null; } - @Override public int getType() { return TGComponentManager.ATD_ATTACK; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info description=\"" + description); @@ -389,7 +379,9 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + // try { + NodeList nli; Node n1, n2; Element elt; @@ -428,6 +420,7 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall } } + public String getDescription() { return description; } @@ -446,6 +439,7 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall return s; } + public boolean isRootAttack() { return isRootAttack; } @@ -454,14 +448,8 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall setFather(null); TDiagramPanel tdp = getTDiagramPanel(); setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + } - - /** - * Issue #69 - * @return - */ - @Override - public boolean canBeDisabled() { - return true; - } + + } diff --git a/src/main/java/ui/atd/ATDAttackConnector.java b/src/main/java/ui/atd/ATDAttackConnector.java index 300ce4ea0e..7590b0414b 100644 --- a/src/main/java/ui/atd/ATDAttackConnector.java +++ b/src/main/java/ui/atd/ATDAttackConnector.java @@ -36,8 +36,12 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.atd; + import myutil.Conversion; import myutil.GraphicLib; import ui.*; @@ -62,6 +66,7 @@ public class ATDAttackConnector extends TGConnectorWithCommentConnectionPoints protected double oldScaleFactor; protected int fontSize = 12; + public ATDAttackConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); myImageIcon = IconManager.imgic202; @@ -70,7 +75,6 @@ public class ATDAttackConnector extends TGConnectorWithCommentConnectionPoints oldScaleFactor = tdp.getZoom(); } - @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ /*if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { g.drawLine(x1, y1, x2, y2); @@ -133,19 +137,19 @@ public class ATDAttackConnector extends TGConnectorWithCommentConnectionPoints g.fillRect(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz);*/ Point p = new Point(x2, y2); -// if (p == null) { -// // -// } else { - if (Point2D.distance(x1, y1, p.x, p.y) < GraphicLib.longueur * 1.5) { + if (p == null) { // - if ((p.x != x1) || (p.y != y1)) { - g.drawLine(x1, y1, p.x, p.y); + } else { + if (Point2D.distance(x1, y1, p.x, p.y) < GraphicLib.longueur * 1.5) { // + if ((p.x != x1) || (p.y != y1)) { + g.drawLine(x1, y1, p.x, p.y); + // + } + } else { + GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, p.x, p.y, true); } - } else { - GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, p.x, p.y, true); } - // } if (value.length() > 0) { Font f = g.getFont(); @@ -156,9 +160,9 @@ public class ATDAttackConnector extends TGConnectorWithCommentConnectionPoints g.drawString(value, x2+(cz/2)+1, y2); g.setFont(f); } + } - @Override public boolean editOndoubleClick(JFrame frame) { String oldValue = value; String text = getName() + "Connector"; @@ -171,6 +175,8 @@ public class ATDAttackConnector extends TGConnectorWithCommentConnectionPoints s = Conversion.removeFirstSpaces(s); } + // + if ((s != null) && (!s.equals(oldValue))) { setValue(s); return true; @@ -179,12 +185,11 @@ public class ATDAttackConnector extends TGConnectorWithCommentConnectionPoints return false; } - @Override + public int getType() { return TGComponentManager.ATD_ATTACK_CONNECTOR; } - @Override public void rescale(double scaleFactor){ // int xx, yy; @@ -207,4 +212,9 @@ public class ATDAttackConnector extends TGConnectorWithCommentConnectionPoints oldScaleFactor = scaleFactor; } + + + + + } diff --git a/src/main/java/ui/atd/ATDCompositionConnector.java b/src/main/java/ui/atd/ATDCompositionConnector.java index 52ee0ddb63..daa43954f2 100644 --- a/src/main/java/ui/atd/ATDCompositionConnector.java +++ b/src/main/java/ui/atd/ATDCompositionConnector.java @@ -36,8 +36,12 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.atd; + import ui.*; import ui.util.IconManager; @@ -59,7 +63,8 @@ public class ATDCompositionConnector extends TGConnectorWithCommentConnectionPo protected int xp1, xp2, yp1, yp2; protected double oldScaleFactor; protected boolean rescaled; - + + public ATDCompositionConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); myImageIcon = IconManager.imgic202; @@ -69,7 +74,6 @@ public class ATDCompositionConnector extends TGConnectorWithCommentConnectionPo rescaled = true; } - @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ /*if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { g.drawLine(x1, y1, x2, y2); @@ -82,7 +86,7 @@ public class ATDCompositionConnector extends TGConnectorWithCommentConnectionPo xp2 = x2; yp1 = y1; yp2 = y2; - //Double alpha; + Double alpha; int dd = (int)(d*tdp.getZoom()); int DD = (int)(D*tdp.getZoom()); @@ -165,7 +169,6 @@ public class ATDCompositionConnector extends TGConnectorWithCommentConnectionPo rescaled = false; } - @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (p != null) { if (p.contains(x1, y1)) { @@ -176,7 +179,6 @@ public class ATDCompositionConnector extends TGConnectorWithCommentConnectionPo return null; } - @Override public void rescale(double scaleFactor){ // int xx, yy; @@ -201,8 +203,11 @@ public class ATDCompositionConnector extends TGConnectorWithCommentConnectionPo rescaled = true; } - @Override + public int getType() { return TGComponentManager.ATD_COMPOSITION_CONNECTOR; } + + + } diff --git a/src/main/java/ui/avatarad/AvatarADAcceptEventAction.java b/src/main/java/ui/avatarad/AvatarADAcceptEventAction.java index 4c2cb5c064..34987e1a28 100755 --- a/src/main/java/ui/avatarad/AvatarADAcceptEventAction.java +++ b/src/main/java/ui/avatarad/AvatarADAcceptEventAction.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; import myutil.GraphicLib; @@ -53,7 +56,7 @@ import java.awt.geom.Line2D; * @version 1.0 02/09/2011 * @author Ludovic APVRILLE */ -public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledComponent/* Issue #69 AvatarADBasicComponent*/ implements EmbeddedComment, BasicErrorHighlight { +public class AvatarADAcceptEventAction extends AvatarADBasicComponent implements EmbeddedComment, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 6; protected int textY = 15; @@ -66,8 +69,8 @@ public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledCompon public AvatarADAcceptEventAction(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - initScaling(30, 20); - minWidth = (int)(30* tdp.getZoom()); + initScaling(30, 20); + minWidth = (int)(30* tdp.getZoom()); oldScaleFactor = tdp.getZoom(); nbConnectingPoint = 2; @@ -86,7 +89,6 @@ public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledCompon myImageIcon = IconManager.imgic904; } - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -140,7 +142,6 @@ public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledCompon } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -153,11 +154,15 @@ public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledCompon return null; } + + public String getEventName() { return value; } - @Override + + + public boolean editOndoubleClick(JFrame frame) { String oldValue = value; @@ -177,13 +182,15 @@ public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledCompon } - @Override + + public int getType() { return TGComponentManager.AAD_ACCEPT_EVENT_ACTION; } - @Override + public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + } diff --git a/src/main/java/ui/avatarad/AvatarADAction.java b/src/main/java/ui/avatarad/AvatarADAction.java index 3d0e619b91..aef9de2da3 100755 --- a/src/main/java/ui/avatarad/AvatarADAction.java +++ b/src/main/java/ui/avatarad/AvatarADAction.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; import myutil.GraphicLib; @@ -53,7 +56,7 @@ import java.awt.geom.Line2D; * @version 1.0 02/09/2011 * @author Ludovic APVRILLE */ -public class AvatarADAction extends AvatarADBasicCanBeDisabledComponent/* Issue #69 AvatarADBasicComponent*/ implements EmbeddedComment, BasicErrorHighlight { +public class AvatarADAction extends AvatarADBasicComponent implements EmbeddedComment, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -85,7 +88,6 @@ public class AvatarADAction extends AvatarADBasicCanBeDisabledComponent/* Issue myImageIcon = IconManager.imgic204; } - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -116,7 +118,6 @@ public class AvatarADAction extends AvatarADBasicCanBeDisabledComponent/* Issue } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -129,7 +130,6 @@ public class AvatarADAction extends AvatarADBasicCanBeDisabledComponent/* Issue return null; } - @Override public boolean editOndoubleClick(JFrame frame) { oldValue = value; @@ -177,13 +177,13 @@ public class AvatarADAction extends AvatarADBasicCanBeDisabledComponent/* Issue return ret; } - @Override public int getType() { return TGComponentManager.AAD_ACTION; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + + } diff --git a/src/main/java/ui/avatarad/AvatarADActivity.java b/src/main/java/ui/avatarad/AvatarADActivity.java index ad62604325..b8c4cc814e 100644 --- a/src/main/java/ui/avatarad/AvatarADActivity.java +++ b/src/main/java/ui/avatarad/AvatarADActivity.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; import myutil.GraphicLib; @@ -43,11 +46,9 @@ import ui.*; import ui.util.IconManager; import javax.swing.*; - -import java.awt.Font; -import java.awt.Graphics; +import java.awt.*; import java.util.LinkedList; -import java.util.List; + /** * Class AvatarADActivity @@ -57,22 +58,23 @@ import java.util.List; * @author Ludovic APVRILLE */ public class AvatarADActivity extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent { -// private int textY1 = 3; + private int textY1 = 3; - //private int maxFontSize = 12; - // private int minFontSize = 4; - //private int currentFontSize = -1; + private int maxFontSize = 12; + private int minFontSize = 4; + private int currentFontSize = -1; private boolean displayText = true; private int textX = 7; + public String oldValue; public AvatarADActivity(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - initScaling(100, 50); - minWidth = (int)(40* tdp.getZoom()); - minHeight = (int)(30* tdp.getZoom()); + initScaling(100, 50); + minWidth = (int)(40* tdp.getZoom()); + minHeight = (int)(30* tdp.getZoom()); oldScaleFactor = tdp.getZoom(); nbConnectingPoint = 32; @@ -135,7 +137,7 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement setValue(name); oldValue = value; - //currentFontSize = maxFontSize; + currentFontSize = maxFontSize; oldScaleFactor = tdp.getZoom(); myImageIcon = IconManager.imgic700; @@ -143,7 +145,6 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement //actionOnAdd(); } - @Override public void internalDrawing(Graphics g) { Font f = g.getFont(); Font fold = f; @@ -199,7 +200,7 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement g.drawRect(x, y, width, height); int decY = (int)(15 * tdp.getZoom()); int decX = (int)(20 * tdp.getZoom()); - int h = g.getFontMetrics().getHeight(); + int h = g.getFontMetrics().getHeight(); if ((height > decY) && (width > decX)) { g.drawLine(x, y+decY, x+decY, y+decY); g.drawLine(x+decY, y+decY, x+decX, y+decY-5); @@ -229,7 +230,7 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement g.setFont(fold); } - @Override + public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -243,8 +244,8 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement return value; } - @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { + oldValue = value; //String text = getName() + ": "; @@ -271,12 +272,11 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement } - @Override + public int getType() { return TGComponentManager.AAD_ACTIVITY; } - @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { if (tgc instanceof AvatarADBasicComponent) { return true; @@ -290,7 +290,6 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement } - @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { boolean swallowed = false; @@ -341,7 +340,6 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement return true; } - @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeMyInternalComponent(tgc, false); } @@ -381,7 +379,7 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement return false; } - @Override + public void hasBeenResized() { for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof AvatarADBasicComponent) { @@ -401,8 +399,8 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement } - @Override public void resizeWithFather() { + if ((father != null) && (father instanceof AvatarADActivity)) { // Too large to fit in the father? -> resize it! resizeToFatherSize(); @@ -412,8 +410,8 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement } } - public List<AvatarADActivity> getActivityList() { - List<AvatarADActivity> list = new LinkedList<AvatarADActivity>(); + public LinkedList<AvatarADActivity> getActivityList() { + LinkedList<AvatarADActivity> list = new LinkedList<AvatarADActivity>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof AvatarADActivity) { list.add((AvatarADActivity)(tgcomponent[i])); @@ -422,8 +420,8 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement return list; } - public List<AvatarADActivity> getFullActivityList() { - List<AvatarADActivity> list = new LinkedList<AvatarADActivity>(); + public LinkedList<AvatarADActivity> getFullActivityList() { + LinkedList<AvatarADActivity> list = new LinkedList<AvatarADActivity>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof AvatarADActivity) { list.add((AvatarADActivity)(tgcomponent[i])); @@ -434,7 +432,7 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement } public boolean hasInternalActivityWithName(String name) { - List<AvatarADActivity> list = getFullActivityList(); + LinkedList<AvatarADActivity> list = getFullActivityList(); for(AvatarADActivity s: list) { if (s.getValue().compareTo(name) ==0) { return true; @@ -443,7 +441,6 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement return false; } - @Override public int getDefaultConnector() { return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; } @@ -474,13 +471,6 @@ public class AvatarADActivity extends TGCScalableWithInternalComponent implement public boolean isACompositeActivity() { return (nbInternalTGComponent > 0); } - - /* Issue #69 - * (non-Javadoc) - * @see ui.AbstractCDElement#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - return true; - } + + } diff --git a/src/main/java/ui/avatarad/AvatarADAssociationConnector.java b/src/main/java/ui/avatarad/AvatarADAssociationConnector.java index 56b3f58357..e0944602b8 100755 --- a/src/main/java/ui/avatarad/AvatarADAssociationConnector.java +++ b/src/main/java/ui/avatarad/AvatarADAssociationConnector.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; import myutil.GraphicLib; import ui.*; -import ui.ad.TADConnector; import java.awt.*; import java.awt.geom.Point2D; @@ -53,14 +55,14 @@ import java.util.Vector; * @version 1.0 01/09/2011 * @author Ludovic APVRILLE */ -public class AvatarADAssociationConnector extends TADConnector/* Issue #69 TGConnector*/ { +public class AvatarADAssociationConnector extends TGConnector { int w, h; public AvatarADAssociationConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); } - @Override + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { g.drawLine(x1, y1, x2, y2); @@ -73,7 +75,6 @@ public class AvatarADAssociationConnector extends TADConnector/* Issue #69 TGCo GraphicLib.dashedLine(g, x1, y1, x2, y2); }*/ - @Override public TGComponent extraIsOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { return this; @@ -81,21 +82,15 @@ public class AvatarADAssociationConnector extends TADConnector/* Issue #69 TGCo return null; } - @Override public int getType() { return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; } - /** - * Issue #69 - * @return - */ - @Override - public boolean canBeDisabled() { - if ( p2 != null && ( p2.getFather() instanceof AvatarADStopState || p2.getFather() instanceof AvatarADStopFlow ) ) { - return false; - } - - return super.canBeDisabled(); - } } + + + + + + + diff --git a/src/main/java/ui/avatarad/AvatarADBasicCanBeDisabledComponent.java b/src/main/java/ui/avatarad/AvatarADBasicCanBeDisabledComponent.java deleted file mode 100644 index 3465351a35..0000000000 --- a/src/main/java/ui/avatarad/AvatarADBasicCanBeDisabledComponent.java +++ /dev/null @@ -1,17 +0,0 @@ -package ui.avatarad; - -import ui.TDiagramPanel; -import ui.TGComponent; - -public abstract class AvatarADBasicCanBeDisabledComponent extends AvatarADBasicComponent { - - public AvatarADBasicCanBeDisabledComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, - TGComponent _father, TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - } - - @Override - public boolean canBeDisabled() { - return true; - } -} diff --git a/src/main/java/ui/avatarad/AvatarADBasicComponent.java b/src/main/java/ui/avatarad/AvatarADBasicComponent.java index 8dc5982201..3721dec6eb 100644 --- a/src/main/java/ui/avatarad/AvatarADBasicComponent.java +++ b/src/main/java/ui/avatarad/AvatarADBasicComponent.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; import ui.*; @@ -48,18 +51,16 @@ import ui.*; * @author Ludovic APVRILLE */ public abstract class AvatarADBasicComponent extends TGCScalableWithoutInternalComponent implements SwallowedTGComponent { - // private int lineLength = 5; + private int lineLength = 5; public AvatarADBasicComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); } - @Override public int getDefaultConnector() { return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; } - @Override public void resizeWithFather() { if ((father != null) && (father instanceof AvatarADActivity)) { // Too large to fit in the father? -> resize it! @@ -69,4 +70,5 @@ public abstract class AvatarADBasicComponent extends TGCScalableWithoutInternalC setMoveCd(x, y); } } + } diff --git a/src/main/java/ui/avatarad/AvatarADChoice.java b/src/main/java/ui/avatarad/AvatarADChoice.java index b261c689a5..7830ed0ca7 100755 --- a/src/main/java/ui/avatarad/AvatarADChoice.java +++ b/src/main/java/ui/avatarad/AvatarADChoice.java @@ -36,15 +36,17 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; -import ui.EmbeddedComment; -import ui.SwallowedTGComponent; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADChoice; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; +import java.awt.geom.Line2D; /** * Class AvatarADChoice @@ -53,138 +55,125 @@ import ui.ad.TADChoice; * @version 1.0 01/09/2011 * @author Ludovic APVRILLE */ -public class AvatarADChoice extends TADChoice /* Issue #69 TGCScalableWithInternalComponent*/ implements SwallowedTGComponent, EmbeddedComment/*, BasicErrorHighlight*/ { -// private int lineLength = 10; -// private int lineOutLength = 25; -// private int textX1, textY1, textX2, textY2, textX3, textY3; +public class AvatarADChoice extends TGCScalableWithInternalComponent implements SwallowedTGComponent, EmbeddedComment, BasicErrorHighlight { + private int lineLength = 10; + private int lineOutLength = 25; + private int textX1, textY1, textX2, textY2, textX3, textY3; protected int stateOfError = 0; // Not yet checked public AvatarADChoice(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// -// initScaling(30, 30); -// oldScaleFactor = tdp.getZoom(); -// -// textX1 = -lineOutLength; -// textY1 = height/2 - 5; -// textX2 = width + 5; -// textY2 = height/2 - 5; -// textX3 = width /2 + 5; -// textY3 = height + 15; -// -// nbConnectingPoint = 4; -// connectingPoint = new TGConnectingPoint[nbConnectingPoint]; -// connectingPoint[0] = new AvatarADConnectingPoint(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new AvatarADConnectingPoint(this, -lineOutLength, 0, false, true, 0.0, 0.5); -// connectingPoint[2] = new AvatarADConnectingPoint(this, lineOutLength, 0, false, true, 1.0, 0.5); -// connectingPoint[3] = new AvatarADConnectingPoint(this, 0, lineOutLength, false, true, 0.5, 1.0); -// -// nbInternalTGComponent = 3; -// tgcomponent = new TGComponent[nbInternalTGComponent]; -// -// TGCScalableOneLineText tgc = new TGCScalableOneLineText(x+textX1, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 1"); -// tgcomponent[0] = tgc; -// -// tgc = new TGCScalableOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 2"); -// tgcomponent[1] = tgc; -// -// tgc = new TGCScalableOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 3"); -// tgcomponent[2] = tgc; -// -// moveable = true; -// editable = false; -// removable = true; -// -// name = "choice"; -// -// myImageIcon = IconManager.imgic208; - } - - @Override - protected void createConnectingPoints() { + + initScaling(30, 30); + oldScaleFactor = tdp.getZoom(); + + textX1 = -lineOutLength; + textY1 = height/2 - 5; + textX2 = width + 5; + textY2 = height/2 - 5; + textX3 = width /2 + 5; + textY3 = height + 15; + nbConnectingPoint = 4; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; connectingPoint[0] = new AvatarADConnectingPoint(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new AvatarADConnectingPoint(this, -lineOutLength, 0, false, true, 0.0, 0.5); connectingPoint[2] = new AvatarADConnectingPoint(this, lineOutLength, 0, false, true, 1.0, 0.5); connectingPoint[3] = new AvatarADConnectingPoint(this, 0, lineOutLength, false, true, 0.5, 1.0); + + nbInternalTGComponent = 3; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGCScalableOneLineText tgc = new TGCScalableOneLineText(x+textX1, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 1"); + tgcomponent[0] = tgc; + + tgc = new TGCScalableOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 2"); + tgcomponent[1] = tgc; + + tgc = new TGCScalableOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 3"); + tgcomponent[2] = tgc; + + moveable = true; + editable = false; + removable = true; + + name = "choice"; + + myImageIcon = IconManager.imgic208; + } + + public void internalDrawing(Graphics g) { + if (stateOfError > 0) { + Color c = g.getColor(); + switch(stateOfError) { + case ErrorHighlight.OK: + g.setColor(ColorManager.CHOICE); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + } + // Making the polygon + int [] px1 = {x+(width/2), x+width+2, x + (width/2), x}; + int [] py1 = {y, y + height/2, y+height+2, y+height/2}; + g.fillPolygon(px1, py1, 4); + g.setColor(c); + } + + g.drawLine(x+(width/2), y, x+width, y + height/2); + g.drawLine(x, y + height / 2, x+width/2, y + height); + g.drawLine(x + width/2, y, x, y + height/2); + g.drawLine(x + width, y + height/2, x + width/2, y + height); + + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x, y + height/2, x-lineOutLength, y + height/2); + g.drawLine(x + width, y + height/2, x+ width + lineOutLength, y + height/2); + g.drawLine(x+(width/2), y + height, x+(width/2), y + height + lineOutLength); + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y + height, x+(width/2), y + height + lineOutLength, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x + width, y + height/2, x+ width + lineOutLength, y + height/2, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x, y + height/2, x-lineOutLength, y + height/2, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y, x+(width/2), y - lineLength, _x, _y)) < distanceSelected) { + return this; + } + + return null; } -// -// @Override -// public void internalDrawing(Graphics g) { -// if (stateOfError > 0) { -// Color c = g.getColor(); -// switch(stateOfError) { -// case ErrorHighlight.OK: -// g.setColor(ColorManager.CHOICE); -// break; -// default: -// g.setColor(ColorManager.UNKNOWN_BOX_ACTION); -// } -// // Making the polygon -// int [] px1 = {x+(width/2), x+width+2, x + (width/2), x}; -// int [] py1 = {y, y + height/2, y+height+2, y+height/2}; -// g.fillPolygon(px1, py1, 4); -// g.setColor(c); -// } -// -// g.drawLine(x+(width/2), y, x+width, y + height/2); -// g.drawLine(x, y + height / 2, x+width/2, y + height); -// g.drawLine(x + width/2, y, x, y + height/2); -// g.drawLine(x + width, y + height/2, x + width/2, y + height); -// -// g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); -// g.drawLine(x, y + height/2, x-lineOutLength, y + height/2); -// g.drawLine(x + width, y + height/2, x+ width + lineOutLength, y + height/2); -// g.drawLine(x+(width/2), y + height, x+(width/2), y + height + lineOutLength); -// } -// -// @Override -// public TGComponent isOnOnlyMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+(width/2), y + height, x+(width/2), y + height + lineOutLength, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x + width, y + height/2, x+ width + lineOutLength, y + height/2, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x, y + height/2, x-lineOutLength, y + height/2, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+(width/2), y, x+(width/2), y - lineLength, _x, _y)) < distanceSelected) { -// return this; -// } -// -// return null; -// } -// -// public String getGuard(int i) { -// if ((i>=0) && (i<nbInternalTGComponent)) { -// return tgcomponent[i].getValue(); -// } -// return ""; -// } -// -// public void setGuard(String guard, int i) { -// if ((i>=0) && (i<nbInternalTGComponent)) { -// tgcomponent[i].setValue(guard); -// } -// } - - @Override + + public String getGuard(int i) { + if ((i>=0) && (i<nbInternalTGComponent)) { + return tgcomponent[i].getValue(); + } + return ""; + } + + public void setGuard(String guard, int i) { + if ((i>=0) && (i<nbInternalTGComponent)) { + tgcomponent[i].setValue(guard); + } + } + public void resizeWithFather() { if ((father != null) && (father instanceof AvatarADActivity)) { // Too large to fit in the father? -> resize it! @@ -195,17 +184,16 @@ public class AvatarADChoice extends TADChoice /* Issue #69 TGCScalableWithIntern } } - @Override public int getType() { return TGComponentManager.AAD_CHOICE; } - @Override public int getDefaultConnector() { return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; } -// -// public void setStateAction(int _stateAction) { -// stateOfError = _stateAction; -// } + + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } + } diff --git a/src/main/java/ui/avatarad/AvatarADConnectingPoint.java b/src/main/java/ui/avatarad/AvatarADConnectingPoint.java index 607ee7b091..655f69cda3 100644 --- a/src/main/java/ui/avatarad/AvatarADConnectingPoint.java +++ b/src/main/java/ui/avatarad/AvatarADConnectingPoint.java @@ -36,8 +36,12 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; + import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -49,14 +53,14 @@ import ui.TGConnectingPointWidthHeight; * @version 1.0 01/09/2011 * @author Ludovic APVRILLE */ -public class AvatarADConnectingPoint extends TGConnectingPointWidthHeight { +public class AvatarADConnectingPoint extends TGConnectingPointWidthHeight { public AvatarADConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } - @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.AAD_ASSOCIATION_CONNECTOR; } + } diff --git a/src/main/java/ui/avatarad/AvatarADJunction.java b/src/main/java/ui/avatarad/AvatarADJunction.java index 31af72842d..da184855f6 100755 --- a/src/main/java/ui/avatarad/AvatarADJunction.java +++ b/src/main/java/ui/avatarad/AvatarADJunction.java @@ -36,6 +36,7 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.avatarad; import ui.TDiagramPanel; @@ -47,6 +48,7 @@ import ui.util.IconManager; import java.awt.*; import java.awt.geom.Line2D; + /** * Class AvatarADJunction * Junction between several activities, without any synchronization. To be used in avatar activity diagrams @@ -100,7 +102,7 @@ public class AvatarADJunction extends AvatarADBasicComponent { myImageIcon = IconManager.imgic212; } - @Override + public void internalDrawing(Graphics g) { //g.drawLine(x +width/2, y, x+width/2, y + height); //g.drawLine(x, y + (height/2), x+width, y + (height/2)); @@ -116,7 +118,6 @@ public class AvatarADJunction extends AvatarADBasicComponent { g.drawLine(x + width / 2 + range, y + height / 2, x + width / 2, y + height / 2 + range); } - @Override public TGComponent isOnMe(int _x, int _y) { // vertical line if ((int) (Line2D.ptSegDistSq(x + width / 2, y, x + width / 2, y + height, _x, _y)) < distanceSelected) { @@ -129,12 +130,12 @@ public class AvatarADJunction extends AvatarADBasicComponent { return null; } - @Override public int getType() { return TGComponentManager.AAD_JUNCTION; } -// public int getDefaultConnector() { -// return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; -// } + public int getDefaultConnector() { + return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; + } + } diff --git a/src/main/java/ui/avatarad/AvatarADPanel.java b/src/main/java/ui/avatarad/AvatarADPanel.java index a45b09bfcc..8681fecd95 100644 --- a/src/main/java/ui/avatarad/AvatarADPanel.java +++ b/src/main/java/ui/avatarad/AvatarADPanel.java @@ -36,13 +36,21 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; +//import java.awt.*; + import ui.*; import java.util.ArrayList; import java.util.Iterator; -import java.util.List; + +//import org.w3c.dom.*; +//import org.xml.sax.*; +//import javax.xml.parsers.*; /** * Class AvatarADPanel @@ -63,52 +71,41 @@ public class AvatarADPanel extends TDiagramPanel implements TDPWithAttributes{ addMouseMotionListener(tdmm);*/ } - @Override public boolean actionOnDoubleClick(TGComponent tgc) { return true; } - @Override public boolean actionOnAdd(TGComponent tgc) { return false; } - - @Override public boolean actionOnValueChanged(TGComponent tgc) { return false; } - @Override public boolean actionOnRemove(TGComponent tgc) { return false; } - @Override public String getXMLHead() { return "<AvatarADPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; } - @Override public String getXMLTail() { return "</AvatarADPanel>"; } - @Override public String getXMLSelectedHead() { return "<AvatarADPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } - @Override public String getXMLSelectedTail() { return "</AvatarADPanelCopy>"; } - @Override public String getXMLCloneHead() { return "<AvatarADPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } - @Override public String getXMLCloneTail() { return "</AvatarADPanelCopy>"; } @@ -121,41 +118,47 @@ public class AvatarADPanel extends TDiagramPanel implements TDPWithAttributes{ // Position correctly guards of choice } - @Override + + public boolean hasAutoConnect() { return false; } public void setConnectorsToFront() { TGComponent tgc; - Iterator<TGComponent> iterator = componentList.listIterator(); + + // + + Iterator iterator = componentList.listIterator(); - List<TGComponent> list = new ArrayList<TGComponent>(); + ArrayList<TGComponent> list = new ArrayList<TGComponent>(); while(iterator.hasNext()) { - tgc = iterator.next(); + tgc = (TGComponent)(iterator.next()); if (!(tgc instanceof TGConnector)) { list.add(tgc); } } + // for(TGComponent tgc1: list) { + // componentList.remove(tgc1); componentList.add(tgc1); } } public void alignPartitions() { - AvatarADPartition ontheLeft = null;//, sdi; + AvatarADPartition ontheLeft = null, sdi; int x = getMaxX(),xtmp; int y; int i; TGComponent tgc; - Iterator<TGComponent> iterator = componentList.listIterator(); + Iterator iterator = componentList.listIterator(); // search for the instances which is the most on the left while(iterator.hasNext()) { - tgc = iterator.next(); + tgc = (TGComponent)(iterator.next()); if (tgc instanceof AvatarADPartition) { xtmp = tgc.getX(); if (xtmp < x) { @@ -177,5 +180,7 @@ public class AvatarADPanel extends TDiagramPanel implements TDPWithAttributes{ tgc.setCd(tgc.getX(), y); } } + } + } diff --git a/src/main/java/ui/avatarad/AvatarADParallel.java b/src/main/java/ui/avatarad/AvatarADParallel.java index 0a583b4283..311bf463dc 100755 --- a/src/main/java/ui/avatarad/AvatarADParallel.java +++ b/src/main/java/ui/avatarad/AvatarADParallel.java @@ -36,17 +36,17 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.avatarad; -import java.awt.Graphics; -import java.util.Arrays; -import java.util.List; + + +package ui.avatarad; import myutil.GraphicLib; import ui.*; -import ui.ad.EnablingADConnectorVisitor; import ui.util.IconManager; +import java.awt.*; + /** * Class AvatarADParallel * Parallel operator. All activities start together @@ -55,9 +55,9 @@ import ui.util.IconManager; * @version 1.0 02/09/2011 * @author Ludovic APVRILLE */ -public class AvatarADParallel extends AvatarADBasicCanBeDisabledComponent /* Issue #69 AvatarADBasicComponent*/ { +public class AvatarADParallel extends AvatarADBasicComponent{ private int lineLength = 0; - // private int textX, textY; + private int textX, textY; public AvatarADParallel(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -65,8 +65,8 @@ public class AvatarADParallel extends AvatarADBasicCanBeDisabledComponent /* Iss initScaling(150, 5); oldScaleFactor = tdp.getZoom(); -// textX = width - 10; -// textY = height - 8; + textX = width - 10; + textY = height - 8; nbConnectingPoint = 10; connectingPoint = new TGConnectingPoint[10]; @@ -93,13 +93,11 @@ public class AvatarADParallel extends AvatarADBasicCanBeDisabledComponent /* Iss myImageIcon = IconManager.imgic206; } - @Override public void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -115,37 +113,18 @@ public class AvatarADParallel extends AvatarADBasicCanBeDisabledComponent /* Iss tgcomponent[0].setValue(val); } - @Override public int getType() { return TGComponentManager.AAD_PARALLEL; } -// -// public int getDefaultConnector() { -// return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; -// } - - public List<TGConnectingPoint> getEnterConnectingPoints() { - return Arrays.asList( Arrays.copyOfRange( connectingPoint, 0, 5 ) ); - } - - public List<TGConnectingPoint> getExitConnectingPoints() { - return Arrays.asList( Arrays.copyOfRange( connectingPoint, 5, connectingPoint.length ) ); - } - /** - * Issue #69 - * @param _enabled - */ - @Override - public void setEnabled( final boolean _enabled ) { - super.setEnabled( _enabled ); - - final List<TGConnectingPoint> enterConPoints = getEnterConnectingPoints(); - - for ( final TGConnectingPoint point : connectingPoint ) { - if ( !enterConPoints.contains( point ) ) { - point.acceptForward( new EnablingADConnectorVisitor( _enabled ) ); - } - } + public int getDefaultConnector() { + return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; } } + + + + + + + diff --git a/src/main/java/ui/avatarad/AvatarADPartition.java b/src/main/java/ui/avatarad/AvatarADPartition.java index 7410edfa4f..4719fb9847 100755 --- a/src/main/java/ui/avatarad/AvatarADPartition.java +++ b/src/main/java/ui/avatarad/AvatarADPartition.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; import myutil.GraphicLib; @@ -52,18 +55,18 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarADPartition extends AvatarADBasicComponent implements EmbeddedComment{ - //private int lineLength = 5; + private int lineLength = 5; public AvatarADPartition(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - initScaling(10, 500); - oldScaleFactor = tdp.getZoom(); - - minWidth = (int)(10* tdp.getZoom()); - maxWidth = (int)(30* tdp.getZoom()); - minHeight = (int)(250* tdp.getZoom()); - maxHeight = (int)(1500* tdp.getZoom()); + initScaling(10, 500); + oldScaleFactor = tdp.getZoom(); + + minWidth = (int)(10* tdp.getZoom()); + maxWidth = (int)(30* tdp.getZoom()); + minHeight = (int)(250* tdp.getZoom()); + maxHeight = (int)(1500* tdp.getZoom()); nbConnectingPoint = 0; @@ -78,13 +81,11 @@ public class AvatarADPartition extends AvatarADBasicComponent implements Embedde myImageIcon = IconManager.imgic222; } - @Override public void internalDrawing(Graphics g) { g.drawLine(x+(width/2), y, x+(width/2), y +height); g.drawLine(x+(width/2)+1, y, x+(width/2)+1, y +height); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -93,12 +94,12 @@ public class AvatarADPartition extends AvatarADBasicComponent implements Embedde return null; } - @Override public int getType() { return TGComponentManager.AAD_PARTITION; } -// -// public int getDefaultConnector() { -// return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; -// } + + public int getDefaultConnector() { + return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; + } + } diff --git a/src/main/java/ui/avatarad/AvatarADSendSignalAction.java b/src/main/java/ui/avatarad/AvatarADSendSignalAction.java index 6c01f804d1..6b48304f34 100755 --- a/src/main/java/ui/avatarad/AvatarADSendSignalAction.java +++ b/src/main/java/ui/avatarad/AvatarADSendSignalAction.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; import myutil.GraphicLib; @@ -53,7 +56,7 @@ import java.awt.geom.Line2D; * @version 1.0 02/09/2011 * @author Ludovic APVRILLE */ -public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponent/* Issue #69 AvatarADBasicComponent*/ implements EmbeddedComment, BasicErrorHighlight { +public class AvatarADSendSignalAction extends AvatarADBasicComponent implements EmbeddedComment, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -69,7 +72,7 @@ public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponen minWidth = (int)(30* tdp.getZoom()); oldScaleFactor = tdp.getZoom(); - nbConnectingPoint = 2; + nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; connectingPoint[0] = new AvatarADConnectingPoint(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[1] = new AvatarADConnectingPoint(this, 0, lineLength, false, true, 0.5, 1.0); @@ -84,8 +87,8 @@ public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponen myImageIcon = IconManager.imgic904; } - @Override public void internalDrawing(Graphics g) { + int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); if ((w1 != width) & (!tdp.isScaled())) { @@ -139,11 +142,14 @@ public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponen g.drawLine(x+width-linebreak, y, x+width, y+height/2); g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); + + g.drawString("sig", x+(width-w) / 2, y); g.drawString(value, x + (width - w) / 2 , y + (int)((textY*tdp.getZoom()))); + + } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -160,7 +166,6 @@ public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponen return value; } - @Override public boolean editOndoubleClick(JFrame frame) { String oldValue = value; @@ -180,12 +185,12 @@ public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponen } - @Override public int getType() { return TGComponentManager.AAD_SEND_SIGNAL_ACTION; } - @Override + + public void setStateAction(int _stateAction) { stateOfError = _stateAction; } diff --git a/src/main/java/ui/avatarad/AvatarADStartState.java b/src/main/java/ui/avatarad/AvatarADStartState.java index 4bbe93d0e6..f24098652c 100755 --- a/src/main/java/ui/avatarad/AvatarADStartState.java +++ b/src/main/java/ui/avatarad/AvatarADStartState.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; import myutil.GraphicLib; @@ -52,13 +55,13 @@ import java.awt.geom.Line2D; * @version 1.0 01/09/2011 * @author Ludovic APVRILLE */ -public class AvatarADStartState extends AvatarADBasicComponent implements EmbeddedComment { +public class AvatarADStartState extends AvatarADBasicComponent implements EmbeddedComment{ private int lineLength = 5; public AvatarADStartState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - initScaling(15, 15); + initScaling(15, 15); oldScaleFactor = tdp.getZoom(); nbConnectingPoint = 1; @@ -76,13 +79,11 @@ public class AvatarADStartState extends AvatarADBasicComponent implements Embedd myImageIcon = IconManager.imgic222; } - @Override public void internalDrawing(Graphics g) { g.fillOval(x, y, width, height); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -95,13 +96,12 @@ public class AvatarADStartState extends AvatarADBasicComponent implements Embedd return null; } - @Override public int getType() { return TGComponentManager.AAD_START_STATE; } -// -// public int getDefaultConnector() { -// return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; -// } + + public int getDefaultConnector() { + return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; + } } diff --git a/src/main/java/ui/avatarad/AvatarADStopFlow.java b/src/main/java/ui/avatarad/AvatarADStopFlow.java index be3ca80a23..a3bbdfb88d 100755 --- a/src/main/java/ui/avatarad/AvatarADStopFlow.java +++ b/src/main/java/ui/avatarad/AvatarADStopFlow.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; import myutil.GraphicLib; @@ -52,7 +55,7 @@ import java.awt.*; * @author Ludovic APVRILLE */ public class AvatarADStopFlow extends AvatarADBasicComponent implements EmbeddedComment, AllowedBreakpoint { -// private int internalCircleSize = 16; + private int internalCircleSize = 16; private int lineLength = 5; public AvatarADStopFlow(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { @@ -76,7 +79,6 @@ public class AvatarADStopFlow extends AvatarADBasicComponent implements Embedded myImageIcon = IconManager.imgic210; } - @Override public void internalDrawing(Graphics g) { ColorManager.setColor(g, state, 0); //g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); @@ -86,7 +88,6 @@ public class AvatarADStopFlow extends AvatarADBasicComponent implements Embedded g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -94,12 +95,12 @@ public class AvatarADStopFlow extends AvatarADBasicComponent implements Embedded return null; } - @Override public int getType() { return TGComponentManager.AAD_STOP_FLOW; } -// -// public int getDefaultConnector() { -// return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; -// } + + public int getDefaultConnector() { + return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; + } + } diff --git a/src/main/java/ui/avatarad/AvatarADStopState.java b/src/main/java/ui/avatarad/AvatarADStopState.java index e3f1e919f4..875892b8ef 100755 --- a/src/main/java/ui/avatarad/AvatarADStopState.java +++ b/src/main/java/ui/avatarad/AvatarADStopState.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarad; import myutil.GraphicLib; @@ -76,7 +79,6 @@ public class AvatarADStopState extends AvatarADBasicComponent implements Embedde myImageIcon = IconManager.imgic210; } - @Override public void internalDrawing(Graphics g) { ColorManager.setColor(g, state, 0); g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); @@ -84,7 +86,7 @@ public class AvatarADStopState extends AvatarADBasicComponent implements Embedde g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); } - @Override + public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -92,12 +94,12 @@ public class AvatarADStopState extends AvatarADBasicComponent implements Embedde return null; } - @Override public int getType() { return TGComponentManager.AAD_STOP_STATE; } -// -// public int getDefaultConnector() { -// return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; -// } + + public int getDefaultConnector() { + return TGComponentManager.AAD_ASSOCIATION_CONNECTOR; + } + } diff --git a/src/main/java/ui/avatarad/AvatarADToolBar.java b/src/main/java/ui/avatarad/AvatarADToolBar.java index b1ba6354ff..f491f119af 100644 --- a/src/main/java/ui/avatarad/AvatarADToolBar.java +++ b/src/main/java/ui/avatarad/AvatarADToolBar.java @@ -36,6 +36,7 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.avatarad; import ui.MainGUI; @@ -44,6 +45,9 @@ import ui.TToolBar; import javax.swing.*; +//import java.awt.*; +//import java.awt.event.*; + /** * Class AvatarADToolBar * Implements the toolbar to be used in conjunction with the panel of @@ -58,6 +62,7 @@ public class AvatarADToolBar extends TToolBar { public AvatarADToolBar(MainGUI _mgui) { super(_mgui); + } protected void setActive(boolean b) { @@ -157,10 +162,14 @@ public class AvatarADToolBar extends TToolBar { button = this.add(mgui.actions[TGUIAction.AAD_ALIGN_PARTITION]); button.addMouseListener(mgui.mouseHandler); + /*this.addSeparator(); this.addSeparator(); button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_ATTR]); button.addMouseListener(mgui.mouseHandler);*/ + + } + } // Class diff --git a/src/main/java/ui/avatarbd/AvatarBDPerformancePragma.java b/src/main/java/ui/avatarbd/AvatarBDPerformancePragma.java index af0b233b44..e1b2a7f95f 100644 --- a/src/main/java/ui/avatarbd/AvatarBDPerformancePragma.java +++ b/src/main/java/ui/avatarbd/AvatarBDPerformancePragma.java @@ -227,7 +227,7 @@ public class AvatarBDPerformancePragma extends TGCScalableWithoutInternalCompone } - private void makeValue() { + public void makeValue() { values = Conversion.wrapText(value); properties.clear(); for (String s : values) { diff --git a/src/main/java/ui/avatarbd/AvatarBDPragma.java b/src/main/java/ui/avatarbd/AvatarBDPragma.java index 1fbb30ab86..f3b9419132 100755 --- a/src/main/java/ui/avatarbd/AvatarBDPragma.java +++ b/src/main/java/ui/avatarbd/AvatarBDPragma.java @@ -36,6 +36,7 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.avatarbd; import myutil.Conversion; @@ -54,9 +55,6 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PipedInputStream; import java.io.PipedOutputStream; -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -69,11 +67,11 @@ import proverifspec.ProVerifResultTraceStep; import ui.interactivesimulation.JFrameSimulationSDPanel; import javax.swing.*; +import java.awt.*; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; -import java.util.List; /** * Class Pragma @@ -86,9 +84,9 @@ import java.util.List; public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { protected String[] values; - protected List<String> models; - protected List<String> properties; - public List<String> syntaxErrors; + protected LinkedList<String> models; + protected LinkedList<String> properties; + public ArrayList<String> syntaxErrors; protected int textX = 25; protected int textY = 5; protected int marginY = 20; @@ -167,15 +165,14 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { makeValue(); } - public List<String> getProperties() { + public LinkedList<String> getProperties() { return properties; } - public List<String> getModels() { + public LinkedList<String> getModels() { return this.models; } - @Override public void internalDrawing(Graphics g) { Font f = g.getFont(); Font fold = f; @@ -302,6 +299,7 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { } */ g.setColor(c); + } public void makeValue() { @@ -404,6 +402,7 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { // if (c1==Color.gray){ // g.drawString("?", _x+4, _y+2); // } + } @Override @@ -420,7 +419,7 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { String s = jdn.getText(); if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { - // String tmp = s; + String tmp = s; setValue(s); makeValue(); return true; @@ -428,7 +427,6 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { return false; } - @Override public TGComponent isOnMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -436,12 +434,10 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { return null; } - @Override public String getToolTipText() { return "The lock shows status of weak and strong authenticity. Green: Proved True, Red: Proved False, Grey: Cannot be proved"; } - @Override public void rescale(double scaleFactor) { //TraceManager.addDev("Rescaling BD Pragma"); /*dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; @@ -454,12 +450,10 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { super.rescale(scaleFactor); } - @Override public int getType() { return TGComponentManager.PRAGMA; } - @Override protected String translateExtraParam() { if (values == null) { makeValue(); @@ -547,9 +541,10 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { } catch (IOException ignored) { } } + break; - break; } } + // } } diff --git a/src/main/java/ui/avatarbd/AvatarBDSafetyPragma.java b/src/main/java/ui/avatarbd/AvatarBDSafetyPragma.java index bbf87cdbbb..1e9e99b538 100644 --- a/src/main/java/ui/avatarbd/AvatarBDSafetyPragma.java +++ b/src/main/java/ui/avatarbd/AvatarBDSafetyPragma.java @@ -36,6 +36,7 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.avatarbd; import myutil.Conversion; @@ -48,10 +49,7 @@ import ui.util.IconManager; import ui.window.JDialogSafetyPragma; import javax.swing.*; - -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics; +import java.awt.*; import java.util.*; /** @@ -65,7 +63,7 @@ import java.util.*; public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { protected String[] values; - protected List<String> properties; + protected LinkedList<String> properties; protected int textX = 25; protected int textY = 5; protected int marginY = 20; @@ -74,7 +72,7 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { protected int lockX = 1; protected int lockY = 5; protected Graphics myg; - public List<String> syntaxErrors; + public ArrayList<String> syntaxErrors; protected Color myColor; private Font myFont;//, myFontB; @@ -129,11 +127,10 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { return values; } - public List<String> getProperties() { + public LinkedList<String> getProperties() { return properties; } - @Override public void internalDrawing(Graphics g) { Font f = g.getFont(); Font fold = f; @@ -224,7 +221,8 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { } - private void makeValue() { + public void makeValue() { + values = Conversion.wrapText(value); properties.clear(); for (String s : values) { @@ -260,7 +258,7 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { } }*/ - @Override + public boolean editOndoubleClick(JFrame frame) { String oldValue = value; @@ -281,7 +279,6 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { return false; } - @Override public TGComponent isOnMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -289,7 +286,6 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { return null; } - @Override public void rescale(double scaleFactor) { /*dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; lineHeight = (int)(dlineHeight); @@ -301,12 +297,10 @@ public class AvatarBDSafetyPragma extends TGCScalableWithoutInternalComponent { super.rescale(scaleFactor); } - @Override public int getType() { return TGComponentManager.SAFETY_PRAGMA; } - @Override protected String translateExtraParam() { if (values == null) { makeValue(); diff --git a/src/main/java/ui/avatardd/ADDArtifact.java b/src/main/java/ui/avatardd/ADDArtifact.java index 168176f98a..2570aa5fce 100755 --- a/src/main/java/ui/avatardd/ADDArtifact.java +++ b/src/main/java/ui/avatardd/ADDArtifact.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatardd; import myutil.GraphicLib; @@ -92,8 +95,9 @@ public class ADDArtifact extends TGCWithoutInternalComponent implements Swallowe myImageIcon = IconManager.imgic702; } - @Override + public void internalDrawing(Graphics g) { + if (oldValue.compareTo(value) != 0) { setValue(value, g); } @@ -132,7 +136,6 @@ public class ADDArtifact extends TGCWithoutInternalComponent implements Swallowe // } - @Override public void resizeWithFather() { if ((father != null) && ((father instanceof ADDCPUNode))) { // @@ -142,9 +145,9 @@ public class ADDArtifact extends TGCWithoutInternalComponent implements Swallowe } } - @Override + public boolean editOndoubleClick(JFrame frame) { -// String tmp; + String tmp; boolean error = false; /*JDialogTMLTaskArtifact dialog = new JDialogTMLTaskArtifact(frame, "Setting artifact attributes", this); @@ -196,7 +199,6 @@ public class ADDArtifact extends TGCWithoutInternalComponent implements Swallowe value = referenceTaskName + "::" + taskName; } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -204,12 +206,10 @@ public class ADDArtifact extends TGCWithoutInternalComponent implements Swallowe return null; } - @Override public int getType() { return TGComponentManager.ADD_ARTIFACT; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info value=\"" + value + "\" taskName=\"" + taskName + "\" referenceTaskName=\""); @@ -263,7 +263,7 @@ public class ADDArtifact extends TGCWithoutInternalComponent implements Swallowe } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeFullValue(); } @@ -291,4 +291,8 @@ public class ADDArtifact extends TGCWithoutInternalComponent implements Swallowe public String getAttributesToFile() { return ""; } + + + + } diff --git a/src/main/java/ui/avatardd/ADDBlockArtifact.java b/src/main/java/ui/avatardd/ADDBlockArtifact.java index bdca0ae1e8..c5ca6a3cf1 100755 --- a/src/main/java/ui/avatardd/ADDBlockArtifact.java +++ b/src/main/java/ui/avatardd/ADDBlockArtifact.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatardd; import myutil.GraphicLib; @@ -93,8 +96,9 @@ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements Swa myImageIcon = IconManager.imgic702; } - @Override + public void internalDrawing(Graphics g) { + if (oldValue.compareTo(value) != 0) { setValue(value, g); } @@ -133,7 +137,6 @@ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements Swa // } - @Override public void resizeWithFather() { if ((father != null) && ((father instanceof ADDCPUNode))) { // @@ -143,8 +146,8 @@ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements Swa } } - @Override - public boolean editOndoubleClick(JFrame frame) { + + public boolean editOndoubleClick(JFrame frame) { String tmp; boolean error = false; @@ -188,14 +191,15 @@ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements Swa makeFullValue(); + return !error; + } private void makeFullValue() { value = referenceTaskName + "::" + taskName; } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -203,12 +207,10 @@ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements Swa return null; } - @Override public int getType() { return TGComponentManager.ADD_ARTIFACT; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info value=\"" + value + "\" taskName=\"" + taskName + "\" referenceTaskName=\""); @@ -222,6 +224,7 @@ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements Swa public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ // try { + NodeList nli; Node n1, n2; Element elt; @@ -260,7 +263,7 @@ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements Swa } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeFullValue(); } @@ -281,4 +284,5 @@ public class ADDBlockArtifact extends TGCWithoutInternalComponent implements Swa public String getTaskName() { return taskName; } + } diff --git a/src/main/java/ui/avatardd/ADDBridgeNode.java b/src/main/java/ui/avatardd/ADDBridgeNode.java index 197ddca0fd..9961306d2b 100755 --- a/src/main/java/ui/avatardd/ADDBridgeNode.java +++ b/src/main/java/ui/avatardd/ADDBridgeNode.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatardd; import org.w3c.dom.Element; @@ -62,6 +65,7 @@ public class ADDBridgeNode extends ADDCommunicationNode implements WithAttribute private int derivationy = 3; private String stereotype = "BRIDGE"; + public ADDBridgeNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -106,7 +110,6 @@ public class ADDBridgeNode extends ADDCommunicationNode implements WithAttribute myImageIcon = IconManager.imgic700; } - @Override public void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); @@ -138,8 +141,8 @@ public class ADDBridgeNode extends ADDCommunicationNode implements WithAttribute g.drawImage(IconManager.img9, x + width - 20, y + 4, null); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { + Polygon pol = new Polygon(); pol.addPoint(x, y); pol.addPoint(x + derivationx, y - derivationy); @@ -163,7 +166,6 @@ public class ADDBridgeNode extends ADDCommunicationNode implements WithAttribute return name; } - @Override public boolean editOndoubleClick(JFrame frame) { // boolean error = false; //String errors = ""; @@ -232,12 +234,11 @@ public class ADDBridgeNode extends ADDCommunicationNode implements WithAttribute return true; } - @Override + public int getType() { return TGComponentManager.ADD_BRIDGENODE; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -294,14 +295,17 @@ public class ADDBridgeNode extends ADDCommunicationNode implements WithAttribute } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } } - - public String getAttributes() { - String attr = ""; - //attr += "Buffer size (in byte) = " + bufferByteDataSize + "\n"; - //attr += "Clock ratio = " + clockRatio + "\n"; - return attr; - } + + + public String getAttributes() { + String attr = ""; + //attr += "Buffer size (in byte) = " + bufferByteDataSize + "\n"; + //attr += "Clock ratio = " + clockRatio + "\n"; + return attr; + } + + } diff --git a/src/main/java/ui/avatardd/ADDBusNode.java b/src/main/java/ui/avatardd/ADDBusNode.java index d01b97c8c5..131b8d89a0 100755 --- a/src/main/java/ui/avatardd/ADDBusNode.java +++ b/src/main/java/ui/avatardd/ADDBusNode.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatardd; import myutil.GraphicLib; @@ -69,6 +72,8 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { private int fifoDepth = 0; private int minLatency = 0; + + public ADDBusNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -113,7 +118,6 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { myImageIcon = IconManager.imgic700; } - @Override public void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); @@ -149,8 +153,8 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { g.drawImage(IconManager.img9, x + width - 20, y + 4, null); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { + Polygon pol = new Polygon(); pol.addPoint(x, y); pol.addPoint(x + derivationx, y - derivationy); @@ -174,7 +178,6 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { return name; } - @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -201,6 +204,8 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { } } + + if (dialog.getIndex().length() != 0) { try { tmp = index; @@ -231,6 +236,7 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { } } + if (dialog.getNbOfAttachedTargets().length() != 0) { try { tmp = nbOfAttachedTargets; @@ -288,12 +294,11 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { return true; } - @Override + public int getType() { return TGComponentManager.ADD_BUSNODE; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -310,7 +315,9 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + // try { + NodeList nli; Node n1, n2; Element elt; @@ -356,10 +363,13 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } } + + + public String getAttributes() { String attr = ""; attr += "index = " + index + "\n"; @@ -386,8 +396,8 @@ public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { public int getFifoDepth() { return fifoDepth;} public int getMinLatency() { return minLatency;} - @Override public String toString(){ return "Bus"; } + } diff --git a/src/main/java/ui/avatardd/ADDCPUNode.java b/src/main/java/ui/avatardd/ADDCPUNode.java index 005a95d4f7..7d328a1ca0 100755 --- a/src/main/java/ui/avatardd/ADDCPUNode.java +++ b/src/main/java/ui/avatardd/ADDCPUNode.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatardd; import myutil.GraphicLib; @@ -75,6 +78,7 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri protected int index = 0; protected int monitored = 0; + public ADDCPUNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -119,11 +123,11 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri myImageIcon = IconManager.imgic700; } - @Override public void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); + // Top lines g.drawLine(x, y, x + derivationx, y - derivationy); g.drawLine(x + width, y, x + width + derivationx, y - derivationy); @@ -153,7 +157,6 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri g.drawImage(IconManager.img9, x + width - 20, y + 4, null); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { Polygon pol = new Polygon(); @@ -179,7 +182,6 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri return name; } - @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -206,6 +208,7 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri } } + if (dialog.getNbOFIRQ().length() != 0) { try { tmp = nbOfIrq; @@ -311,6 +314,8 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri } } + + /*if (dialog.getClockRatio().length() != 0) { try { tmp = clockRatio; @@ -326,7 +331,7 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri } }*/ - if (dialog.getIndex().length() != 0) { + if (dialog.getIndex().length() != 0) { try { tmp = index; index = Integer.decode(dialog.getIndex()).intValue(); @@ -341,7 +346,8 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri } } - if (dialog.getMonitored() != 0) { + + if (dialog.getMonitored() != 0) { try { tmp = monitored; @@ -368,19 +374,17 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri return true; } - @Override + public int getType() { return TGComponentManager.ADD_CPUNODE; } - @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { //TraceManager.addDev("Accept swallowed?"); return tgc instanceof ADDBlockArtifact; } - @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { //TraceManager.addDev("Add swallowed?"); //Set its coordinates @@ -397,7 +401,6 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri } - @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } @@ -415,7 +418,6 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri return v; } - @Override public void hasBeenResized() { for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof ADDBlockArtifact) { @@ -425,7 +427,6 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); @@ -492,15 +493,15 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } } - @Override public int getDefaultConnector() { return TGComponentManager.ADD_CONNECTOR; } + public String getAttributes() { String attr = ""; attr += "Nb of irq = " + nbOfIrq + "\n"; @@ -551,7 +552,8 @@ public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttri } public void setMonitored(int _monitored){ - monitored = _monitored; + monitored = _monitored; } + } diff --git a/src/main/java/ui/avatardd/ADDChannelArtifact.java b/src/main/java/ui/avatardd/ADDChannelArtifact.java index 7d5944d04d..4048be6ee3 100755 --- a/src/main/java/ui/avatardd/ADDChannelArtifact.java +++ b/src/main/java/ui/avatardd/ADDChannelArtifact.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatardd; import myutil.GraphicLib; @@ -94,8 +97,9 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S myImageIcon = IconManager.imgic702; } - @Override + public void internalDrawing(Graphics g) { + if (oldValue.compareTo(value) != 0) { setValue(value, g); } @@ -118,6 +122,7 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); g.drawString(value, x + textX , y + textY); + } public void setValue(String val, Graphics g) { @@ -133,7 +138,6 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S // } - @Override public void resizeWithFather() { if ((father != null) && ((father instanceof ADDRAMNode))) { // @@ -143,7 +147,7 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S } } - @Override + public boolean editOndoubleClick(JFrame frame) { String tmp; boolean error = false; @@ -200,7 +204,6 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S value = referenceDiagram + "::" + channelName; }*/ - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -212,7 +215,6 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S return TGComponentManager.ADD_CHANNELARTIFACT; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info value=\"" + value + "\" channelName=\"" + channelName + "\" fullChannelName=\"" + fullChannelName + "\" referenceDiagram=\""); @@ -272,7 +274,7 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeFullValue(); } @@ -299,6 +301,7 @@ public class ADDChannelArtifact extends TGCWithoutInternalComponent implements S } public String getStatusInformation() { - return "Name of the channel: " + fullChannelName; + return "Name of the channel: " + fullChannelName; } + } diff --git a/src/main/java/ui/avatarmad/AvatarMADCompositionConnector.java b/src/main/java/ui/avatarmad/AvatarMADCompositionConnector.java index 8708601a6c..f4f325f904 100644 --- a/src/main/java/ui/avatarmad/AvatarMADCompositionConnector.java +++ b/src/main/java/ui/avatarmad/AvatarMADCompositionConnector.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarmad; import ui.*; @@ -44,6 +47,8 @@ import ui.util.IconManager; import java.awt.*; import java.util.Vector; +//import java.awt.geom.*; + /** * Class AvatarMADCompositionConnector * Connector to be used in Avatar MAD. Connects two assumptions @@ -52,7 +57,7 @@ import java.util.Vector; * @author Ludovic APVRILLE */ public class AvatarMADCompositionConnector extends TGConnectorWithCommentConnectionPoints { - // int w, h; + int w, h; private int radius = 5; public AvatarMADCompositionConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { @@ -62,7 +67,7 @@ public class AvatarMADCompositionConnector extends TGConnectorWithCommentConnec myImageIcon = IconManager.imgic1012; } - @Override + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ //g.drawLine(x1, y1, x2, y2); diff --git a/src/main/java/ui/avatarmad/AvatarMADConnector.java b/src/main/java/ui/avatarmad/AvatarMADConnector.java deleted file mode 100644 index 421f6b4f82..0000000000 --- a/src/main/java/ui/avatarmad/AvatarMADConnector.java +++ /dev/null @@ -1,84 +0,0 @@ -package ui.avatarmad; - -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Point; -import java.util.Vector; - -import myutil.GraphicLib; -import ui.ForwardComponentsEnabledVisitor; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGConnectingPoint; -import ui.TGConnectorWithCommentConnectionPoints; -import ui.ad.CanBeDisabledADElementVisitor; - -public abstract class AvatarMADConnector extends TGConnectorWithCommentConnectionPoints { - - int w, h; - - public AvatarMADConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, - TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, - Vector<Point> _listPoint) { - super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); - } - - @Override - protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ - - //g.drawLine(x1, y1, x2, y2); - GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); - - // Indicate semantics - - Font f = g.getFont(); - Font old = f; - if (f.getSize() != tdp.getFontSize()) { - f = f.deriveFont((float)tdp.getFontSize()); - g.setFont(f); - } - - w = g.getFontMetrics().stringWidth(value); - h = g.getFontMetrics().getHeight(); - g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); - g.setFont(old); - } - - @Override - public TGComponent extraIsOnOnlyMe(int x1, int y1) { - if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { - return this; - } - return null; - } - - /** - * Issue #69 - * @return - */ - @Override - public boolean canBeDisabled() { -// if ( p2 != null && p2.getFather() instanceof AvatarSMDStopState ) { -// return false; -// } - - final CanBeDisabledADElementVisitor visitor = new CanBeDisabledADElementVisitor(); - acceptBackward( visitor ); - - return visitor.isCanBeDisabled(); - } - - /** Issue #69 - * @return - */ - public boolean isEnabled( boolean checkBranch ) { - if ( checkBranch && p2 != null ) { - final ForwardComponentsEnabledVisitor visitor = new ForwardComponentsEnabledVisitor(); - p2.acceptForward( visitor ); - - return visitor.isEnabled(); - } - - return super.isEnabled(); - } -} diff --git a/src/main/java/ui/avatarmad/AvatarMADImpactConnector.java b/src/main/java/ui/avatarmad/AvatarMADImpactConnector.java index 9be09e1278..ae483cb103 100644 --- a/src/main/java/ui/avatarmad/AvatarMADImpactConnector.java +++ b/src/main/java/ui/avatarmad/AvatarMADImpactConnector.java @@ -36,16 +36,19 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarmad; -import java.awt.Point; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; import java.util.Vector; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.util.IconManager; +//import java.awt.geom.*; /** * Class AvatarMADImpactConnector @@ -54,8 +57,8 @@ import ui.util.IconManager; * @version 1.0 27/08/2013 * @author Ludovic APVRILLE */ -public class AvatarMADImpactConnector extends AvatarMADConnector /* Issue #69 TGConnectorWithCommentConnectionPoints*/ { - // int w, h; +public class AvatarMADImpactConnector extends TGConnectorWithCommentConnectionPoints { + int w, h; public AvatarMADImpactConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); @@ -64,35 +67,36 @@ public class AvatarMADImpactConnector extends AvatarMADConnector /* Issue #69 T myImageIcon = IconManager.imgic1008; } -// protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ -// -// //g.drawLine(x1, y1, x2, y2); -// GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); -// -// // Indicate semantics -// -// Font f = g.getFont(); -// Font old = f; -// if (f.getSize() != tdp.getFontSize()) { -// f = f.deriveFont((float)tdp.getFontSize()); -// g.setFont(f); -// } -// -// w = g.getFontMetrics().stringWidth(value); -// h = g.getFontMetrics().getHeight(); -// g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); -// g.setFont(old); -// } -// -// public TGComponent extraIsOnOnlyMe(int x1, int y1) { -// if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { -// return this; -// } -// return null; -// } - - @Override + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + + //g.drawLine(x1, y1, x2, y2); + GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); + + // Indicate semantics + + Font f = g.getFont(); + Font old = f; + if (f.getSize() != tdp.getFontSize()) { + f = f.deriveFont((float)tdp.getFontSize()); + g.setFont(f); + } + + w = g.getFontMetrics().stringWidth(value); + h = g.getFontMetrics().getHeight(); + g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); + g.setFont(old); + } + + public TGComponent extraIsOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { + return this; + } + return null; + } + public int getType() { return TGComponentManager.AVATARMAD_IMPACT_CONNECTOR; } + } diff --git a/src/main/java/ui/avatarmad/AvatarMADMeetConnector.java b/src/main/java/ui/avatarmad/AvatarMADMeetConnector.java index f1b8e739b6..097ea94ff1 100644 --- a/src/main/java/ui/avatarmad/AvatarMADMeetConnector.java +++ b/src/main/java/ui/avatarmad/AvatarMADMeetConnector.java @@ -36,16 +36,19 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarmad; -import java.awt.Point; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; import java.util.Vector; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.util.IconManager; +//import java.awt.geom.*; /** * Class AvatarMADMeetConnector @@ -54,8 +57,8 @@ import ui.util.IconManager; * @version 1.0 05/02/2014 * @author Ludovic APVRILLE */ -public class AvatarMADMeetConnector extends AvatarMADConnector /* Issue #69 TGConnectorWithCommentConnectionPoints*/ { - // int w, h; +public class AvatarMADMeetConnector extends TGConnectorWithCommentConnectionPoints { + int w, h; public AvatarMADMeetConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); @@ -64,34 +67,36 @@ public class AvatarMADMeetConnector extends AvatarMADConnector /* Issue #69 TGC myImageIcon = IconManager.imgic1008; } -// protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ -// -// //g.drawLine(x1, y1, x2, y2); -// GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); -// -// // Indicate semantics -// -// Font f = g.getFont(); -// Font old = f; -// if (f.getSize() != tdp.getFontSize()) { -// f = f.deriveFont((float)tdp.getFontSize()); -// g.setFont(f); -// } -// -// w = g.getFontMetrics().stringWidth(value); -// h = g.getFontMetrics().getHeight(); -// g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); -// g.setFont(old); -// } -// -// public TGComponent extraIsOnOnlyMe(int x1, int y1) { -// if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { -// return this; -// } -// return null; -// } + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + + //g.drawLine(x1, y1, x2, y2); + GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); + + // Indicate semantics + + Font f = g.getFont(); + Font old = f; + if (f.getSize() != tdp.getFontSize()) { + f = f.deriveFont((float)tdp.getFontSize()); + g.setFont(f); + } + + w = g.getFontMetrics().stringWidth(value); + h = g.getFontMetrics().getHeight(); + g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); + g.setFont(old); + } + + public TGComponent extraIsOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { + return this; + } + return null; + } public int getType() { return TGComponentManager.AVATARMAD_MEET_CONNECTOR; } + } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDBasicCanBeDisabledComponent.java b/src/main/java/ui/avatarsmd/AvatarSMDBasicCanBeDisabledComponent.java deleted file mode 100644 index 2c6e38b07e..0000000000 --- a/src/main/java/ui/avatarsmd/AvatarSMDBasicCanBeDisabledComponent.java +++ /dev/null @@ -1,25 +0,0 @@ -package ui.avatarsmd; - -import ui.TDiagramPanel; -import ui.TGComponent; - -public abstract class AvatarSMDBasicCanBeDisabledComponent extends AvatarSMDBasicComponent { - - public AvatarSMDBasicCanBeDisabledComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, - boolean _pos, TGComponent _father, TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.AbstractCDElement#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - if ( getFather() instanceof AvatarSMDState ) { - return getFather().isEnabled(); - } - - return true; - } -} diff --git a/src/main/java/ui/avatarsmd/AvatarSMDBasicComponent.java b/src/main/java/ui/avatarsmd/AvatarSMDBasicComponent.java index 3a80d4a6df..fa760549d9 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDBasicComponent.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDBasicComponent.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarsmd; import ui.*; @@ -48,18 +51,16 @@ import ui.*; * @author Ludovic APVRILLE */ public abstract class AvatarSMDBasicComponent extends TGCWithoutInternalComponent implements SwallowedTGComponent { - //private int lineLength = 5; + private int lineLength = 5; public AvatarSMDBasicComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); } - @Override public int getDefaultConnector() { - return TGComponentManager.AVATARSMD_CONNECTOR; + return TGComponentManager.AVATARSMD_CONNECTOR; } - @Override public void resizeWithFather() { if ((father != null) && (father instanceof AvatarSMDState)) { // Too large to fit in the father? -> resize it! @@ -69,8 +70,5 @@ public abstract class AvatarSMDBasicComponent extends TGCWithoutInternalComponen setMoveCd(x, y); } } - - protected boolean isContainedInEnabledState() { - return getFather() instanceof AvatarSMDState && getFather().isEnabled(); - } + } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDChoice.java b/src/main/java/ui/avatarsmd/AvatarSMDChoice.java index df16dedae6..8e7c4bf1d2 100755 --- a/src/main/java/ui/avatarsmd/AvatarSMDChoice.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDChoice.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarsmd; import myutil.GraphicLib; @@ -55,21 +58,21 @@ import java.awt.geom.Line2D; public class AvatarSMDChoice extends AvatarSMDBasicComponent implements EmbeddedComment, BasicErrorHighlight, PartOfInvariant { private int lineLength = 10; private int lineOutLength = 10; -// private int textX1, textY1, textX2, textY2, textX3, textY3; + private int textX1, textY1, textX2, textY2, textX3, textY3; - protected int stateOfError = 0; // Not yet checked + protected int stateOfError = 0; // Not yet checked public AvatarSMDChoice(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); width = 30; height = 30; -// textX1 = -lineOutLength; -// textY1 = height/2 - 5; -// textX2 = width + 5; -// textY2 = height/2 - 5; -// textX3 = width /2 + 5; -// textY3 = height + 15; + textX1 = -lineOutLength; + textY1 = height/2 - 5; + textX2 = width + 5; + textY2 = height/2 - 5; + textX3 = width /2 + 5; + textY3 = height + 15; nbConnectingPoint = 7; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; @@ -95,7 +98,6 @@ public class AvatarSMDChoice extends AvatarSMDBasicComponent implements Embedded myImageIcon = IconManager.imgic208; } - @Override public void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); @@ -124,7 +126,6 @@ public class AvatarSMDChoice extends AvatarSMDBasicComponent implements Embedded g.drawLine(x+(width/2), y + height, x+(width/2), y + height + lineOutLength); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -149,18 +150,18 @@ public class AvatarSMDChoice extends AvatarSMDBasicComponent implements Embedded return null; } - @Override + public int getType() { return TGComponentManager.AVATARSMD_CHOICE; } - @Override public int getDefaultConnector() { - return TGComponentManager.AVATARSMD_CONNECTOR; + return TGComponentManager.AVATARSMD_CONNECTOR; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + + } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDConnector.java b/src/main/java/ui/avatarsmd/AvatarSMDConnector.java index 220f270353..127a1e7912 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDConnector.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDConnector.java @@ -36,6 +36,7 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.avatarsmd; import myutil.GraphicLib; @@ -123,7 +124,6 @@ public class AvatarSMDConnector extends TGConnectorWithCommentConnectionPoints i tgc.setTimes(minDelay, maxDelay, minCompute, maxCompute); } - @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2) { if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { g.drawLine(x1, y1, x2, y2); @@ -132,7 +132,6 @@ public class AvatarSMDConnector extends TGConnectorWithCommentConnectionPoints i } } - @Override public boolean editOndoubleClick(JFrame frame) { AvatarSMDTransitionInfo info = getAvatarSMDTransitionInfo(); if (info == null) { @@ -141,7 +140,6 @@ public class AvatarSMDConnector extends TGConnectorWithCommentConnectionPoints i return info.editOndoubleClick(frame); } - @Override public int getType() { return TGComponentManager.AVATARSMD_CONNECTOR; } @@ -159,191 +157,66 @@ public class AvatarSMDConnector extends TGConnectorWithCommentConnectionPoints i return getAvatarSMDTransitionInfo().getGuard(); } - public String getEffectiveGuard() { - return getAvatarSMDTransitionInfo().getEffectiveGuard(); + public String getTotalMinDelay() { + String s1 = getAvatarSMDTransitionInfo().getAfterMinDelay(); + String s2 = getAvatarSMDTransitionInfo().getComputeMinDelay(); + return addedDelays(s1, s2); + } + + public String getTotalMaxDelay() { + String s1 = getAvatarSMDTransitionInfo().getAfterMaxDelay(); + String s2 = getAvatarSMDTransitionInfo().getComputeMaxDelay(); + return addedDelays(s1, s2); + } + + public String addedDelays(String s1, String s2) { + if (s1.trim().length() == 0) { + return s2.trim(); + } else { + if (s2.trim().length() == 0) { + return s1; + } else { + return "(" + s1 + ") + (" + s2 + ")"; + } + } } -// -// public String getTotalMinDelay() { -// String s1 = getAvatarSMDTransitionInfo().getAfterMinDelay(); -// String s2 = getAvatarSMDTransitionInfo().getComputeMinDelay(); -// return addedDelays(s1, s2); -// } -// -// public String getTotalMaxDelay() { -// String s1 = getAvatarSMDTransitionInfo().getAfterMaxDelay(); -// String s2 = getAvatarSMDTransitionInfo().getComputeMaxDelay(); -// return addedDelays(s1, s2); -// } -// -// public String addedDelays(String s1, String s2) { -// if (s1.trim().length() == 0) { -// return s2.trim(); -// } else { -// if (s2.trim().length() == 0) { -// return s1; -// } else { -// return "(" + s1 + ") + (" + s2 + ")"; -// } -// } -// } public Vector<String> getActions() { return getAvatarSMDTransitionInfo().getActions(); } - - public Vector<String> getEffectiveActions() { - return getAvatarSMDTransitionInfo().getEffectiveActions(); - } public String getAfterMinDelay() { return getAvatarSMDTransitionInfo().getAfterMinDelay(); } - - public String getEffectiveAfterMinDelay() { - return getAvatarSMDTransitionInfo().getEffectiveAfterMinDelay(); - } public String getAfterMaxDelay() { return getAvatarSMDTransitionInfo().getAfterMaxDelay(); } - public String getEffectiveAfterMaxDelay() { - return getAvatarSMDTransitionInfo().getEffectiveAfterMaxDelay(); - } public String getComputeMinDelay() { return getAvatarSMDTransitionInfo().getComputeMinDelay(); } - - public String getEffectiveComputeMinDelay() { - return getAvatarSMDTransitionInfo().getEffectiveComputeMinDelay(); - } public String getComputeMaxDelay() { return getAvatarSMDTransitionInfo().getComputeMaxDelay(); } - public String getEffectiveComputeMaxDelay() { - return getAvatarSMDTransitionInfo().getEffectiveComputeMaxDelay(); - } - public String getProbability() { return getAvatarSMDTransitionInfo().getProbability(); } - public String getEffectiveProbability() { - return getAvatarSMDTransitionInfo().getEffectiveProbability(); - } -// -// public String getFilesToInclude() { -// return getAvatarSMDTransitionInfo().getFilesToInclude(); -// } -// -// public String getCodeToInclude() { -// return getAvatarSMDTransitionInfo().getCodeToInclude(); -// } - public String getAttributes() { - return getAvatarSMDTransitionInfo().getAttributes(); - } - - /** - * Issue #69 - * @param _enabled - */ - @Override - public void setEnabled( final boolean _enabled ) { - if ( p2 != null ) { - p2.acceptForward( new EnablingAvatarSMDConnectorVisitor( _enabled ) ); - } - } - - /** - * Issue #69 - * @return - */ - @Override - public boolean canBeDisabled() { - if ( p2 != null ) { - if ( p2.getFather() instanceof AvatarSMDStopState ) { - return false; - } - } - - return canBeDisabledContainer(); - } - - public boolean canBeDisabledContainer() { - if ( p2 != null ) { - if ( p2.getFather() instanceof TGComponent && ( (TGComponent) p2.getFather() ).getFather() instanceof AvatarSMDState ) { - if ( !( (TGComponent) p2.getFather() ).getFather().isEnabled() ) { - return false; - } - } - } - - if ( p1 != null ) { - if ( p1.getFather() instanceof TGComponent && ( (TGComponent) p1.getFather() ).getFather() instanceof AvatarSMDState ) { - if ( !( (TGComponent) p1.getFather() ).getFather().isEnabled() ) { - return false; - } - } - } - - return true; - } - - public boolean isContainedInEnabledState() { - final AvatarSMDState sourceContainingState = getContainingState( p1 ); - - if ( sourceContainingState != null && sourceContainingState.isEnabled() ) { - return true; - } - - final AvatarSMDState targetContainingState = getContainingState( p2 ); - - return targetContainingState != null && targetContainingState.isEnabled(); - } - public AvatarSMDState getContainingState() { - final AvatarSMDState sourceContainingState = getContainingState( p1 ); - - final AvatarSMDState targetContainingState = getContainingState( p2 ); - - if ( sourceContainingState == targetContainingState ) { - return sourceContainingState; - } - - return null; + + public String getFilesToInclude() { + return getAvatarSMDTransitionInfo().getFilesToInclude(); } - - private AvatarSMDState getContainingState( final TGConnectingPoint point ) { - if ( p1 == null ) { - return null; - } - - if ( point.getFather() instanceof TGComponent ) { - final TGComponent sourceComponent = (TGComponent) point.getFather(); - - if ( sourceComponent.getFather() instanceof AvatarSMDState ) { - return (AvatarSMDState) sourceComponent.getFather(); - } - } - - return null; + + public String getCodeToInclude() { + return getAvatarSMDTransitionInfo().getCodeToInclude(); } - - - /** Issue #69 - * @return - */ - public boolean isEnabled( boolean checkBranch ) { - if ( checkBranch && p2 != null ) { - final ForwardComponentsEnabledVisitor visitor = new ForwardComponentsEnabledVisitor(); - p2.acceptForward( visitor ); - - return visitor.isEnabled(); - } - - return super.isEnabled(); + + public String getAttributes() { + return getAvatarSMDTransitionInfo().getAttributes(); } } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDExpireTimer.java b/src/main/java/ui/avatarsmd/AvatarSMDExpireTimer.java index da260e9cb6..c4e16b68cd 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDExpireTimer.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDExpireTimer.java @@ -40,7 +40,6 @@ package ui.avatarsmd; import java.awt.Color; import java.awt.Graphics; -import java.awt.Polygon; import java.awt.geom.Line2D; import java.util.List; @@ -68,22 +67,17 @@ import ui.window.JDialogAvatarTimer; * @version 1.0 15/07/2010 * @author Ludovic APVRILLE */ -public class AvatarSMDExpireTimer extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements BasicErrorHighlight, PartOfInvariant { - - protected int lineLength = 5; - - protected int textX = 5; - - protected int textY = 15; - - protected int arc = 5; - - protected int linebreak = 10; +public class AvatarSMDExpireTimer extends AvatarSMDBasicComponent implements BasicErrorHighlight, PartOfInvariant { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int arc = 5; + protected int linebreak = 10; protected int hourglassWidth = 10; - protected int hourglassSpace = 2; + protected int stateOfError = 0; // Not yet checked public AvatarSMDExpireTimer(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { @@ -159,27 +153,13 @@ public class AvatarSMDExpireTimer extends AvatarSMDBasicCanBeDisabledComponent / g.drawLine(x1, y1+height1, x1+linebreak, y1+height1/2); g.setColor(c); - final Polygon shape = new Polygon(); - shape.addPoint( x, y ); - shape.addPoint( x + width, y ); - shape.addPoint( x + width, y + height ); - shape.addPoint( x, y + height ); - shape.addPoint( x + linebreak, y + height / 2 ); - g.drawPolygon( shape ); -// g.drawLine(x, y, x+width, y); -// g.drawLine(x+width, y, x+width, y+height); -// g.drawLine(x, y+height, x+width, y+height); -// g.drawLine(x, y, x+linebreak, y+height/2); -// g.drawLine(x, y+height, x+linebreak, y+height/2); - - // Issue #69 - if ( !isEnabled() && isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillPolygon( shape ); - g.setColor( c ); - } - - // hourglass + g.drawLine(x, y, x+width, y); + g.drawLine(x+width, y, x+width, y+height); + g.drawLine(x, y+height, x+width, y+height); + g.drawLine(x, y, x+linebreak, y+height/2); + g.drawLine(x, y+height, x+linebreak, y+height/2); + + // hourglass g.setColor(ColorManager.AVATAR_SET_TIMER); g.drawLine(x+width+hourglassSpace+1, y+1, x+width+hourglassSpace + hourglassWidth+1, y+1); g.drawLine(x+width+hourglassSpace+1, y+height+1, x+width+hourglassSpace + hourglassWidth+1, y+height+1); @@ -193,6 +173,8 @@ public class AvatarSMDExpireTimer extends AvatarSMDBasicCanBeDisabledComponent / //g.drawString("sig()", x+(width-w) / 2, y); g.drawString(value, x + (width - w) / 2 + textX, y + textY); + + } @Override @@ -243,19 +225,20 @@ public class AvatarSMDExpireTimer extends AvatarSMDBasicCanBeDisabledComponent / value = "expire(" + val0 + ")"; return true; + } - @Override + + + public int getType() { return TGComponentManager.AVATARSMD_EXPIRE_TIMER; } - @Override public int getDefaultConnector() { return TGComponentManager.AVATARSMD_CONNECTOR; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDLibraryFunctionCall.java b/src/main/java/ui/avatarsmd/AvatarSMDLibraryFunctionCall.java index 289727f729..97ee9c8ee5 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDLibraryFunctionCall.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDLibraryFunctionCall.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarsmd; import myutil.GraphicLib; @@ -48,23 +51,18 @@ import ui.util.IconManager; import ui.window.JDialogSMDLibraryFunctionCall; import javax.swing.*; - -import java.awt.Color; -import java.awt.Graphics; +import java.awt.*; import java.util.LinkedList; -import java.util.List; + /** * @version 1.0 04.18.2016 * @author Florian LUGOU */ -public class AvatarSMDLibraryFunctionCall extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 TGCScalableWithoutInternalComponent*/ implements BasicErrorHighlight { - - private List<TAttribute> parameters; - - private List<AvatarSignal> signals; - - private List<TAttribute> returnAttributes; +public class AvatarSMDLibraryFunctionCall extends TGCScalableWithoutInternalComponent implements BasicErrorHighlight { + private LinkedList<TAttribute> parameters; + private LinkedList<AvatarSignal> signals; + private LinkedList<TAttribute> returnAttributes; private AvatarBDLibraryFunction libraryFunction; @@ -106,8 +104,8 @@ public class AvatarSMDLibraryFunctionCall extends AvatarSMDBasicCanBeDisabledCom this.myImageIcon = IconManager.imgic904; } - @Override public void internalDrawing(Graphics graph) { + this.value = this.prettyPrint (); int [] px1 = {this.x, this.x+this.width-AvatarSMDLibraryFunctionCall.linebreak, this.x+this.width, this.x+this.width-AvatarSMDLibraryFunctionCall.linebreak, this.x, this.x+AvatarSMDLibraryFunctionCall.linebreak}; @@ -130,13 +128,6 @@ public class AvatarSMDLibraryFunctionCall extends AvatarSMDBasicCanBeDisabledCom graph.drawPolygon (px1, py1, 6); - // Issue #69 - if ( !isEnabled() && isContainedInEnabledState() ) { - graph.setColor( ColorManager.DISABLED_FILLING ); - graph.fillPolygon( px1, py1, 6 ); - graph.setColor( c ); - } - graph.drawLine (this.x+this.width/2, this.y, this.x+this.width/2, this.y - AvatarSMDLibraryFunctionCall.lineLength); graph.drawLine (this.x+this.width/2, this.y+this.height, this.x+this.width/2, this.y + AvatarSMDLibraryFunctionCall.lineLength + this.height); @@ -158,7 +149,6 @@ public class AvatarSMDLibraryFunctionCall extends AvatarSMDBasicCanBeDisabledCom graph.drawString (this.value, this.x + (this.width - stringWidth) / 2 , this.y + (this.height+h)/2); } - @Override public TGComponent isOnMe(int _x, int _y) { if (_x < this.x || _x > this.x + this.width || _y > this.y + this.height || _y < this.y) return null; @@ -185,7 +175,6 @@ public class AvatarSMDLibraryFunctionCall extends AvatarSMDBasicCanBeDisabledCom return this; } - @Override public boolean editOndoubleClick(JFrame frame) { JDialogSMDLibraryFunctionCall dialog = new JDialogSMDLibraryFunctionCall ( this, @@ -207,27 +196,27 @@ public class AvatarSMDLibraryFunctionCall extends AvatarSMDBasicCanBeDisabledCom this.libraryFunction = libraryFunction; } - public List<TAttribute> getParameters () { + public LinkedList<TAttribute> getParameters () { return this.parameters; } - public void setParameters( List<TAttribute> parameters) { + public void setParameters (LinkedList<TAttribute> parameters) { this.parameters = parameters; } - public List<AvatarSignal> getSignals () { + public LinkedList<AvatarSignal> getSignals () { return this.signals; } - public void setSignals( List<AvatarSignal> signals) { + public void setSignals (LinkedList<AvatarSignal> signals) { this.signals = signals; } - public List<TAttribute> getReturnAttributes () { + public LinkedList<TAttribute> getReturnAttributes () { return this.returnAttributes; } - public void setReturnAttributes( List<TAttribute> returnAttributes) { + public void setReturnAttributes (LinkedList<TAttribute> returnAttributes) { this.returnAttributes = returnAttributes; } @@ -275,12 +264,10 @@ public class AvatarSMDLibraryFunctionCall extends AvatarSMDBasicCanBeDisabledCom return builder.toString (); } - @Override public int getDefaultConnector() { return TGComponentManager.AVATARSMD_CONNECTOR; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } @@ -439,7 +426,7 @@ public class AvatarSMDLibraryFunctionCall extends AvatarSMDBasicCanBeDisabledCom } catch (MalformedModelingException e) { throw e; } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } if (this.libraryFunction != null && diff --git a/src/main/java/ui/avatarsmd/AvatarSMDRandom.java b/src/main/java/ui/avatarsmd/AvatarSMDRandom.java index 2b4fce07b7..79528c6ccb 100755 --- a/src/main/java/ui/avatarsmd/AvatarSMDRandom.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDRandom.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarsmd; import myutil.GraphicLib; @@ -57,7 +60,7 @@ import java.awt.geom.Line2D; * @version 1.0 12/07/2010 * @author Ludovic APVRILLE */ -public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements EmbeddedComment, BasicErrorHighlight { +public class AvatarSMDRandom extends AvatarSMDBasicComponent implements EmbeddedComment, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -94,16 +97,15 @@ public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Is myImageIcon = IconManager.imgic912; } - private void makeValue() { + public void makeValue() { valueRandom = variable + " = RANDOM" + functionId + "[" + minValue + ", " + maxValue + "]"; } public void setVariable(String v){ variable=v; } - - @Override public void internalDrawing(Graphics g) { + if (valueRandom.length() == 0) { makeValue(); } @@ -116,9 +118,8 @@ public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Is //updateConnectingPoints(); } - Color c = g.getColor(); - if (stateOfError > 0) { + Color c = g.getColor(); switch(stateOfError) { case ErrorHighlight.OK: g.setColor(ColorManager.RANDOM); @@ -131,22 +132,13 @@ public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Is } g.drawRoundRect(x, y, width, height, arc, arc); - - // Issue #69 - if ( !isEnabled() && isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillRoundRect(x, y, width, height, arc, arc); - g.setColor( c ); - } - - g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); //g.drawLine(x+width, y+height/2, x+width +lineLength, y+height/2); g.drawString(valueRandom, x + (width - w) / 2 , y + textY); } - @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -202,7 +194,6 @@ public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Is return true; } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -235,7 +226,6 @@ public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Is return functionId; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data variable=\""); @@ -253,13 +243,18 @@ public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Is @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + // try { + NodeList nli; Node n1, n2; Element elt; // int k; String s; + // + // + for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); // @@ -289,18 +284,19 @@ public class AvatarSMDRandom extends AvatarSMDBasicCanBeDisabledComponent /* Is } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeValue(); } - @Override + public int getType() { return TGComponentManager.AVATARSMD_RANDOM; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + + } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDReceiveSignal.java b/src/main/java/ui/avatarsmd/AvatarSMDReceiveSignal.java index b705e2a4c3..97637c4760 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDReceiveSignal.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDReceiveSignal.java @@ -40,10 +40,8 @@ package ui.avatarsmd; import java.awt.Color; import java.awt.Graphics; -import java.awt.Polygon; import java.awt.geom.Line2D; import java.util.List; -import java.util.Map; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; @@ -75,7 +73,7 @@ import ui.window.JDialogAvatarSignal; * @version 1.0 12/04/2010 * @author Ludovic APVRILLE */ -public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements CheckableAccessibility, LinkedReference, CheckableLatency, BasicErrorHighlight, PartOfInvariant { +public class AvatarSMDReceiveSignal extends AvatarSMDBasicComponent implements CheckableAccessibility, LinkedReference, CheckableLatency, BasicErrorHighlight, PartOfInvariant { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -83,12 +81,14 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent protected int linebreak = 10; protected int textX1 = 2; - private Map<String, String> latencyVals; + private ConcurrentHashMap<String, String> latencyVals; + protected int latencyX=30; protected int latencyY=25; protected int textWidth=10; protected int textHeight=20; + protected int stateOfError = 0; // Not yet checked @@ -125,6 +125,7 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent @Override public void internalDrawing(Graphics g) { + int w = g.getFontMetrics().stringWidth(value + textX1); int w1 = Math.max(minWidth, w + 2 * textX); if ((w1 != width) & (!tdp.isScaled())) { @@ -133,6 +134,7 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent //updateConnectingPoints(); } + if (stateOfError > 0) { Color c = g.getColor(); switch(stateOfError) { @@ -171,27 +173,13 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent g.drawLine(x1, y1, x1+linebreak, y1+height1/2); g.drawLine(x1, y1+height1, x1+linebreak, y1+height1/2); g.setColor(c); - - final Polygon shape = new Polygon(); - shape.addPoint( x, y ); - shape.addPoint( x + width, y ); - shape.addPoint( x + width, y + height ); - shape.addPoint( x, y + height ); - shape.addPoint( x + linebreak, y + height / 2 ); - g.drawPolygon( shape ); -// g.drawLine(x, y, x+width, y); -// g.drawLine(x+width, y, x+width, y+height); -// g.drawLine(x, y+height, x+width, y+height); -// g.drawLine(x, y, x+linebreak, y+height/2); -// g.drawLine(x, y+height, x+linebreak, y+height/2); + g.drawLine(x, y, x+width, y); + g.drawLine(x+width, y, x+width, y+height); + g.drawLine(x, y+height, x+width, y+height); + g.drawLine(x, y, x+linebreak, y+height/2); + g.drawLine(x, y+height, x+linebreak, y+height/2); - // Issue #69 - if ( !isEnabled() && isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillPolygon( shape ); - g.setColor( c ); - } //g.drawString("sig()", x+(width-w) / 2, y); g.drawString(value, x + linebreak + textX1, y + textY); @@ -203,7 +191,6 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent drawLatencyInformation(g); } } - if (reference!=null){ if (reference instanceof AvatarRDRequirement){ AvatarRDRequirement refReq = (AvatarRDRequirement) reference; @@ -211,8 +198,7 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent } } } - - private void drawLatencyInformation(Graphics g){ + public void drawLatencyInformation(Graphics g){ int index=1; for (String s:latencyVals.keySet()){ int w = g.getFontMetrics().stringWidth(s); @@ -292,8 +278,9 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent } } if (reference instanceof TMLADReadChannel){ + // TMLADReadChannel rc = (TMLADReadChannel) reference; - Map<String, String> refLats =rc.getLatencyMap(); + ConcurrentHashMap<String, String> refLats =rc.getLatencyMap(); // for (String checkpoint:refLats.keySet()){ if (s.split("\\-")[1].split(":")[0].equals(checkpoint.split("channel:")[1].split(" ")[0])){ @@ -317,7 +304,6 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent } } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -330,7 +316,7 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent return null; } - //public void makeValue() { + public void makeValue() { /*boolean first = true; value = eventName + "("; for(int i=0; i<nParam; i++) { @@ -346,7 +332,7 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent } value += ")";*/ - // } + } public String getSignalName() { if (value == null) { @@ -434,17 +420,15 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicCanBeDisabledComponent } - @Override + public int getType() { return TGComponentManager.AVATARSMD_RECEIVE_SIGNAL; } - @Override - public int getDefaultConnector() { - return TGComponentManager.AVATARSMD_CONNECTOR; + public int getDefaultConnector() { + return TGComponentManager.AVATARSMD_CONNECTOR; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDResetTimer.java b/src/main/java/ui/avatarsmd/AvatarSMDResetTimer.java index 6eab76979e..a65555c45f 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDResetTimer.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDResetTimer.java @@ -40,7 +40,6 @@ package ui.avatarsmd; import java.awt.Color; import java.awt.Graphics; -import java.awt.Polygon; import java.awt.geom.Line2D; import java.util.List; @@ -68,7 +67,7 @@ import ui.window.JDialogAvatarTimer; * @version 1.0 15/07/2010 * @author Ludovic APVRILLE */ -public class AvatarSMDResetTimer extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements BasicErrorHighlight, PartOfInvariant { +public class AvatarSMDResetTimer extends AvatarSMDBasicComponent implements BasicErrorHighlight, PartOfInvariant { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -106,8 +105,8 @@ public class AvatarSMDResetTimer extends AvatarSMDBasicCanBeDisabledComponent /* myImageIcon = IconManager.imgic904; } - @Override public void internalDrawing(Graphics g) { + int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); if ((w1 != width) & (!tdp.isScaled())) { @@ -151,26 +150,11 @@ public class AvatarSMDResetTimer extends AvatarSMDBasicCanBeDisabledComponent /* g.drawLine(x1+width1-linebreak, y1+height1, x1+width1, y1+height1/2); g.setColor(c); - final Polygon shape = new Polygon(); - shape.addPoint( x, y ); - shape.addPoint( x + width - linebreak, y ); - shape.addPoint( x + width, y + height / 2 ); - shape.addPoint( x + width - linebreak, y + height ); - shape.addPoint(x, y + height ); - - g.drawPolygon( shape ); -// g.drawLine(x, y, x+width-linebreak, y); -// g.drawLine(x, y+height, x+width-linebreak, y+height); -// g.drawLine(x, y, x, y+height); -// g.drawLine(x+width-linebreak, y, x+width, y+height/2); -// g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); - - // Issue #69 - if ( !isEnabled() && isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillPolygon( shape ); - g.setColor( c ); - } + g.drawLine(x, y, x+width-linebreak, y); + g.drawLine(x, y+height, x+width-linebreak, y+height); + g.drawLine(x, y, x, y+height); + g.drawLine(x+width-linebreak, y, x+width, y+height/2); + g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); // hourglass g.setColor(ColorManager.AVATAR_SET_TIMER); @@ -186,6 +170,8 @@ public class AvatarSMDResetTimer extends AvatarSMDBasicCanBeDisabledComponent /* //g.drawString("sig()", x+(width-w) / 2, y); g.drawString(value, x + (width - w) / 2 , y + textY); + + } @Override diff --git a/src/main/java/ui/avatarsmd/AvatarSMDSendSignal.java b/src/main/java/ui/avatarsmd/AvatarSMDSendSignal.java index aefcf54dfa..55fd6ffca7 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDSendSignal.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDSendSignal.java @@ -40,10 +40,8 @@ package ui.avatarsmd; import java.awt.Color; import java.awt.Graphics; -import java.awt.Polygon; import java.awt.geom.Line2D; import java.util.List; -import java.util.Map; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; @@ -74,7 +72,7 @@ import ui.window.JDialogAvatarSignal; * @version 1.0 12/04/2010 * @author Ludovic APVRILLE */ -public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements CheckableAccessibility, LinkedReference, CheckableLatency, BasicErrorHighlight, PartOfInvariant { +public class AvatarSMDSendSignal extends AvatarSMDBasicComponent implements CheckableAccessibility, LinkedReference, CheckableLatency, BasicErrorHighlight, PartOfInvariant { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -129,6 +127,7 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* width = w1; //updateConnectingPoints(); } + if (stateOfError > 0) { Color c = g.getColor(); switch(stateOfError) { @@ -168,33 +167,17 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* g.drawLine(x1+width1-linebreak, y1+height1, x1+width1, y1+height1/2); g.setColor(c); - final Polygon shape = new Polygon(); - shape.addPoint( x, y ); - shape.addPoint( x + width - linebreak, y ); - shape.addPoint( x + width, y + height / 2 ); - shape.addPoint( x + width - linebreak, y + height ); - shape.addPoint( x, y + height ); - - g.drawPolygon( shape ); - - // Issue #69 - if ( !isEnabled() && isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillPolygon( shape ); - g.setColor( c ); - } -// g.drawLine(x, y, x+width-linebreak, y); -// g.drawLine(x, y+height, x+width-linebreak, y+height); -// g.drawLine(x, y, x, y+height); -// g.drawLine(x+width-linebreak, y, x+width, y+height/2); -// g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); + g.drawLine(x, y, x+width-linebreak, y); + g.drawLine(x, y+height, x+width-linebreak, y+height); + g.drawLine(x, y, x, y+height); + g.drawLine(x+width-linebreak, y, x+width, y+height/2); + g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); //g.drawString("sig()", x+(width-w) / 2, y); g.drawString(value, x + (width - w) / 2 , y + textY); //g.drawString("Reference " + reference, x-latencyX/2, y+latencyY/2); - - if (getCheckLatency()){ + if (getCheckLatency()){ ConcurrentHashMap<String, String> latency =tdp.getMGUI().getLatencyVals(getAVATARID()); if (latency!=null){ latencyVals=latency; @@ -209,7 +192,7 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* } } - private void drawLatencyInformation(Graphics g){ + public void drawLatencyInformation(Graphics g){ int index=1; for (String s:latencyVals.keySet()){ int w = g.getFontMetrics().stringWidth(s); @@ -291,7 +274,7 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* if (reference instanceof TMLADWriteChannel){ // TMLADWriteChannel rc = (TMLADWriteChannel) reference; - Map<String, String> refLats =rc.getLatencyMap(); + ConcurrentHashMap<String, String> refLats =rc.getLatencyMap(); // for (String checkpoint:refLats.keySet()){ if (s.split("\\-")[1].split(":")[0].equals(checkpoint.split(":")[1].split(" ")[0])){ @@ -309,6 +292,7 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* } } + g.drawString(latencyVals.get(s), x-latencyX/2, y-latencyY*index/2); g.setColor(c); index++; @@ -328,23 +312,23 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicCanBeDisabledComponent /* return null; } -// public void makeValue() { -// /*boolean first = true; -// value = eventName + "("; -// for(int i=0; i<nParam; i++) { -// if (params[i].length() > 0) { -// if (!first) { -// value += ", " + params[i]; -// } else { -// first = false; -// value += params[i]; -// } -// -// } -// } -// value += ")";*/ -// -// } + public void makeValue() { + /*boolean first = true; + value = eventName + "("; + for(int i=0; i<nParam; i++) { + if (params[i].length() > 0) { + if (!first) { + value += ", " + params[i]; + } else { + first = false; + value += params[i]; + } + + } + } + value += ")";*/ + + } public String getSignalName() { if (value == null) { diff --git a/src/main/java/ui/avatarsmd/AvatarSMDSetTimer.java b/src/main/java/ui/avatarsmd/AvatarSMDSetTimer.java index d5915ffa4f..952f1039cc 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDSetTimer.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDSetTimer.java @@ -40,7 +40,6 @@ package ui.avatarsmd; import java.awt.Color; import java.awt.Graphics; -import java.awt.Polygon; import java.awt.geom.Line2D; import java.util.List; @@ -68,7 +67,7 @@ import ui.window.JDialogAvatarTimer; * @version 1.0 15/07/2010 * @author Ludovic APVRILLE */ -public class AvatarSMDSetTimer extends AvatarSMDBasicCanBeDisabledComponent /* Issue #69 AvatarSMDBasicComponent*/ implements BasicErrorHighlight, PartOfInvariant { +public class AvatarSMDSetTimer extends AvatarSMDBasicComponent implements BasicErrorHighlight, PartOfInvariant { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -150,30 +149,14 @@ public class AvatarSMDSetTimer extends AvatarSMDBasicCanBeDisabledComponent /* I g.drawLine(x1+width1-linebreak, y1, x1+width1, y1+height1/2); g.drawLine(x1+width1-linebreak, y1+height1, x1+width1, y1+height1/2); g.setColor(c); - - final Polygon shape = new Polygon(); - shape.addPoint( x, y ); - shape.addPoint( x + width - linebreak, y ); - shape.addPoint( x + width, y + height / 2 ); - shape.addPoint( x + width - linebreak, y + height ); - shape.addPoint(x, y + height ); - g.drawPolygon( shape ); -// -// g.drawLine(x, y, x+width-linebreak, y); -// g.drawLine(x, y+height, x+width-linebreak, y+height); -// g.drawLine(x, y, x, y+height); -// g.drawLine(x+width-linebreak, y, x+width, y+height/2); -// g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); + g.drawLine(x, y, x+width-linebreak, y); + g.drawLine(x, y+height, x+width-linebreak, y+height); + g.drawLine(x, y, x, y+height); + g.drawLine(x+width-linebreak, y, x+width, y+height/2); + g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); - // Issue #69 - if ( !isEnabled() && isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillPolygon( shape ); - g.setColor( c ); - } - - // hourglass + // hourglass g.setColor(ColorManager.AVATAR_SET_TIMER); g.drawLine(x+width+hourglassSpace+1, y+1, x+width+hourglassSpace + hourglassWidth+1, y+1); g.drawLine(x+width+hourglassSpace+1, y+height+1, x+width+hourglassSpace + hourglassWidth+1, y+height+1); @@ -185,8 +168,12 @@ public class AvatarSMDSetTimer extends AvatarSMDBasicCanBeDisabledComponent /* I g.drawLine(x+width+hourglassSpace, y, x+width+hourglassSpace + hourglassWidth, y+height); g.drawLine(x+width+hourglassSpace, y+height, x+width+hourglassSpace + hourglassWidth, y); + + //g.drawString("sig()", x+(width-w) / 2, y); g.drawString(value, x + (width - w) / 2 , y + textY); + + } @Override @@ -252,18 +239,18 @@ public class AvatarSMDSetTimer extends AvatarSMDBasicCanBeDisabledComponent /* I return true; } + + + - @Override public int getType() { return TGComponentManager.AVATARSMD_SET_TIMER; } - @Override - public int getDefaultConnector() { - return TGComponentManager.AVATARSMD_CONNECTOR; + public int getDefaultConnector() { + return TGComponentManager.AVATARSMD_CONNECTOR; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDStartState.java b/src/main/java/ui/avatarsmd/AvatarSMDStartState.java index b815131fe6..a3b25ceca2 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDStartState.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDStartState.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarsmd; import myutil.GraphicLib; @@ -53,8 +56,7 @@ import java.awt.geom.Line2D; * @author Ludovic APVRILLE */ public class AvatarSMDStartState extends AvatarSMDBasicComponent implements EmbeddedComment, PartOfInvariant{ - - private int lineLength = 5; + private int lineLength = 5; public AvatarSMDStartState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -77,13 +79,11 @@ public class AvatarSMDStartState extends AvatarSMDBasicComponent implements Embe myImageIcon = IconManager.imgic222; } - @Override public void internalDrawing(Graphics g) { g.fillOval(x, y, width, height); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -96,28 +96,12 @@ public class AvatarSMDStartState extends AvatarSMDBasicComponent implements Embe return null; } - @Override public int getType() { return TGComponentManager.AVATARSMD_START_STATE; } - @Override public int getDefaultConnector() { - return TGComponentManager.AVATARSMD_CONNECTOR; + return TGComponentManager.AVATARSMD_CONNECTOR; } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#acceptBackward(ui.ICDElementVisitor) - */ - @Override - public void acceptBackward( final ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - - // Needed to escape containing composite state machine - if ( getFather() instanceof AvatarSMDState ) { - getFather().acceptBackward( visitor ); - } - } - } + } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDState.java b/src/main/java/ui/avatarsmd/AvatarSMDState.java index 3f3d3415bd..790ac83d49 100644 --- a/src/main/java/ui/avatarsmd/AvatarSMDState.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDState.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarsmd; import myutil.Conversion; @@ -48,15 +51,11 @@ import ui.util.IconManager; import ui.window.JDialogAvatarState; import javax.swing.*; - -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics; -import java.util.ArrayList; +import java.awt.*; import java.util.LinkedList; -import java.util.List; import java.util.Vector; + /** * Class AvatarSMDState * State. To be used in AVATAR State Machine Diagrams @@ -157,7 +156,7 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements name = tdp.findAvatarSMDStateName("state"); setValue(name); - name = "State"; + name = "State"; oldValue = value; currentFontSize = maxFontSize; @@ -191,7 +190,6 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements mutexStates = null; } - @Override public void internalDrawing(Graphics g) { Font f = g.getFont(); Font fold = f; @@ -237,22 +235,18 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements } + // + Color c = g.getColor(); //g.setColor(ColorManager.AVATAR_STATE); - - // Issue #69 - if ( isEnabled() ) { - Color avat = ColorManager.AVATAR_STATE; - g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); - } - else { - g.setColor( ColorManager.DISABLED_FILLING ); - } - + Color avat = ColorManager.AVATAR_STATE; + g.setColor(new Color(avat.getRed(), avat.getGreen(), Math.min(255, avat.getBlue() + (getMyDepth() * 10)))); g.fillRoundRect(x, y, width, height, 5, 5); g.setColor(c); g.drawRoundRect(x, y, width, height, 5, 5); + + // Strings int w; int h = 0; @@ -312,7 +306,7 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements drawSecurityInformation(g); } - private void drawSecurityInformation(Graphics g) { + public void drawSecurityInformation(Graphics g) { if (securityInformation > 0) { Color c = g.getColor(); @@ -336,9 +330,10 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements g.drawRect(x-12, y, 9, 7); } + } - @Override + public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { @@ -347,12 +342,13 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements return null; } + public String getStateName() { return value; } - @Override public boolean editOndoubleClick(JFrame frame, int _x, int _y) { + oldValue = value; //String text = getName() + ": "; @@ -361,6 +357,7 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements null, getValue());*/ + JDialogAvatarState jdas = new JDialogAvatarState(frame, "Setting state parameters", value, entryCode); // jdas.setSize(600, 550); GraphicLib.centerOnParent(jdas, 600, 550 ); @@ -373,6 +370,7 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements String s = jdas.getStateName(); + if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { //boolean b; if (!TAttribute.isAValidId(s, false, false)) { @@ -409,19 +407,19 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements entryCode = jdas.getEntryCode(); return true; + + } - @Override public void recalculateSize() { width = Math.max(width, value.length()*11); } - @Override + public int getType() { return TGComponentManager.AVATARSMD_STATE; } - @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { if (tgc instanceof AvatarSMDBasicComponent) { return true; @@ -431,7 +429,6 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements } - @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { boolean swallowed = false; @@ -478,7 +475,6 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements return true; } - @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeMyInternalComponent(tgc, false); } @@ -518,7 +514,7 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements return false; } - @Override + public void hasBeenResized() { for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof AvatarSMDBasicComponent) { @@ -535,7 +531,6 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements } - @Override public void resizeWithFather() { if ((father != null) && (father instanceof AvatarSMDState)) { @@ -547,8 +542,8 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements } } - public List<AvatarSMDState> getStateList() { - List<AvatarSMDState> list = new LinkedList<AvatarSMDState>(); + public LinkedList<AvatarSMDState> getStateList() { + LinkedList<AvatarSMDState> list = new LinkedList<AvatarSMDState>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof AvatarSMDState) { list.add((AvatarSMDState)(tgcomponent[i])); @@ -557,8 +552,8 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements return list; } - public List<AvatarSMDState> getFullStateList() { - List<AvatarSMDState> list = new LinkedList<AvatarSMDState>(); + public LinkedList<AvatarSMDState> getFullStateList() { + LinkedList<AvatarSMDState> list = new LinkedList<AvatarSMDState>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof AvatarSMDState) { list.add((AvatarSMDState)(tgcomponent[i])); @@ -569,7 +564,7 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements } public boolean hasInternalStateWithName(String name) { - List<AvatarSMDState> list = getFullStateList(); + LinkedList<AvatarSMDState> list = getFullStateList(); for(AvatarSMDState s: list) { if (s.getValue().compareTo(name) ==0) { return true; @@ -578,14 +573,13 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements return false; } - @Override public int getDefaultConnector() { return TGComponentManager.AVATARSMD_CONNECTOR; } public AvatarSMDState checkForStartStateOfCompositeStates() { AvatarSMDState tgc; - List<AvatarSMDState> list = getFullStateList(); + LinkedList<AvatarSMDState> list = getFullStateList(); for(AvatarSMDState s: list) { tgc = s.checkForStartStateOfCompositeStates(); if (tgc != null) { @@ -603,7 +597,6 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements if (cpt > 1) { return this; } - return null; } @@ -624,7 +617,6 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements return s; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); @@ -697,9 +689,10 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } + /*if (tmpGlobalCode.trim().length() == 0) { globalCode = null; } else { @@ -711,6 +704,8 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements entryCode = Conversion.wrapText(tmpEntryCode); //TraceManager.addDev("Entry code = " + entryCode); } + + } /*public boolean hasGlobalCode() { @@ -779,6 +774,7 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements return ret; } + public void resetSecurityInfo() { securityInformation = NOT_VERIFIED; for(int i=0; i<nbInternalTGComponent; i++) { @@ -801,146 +797,8 @@ public class AvatarSMDState extends TGCScalableWithInternalComponent implements ((AvatarSMDState)tgcomponent[i]).setSecurityInfo(_info, _name); } } - } - /* Issue #69 - * (non-Javadoc) - * @see ui.AbstractCDElement#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - if ( getFather() instanceof AvatarSMDState ) { - return getFather().isEnabled(); - } - - return true; - } - - private List<AvatarSMDConnector> getContainedConnectors() { - final List<AvatarSMDConnector> connectors = new ArrayList<AvatarSMDConnector>(); - - for ( final TGComponent component : tdp.getComponentList() ) { - if ( component instanceof AvatarSMDConnector ) { - final AvatarSMDConnector smdCon = (AvatarSMDConnector) component; - - if ( smdCon.isContainedBy( this ) ) { - connectors.add( smdCon ); - } - } - } - - return connectors; - } - - /** - * Issue #69 - * @param _enabled - */ - @Override - public void setEnabled( final boolean _enabled ) { - if ( _enabled ) { - super.setEnabled( _enabled ); - } - - // Enabling for composite states - for ( final TGComponent component : tgcomponent ) { - if ( component.canBeDisabled() ) { - component.setEnabled( _enabled ); - } - } - - for ( final AvatarSMDConnector containedConnector : getContainedConnectors() ) { - containedConnector.getAvatarSMDTransitionInfo().setEnabled( _enabled ); - } - - if ( !_enabled ) { - super.setEnabled( _enabled ); - } - - // Enabling of states with the same name - for ( final AvatarSMDState sameState : getSameStates() ) { - sameState.doSetEnabled( _enabled ); - } - } - - public List<AvatarSMDState> getSameStates() { - final List<AvatarSMDState> states = new ArrayList<AvatarSMDState>(); - - for ( final TGComponent component : tdp.getComponentList() ) { - if ( component != this && getValue() != null && component instanceof AvatarSMDState && - getFather() == component.getFather() && getValue().equals( component.getValue() ) ) { - states.add( (AvatarSMDState) component ); - } - } - - return states; } - - public AvatarSMDStartState getCompositeStartState() { - if ( tgcomponent == null ) { - return null; - } - - for ( final TGComponent subCompo : tgcomponent ) { - if ( subCompo instanceof AvatarSMDStartState ) { - return (AvatarSMDStartState) subCompo; - } - } - - return null; - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#acceptForward(ui.ICDElementVisitor) - */ - @Override - public void acceptForward( final ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - final AvatarSMDStartState subStartElement = getCompositeStartState(); - - if ( subStartElement != null ) { - subStartElement.acceptForward( visitor ); - } - - if ( connectingPoint != null ) { - for ( final TGConnectingPoint point : connectingPoint ) { - final TGConnector connector = getConnectorConnectedTo( point ); - - if ( connector != null && point == connector.getTGConnectingPointP1() ) { - point.acceptForward( visitor ); - } - } - } - - // Also visit the states with the same name - for ( final AvatarSMDState state : getSameStates() ) { - state.acceptForward( visitor ); - } - } - } - - /* Issue #69 - * (non-Javadoc) - * @see ui.CDElement#acceptBackward(ui.ICDElementVisitor) - */ - @Override - public void acceptBackward( final ICDElementVisitor visitor ) { - if ( visitor.visit( this ) ) { - if ( connectingPoint != null ) { - for ( final TGConnectingPoint point : connectingPoint ) { - final TGConnector connector = getConnectorConnectedTo( point ); - - if ( connector != null && point == connector.getTGConnectingPointP2() ) { - point.acceptBackward( visitor ); - } - } - } - } - - // Also visit the states with the same name - for ( final AvatarSMDState state : getSameStates() ) { - state.acceptBackward( visitor ); - } - } + + } diff --git a/src/main/java/ui/avatarsmd/AvatarSMDToolBar.java b/src/main/java/ui/avatarsmd/AvatarSMDToolBar.java index e774c907fe..356cdb74c8 100755 --- a/src/main/java/ui/avatarsmd/AvatarSMDToolBar.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDToolBar.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.avatarsmd; import ui.MainGUI; @@ -44,6 +47,9 @@ import ui.TToolBar; import javax.swing.*; +//import java.awt.*; +//import java.awt.event.*; + /** * Class AvatarSMDToolBar * Toolbar associated with AVATAR state Machines @@ -53,11 +59,11 @@ import javax.swing.*; */ public class AvatarSMDToolBar extends TToolBar { + public AvatarSMDToolBar(MainGUI _mgui) { super(_mgui); } - @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.ASMD_EDIT].setEnabled(b); mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); @@ -69,7 +75,7 @@ public class AvatarSMDToolBar extends TToolBar { mgui.actions[TGUIAction.ASMD_SEND_SIGNAL].setEnabled(b); mgui.actions[TGUIAction.ASMD_RECEIVE_SIGNAL].setEnabled(b); mgui.actions[TGUIAction.ASMD_LIBRARY_FUNCTION_CALL].setEnabled(b); - //mgui.actions[TGUIAction.ASMD_PARALLEL].setEnabled(b); + mgui.actions[TGUIAction.ASMD_PARALLEL].setEnabled(b); mgui.actions[TGUIAction.ASMD_STATE].setEnabled(b); mgui.actions[TGUIAction.ASMD_CHOICE].setEnabled(b); mgui.actions[TGUIAction.ASMD_RANDOM].setEnabled(b); @@ -91,7 +97,6 @@ public class AvatarSMDToolBar extends TToolBar { mgui.updateZoomInfo(); } - @Override protected void setButtons() { JButton button; @@ -106,10 +111,12 @@ public class AvatarSMDToolBar extends TToolBar { button = this.add(mgui.actions[TGUIAction.CONNECTOR_COMMENT]); button.addMouseListener(mgui.mouseHandler); + this.addSeparator(); button = this.add(mgui.actions[TGUIAction.ASMD_CONNECTOR]); button.addMouseListener(mgui.mouseHandler); + this.addSeparator(); @@ -178,6 +185,7 @@ public class AvatarSMDToolBar extends TToolBar { button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_AVATAR_ID]); button.addMouseListener(mgui.mouseHandler); + } } // Class diff --git a/src/main/java/ui/avatarsmd/AvatarSMDTransitionInfo.java b/src/main/java/ui/avatarsmd/AvatarSMDTransitionInfo.java index bf7ff92a96..2b06c17854 100755 --- a/src/main/java/ui/avatarsmd/AvatarSMDTransitionInfo.java +++ b/src/main/java/ui/avatarsmd/AvatarSMDTransitionInfo.java @@ -36,38 +36,24 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.avatarsmd; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; - -import javax.swing.JFrame; +package ui.avatarsmd; +import myutil.Conversion; +import myutil.GraphicLib; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - -import myutil.GraphicLib; -import ui.AvatarMethod; -import ui.ColorManager; -import ui.Expression; -import ui.GTURTLEModeling; -import ui.MalformedModelingException; -import ui.RangeExpression; -import ui.TAttribute; -import ui.TDiagramPanel; -import ui.TGCWithoutInternalComponent; -import ui.TGComponent; -import ui.TGConnectingPoint; -import ui.TGConnectingPointComment; -import ui.TGState; -import ui.WithAttributes; +import ui.*; import ui.util.IconManager; import ui.window.JDialogAvatarTransition; +import javax.swing.*; + +import java.awt.Graphics; +import java.util.List; +import java.util.Vector; + /** * Class AvatarSMDTransitionInfo * Internal component that represents a set of parameter for a transition @@ -79,37 +65,19 @@ import ui.window.JDialogAvatarTransition; */ public class AvatarSMDTransitionInfo extends TGCWithoutInternalComponent implements WithAttributes { - private static final String NULL_EXPR = ""; - - private static final String NULL_GUARD_EXPR = "[ ]"; - - static final String DISABLED_GUARD_EXPR = NULL_GUARD_EXPR; - - static final String DISABLED_DELAY_EXPR = NULL_EXPR; - - static final String DISABLED_PROBABILITY_EXPR = NULL_EXPR; - - static final String DISABLED_ACTION_EXPR = NULL_EXPR; // private static String FILE_INFO = "(user files specified)"; // private static String CODE_INFO = "(user code specified)"; - private final Expression guard; - - private final RangeExpression afterDelay; - - private final RangeExpression computeDelay; -// protected String guard; -// protected String afterMin; -// protected String afterMax; -// protected String computeMin; -// protected String computeMax; - private final Expression probability; - - private Vector<Expression> listOfActions; - // protected Vector<String> listOfActions; + protected String guard; + protected String afterMin; + protected String afterMax; + protected String computeMin; + protected String computeMax; + protected String probability = ""; + protected Vector<String> listOfActions; -// protected String[] filesToInclude; -// protected String[] codeToInclude; + protected String[] filesToInclude; + protected String[] codeToInclude; protected int minWidth = 10; protected int minHeight = 15; @@ -124,18 +92,13 @@ public class AvatarSMDTransitionInfo extends TGCWithoutInternalComponent impleme editable = true; removable = false; - guard = new Expression( NULL_GUARD_EXPR, NULL_GUARD_EXPR, null ); - afterDelay = new RangeExpression( NULL_EXPR, NULL_EXPR, NULL_EXPR, "after (%s, %s)", null ); - computeDelay = new RangeExpression( NULL_EXPR, NULL_EXPR, NULL_EXPR, "computeFor (%s, %s)", null ); - probability = new Expression( NULL_EXPR, NULL_EXPR, "weight=%s" ); - -// guard = "[ ]"; -// afterMin = ""; -// afterMax = ""; -// computeMin = ""; -// computeMax = ""; -// filesToInclude = null; -// codeToInclude = null; + guard = "[ ]"; + afterMin = ""; + afterMax = ""; + computeMin = ""; + computeMax = ""; + filesToInclude = null; + codeToInclude = null; nbConnectingPoint = 4; @@ -145,205 +108,129 @@ public class AvatarSMDTransitionInfo extends TGCWithoutInternalComponent impleme connectingPoint[2] = new TGConnectingPointComment(this, 0, 0, true, true, 1.0, 0.5); connectingPoint[3] = new TGConnectingPointComment(this, 0, 0, true, true, 0.0, 0.5); - listOfActions = new Vector<Expression>(); - //listOfActions = new Vector<String>(); + listOfActions = new Vector<String>(); myImageIcon = IconManager.imgic302; } public Vector<String> getListOfActions() { - final Vector<String> actions = new Vector<String>( listOfActions.size() ); - - for ( final Expression action : listOfActions ) { - actions.add( action.getText() ); - } - - return actions; -// return listOfActions; + return listOfActions; } - - public void setGuard(String s){ - guard.setText( s ); + + public void setGuard(String s) { + guard = s; } public void setProbability(String s) { - probability.setText( s ); + probability = s; } - - public void addAction(String s){ - listOfActions.add( new Expression( s ) ); -// listOfActions.add(s); + + public void addAction(String s) { + listOfActions.add(s); } - @Override public void internalDrawing(Graphics g) { int step = 0; - // String s; + String s; h = g.getFontMetrics().getHeight(); for (int j = 0; j < nbConnectingPoint; j++) { connectingPoint[j].setCdY(-h + 1); } -// ColorManager.setColor(g, getState(), 0); - // Issue #69 - final int inc = getExpressionTextHight(); -// int inc = h; - + ColorManager.setColor(g, getState(), 0); + int inc = h; boolean atLeastOneThing = false; - if ( !guard.isNull() ) { - atLeastOneThing = true; + g.setColor(ColorManager.AVATAR_GUARD); - final String formattedExpr = guard.toString(); - final int textWidth = g.getFontMetrics().stringWidth( formattedExpr ); - - if (tdp.isDrawingMain()) { - width = Math.max( textWidth, width ); - width = Math.max(minWidth, width); - } - - // Issue #69 - if ( !guard.isEnabled() && getFather().isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillRoundRect( x, y + step - inc + 2, textWidth + 2, inc + 2, 5, 5 ); - } - - g.setColor( guard.isEnabled() ? ColorManager.AVATAR_GUARD : ColorManager.DISABLED ); - g.drawString( formattedExpr, x, y + step) ; - - step += inc; + if (tdp.isDrawingMain()) { + width = minWidth; } - if ( !afterDelay.isNull() ) { - atLeastOneThing = true; - - final String formattedExpr = afterDelay.toString(); - final int textWidth = g.getFontMetrics().stringWidth( formattedExpr ); - - if (tdp.isDrawingMain()) { - width = Math.max( textWidth, width ); - width = Math.max(minWidth, width); - } - - // Issue #69 - if ( !afterDelay.isEnabled() && getFather().isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillRoundRect( x, y + step - inc + 2, textWidth + 2, inc + 2, 5, 5 ); + if (guard.length() > 0) { + if (guard.replaceAll("\\s+", "").compareTo("[]") != 0) { + g.drawString(guard, x, y + step); + atLeastOneThing = true; + if (tdp.isDrawingMain()) { + width = Math.max(g.getFontMetrics().stringWidth(guard), width); + width = Math.max(minWidth, width); + } + step += inc; } - - g.setColor( afterDelay.isEnabled() ? ColorManager.AVATAR_TIME : ColorManager.DISABLED ); - g.drawString( formattedExpr, x, y + step ); - - step += inc; -// } -// else { -// final String s = "after (" + afterMinDelayExp + ")"; -// -// g.drawString(s, x, y + step); -// -// atLeastOneThing = true; -// -// if (tdp.isDrawingMain()) { -// width = Math.max(g.getFontMetrics().stringWidth(s), width); -// width = Math.max(minWidth, width); -// } -// -// step += inc; -// } } - if ( !computeDelay.isNull() ) { - atLeastOneThing = true; - - final String formattedExpr = computeDelay.toString(); - final int textWidth = g.getFontMetrics().stringWidth( formattedExpr ); + g.setColor(ColorManager.AVATAR_TIME); - if (tdp.isDrawingMain()) { - width = Math.max( textWidth, width ); - width = Math.max(minWidth, width); + if (afterMin.length() > 0) { + if (afterMax.length() > 0) { + s = "after (" + afterMin + "," + afterMax + ")"; + g.drawString(s, x, y + step); + atLeastOneThing = true; + if (tdp.isDrawingMain()) { + width = Math.max(g.getFontMetrics().stringWidth(s), width); + width = Math.max(minWidth, width); + } + step += inc; + } else { + s = "after (" + afterMin + ")"; + g.drawString(s, x, y + step); + atLeastOneThing = true; + if (tdp.isDrawingMain()) { + width = Math.max(g.getFontMetrics().stringWidth(s), width); + width = Math.max(minWidth, width); + } + step += inc; } + } - // Issue #69 - if ( !computeDelay.isEnabled() && getFather().isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillRoundRect( x, y + step - inc + 2, textWidth + 2, inc + 2, 5, 5 ); + if (computeMin.length() > 0) { + if (computeMax.length() > 0) { + s = "computeFor (" + computeMin + "," + computeMax + ")"; + g.drawString(s, x, y + step); + atLeastOneThing = true; + if (tdp.isDrawingMain()) { + width = Math.max(g.getFontMetrics().stringWidth(s), width); + width = Math.max(minWidth, width); + } + step += inc; + } else { + s = "computeFor (" + computeMin + ")"; + g.drawString(s, x, y + step); + atLeastOneThing = true; + if (tdp.isDrawingMain()) { + width = Math.max(g.getFontMetrics().stringWidth(s), width); + width = Math.max(minWidth, width); + } + step += inc; } - - g.setColor( computeDelay.isEnabled() ? ColorManager.AVATAR_TIME : ColorManager.DISABLED ); - g.drawString( formattedExpr, x, y + step ); - - step += inc; } - if ( !probability.isNull() ) { - atLeastOneThing = true; - final String formattedExpr = probability.toString(); - final int textWidth = g.getFontMetrics().stringWidth( formattedExpr ); - + if ((probability != null) && (probability.length() > 0)) { + s = "weight=" + probability; + g.drawString(s, x, y + step); + atLeastOneThing = true; if (tdp.isDrawingMain()) { - width = Math.max( textWidth, width ); + width = Math.max(g.getFontMetrics().stringWidth(s), width); width = Math.max(minWidth, width); } - - // Issue #69 - if ( !probability.isEnabled() && getFather().isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillRoundRect( x, y + step - inc + 2, textWidth + 2, inc + 2, 5, 5 ); - } - - g.setColor( probability.isEnabled() ? ColorManager.AVATAR_GUARD : ColorManager.DISABLED ); - g.drawString( formattedExpr, x, y + step) ; - - step += inc; -// s = "weight=" + probability; -// g.drawString(s, x, y + step); -// atLeastOneThing = true; -// if (tdp.isDrawingMain()) { -// width = Math.max(g.getFontMetrics().stringWidth(s), width); -// width = Math.max(minWidth, width); -// } -// step += inc; + step += inc; } - // g.setColor(ColorManager.AVATAR_ACTION); - - for( final Expression action : listOfActions ) { - if ( !action.isNull() ) { - atLeastOneThing = true; - - final String formattedExpr = action.toString(); - final int textWidth = g.getFontMetrics().stringWidth( formattedExpr ); - - if (tdp.isDrawingMain()) { - width = Math.max( textWidth, width ); - width = Math.max( minWidth, width); - } - - // Issue #69 - if ( !action.isEnabled() && getFather().isContainedInEnabledState() ) { - g.setColor( ColorManager.DISABLED_FILLING ); - g.fillRoundRect( x, y + step - inc + 2, textWidth + 2, inc + 2, 5, 5 ); - } - - g.setColor( action.isEnabled() ? ColorManager.AVATAR_ACTION : ColorManager.DISABLED ); - g.drawString( formattedExpr, x, y + step ); - - step += inc; + g.setColor(ColorManager.AVATAR_ACTION); + + for (int i = 0; i < listOfActions.size(); i++) { + s = listOfActions.get(i); + if (s.length() > 0) { + g.drawString(s, x, y + step); + atLeastOneThing = true; + if (tdp.isDrawingMain()) { + width = Math.max(g.getFontMetrics().stringWidth(s), width); + width = Math.max(minWidth, width); + } + step += inc; } } -// for (int i = 0; i < listOfActions.size(); i++) { -// s = listOfActions.get(i); -// if (s.length() > 0) { -// g.drawString(s, x, y + step); -// atLeastOneThing = true; -// if (tdp.isDrawingMain()) { -// width = Math.max(g.getFontMetrics().stringWidth(s), width); -// width = Math.max(minWidth, width); -// } -// step += inc; -// } -// } /*g.setColor(ColorManager.AVATAR_CODE); @@ -376,51 +263,13 @@ public class AvatarSMDTransitionInfo extends TGCWithoutInternalComponent impleme width = minWidth; } - //ColorManager.setColor(g, state, 0); + ColorManager.setColor(g, state, 0); if ((getState() == TGState.POINTER_ON_ME) || (getState() == TGState.POINTED) || (getState() == TGState.MOVING)) { - ColorManager.setColor( g, state, 0, isEnabled() ); - - final Rectangle rectangle = new Rectangle( x - 1, y - h + 2, width + 2, height + 2 ); - - if ( inc != 0 && isOnMe( tdp.currentX, tdp.currentY ) == this ) { - - // Issue #69: Draw rectangle only around the pointed line - final Expression selExpr = getSelectedExpression(); - final int exprWidth; - - if ( selExpr == null ) { - exprWidth = width; - } - else { - exprWidth = g.getFontMetrics().stringWidth( selExpr.toString() ); - ColorManager.setColor( g, state, 0, selExpr.isEnabled() ); - } - - final int pointedExpOrder = getPointedExpressionOrder() - 1; - - rectangle.y = y + pointedExpOrder * inc + 2; - rectangle.width = exprWidth + 2; - rectangle.height = inc + 2; - } - - g.drawRoundRect( rectangle.x, rectangle.y, rectangle.width, rectangle.height, 5, 5 ); - // g.drawRoundRect(x - 1, y - h + 2, width + 2, height + 2, 5, 5); + g.drawRoundRect(x - 1, y - h + 2, width + 2, height + 2, 5, 5); } } - private int getExpressionTextHight() { - return h; - } - - private Integer getPointedExpressionOrder() { - if ( getExpressionTextHight() != 0 ) { - return ( tdp.currentY + 10 - y ) / getExpressionTextHight(); - } - - return null; - } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y - h + 2, width, height)) { return this; @@ -437,18 +286,7 @@ public class AvatarSMDTransitionInfo extends TGCWithoutInternalComponent impleme public boolean editOndoubleClick(JFrame frame) { List<TAttribute> attributes = tdp.getMGUI().getAllAttributes(); List<AvatarMethod> methods = tdp.getMGUI().getAllMethods(); - JDialogAvatarTransition jdat = new JDialogAvatarTransition( frame, - "Setting transition parameters", - getGuard(), - getAfterMinDelay(), - getAfterMaxDelay(), -// getComputeMinDelay(), -// getComputeMaxDelay(), - listOfActions, - attributes, - methods, - getProbability() ); - //JDialogAvatarTransition jdat = new JDialogAvatarTransition(frame, "Setting transition parameters", guard, afterMin, afterMax, computeMin, computeMax, listOfActions, attributes, methods, filesToInclude, codeToInclude, probability); + JDialogAvatarTransition jdat = new JDialogAvatarTransition(frame, "Setting transition parameters", guard, afterMin, afterMax, computeMin, computeMax, listOfActions, attributes, methods, filesToInclude, codeToInclude, probability); // jdat.setSize(600, 550); GraphicLib.centerOnParent(jdat, 600, 550); jdat.setVisible(true); // blocked until dialog has been closed @@ -458,115 +296,84 @@ public class AvatarSMDTransitionInfo extends TGCWithoutInternalComponent impleme return false; } - guard.setText( jdat.getGuard().trim() ); + guard = jdat.getGuard().trim(); - int index = getGuard().indexOf('['); + int index = guard.indexOf('['); if (index == -1) { - guard.setText( "[ " + guard + " ]" ); + guard = "[ " + guard + " ]"; } - afterDelay.getMinExpression().setText( jdat.getAfterMin().trim() ); - afterDelay.getMaxExpression().setText( jdat.getAfterMax().trim() ); -// computeDelay.getMinExpression().setText( jdat.getComputeMin().trim() ); -// computeDelay.getMaxExpression().setText( jdat.getComputeMax().trim() ); - listOfActions.clear(); - listOfActions.addAll( jdat.getActions() ); -// guard = jdat.getGuard().trim(); -// -// int index = guard.indexOf('['); -// if (index == -1) { -// guard = "[ " + guard + " ]"; -// } -// -// afterMin = jdat.getAfterMin().trim(); -// afterMax = jdat.getAfterMax().trim(); -// computeMin = jdat.getComputeMin().trim(); -// computeMax = jdat.getComputeMax().trim(); -// filesToInclude = jdat.getFilesToInclude(); -// codeToInclude = jdat.getCodeToInclude(); - probability.setText( jdat.getProbability().trim() ); - + afterMin = jdat.getAfterMin().trim(); + afterMax = jdat.getAfterMax().trim(); + computeMin = jdat.getComputeMin().trim(); + computeMax = jdat.getComputeMax().trim(); + filesToInclude = jdat.getFilesToInclude(); + codeToInclude = jdat.getCodeToInclude(); + probability = jdat.getProbability(); return true; } - - private String toXML( final String tag, - final Expression expression ) { - return "<" + tag + " value=\"" + GTURTLEModeling.transformString( expression.getText() ) + "\" enabled=\"" + expression.isEnabled() + "\"/>" + System.lineSeparator(); - } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); - sb.append( toXML( "guard", guard ) ); - sb.append( toXML( "afterMin", afterDelay.getMinExpression() ) ); - sb.append( toXML( "afterMax", afterDelay.getMaxExpression() ) ); - sb.append( toXML( "computeMin", computeDelay.getMinExpression() ) ); - sb.append( toXML( "computeMax", computeDelay.getMaxExpression() ) ); - sb.append( toXML( "probability", probability ) ); -// sb.append("<guard value=\""); -// sb.append(GTURTLEModeling.transformString(guard)); -// sb.append("\" />\n"); -// -// sb.append("<afterMin value=\""); -// sb.append(GTURTLEModeling.transformString(afterMin)); -// sb.append("\" />\n"); -// -// sb.append("<afterMax value=\""); -// sb.append(GTURTLEModeling.transformString(afterMax)); -// sb.append("\" />\n"); -// -// sb.append("<computeMin value=\""); -// sb.append(GTURTLEModeling.transformString(computeMin)); -// sb.append("\" />\n"); -// -// sb.append("<computeMax value=\""); -// sb.append(GTURTLEModeling.transformString(computeMax)); -// sb.append("\" />\n"); - -// sb.append("<probability value=\""); -// sb.append(GTURTLEModeling.transformString(probability)); -// sb.append("\" />\n"); - - for( final Expression action : listOfActions ) { - sb.append( toXML( "actions", action ) ); + sb.append("<guard value=\""); + sb.append(GTURTLEModeling.transformString(guard)); + sb.append("\" />\n"); + + sb.append("<afterMin value=\""); + sb.append(GTURTLEModeling.transformString(afterMin)); + sb.append("\" />\n"); + + sb.append("<afterMax value=\""); + sb.append(GTURTLEModeling.transformString(afterMax)); + sb.append("\" />\n"); + + sb.append("<computeMin value=\""); + sb.append(GTURTLEModeling.transformString(computeMin)); + sb.append("\" />\n"); + + sb.append("<computeMax value=\""); + sb.append(GTURTLEModeling.transformString(computeMax)); + sb.append("\" />\n"); + + sb.append("<probability value=\""); + sb.append(GTURTLEModeling.transformString(probability)); + sb.append("\" />\n"); + + for (int i = 0; i < listOfActions.size(); i++) { + sb.append("<actions value=\""); + sb.append(GTURTLEModeling.transformString(listOfActions.get(i))); + sb.append("\" />\n"); + } + + if (filesToInclude != null) { + for (int i = 0; i < filesToInclude.length; i++) { + sb.append("<filesToIncludeLine value=\""); + sb.append(GTURTLEModeling.transformString(filesToInclude[i])); + sb.append("\" />\n"); + } + } + + if (codeToInclude != null) { + for (int i = 0; i < codeToInclude.length; i++) { + sb.append("<codeToIncludeLine value=\""); + sb.append(GTURTLEModeling.transformString(codeToInclude[i])); + sb.append("\" />\n"); + } } -// -// for (int i = 0; i < listOfActions.size(); i++) { -// sb.append("<actions value=\""); -// sb.append(GTURTLEModeling.transformString(listOfActions.get(i))); -// sb.append("\" />\n"); -// } -// -// if (filesToInclude != null) { -// for (int i = 0; i < filesToInclude.length; i++) { -// sb.append("<filesToIncludeLine value=\""); -// sb.append(GTURTLEModeling.transformString(filesToInclude[i])); -// sb.append("\" />\n"); -// } -// } -// -// if (codeToInclude != null) { -// for (int i = 0; i < codeToInclude.length; i++) { -// sb.append("<codeToIncludeLine value=\""); -// sb.append(GTURTLEModeling.transformString(codeToInclude[i])); -// sb.append("\" />\n"); -// } -// } sb.append("</extraparam>\n"); - return new String(sb); } @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { // -// String tmpFilesToInclude = ""; -// String tmpCodeToInclude = ""; + String tmpFilesToInclude = ""; + String tmpCodeToInclude = ""; try { - listOfActions = new Vector<Expression>(); -// listOfActions = new Vector<String>(); + listOfActions = new Vector<String>(); + NodeList nli; Node n1, n2; Element elt; @@ -586,100 +393,43 @@ public class AvatarSMDTransitionInfo extends TGCWithoutInternalComponent impleme if (elt.getTagName().equals("guard")) { s = elt.getAttribute("value"); if (s != null) { - guard.setText( s ); - - // Issue #69 loading enabling parameters - s = elt.getAttribute("enabled"); - - if ( s != null && !s.isEmpty() ) { - guard.setEnabled( Boolean.parseBoolean( s ) ); - } -// guard = s; + guard = s; } } if (elt.getTagName().equals("afterMin")) { s = elt.getAttribute("value"); if (s != null) { - afterDelay.getMinExpression().setText( s ); - - // Issue #69 loading enabling parameters - s = elt.getAttribute( "enabled" ); - - if ( s != null && !s.isEmpty() ) { - afterDelay.getMinExpression().setEnabled( Boolean.parseBoolean( s ) ); - } -// afterMin = s; + afterMin = s; } } if (elt.getTagName().equals("afterMax")) { s = elt.getAttribute("value"); if (s != null) { - afterDelay.getMaxExpression().setText( s ); - - // Issue #69 loading enabling parameters - s = elt.getAttribute("enabled"); - - if ( s != null && !s.isEmpty() ) { - afterDelay.getMaxExpression().setEnabled( Boolean.parseBoolean( s ) ); - } -// afterMax = s; + afterMax = s; } } if (elt.getTagName().equals("computeMin")) { s = elt.getAttribute("value"); if (s != null) { - computeDelay.getMinExpression().setText( s ); - - // Issue #69 loading enabling parameters - s = elt.getAttribute("enabled"); - - if ( s != null && !s.isEmpty() ) { - computeDelay.getMinExpression().setEnabled( Boolean.parseBoolean( s ) ); - } - //computeMin = s; + computeMin = s; } } if (elt.getTagName().equals("computeMax")) { s = elt.getAttribute("value"); if (s != null) { - computeDelay.getMaxExpression().setText( s ); - - // Issue #69 loading enabling parameters - s = elt.getAttribute("enabled"); - - if ( s != null && !s.isEmpty() ) { - computeDelay.getMaxExpression().setEnabled( Boolean.parseBoolean( s ) ); - } - //computeMax = s; + computeMax = s; } } if (elt.getTagName().equals("probability")) { s = elt.getAttribute("value"); if (s != null) { - probability.setText( s ); - - // Issue #69 loading enabling parameters - s = elt.getAttribute("enabled"); - - if ( s != null && !s.isEmpty() ) { - probability.setEnabled( Boolean.parseBoolean( s ) ); - } -// probability = s; + probability = s; } } if (elt.getTagName().equals("actions")) { s = elt.getAttribute("value"); if (s != null) { - final Expression action = new Expression( s ); - listOfActions.add( action ); - - // Issue #69 loading enabling parameters - s = elt.getAttribute("enabled"); - - if ( s != null && !s.isEmpty() ) { - action.setEnabled( Boolean.parseBoolean( s ) ); - } - //listOfActions.add(s); + listOfActions.add(s); } } @@ -706,306 +456,100 @@ public class AvatarSMDTransitionInfo extends TGCWithoutInternalComponent impleme } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); + } + + + if (tmpFilesToInclude.trim().length() == 0) { + filesToInclude = null; + } else { + filesToInclude = Conversion.wrapText(tmpFilesToInclude); + } + if (tmpCodeToInclude.trim().length() == 0) { + codeToInclude = null; + } else { + codeToInclude = Conversion.wrapText(tmpCodeToInclude); } -// -// -// if (tmpFilesToInclude.trim().length() == 0) { -// filesToInclude = null; -// } else { -// filesToInclude = Conversion.wrapText(tmpFilesToInclude); -// } -// if (tmpCodeToInclude.trim().length() == 0) { -// codeToInclude = null; -// } else { -// codeToInclude = Conversion.wrapText(tmpCodeToInclude); -// } } public String getGuard() { - return guard.getText(); -// return guard; - } - - /** - * Issue #69 - * @return - */ - public String getEffectiveGuard() { - return guard.getEffectiveExpression( DISABLED_GUARD_EXPR ); + return guard; } public String getAfterMinDelay() { - return afterDelay.getMinExpression().getText(); -// return afterMin; - } - - /** - * Issue #69 - * @return - */ - public String getEffectiveAfterMinDelay() { - return afterDelay.getMinExpression().getEffectiveExpression( DISABLED_DELAY_EXPR ); + return afterMin; } public String getAfterMaxDelay() { - return afterDelay.getMaxExpression().getText(); - //return afterMax; - } - - /** - * Issue #69 - * @return - */ - public String getEffectiveAfterMaxDelay() { - return afterDelay.getMaxExpression().getEffectiveExpression( DISABLED_DELAY_EXPR ); + return afterMax; } public String getComputeMinDelay() { - return computeDelay.getMinExpression().getText(); - //return computeMin; + return computeMin; } - /** - * Issue #69 - * @return - */ - public String getEffectiveComputeMinDelay() { - return computeDelay.getMinExpression().getEffectiveExpression( DISABLED_DELAY_EXPR ); + public String getComputeMaxDelay() { + return computeMax; } - public String getComputeMaxDelay() { - return computeDelay.getMaxExpression().getText(); - //return computeMax; + public String getProbability() { + return probability; } - /** - * Issue #69 - * @return - */ - public String getEffectiveComputeMaxDelay() { - return computeDelay.getMaxExpression().getEffectiveExpression( DISABLED_DELAY_EXPR ); + public void setTimes(String minDelay, String maxDelay, String minCompute, String maxCompute) { + computeMin = minCompute; + computeMax = maxCompute; + afterMin = minDelay; + afterMax = maxDelay; } - public String getProbability() { - return probability.getText(); + public Vector<String> getActions() { + return listOfActions; } - public String getEffectiveProbability() { - return probability.getEffectiveExpression( DISABLED_PROBABILITY_EXPR ); + public boolean hasFilesToInclude() { + return ((filesToInclude != null) && (filesToInclude.length > 0)); } - public void setTimes(String minDelay, String maxDelay, String minCompute, String maxCompute) { - computeDelay.getMinExpression().setText( minCompute ); - computeDelay.getMaxExpression().setText( maxCompute ); - afterDelay.getMinExpression().setText( minDelay ); - afterDelay.getMaxExpression().setText(maxDelay ); -// computeMin = minCompute; -// computeMax = maxCompute; -// afterMin = minDelay; -// afterMax = maxDelay; + public boolean hasCodeToInclude() { + return ((codeToInclude != null) && (codeToInclude.length > 0)); } - public Vector<String> getActions() { - final Vector<String> actionExpressions = new Vector<String>( listOfActions.size() ); - - for ( final Expression action : listOfActions ) { - actionExpressions.add( action.getText() ); - } - - return actionExpressions; -// return listOfActions; + public String getFilesToInclude() { + if (filesToInclude == null) { + return null; + } + String ret = ""; + for (int i = 0; i < filesToInclude.length; i++) { + ret += filesToInclude[i] + "\n"; + } + return ret; } - /** - * Issue #69 - * @return - */ - public Vector<String> getEffectiveActions() { - final Vector<String> actionExpressions = new Vector<String>( listOfActions.size() ); - - for ( final Expression action : listOfActions ) { - actionExpressions.add( action.getEffectiveExpression( DISABLED_ACTION_EXPR ) ); - } - - return actionExpressions; + public String getCodeToInclude() { + if (codeToInclude == null) { + return null; + } + String ret = ""; + for (int i = 0; i < codeToInclude.length; i++) { + ret += codeToInclude[i] + "\n"; + } + return ret; } -// -// public boolean hasFilesToInclude() { -// return ((filesToInclude != null) && (filesToInclude.length > 0)); -// } -// -// public boolean hasCodeToInclude() { -// return ((codeToInclude != null) && (codeToInclude.length > 0)); -// } -// -// public String getFilesToInclude() { -// if (filesToInclude == null) { -// return null; -// } -// String ret = ""; -// for (int i = 0; i < filesToInclude.length; i++) { -// ret += filesToInclude[i] + "\n"; -// } -// return ret; -// } -// -// public String getCodeToInclude() { -// if (codeToInclude == null) { -// return null; -// } -// String ret = ""; -// for (int i = 0; i < codeToInclude.length; i++) { -// ret += codeToInclude[i] + "\n"; -// } -// return ret; -// } public String getAttributes() { String attr = ""; - if ( !guard.isNull()) + if (guard.length() > 0) attr += " guard: " + getGuard(); - if (!afterDelay.isNull() ) - attr += " delay: [" + afterDelay.getMinExpression().getText() + "," + afterDelay.getMaxExpression().getText() + "] "; - if ( !probability.isNull() ) - attr += " weight:" + getProbability(); + if (afterMin.length() > 0 || afterMax.length()>0) + attr += " delay: [" + afterMin + "," + afterMax + "] "; + if (probability.length() > 0) + attr += " weight:" + probability; - for(final Expression action : listOfActions) { - attr += " / " + action.getText(); - } + for(String s: listOfActions) + attr += " / " + s; return attr; - } - - @Override - public AvatarSMDConnector getFather() { - return (AvatarSMDConnector) super.getFather(); - } - - @Override - public void setFather( final TGComponent _father ) { - if ( _father != null && !( _father instanceof AvatarSMDConnector ) ) { - throw new IllegalArgumentException( "Father should be an instance of '" + AvatarSMDConnector.class.getName() + "'." ); - } - - super.setFather( _father ); - } - /* Issue #69 - * (non-Javadoc) - * @see ui.AbstractCDElement#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - final AvatarSMDConnector transitionCon = getFather(); - - if ( transitionCon == null ) { - return false; - } - - return transitionCon.canBeDisabledContainer(); } - - @Override - public void setEnabled( final boolean enabled ) { - final Expression selExpr = getSelectedExpression(); - - if ( selExpr == null ) { - guard.setEnabled( enabled ); - afterDelay.setEnabled( enabled ); - computeDelay.setEnabled( enabled ); - probability.setEnabled( enabled ); - - for ( final Expression actionExpr : listOfActions ) { - actionExpr.setEnabled( enabled ); - } - } - else { - selExpr.setEnabled( enabled ); - } - } - - @Override - public boolean isEnabled() { - return isEnabledCheckNull( false ); - } - - public boolean isEnabledNotNull() { - return isEnabledCheckNull( true ); - } - - private boolean isEnabledCheckNull( final boolean checkNull ) { - - // Used by the UI to toggle enabled - final Expression selExpr = getSelectedExpression(); - - if ( selExpr != null ) { - return selExpr.isEnabled(); - } - - for ( final Expression actExpr : listOfActions ) { - if ( actExpr.isEnabled() ) { - return true; - } - } - - return ( guard.isEnabled() && ( !checkNull || !guard.isNull() ) ) || - ( afterDelay.isEnabled() && ( !checkNull || !afterDelay.isNull() ) ) || - ( computeDelay.isEnabled() && ( !checkNull || !computeDelay.isNull() ) ) || - ( probability.isEnabled() && ( !checkNull || !probability.isNull() ) ); - } - - public boolean isNull() { - for ( final Expression actExpr : listOfActions ) { - if ( !actExpr.isNull() ) { - return false; - } - } - - return guard.isNull() && afterDelay.isNull() && computeDelay.isNull() && probability.isNull(); - } - - private List<Expression> getNonNullExpressions() { - final List<Expression> expressions = new ArrayList<Expression>(); - - if ( !guard.isNull() ) { - expressions.add( guard ); - } - - if ( !afterDelay.isNull() ) { - expressions.add( afterDelay ); - } - - if ( !computeDelay.isNull() ) { - expressions.add( computeDelay ); - } - - if ( !probability.isNull() ) { - expressions.add( probability ); - } - - for ( final Expression expr : listOfActions ) { - if ( !expr.isNull() ) { - expressions.add( expr ); - } - } - - return expressions; - } - - private Expression getSelectedExpression() { - final Integer selectedExpressionIndex = getPointedExpressionOrder(); - - if ( selectedExpressionIndex == null || selectedExpressionIndex < 0 ) { - return null; - } - - final List<Expression> expressions = getNonNullExpressions(); - - if ( selectedExpressionIndex >= expressions.size() ) { - return null; - } - - return expressions.get( selectedExpressionIndex ); - } } diff --git a/src/main/java/ui/avatarsmd/EnablingAvatarSMDConnectorVisitor.java b/src/main/java/ui/avatarsmd/EnablingAvatarSMDConnectorVisitor.java deleted file mode 100644 index a528ab7029..0000000000 --- a/src/main/java/ui/avatarsmd/EnablingAvatarSMDConnectorVisitor.java +++ /dev/null @@ -1,31 +0,0 @@ -package ui.avatarsmd; - -import ui.CDElement; -import ui.TrackingCDElementVisitor; - -public class EnablingAvatarSMDConnectorVisitor extends TrackingCDElementVisitor { - - private final boolean enabled; - - public EnablingAvatarSMDConnectorVisitor( final boolean enabled ) { - super(); - - this.enabled = enabled; - } - - @Override - public boolean visit( final CDElement element ) { - if ( !super.visit( element ) ) { - return false; - } - - if ( element instanceof AvatarSMDConnector ) { - ( (AvatarSMDConnector) element ).getAvatarSMDTransitionInfo().setEnabled( enabled ); - } - else if ( element.canBeDisabled() ) { - element.setEnabled( enabled ); - } - - return true; - } -} diff --git a/src/main/java/ui/avatarsmd/FindAvatarSMDComponentsToBeTranslatedVisitor.java b/src/main/java/ui/avatarsmd/FindAvatarSMDComponentsToBeTranslatedVisitor.java deleted file mode 100644 index 7a1877ad55..0000000000 --- a/src/main/java/ui/avatarsmd/FindAvatarSMDComponentsToBeTranslatedVisitor.java +++ /dev/null @@ -1,105 +0,0 @@ -package ui.avatarsmd; - -import java.util.LinkedHashSet; -import java.util.Set; - -import ui.CDElement; -import ui.TGComponent; -import ui.TGConnector; -import ui.TrackingCDElementVisitor; - -public class FindAvatarSMDComponentsToBeTranslatedVisitor extends TrackingCDElementVisitor { - - private final Set<TGComponent> componentsToBeTranslated; - - private final Set<TGConnector> prunedConnectors; - - public FindAvatarSMDComponentsToBeTranslatedVisitor() { - componentsToBeTranslated = new LinkedHashSet<TGComponent>(); - prunedConnectors = new LinkedHashSet<TGConnector>(); - } - - @Override - public boolean visit( final CDElement element ) { - if ( !super.visit( element ) ) { - return false; - } - - if ( element instanceof TGComponent && !( element instanceof TGConnector ) ) { - final TGComponent component = (TGComponent) element; - - if ( shouldBeTranslated( component ) ) { - componentsToBeTranslated.add( (TGComponent) element ); - } - } - - return true; - } - - public Set<TGComponent> getComponentsToBeTranslated() { - return componentsToBeTranslated; - } - - private boolean shouldBeTranslated( final TGComponent diagramCompo ) { - - // Do not translate components contained in disabled components (e.g. composite state machines) - if ( diagramCompo.getFather() != null && !diagramCompo.getFather().isEnabled() ) { - return false; - } - - if ( diagramCompo.isEnabled() ) { - return true; - } - - // We don't know if the target component can accept more than one input connections so we keep the node - if ( diagramCompo.getInputConnectors().size() > 1 ) { - return true; - } - - // We don't know if the source component can accept more than one output connections so we keep the node - if ( diagramCompo.getOutputConnectors().size() > 1 ) { - return true; - } - - final AvatarSMDConnector inputConnector = (AvatarSMDConnector) diagramCompo.getInputConnectors().get( 0 ); - final TGComponent previousCompo = (TGComponent) inputConnector.getTGConnectingPointP1().getFather(); - - // The previous component in the graph is not translated so we don't know if the new input edge will be - // null or enabled so we translate the component - if ( !componentsToBeTranslated.contains( previousCompo ) ) { - return true; - } - - final AvatarSMDTransitionInfo inputTransInfo = inputConnector.getAvatarSMDTransitionInfo(); - - // The input transition is null or disabled so the component does not need to be translated and the transition - // can be merged with the output transition - if ( inputTransInfo.isNull() || !inputTransInfo.isEnabledNotNull() ) { - prunedConnectors.add( inputConnector ); - - return false; - } - - if ( diagramCompo.getOutputConnectors().isEmpty() ) { - return true; - } - - final AvatarSMDConnector outputConnector = (AvatarSMDConnector) diagramCompo.getOutputConnectors().get( 0 ); - - final AvatarSMDTransitionInfo outputTransInfo = outputConnector.getAvatarSMDTransitionInfo(); - - // The output transition is null or disabled so the component does not need to be translated and the transition - // can be merged with the input transition - if ( outputTransInfo.isNull() || !inputTransInfo.isEnabledNotNull() ) { - prunedConnectors.add( outputConnector ); - - return false; - } - - return true; - } - - public Set<TGConnector> getPrunedConnectors() { - return prunedConnectors; - } -} diff --git a/src/main/java/ui/avatarsmd/FindNextEnabledAvatarSMDConnectingPointVisitor.java b/src/main/java/ui/avatarsmd/FindNextEnabledAvatarSMDConnectingPointVisitor.java deleted file mode 100644 index 004dd4746d..0000000000 --- a/src/main/java/ui/avatarsmd/FindNextEnabledAvatarSMDConnectingPointVisitor.java +++ /dev/null @@ -1,43 +0,0 @@ -package ui.avatarsmd; - -import java.util.HashSet; -import java.util.Set; - -import ui.CDElement; -import ui.FindNextEnabledConnectingPointVisitor; -import ui.TGComponent; -import ui.TGConnector; - -public class FindNextEnabledAvatarSMDConnectingPointVisitor extends FindNextEnabledConnectingPointVisitor { - - private final Set<TGComponent> componentsToBeTranslated; - - public FindNextEnabledAvatarSMDConnectingPointVisitor( final Set<TGConnector> disabledConnectors, - final Set<TGComponent> componentsToBeTranslated ) { - super( disabledConnectors ); - - this.componentsToBeTranslated = new HashSet<TGComponent>(); - this.componentsToBeTranslated.addAll( componentsToBeTranslated ); - } - - @Override - protected boolean pruneConnector( final TGConnector connector ) { - final AvatarSMDConnector smdCon = (AvatarSMDConnector) connector; - - final AvatarSMDState containingState = smdCon.getContainingState(); - - // Do not translate connectors that connect two component contained in a disabled state machine - if ( containingState != null && !containingState.isEnabled() ) { - return true; - } - - final AvatarSMDTransitionInfo transInfo = smdCon.getAvatarSMDTransitionInfo(); - - return !transInfo.isEnabledNotNull() || transInfo.isNull(); - } - - @Override - protected boolean pruneElement( final CDElement diagramElement ) { - return !componentsToBeTranslated.contains( diagramElement ); - } -} diff --git a/src/main/java/ui/ftd/FTDFault.java b/src/main/java/ui/ftd/FTDFault.java index f4862392ae..e14ba3352c 100644 --- a/src/main/java/ui/ftd/FTDFault.java +++ b/src/main/java/ui/ftd/FTDFault.java @@ -36,8 +36,12 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ftd; + import myutil.GraphicLib; import myutil.TraceManager; import org.w3c.dom.Element; @@ -50,6 +54,11 @@ import ui.window.JDialogFault; import javax.swing.*; import java.awt.*; + +//import org.w3c.dom.*; +//import org.xml.sax.*; +//import javax.xml.parsers.*; + /** * Class FTDFault * Panel used for drawing fault trees @@ -58,7 +67,7 @@ import java.awt.*; * @author Ludovic APVRILLE */ -public class FTDFault extends TGCScalableWithInternalComponent implements SwallowedTGComponent, WithAttributes, CheckableAccessibility/*, Issue #69 CanBeDisabled*/ { +public class FTDFault extends TGCScalableWithInternalComponent implements SwallowedTGComponent, WithAttributes, CheckableAccessibility, CanBeDisabled { public static double DEFAULT_PROBABILITY = 0.5; private int textY1 = 3; @@ -130,7 +139,6 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo myImageIcon = IconManager.imgic702; } - @Override public void internalDrawing(Graphics g) { String ster; if (isRootFault) { @@ -175,11 +183,7 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo g.setColor(ColorManager.FTD_FAULT); } } else { - // Issue #69: Disabled color now managed in TGComponent / ColorManager - // For filled shapes ensure background color is white so that text is - // readable - g.setColor( ColorManager.DISABLED_FILLING ); - //g.setColor(ColorManager.FTD_FAULT_DISABLED); + g.setColor(ColorManager.FTD_FAULT_DISABLED); } g.fill3DRect(x+1, y+1, width-1, height-1, true); @@ -230,22 +234,25 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo } } - // Issue #69 -// if (!isEnabled()) { -// String val = "disabled"; -// w = g.getFontMetrics().stringWidth(val); -// //int h = currentFontSize + (int)(textY1 * tdp.getZoom()); -// g.setFont(f.deriveFont(Font.ITALIC)); -// g.drawString(val, x + (width - w - 5), y + height - 2); -// } + if (!isEnabled()) { + String val = "disabled"; + w = g.getFontMetrics().stringWidth(val); + //int h = currentFontSize + (int)(textY1 * tdp.getZoom()); + g.setFont(f.deriveFont(Font.ITALIC)); + g.drawString(val, x + (width - w - 5), y + height - 2); + } + + + } else { TraceManager.addDev("-------------------------------------------------- Cannot display text of attack"); } g.setFont(fold); + } - private void setValue(String val, Graphics g) { + public void setValue(String val, Graphics g) { oldValue = value; String ster; if (isRootFault) { @@ -271,10 +278,12 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo resizeWithFather(); } + g.setFont(f0); + + // } - @Override public void resizeWithFather() { if ((father != null) && (father instanceof FTDBlock)) { // @@ -284,7 +293,7 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo } } - @Override + public boolean editOndoubleClick(JFrame frame) { String tmp; boolean error = false; @@ -319,6 +328,8 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo probability = new Double(dialog.getProbability()).doubleValue(); } + + isRootFault = dialog.isRootFault(); if (error) { @@ -331,20 +342,18 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo return !error; } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; } return null; } - @Override public int getType() { return TGComponentManager.FTD_FAULT; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info description=\"" + description); @@ -352,13 +361,14 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo sb.append("\" probability=\"" + probability); sb.append("\" />\n"); sb.append("</extraparam>\n"); - return new String(sb); } @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + // try { + NodeList nli; Node n1, n2; Element elt; @@ -408,10 +418,11 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } } + public double getProbability() { return probability; } @@ -434,6 +445,7 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo return s; } + public boolean isRootFault() { return isRootFault; } @@ -444,13 +456,6 @@ public class FTDFault extends TGCScalableWithInternalComponent implements Swallo setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); } - - /** - * Issue #69 - * @return - */ - @Override - public boolean canBeDisabled() { - return true; - } + + } diff --git a/src/main/java/ui/ncdd/NCDiagramPanel.java b/src/main/java/ui/ncdd/NCDiagramPanel.java index 19a5228ee2..87f1f197fc 100755 --- a/src/main/java/ui/ncdd/NCDiagramPanel.java +++ b/src/main/java/ui/ncdd/NCDiagramPanel.java @@ -36,21 +36,19 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ncdd; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; import org.w3c.dom.Element; +import ui.*; -import ui.MainGUI; -import ui.TDPWithAttributes; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGConnectingPoint; -import ui.TToolBar; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.ListIterator; /** * Class NCDiagramPanel @@ -68,7 +66,6 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { addMouseMotionListener(tdmm);*/ } - @Override public boolean actionOnDoubleClick(TGComponent tgc) { // /*if (tgc instanceof TCDTClass) { @@ -89,7 +86,6 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return false; } - @Override public boolean actionOnAdd(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -100,7 +96,6 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return false; } - @Override public boolean actionOnRemove(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -111,7 +106,6 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return false; } - @Override public boolean actionOnValueChanged(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { return actionOnDoubleClick(tgc); @@ -119,32 +113,26 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return false; } - @Override public String getXMLHead() { return "<NCDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + " >"; } - @Override public String getXMLTail() { return "</NCDiagramPanel>"; } - @Override public String getXMLSelectedHead() { return "<NCDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } - @Override public String getXMLSelectedTail() { return "</NCDiagramPanelCopy>"; } - @Override public String getXMLCloneHead() { return "<NCDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } - @Override public String getXMLCloneTail() { return "</NCDiagramPanelCopy>"; } @@ -189,8 +177,8 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return true; }*/ - public List<TGComponent> getListOfNodes() { - List<TGComponent> ll = new LinkedList<>(); + public LinkedList<TGComponent> getListOfNodes() { + LinkedList<TGComponent> ll = new LinkedList<>(); for (TGComponent tgc : componentList) { if (tgc instanceof NCEqNode) { @@ -206,8 +194,8 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return ll; } - public List<NCEqNode> getListOfEqNode() { - List<NCEqNode> ll = new LinkedList<>(); + public LinkedList<NCEqNode> getListOfEqNode() { + LinkedList<NCEqNode> ll = new LinkedList<>(); for (TGComponent tgc : this.componentList) { if (tgc instanceof NCEqNode) { @@ -230,8 +218,8 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return null; } - public List<NCSwitchNode> getListOfSwitchNode() { - List<NCSwitchNode> ll = new LinkedList<>(); + public LinkedList<NCSwitchNode> getListOfSwitchNode() { + LinkedList<NCSwitchNode> ll = new LinkedList<>(); for (TGComponent tgc : this.componentList) { if (tgc instanceof NCSwitchNode) { ll.add((NCSwitchNode) tgc); @@ -241,8 +229,8 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return ll; } - public List<NCConnectorNode> getListOfLinks() { - List<NCConnectorNode> ll = new LinkedList<>(); + public LinkedList<NCConnectorNode> getListOfLinks() { + LinkedList<NCConnectorNode> ll = new LinkedList<>(); for (TGComponent tgc : this.componentList) { if (tgc instanceof NCConnectorNode) { ll.add((NCConnectorNode) tgc); @@ -252,15 +240,15 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return ll; } - public List<String> getInterfaces(NCSwitchNode sw) { - ListIterator<NCConnectorNode> iterator = getListOfLinks().listIterator(); + public ArrayList<String> getInterfaces(NCSwitchNode sw) { + ListIterator iterator = getListOfLinks().listIterator(); NCConnectorNode lk; TGConnectingPoint p; - List<String> list = new ArrayList<String>(); + ArrayList<String> list = new ArrayList<String>(); while (iterator.hasNext()) { - lk = iterator.next(); + lk = (NCConnectorNode) (iterator.next()); p = lk.getTGConnectingPointP1(); if (sw.belongsToMe(p)) { list.add(lk.getInterfaceName()); @@ -275,10 +263,10 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return list; } - public List<NCRoute> getAllRoutesFor(NCSwitchNode sw, NCTrafficArtifact arti) { - List<NCRoute> list = sw.getRoutesList(); + public ArrayList<NCRoute> getAllRoutesFor(NCSwitchNode sw, NCTrafficArtifact arti) { + ArrayList<NCRoute> list = sw.getRoutesList(); - List<NCRoute> ret = new ArrayList<NCRoute>(); + ArrayList<NCRoute> ret = new ArrayList<NCRoute>(); for (NCRoute route : list) { if (route.traffic.equals(arti.getValue())) { @@ -289,15 +277,15 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return ret; } - public List<NCSwitchNode> getSwitchesOfEq(NCEqNode eq) { - ListIterator<NCConnectorNode> iterator = getListOfLinks().listIterator(); + public ArrayList<NCSwitchNode> getSwitchesOfEq(NCEqNode eq) { + ListIterator iterator = getListOfLinks().listIterator(); NCConnectorNode lk; TGConnectingPoint p; ArrayList<NCSwitchNode> list = new ArrayList<NCSwitchNode>(); while (iterator.hasNext()) { - lk = iterator.next(); + lk = (NCConnectorNode) (iterator.next()); p = lk.getTGConnectingPointP1(); if (eq.belongsToMe(p)) { list.add((NCSwitchNode) (getComponentToWhichBelongs(lk.getTGConnectingPointP2()))); @@ -312,15 +300,15 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return list; } - public List<NCConnectorNode> getConnectorOfEq(NCEqNode eq) { - ListIterator<NCConnectorNode> iterator = getListOfLinks().listIterator(); + public ArrayList<NCConnectorNode> getConnectorOfEq(NCEqNode eq) { + ListIterator iterator = getListOfLinks().listIterator(); NCConnectorNode lk; TGConnectingPoint p; - List<NCConnectorNode> list = new ArrayList<NCConnectorNode>(); + ArrayList<NCConnectorNode> list = new ArrayList<NCConnectorNode>(); while (iterator.hasNext()) { - lk = iterator.next(); + lk = (NCConnectorNode) (iterator.next()); p = lk.getTGConnectingPointP1(); if (eq.belongsToMe(p)) { list.add(lk); @@ -335,14 +323,14 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { return list; } - public List<NCTrafficArtifact> getTrafficArtifacts() { - ListIterator<NCEqNode> iterator = getListOfEqNode().listIterator(); + public ArrayList<NCTrafficArtifact> getTrafficArtifacts() { + ListIterator iterator = getListOfEqNode().listIterator(); NCEqNode eq; - List<NCTrafficArtifact> list = new ArrayList<NCTrafficArtifact>(); + ArrayList<NCTrafficArtifact> list = new ArrayList<NCTrafficArtifact>(); while (iterator.hasNext()) { - eq = iterator.next(); + eq = (NCEqNode) (iterator.next()); eq.addAllTrafficArtifacts(list); } @@ -350,11 +338,11 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { } public NCEqNode getNCEqNodeOf(NCTrafficArtifact arti) { - ListIterator<NCEqNode> iterator = getListOfEqNode().listIterator(); + ListIterator iterator = getListOfEqNode().listIterator(); NCEqNode eq; while (iterator.hasNext()) { - eq = iterator.next(); + eq = (NCEqNode) (iterator.next()); if (eq.hasTraffic(arti)) { return eq; } @@ -364,14 +352,14 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { } - public List<String> getTraffics() { - ListIterator<NCEqNode> iterator = getListOfEqNode().listIterator(); + public ArrayList<String> getTraffics() { + ListIterator iterator = getListOfEqNode().listIterator(); NCEqNode eq; - List<String> list = new ArrayList<String>(); + ArrayList<String> list = new ArrayList<String>(); while (iterator.hasNext()) { - eq = iterator.next(); + eq = (NCEqNode) (iterator.next()); eq.addAllTraffics(list); } @@ -411,6 +399,7 @@ public class NCDiagramPanel extends TDiagramPanel implements TDPWithAttributes { } public NCConnectorNode getLinkByName(String name) { + for (TGComponent tgc : this.componentList) { if (tgc instanceof NCConnectorNode) { NCConnectorNode link = (NCConnectorNode) tgc; diff --git a/src/main/java/ui/ncdd/NCEqNode.java b/src/main/java/ui/ncdd/NCEqNode.java index 563cde5846..a92bfe543b 100755 --- a/src/main/java/ui/ncdd/NCEqNode.java +++ b/src/main/java/ui/ncdd/NCEqNode.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ncdd; import myutil.GraphicLib; @@ -44,13 +47,8 @@ import ui.util.IconManager; import ui.window.JDialogNCEqNode; import javax.swing.*; - -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Polygon; +import java.awt.*; import java.util.ArrayList; -import java.util.List; import java.util.Vector; @@ -115,7 +113,6 @@ public class NCEqNode extends TGCWithInternalComponent implements SwallowTGCompo myImageIcon = IconManager.imgic700; } - @Override public void internalDrawing(Graphics g) { Color c = g.getColor(); g.draw3DRect(x, y, width, height, true); @@ -149,7 +146,6 @@ public class NCEqNode extends TGCWithInternalComponent implements SwallowTGCompo g.drawImage(IconManager.imgic1100.getImage(), x + width - 20, y + 4, null); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { Polygon pol = new Polygon(); @@ -183,7 +179,6 @@ public class NCEqNode extends TGCWithInternalComponent implements SwallowTGCompo return type; } - @Override public boolean editOndoubleClick(JFrame frame) { // String oldName = name; @@ -230,18 +225,16 @@ public class NCEqNode extends TGCWithInternalComponent implements SwallowTGCompo return true; } - @Override + public int getType() { return TGComponentManager.NCDD_EQNODE; } - @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof NCTrafficArtifact; } - @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { if (tgc instanceof NCTrafficArtifact) { @@ -258,11 +251,11 @@ public class NCEqNode extends TGCWithInternalComponent implements SwallowTGCompo } - @Override public void removeSwallowedTGComponent(TGComponent tgc) { removeInternalComponent(tgc); } + public Vector<NCTrafficArtifact> getArtifactList() { Vector<NCTrafficArtifact> v = new Vector<NCTrafficArtifact> (); for(int i=0; i<nbInternalTGComponent; i++) { @@ -273,13 +266,13 @@ public class NCEqNode extends TGCWithInternalComponent implements SwallowTGCompo return v; } - public void addAllTraffics( List<String> list) { + public void addAllTraffics(ArrayList<String> list) { for(int i=0; i<nbInternalTGComponent; i++) { list.add(tgcomponent[i].getValue()); } } - public void addAllTrafficArtifacts( List<NCTrafficArtifact> list) { + public void addAllTrafficArtifacts(ArrayList<NCTrafficArtifact> list) { for(int i=0; i<nbInternalTGComponent; i++) { list.add((NCTrafficArtifact)(tgcomponent[i])); } @@ -303,13 +296,14 @@ public class NCEqNode extends TGCWithInternalComponent implements SwallowTGCompo } - @Override + + public int getDefaultConnector() { return TGComponentManager.CONNECTOR_NODE_NC; } - public String getAttributes() { - String attr = "Type: "; + public String getAttributes() { + String attr = "Type: "; if (type == 0) { attr += "Standard\n"; } else { @@ -322,7 +316,8 @@ public class NCEqNode extends TGCWithInternalComponent implements SwallowTGCompo pol = "SP"; } attr += "Scheduling policy = " + pol + "\n"; - return attr; + } + } diff --git a/src/main/java/ui/ncdd/NCRouteArtifact.java b/src/main/java/ui/ncdd/NCRouteArtifact.java index 3f5e3c2bfe..5254257b7a 100755 --- a/src/main/java/ui/ncdd/NCRouteArtifact.java +++ b/src/main/java/ui/ncdd/NCRouteArtifact.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.ncdd; import myutil.GraphicLib; @@ -47,11 +50,8 @@ import ui.util.IconManager; import ui.window.JDialogNCRoute; import javax.swing.*; - -import java.awt.Color; -import java.awt.Graphics; +import java.awt.*; import java.util.ArrayList; -import java.util.List; import java.util.Vector; /** @@ -95,8 +95,8 @@ public class NCRouteArtifact extends TGCWithoutInternalComponent implements Swal myImageIcon = IconManager.imgic702; } - @Override public void internalDrawing(Graphics g) { + if (oldValue.compareTo(value) != 0) { setValue(value, g); } @@ -117,9 +117,10 @@ public class NCRouteArtifact extends TGCWithoutInternalComponent implements Swal g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); g.drawString(value, x + textX , y + textY); + } - private void setValue(String val, Graphics g) { + public void setValue(String val, Graphics g) { oldValue = value; int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX + fileX + space); @@ -129,9 +130,9 @@ public class NCRouteArtifact extends TGCWithoutInternalComponent implements Swal width = w1; resizeWithFather(); } + // } - @Override public void resizeWithFather() { if ((father != null) && ((father instanceof NCEqNode) || (father instanceof NCSwitchNode))) { // @@ -141,16 +142,15 @@ public class NCRouteArtifact extends TGCWithoutInternalComponent implements Swal } } - @Override public boolean editOndoubleClick(JFrame frame) { String tmp; boolean error = false; Vector<NCRoute> vroutes = new Vector<NCRoute>(routes); - List<String> inputInterfaces = ((NCDiagramPanel)tdp).getInterfaces((NCSwitchNode)(getFather())); - List<String> traffics = ((NCDiagramPanel)tdp).getTraffics(); - List<String> outputInterfaces = new ArrayList<>(inputInterfaces); + ArrayList<String> inputInterfaces = ((NCDiagramPanel)tdp).getInterfaces((NCSwitchNode)(getFather())); + ArrayList<String> traffics = ((NCDiagramPanel)tdp).getTraffics(); + ArrayList<String> outputInterfaces = new ArrayList<>(inputInterfaces); JDialogNCRoute dialog = new JDialogNCRoute(frame, "Setting route attributes", value, vroutes, inputInterfaces, traffics, outputInterfaces); // dialog.setSize(900, 500); @@ -196,7 +196,6 @@ public class NCRouteArtifact extends TGCWithoutInternalComponent implements Swal } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -204,12 +203,10 @@ public class NCRouteArtifact extends TGCWithoutInternalComponent implements Swal return null; } - @Override public int getType() { return TGComponentManager.NCDD_ROUTE_ARTIFACT; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); for(NCRoute route: routes) { @@ -268,7 +265,7 @@ public class NCRouteArtifact extends TGCWithoutInternalComponent implements Swal //makeFullValue(); } - public List<NCRoute> getRoutes() { + public java.util.List<NCRoute> getRoutes() { return routes; } diff --git a/src/main/java/ui/tmlad/TGConnectingPointTMLAD.java b/src/main/java/ui/tmlad/TGConnectingPointTMLAD.java index a397a102bd..a1f5ab0902 100755 --- a/src/main/java/ui/tmlad/TGConnectingPointTMLAD.java +++ b/src/main/java/ui/tmlad/TGConnectingPointTMLAD.java @@ -36,11 +36,16 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; +//import java.awt.*; + import ui.CDElement; import ui.TGComponentManager; -import ui.ad.TGConnectingPointAD; +import ui.TGConnectingPointWidthHeight; /** * Class TGConnectingPointTMLAD @@ -49,14 +54,21 @@ import ui.ad.TGConnectingPointAD; * @version 1.0 28/10/2005 * @author Ludovic APVRILLE */ -public class TGConnectingPointTMLAD extends TGConnectingPointAD /* Issue #69TGConnectingPoint*/ { +public class TGConnectingPointTMLAD extends TGConnectingPointWidthHeight{ public TGConnectingPointTMLAD(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } - @Override public boolean isCompatibleWith(int type) { return type == TGComponentManager.CONNECTOR_TMLAD; } + } + + + + + + + diff --git a/src/main/java/ui/tmlad/TGConnectorTMLAD.java b/src/main/java/ui/tmlad/TGConnectorTMLAD.java index 35955d3d25..c7943dd2e9 100755 --- a/src/main/java/ui/tmlad/TGConnectorTMLAD.java +++ b/src/main/java/ui/tmlad/TGConnectorTMLAD.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; import ui.*; -import ui.ad.TADConnector; import ui.util.IconManager; import java.awt.*; @@ -54,9 +56,8 @@ import java.util.Vector; * @version 1.0 30/09/2004 * @author Ludovic APVRILLE */ -public class TGConnectorTMLAD extends TADConnector /* Issue #69 TGConnector*/ { - - protected int arrowLength = 10; +public class TGConnectorTMLAD extends TGConnector { + protected int arrowLength = 10; public TGConnectorTMLAD(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); @@ -64,7 +65,6 @@ public class TGConnectorTMLAD extends TADConnector /* Issue #69 TGConnector*/ { myImageIcon = IconManager.imgic202; } - @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { g.drawLine(x1, y1, x2, y2); @@ -73,8 +73,14 @@ public class TGConnectorTMLAD extends TADConnector /* Issue #69 TGConnector*/ { } } - @Override public int getType() { return TGComponentManager.CONNECTOR_TMLAD; } } + + + + + + + diff --git a/src/main/java/ui/tmlad/TMLADActionState.java b/src/main/java/ui/tmlad/TMLADActionState.java index a216f7d045..75d464612c 100755 --- a/src/main/java/ui/tmlad/TMLADActionState.java +++ b/src/main/java/ui/tmlad/TMLADActionState.java @@ -36,25 +36,17 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; -import java.awt.Color; -import java.awt.Graphics; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; -import ui.AllowedBreakpoint; -import ui.BasicErrorHighlight; -import ui.CheckableAccessibility; -import ui.CheckableLatency; -import ui.ColorManager; -import ui.EmbeddedComment; -import ui.ErrorHighlight; -import ui.PostJavaCode; -import ui.PreJavaCode; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADActionState; +import java.awt.*; +import java.awt.geom.Line2D; /** * Class TMLADActionState @@ -63,45 +55,36 @@ import ui.ad.TADActionState; * @version 1.0 21/11/2005 * @author Ludovic APVRILLE */ -public class TMLADActionState extends TADActionState/* Issue #69 TGCOneLineText */implements PreJavaCode, PostJavaCode, CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { -// protected int lineLength = 5; -// protected int textX = 5; -// protected int textY = 15; -// protected int arc = 5; -// -// protected int stateOfError = 0; // Not yet checked +public class TMLADActionState extends TGCOneLineText implements PreJavaCode, PostJavaCode, CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int arc = 5; + + protected int stateOfError = 0; // Not yet checked public TMLADActionState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// -// width = 30; -// height = 20; -// minWidth = 30; -// -// nbConnectingPoint = 2; -// connectingPoint = new TGConnectingPoint[2]; -// connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); -// -// moveable = true; -// editable = true; -// removable = true; -// -// value = "action"; -// name = "action state"; -// -// myImageIcon = IconManager.imgic204; + + width = 30; + height = 20; + minWidth = 30; + + nbConnectingPoint = 2; + connectingPoint = new TGConnectingPoint[2]; + connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); + + moveable = true; + editable = true; + removable = true; + + value = "action"; + name = "action state"; + + myImageIcon = IconManager.imgic204; } - @Override - protected void createConnectingPoints() { - nbConnectingPoint = 2; - connectingPoint = new TGConnectingPoint[ nbConnectingPoint ]; - connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); - } - - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -111,9 +94,9 @@ public class TMLADActionState extends TADActionState/* Issue #69 TGCOneLineText //updateConnectingPoints(); } - if (stateAction > 0) { + if (stateOfError > 0) { Color c = g.getColor(); - switch(stateAction) { + switch(stateOfError) { case ErrorHighlight.OK: g.setColor(ColorManager.ATTRIBUTE_BOX_ACTION); break; @@ -129,25 +112,25 @@ public class TMLADActionState extends TADActionState/* Issue #69 TGCOneLineText g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); g.drawString(value, x + (width - w) / 2 , y + textY); + + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, _x, _y)) < distanceSelected) { + return this; + } + + return null; } -// public TGComponent isOnMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, _x, _y)) < distanceSelected) { -// return this; -// } -// -// return null; -// } -// -// public String getAction() { -// return value; -// } + public String getAction() { + return value; + } - @Override public String getAction(int cpt) { if (cpt <0) { return value; @@ -173,17 +156,17 @@ public class TMLADActionState extends TADActionState/* Issue #69 TGCOneLineText return ret; } - @Override public int getType() { return TGComponentManager.TMLAD_ACTION_STATE; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } -// public void setStateAction(int _stateAction) { -// stateOfError = _stateAction; -// } + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } + + } diff --git a/src/main/java/ui/tmlad/TMLADChoice.java b/src/main/java/ui/tmlad/TMLADChoice.java index c2f1175b4b..6d054ed994 100755 --- a/src/main/java/ui/tmlad/TMLADChoice.java +++ b/src/main/java/ui/tmlad/TMLADChoice.java @@ -36,16 +36,17 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; -import ui.AllowedBreakpoint; -import ui.BasicErrorHighlight; -import ui.EmbeddedComment; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADChoice; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; +import java.awt.geom.Line2D; /** * Class TMLADChoice @@ -54,13 +55,13 @@ import ui.ad.TADChoice; * @version 1.0 21/11/2005 * @author Ludovic APVRILLE */ -public class TMLADChoice extends TADChoice /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { -// private int lineLength = 10; -// private int lineOutLength = 25; -// private int textX1, textY1, textX2, textY2, textX3, textY3; -// -// protected int stateOfError = 0; // Not yet checked -// public final static int NOT_VERIFIED = 0; +public class TMLADChoice extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + private int lineLength = 10; + private int lineOutLength = 25; + private int textX1, textY1, textX2, textY2, textX3, textY3; + + protected int stateOfError = 0; // Not yet checked + public final static int NOT_VERIFIED = 0; public final static int REACHABLE = 1; public final static int NOT_REACHABLE = 2; @@ -69,161 +70,150 @@ public class TMLADChoice extends TADChoice /* Issue #69 TGCWithInternalComponent public TMLADChoice(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// width = 30; -// height = 30; -// textX1 = -lineOutLength; -// textY1 = height/2 - 5; -// textX2 = width + 5; -// textY2 = height/2 - 5; -// textX3 = width /2 + 5; -// textY3 = height + 15; -// -// nbConnectingPoint = 4; -// connectingPoint = new TGConnectingPoint[nbConnectingPoint]; -// connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new TGConnectingPointTMLAD(this, -lineOutLength, 0, false, true, 0.0, 0.5); -// connectingPoint[2] = new TGConnectingPointTMLAD(this, lineOutLength, 0, false, true, 1.0, 0.5); -// connectingPoint[3] = new TGConnectingPointTMLAD(this, 0, lineOutLength, false, true, 0.5, 1.0); -// -// nbInternalTGComponent = 3; -// tgcomponent = new TGComponent[nbInternalTGComponent]; -// -// TGCOneLineText tgc = new TGCOneLineText(x+textX1, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 1"); -// tgcomponent[0] = tgc; -// -// tgc = new TGCOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 2"); -// tgcomponent[1] = tgc; -// -// tgc = new TGCOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 3"); -// tgcomponent[2] = tgc; -// -// moveable = true; -// editable = false; -// removable = true; -// -// name = "choice"; -// -// myImageIcon = IconManager.imgic208; + width = 30; + height = 30; + textX1 = -lineOutLength; + textY1 = height/2 - 5; + textX2 = width + 5; + textY2 = height/2 - 5; + textX3 = width /2 + 5; + textY3 = height + 15; + + nbConnectingPoint = 4; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointTMLAD(this, -lineOutLength, 0, false, true, 0.0, 0.5); + connectingPoint[2] = new TGConnectingPointTMLAD(this, lineOutLength, 0, false, true, 1.0, 0.5); + connectingPoint[3] = new TGConnectingPointTMLAD(this, 0, lineOutLength, false, true, 0.5, 1.0); + + nbInternalTGComponent = 3; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGCOneLineText tgc = new TGCOneLineText(x+textX1, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 1"); + tgcomponent[0] = tgc; + + tgc = new TGCOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 2"); + tgcomponent[1] = tgc; + + tgc = new TGCOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 3"); + tgcomponent[2] = tgc; + + moveable = true; + editable = false; + removable = true; + + name = "choice"; + + myImageIcon = IconManager.imgic208; } - - @Override - protected void createConnectingPoints() { - nbConnectingPoint = 4; - connectingPoint = new TGConnectingPoint[nbConnectingPoint]; - connectingPoint[ 0 ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[ 1 ] = new TGConnectingPointTMLAD(this, -lineOutLength, 0, false, true, 0.0, 0.5); - connectingPoint[ 2 ] = new TGConnectingPointTMLAD(this, lineOutLength, 0, false, true, 1.0, 0.5); - connectingPoint[ 3 ] = new TGConnectingPointTMLAD(this, 0, lineOutLength, false, true, 0.5, 1.0); + + public void internalDrawing(Graphics g) { + if (stateOfError > 0) { + Color c = g.getColor(); + switch(stateOfError) { + case ErrorHighlight.OK: + g.setColor(ColorManager.CHOICE); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + } + // Making the polygon + int [] px1 = {x+(width/2), x+width+2, x + (width/2), x}; + int [] py1 = {y, y + height/2, y+height+2, y+height/2}; + g.fillPolygon(px1, py1, 4); + g.setColor(c); + } + + g.drawLine(x+(width/2), y, x+width, y + height/2); + g.drawLine(x, y + height / 2, x+width/2, y + height); + g.drawLine(x + width/2, y, x, y + height/2); + g.drawLine(x + width, y + height/2, x + width/2, y + height); + + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x, y + height/2, x-lineOutLength, y + height/2); + g.drawLine(x + width, y + height/2, x+ width + lineOutLength, y + height/2); + g.drawLine(x+(width/2), y + height, x+(width/2), y + height + lineOutLength); } -// public void internalDrawing(Graphics g) { -// if (stateOfError > 0) { -// Color c = g.getColor(); -// switch(stateOfError) { -// case ErrorHighlight.OK: -// g.setColor(ColorManager.CHOICE); -// break; -// default: -// g.setColor(ColorManager.UNKNOWN_BOX_ACTION); -// } -// // Making the polygon -// int [] px1 = {x+(width/2), x+width+2, x + (width/2), x}; -// int [] py1 = {y, y + height/2, y+height+2, y+height/2}; -// g.fillPolygon(px1, py1, 4); -// g.setColor(c); -// } -// -// g.drawLine(x+(width/2), y, x+width, y + height/2); -// g.drawLine(x, y + height / 2, x+width/2, y + height); -// g.drawLine(x + width/2, y, x, y + height/2); -// g.drawLine(x + width, y + height/2, x + width/2, y + height); -// -// g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); -// g.drawLine(x, y + height/2, x-lineOutLength, y + height/2); -// g.drawLine(x + width, y + height/2, x+ width + lineOutLength, y + height/2); -// g.drawLine(x+(width/2), y + height, x+(width/2), y + height + lineOutLength); -// } -// -// public TGComponent isOnOnlyMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+(width/2), y + height, x+(width/2), y + height + lineOutLength, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x + width, y + height/2, x+ width + lineOutLength, y + height/2, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x, y + height/2, x-lineOutLength, y + height/2, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+(width/2), y, x+(width/2), y - lineLength, _x, _y)) < distanceSelected) { -// return this; -// } -// -// return null; -// } + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y + height, x+(width/2), y + height + lineOutLength, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x + width, y + height/2, x+ width + lineOutLength, y + height/2, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x, y + height/2, x-lineOutLength, y + height/2, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y, x+(width/2), y - lineLength, _x, _y)) < distanceSelected) { + return this; + } + + return null; + } + + public String getGuard(int i) { + if ((i>=0) && (i<nbInternalTGComponent)) { + return tgcomponent[i].getValue(); + } + return ""; + } + public void drawSecurityInformation(Graphics g) { + if (securityInformation > 0) { + + Color c = g.getColor(); + Color c1; + switch(securityInformation) { + case REACHABLE: + c1 = Color.green; + break; + case NOT_REACHABLE: + c1 = Color.red; + break; + default: + return; + } + + GraphicLib.arrowWithLine(g, 1, 0, 10, x-30, y+4, x-15, y+4, true); + g.drawOval(x-11, y-3, 7, 9); + g.setColor(c1); + g.fillRect(x-12, y, 9, 7); + g.setColor(c); + g.drawRect(x-12, y, 9, 7); + + } + + } -// public String getGuard(int i) { -// if ((i>=0) && (i<nbInternalTGComponent)) { -// return tgcomponent[i].getValue(); -// } -// return ""; -// } -// public void drawSecurityInformation(Graphics g) { -// if (securityInformation > 0) { -// -// Color c = g.getColor(); -// Color c1; -// switch(securityInformation) { -// case REACHABLE: -// c1 = Color.green; -// break; -// case NOT_REACHABLE: -// c1 = Color.red; -// break; -// default: -// return; -// } -// -// GraphicLib.arrowWithLine(g, 1, 0, 10, x-30, y+4, x-15, y+4, true); -// g.drawOval(x-11, y-3, 7, 9); -// g.setColor(c1); -// g.fillRect(x-12, y, 9, 7); -// g.setColor(c); -// g.drawRect(x-12, y, 9, 7); -// -// } -// -// } -// -// public void setGuard(String guard, int i) { -// if ((i>=0) && (i<nbInternalTGComponent)) { -// tgcomponent[i].setValue(guard); -// } -// } + public void setGuard(String guard, int i) { + if ((i>=0) && (i<nbInternalTGComponent)) { + tgcomponent[i].setValue(guard); + } + } - @Override public int getType() { return TGComponentManager.TMLAD_CHOICE; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } -// -// public void setStateAction(int _stateAction) { -// stateOfError = _stateAction; -// } + + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } + } diff --git a/src/main/java/ui/tmlad/TMLADDecrypt.java b/src/main/java/ui/tmlad/TMLADDecrypt.java index 09c37ac7b2..5c75a5f955 100755 --- a/src/main/java/ui/tmlad/TMLADDecrypt.java +++ b/src/main/java/ui/tmlad/TMLADDecrypt.java @@ -44,7 +44,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.ad.TADComponentWithoutSubcomponents; import ui.util.IconManager; import ui.window.JDialogMultiString; @@ -61,7 +60,7 @@ import java.util.ArrayList; * @author Ludovic APVRILLE * @version 1.0 21/11/2005 */ -public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADDecrypt extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { private int lineLength = 5; // private int textX, textY; private int ilength = 20; @@ -93,7 +92,6 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T myImageIcon = IconManager.imgic214; } - @Override public void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); @@ -133,7 +131,6 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T g.drawString("sec:" + securityContext, x + 3 * width / 2, y + height / 2); } - @Override public boolean editOndoubleClick(JFrame frame) { String[] labels = new String[1]; String[] values = new String[1]; @@ -154,9 +151,9 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T } return false; + } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -173,7 +170,6 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T return null; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data secPattern=\""); @@ -194,6 +190,9 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T // int k; // String s; + // + // + for (int i = 0; i < nl.getLength(); i++) { n1 = nl.item(i); // @@ -214,22 +213,20 @@ public class TMLADDecrypt extends TADComponentWithoutSubcomponents/* Issue #69 T } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } } - @Override public int getType() { return TGComponentManager.TMLAD_DECRYPT; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } } + diff --git a/src/main/java/ui/tmlad/TMLADDelay.java b/src/main/java/ui/tmlad/TMLADDelay.java index 4a936c36df..fd01729805 100755 --- a/src/main/java/ui/tmlad/TMLADDelay.java +++ b/src/main/java/ui/tmlad/TMLADDelay.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; import ui.*; -import ui.ad.TADComponentWithSubcomponents; import ui.util.IconManager; import java.awt.*; @@ -53,11 +55,11 @@ import java.awt.geom.Line2D; * @version 1.0 10/11/2008 * @author Ludovic APVRILLE */ -public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADDelay extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { private int lineLength = 5; private int textX, textY; -// private int ilength = 10; -// private int lineLength1 = 2; + private int ilength = 10; + private int lineLength1 = 2; protected int stateOfError = 0; // Not yet checked @@ -95,7 +97,6 @@ public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWi myImageIcon = IconManager.imgic214; } - @Override public void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); @@ -115,7 +116,6 @@ public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWi g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -140,18 +140,17 @@ public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWi return ((TGCTimeDelay)tgcomponent[0]).getUnit(); } - @Override public int getType() { return TGComponentManager.TMLAD_DELAY; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + } + diff --git a/src/main/java/ui/tmlad/TMLADDelayInterval.java b/src/main/java/ui/tmlad/TMLADDelayInterval.java index d7234a8439..f7bb0e9277 100755 --- a/src/main/java/ui/tmlad/TMLADDelayInterval.java +++ b/src/main/java/ui/tmlad/TMLADDelayInterval.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; import ui.*; -import ui.ad.TADComponentWithSubcomponents; import ui.util.IconManager; import java.awt.*; @@ -53,11 +55,11 @@ import java.awt.geom.Line2D; * @version 1.0 10/11/2008 * @author Ludovic APVRILLE */ -public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADDelayInterval extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { private int lineLength = 5; private int textX, textY; -// private int ilength = 10; -// private int lineLength1 = 2; + private int ilength = 10; + private int lineLength1 = 2; private int incrementY = 3; private int segment = 4; @@ -97,8 +99,8 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue # myImageIcon = IconManager.imgic214; } - @Override public void internalDrawing(Graphics g) { + if (stateOfError > 0) { Color c = g.getColor(); switch(stateOfError) { @@ -128,7 +130,6 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue # } } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -157,12 +158,10 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue # ((TGCTimeDelay)(tgcomponent[0])).setMaxDelay(val); } - @Override public int getType() { return TGComponentManager.TMLAD_INTERVAL_DELAY; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } @@ -171,8 +170,8 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue # return ((TGCTimeDelay)tgcomponent[0]).getUnit(); } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + } diff --git a/src/main/java/ui/tmlad/TMLADEncrypt.java b/src/main/java/ui/tmlad/TMLADEncrypt.java index f3fac8dc34..11ecb9a380 100755 --- a/src/main/java/ui/tmlad/TMLADEncrypt.java +++ b/src/main/java/ui/tmlad/TMLADEncrypt.java @@ -44,7 +44,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.ad.TADComponentWithoutSubcomponents; import ui.util.IconManager; import ui.window.JDialogCryptographicConfiguration; @@ -60,7 +59,7 @@ import java.awt.geom.Line2D; * @author Ludovic APVRILLE * @version 1.0 21/11/2005 */ -public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADEncrypt extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { private int lineLength = 5; // private int textX, textY; private int ex = 5; @@ -102,7 +101,6 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T myImageIcon = IconManager.imgic214; } - @Override public void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); @@ -183,8 +181,8 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T g.drawImage(IconManager.imgic7000.getImage(), x - 22, y + height / 2, null); } - @Override public boolean editOndoubleClick(JFrame frame) { + //JDialogTwoString jdts = new JDialogTwoString(frame, "Setting channel's properties", "Channel name", channelName, "Nb of samples", nbOfSamples);] String[] values = new String[]{securityContext, type, message_overhead, encTime, size, nonce, formula, decTime, key, algorithm}; String[] nonces = tdp.getMGUI().getAllNonce(); @@ -211,7 +209,6 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T return false; } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -228,7 +225,6 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T return null; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data secContext=\""); @@ -256,13 +252,18 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + // try { + NodeList nli; Node n1, n2; Element elt; // int k; // String s; + // + // + for (int i = 0; i < nl.getLength(); i++) { n1 = nl.item(i); // @@ -291,22 +292,20 @@ public class TMLADEncrypt extends TADComponentWithoutSubcomponents/* Issue #69 T } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } } - @Override public int getType() { return TGComponentManager.TMLAD_ENCRYPT; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } } + diff --git a/src/main/java/ui/tmlad/TMLADExecC.java b/src/main/java/ui/tmlad/TMLADExecC.java index c7be2687dd..e8df888ce2 100755 --- a/src/main/java/ui/tmlad/TMLADExecC.java +++ b/src/main/java/ui/tmlad/TMLADExecC.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; import ui.*; -import ui.ad.TADComponentWithSubcomponents; import ui.util.IconManager; import java.awt.*; @@ -53,7 +55,7 @@ import java.awt.geom.Line2D; * @version 1.0 21/05/2008 * @author Ludovic APVRILLE */ -public class TMLADExecC extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADExecC extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { private int lineLength = 5; private int textX, textY; private int ilength = 10; @@ -91,7 +93,6 @@ public class TMLADExecC extends TADComponentWithSubcomponents /* Issue #69 TGCWi myImageIcon = IconManager.imgic214; } - @Override public void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); @@ -113,7 +114,6 @@ public class TMLADExecC extends TADComponentWithSubcomponents /* Issue #69 TGCWi g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2)- lineLength1, y+(height+ilength)/2); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -134,18 +134,17 @@ public class TMLADExecC extends TADComponentWithSubcomponents /* Issue #69 TGCWi tgcomponent[0].setValue(value); } - @Override public int getType() { return TGComponentManager.TMLAD_EXECC; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + } + diff --git a/src/main/java/ui/tmlad/TMLADExecCInterval.java b/src/main/java/ui/tmlad/TMLADExecCInterval.java index bf07c7eafe..3ba864c723 100755 --- a/src/main/java/ui/tmlad/TMLADExecCInterval.java +++ b/src/main/java/ui/tmlad/TMLADExecCInterval.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; import ui.*; -import ui.ad.TADComponentWithSubcomponents; import ui.util.IconManager; import java.awt.*; @@ -53,7 +55,7 @@ import java.awt.geom.Line2D; * @version 1.0 21/05/2008 * @author Ludovic APVRILLE */ -public class TMLADExecCInterval extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADExecCInterval extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { private int lineLength = 5; private int textX, textY; private int ilength = 10; @@ -91,7 +93,6 @@ public class TMLADExecCInterval extends TADComponentWithSubcomponents /* Issue # myImageIcon = IconManager.imgic214; } - @Override public void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); @@ -113,7 +114,6 @@ public class TMLADExecCInterval extends TADComponentWithSubcomponents /* Issue # g.drawLine(x + (width/2) - lineLength1, y+(height-ilength)/2, x + (width/2) - lineLength1, y+(height+ilength)/2); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -142,17 +142,14 @@ public class TMLADExecCInterval extends TADComponentWithSubcomponents /* Issue # ((TGCTimeInterval)(tgcomponent[0])).setMaxDelay(val); } - @Override public int getType() { return TGComponentManager.TMLAD_EXECC_INTERVAL; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } diff --git a/src/main/java/ui/tmlad/TMLADExecI.java b/src/main/java/ui/tmlad/TMLADExecI.java index 024b0c5760..cac0941253 100755 --- a/src/main/java/ui/tmlad/TMLADExecI.java +++ b/src/main/java/ui/tmlad/TMLADExecI.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; import ui.*; -import ui.ad.TADComponentWithSubcomponents; import ui.util.IconManager; import java.awt.*; @@ -53,7 +55,7 @@ import java.awt.geom.Line2D; * @version 1.0 21/11/2005 * @author Ludovic APVRILLE */ -public class TMLADExecI extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, CheckableLatency, BasicErrorHighlight { +public class TMLADExecI extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, CheckableLatency, BasicErrorHighlight { private int lineLength = 5; private int textX, textY; private int ilength = 10; @@ -91,7 +93,6 @@ public class TMLADExecI extends TADComponentWithSubcomponents /* Issue #69 TGCWi myImageIcon = IconManager.imgic214; } - @Override public void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); @@ -113,7 +114,6 @@ public class TMLADExecI extends TADComponentWithSubcomponents /* Issue #69 TGCWi g.drawLine(x + (width/2), y+(height-ilength)/2, x + (width/2), y+(height+ilength)/2); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -134,18 +134,16 @@ public class TMLADExecI extends TADComponentWithSubcomponents /* Issue #69 TGCWi tgcomponent[0].setValue(value); } - @Override public int getType() { return TGComponentManager.TMLAD_EXECI; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } } + diff --git a/src/main/java/ui/tmlad/TMLADExecIInterval.java b/src/main/java/ui/tmlad/TMLADExecIInterval.java index 49c6b15468..585478caec 100755 --- a/src/main/java/ui/tmlad/TMLADExecIInterval.java +++ b/src/main/java/ui/tmlad/TMLADExecIInterval.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; import ui.*; -import ui.ad.TADComponentWithSubcomponents; import ui.util.IconManager; import java.awt.*; @@ -53,7 +55,7 @@ import java.awt.geom.Line2D; * @version 1.0 02/12/2005 * @author Ludovic APVRILLE */ -public class TMLADExecIInterval extends TADComponentWithSubcomponents /* Issue #69 TGCWithInternalComponent */ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADExecIInterval extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { private int lineLength = 5; private int textX, textY; private int ilength = 10; @@ -91,7 +93,6 @@ public class TMLADExecIInterval extends TADComponentWithSubcomponents /* Issue # myImageIcon = IconManager.imgic214; } - @Override public void internalDrawing(Graphics g) { if (stateOfError > 0) { Color c = g.getColor(); @@ -113,7 +114,6 @@ public class TMLADExecIInterval extends TADComponentWithSubcomponents /* Issue # g.drawLine(x + (width/2), y+(height-ilength)/2, x + (width/2), y+(height+ilength)/2); } - @Override public TGComponent isOnOnlyMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -142,18 +142,16 @@ public class TMLADExecIInterval extends TADComponentWithSubcomponents /* Issue # ((TGCTimeInterval)(tgcomponent[0])).setMaxDelay(val); } - @Override public int getType() { return TGComponentManager.TMLAD_EXECI_INTERVAL; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + } diff --git a/src/main/java/ui/tmlad/TMLADForEverLoop.java b/src/main/java/ui/tmlad/TMLADForEverLoop.java index a59a009886..58cb33eb2e 100755 --- a/src/main/java/ui/tmlad/TMLADForEverLoop.java +++ b/src/main/java/ui/tmlad/TMLADForEverLoop.java @@ -36,21 +36,17 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; -import java.awt.Color; -import java.awt.Graphics; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; -import ui.AllowedBreakpoint; -import ui.BasicErrorHighlight; -import ui.ColorManager; -import ui.EmbeddedComment; -import ui.ErrorHighlight; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADForLoop; +import java.awt.*; +import java.awt.geom.Line2D; /** * Class TMLADForEverLoop @@ -59,39 +55,41 @@ import ui.ad.TADForLoop; * @version 1.0 19/11/2008 * @author Ludovic APVRILLE */ -public class TMLADForEverLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { -// protected int lineLength = 5; -// protected int textX = 5; -// protected int textY = 15; -// protected int arc = 5; -// -// protected int stateOfError = 0; // Not yet checked +public class TMLADForEverLoop extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int arc = 5; + + protected int stateOfError = 0; // Not yet checked public TMLADForEverLoop(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// width = 30; -// height = 20; -// minWidth = 30; + width = 30; + height = 20; + minWidth = 30; nbConnectingPoint = 2; connectingPoint = new TGConnectingPoint[2]; - connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop + connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop //connectingPoint[2] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp -// moveable = true; -// editable = true; -// removable = true; + moveable = true; + editable = true; + removable = true; value = "Loop for ever"; name = "for ever loop"; - // myImageIcon = IconManager.imgic912; + myImageIcon = IconManager.imgic912; } - @Override + public void internalDrawing(Graphics g) { + + int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); if ((w1 != width) & (!tdp.isScaled())) { @@ -144,33 +142,32 @@ public class TMLADForEverLoop extends TADForLoop /* Issue #69 TGCWithoutInternal return false; }*/ -// public TGComponent isOnMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+(width/2), y-lineLength, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+width, y+height/2, x+width +lineLength, y+height/2, _x, _y)) < distanceSelected) { -// return this; -// } -// -// return null; -// } + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y-lineLength, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+width, y+height/2, x+width +lineLength, y+height/2, _x, _y)) < distanceSelected) { + return this; + } + + return null; + } + - @Override public int getType() { return TGComponentManager.TMLAD_FOR_EVER_LOOP; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } -// -// public void setStateAction(int _stateAction) { -// stateOfError = _stateAction; -// } + + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } } diff --git a/src/main/java/ui/tmlad/TMLADForLoop.java b/src/main/java/ui/tmlad/TMLADForLoop.java index 75e89fcb6c..c214fd743c 100755 --- a/src/main/java/ui/tmlad/TMLADForLoop.java +++ b/src/main/java/ui/tmlad/TMLADForLoop.java @@ -36,32 +36,23 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.tmlad; -import java.awt.Color; -import java.awt.Graphics; -import javax.swing.JFrame; +package ui.tmlad; + +import myutil.GraphicLib; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - -import myutil.GraphicLib; -import ui.AllowedBreakpoint; -import ui.BasicErrorHighlight; -import ui.ColorManager; -import ui.EmbeddedComment; -import ui.ErrorHighlight; -import ui.GTURTLEModeling; -import ui.MalformedModelingException; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADForLoop; +import ui.*; +import ui.util.IconManager; import ui.window.JDialogMultiString; +import javax.swing.*; +import java.awt.*; +import java.awt.geom.Line2D; + /** * Class TMLADForLoop *For loop of a TML activity diagram @@ -69,48 +60,47 @@ import ui.window.JDialogMultiString; * @version 1.0 21/11/2005 * @author Ludovic APVRILLE */ -public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADForLoop extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + + private final static String IN_LOOP = "inside loop"; + private final static String EXIT_LOOP = "exit loop"; -// private final static String IN_LOOP = "inside loop"; -// private final static String EXIT_LOOP = "exit loop"; -// -// -// protected int lineLength = 5; -// protected int textX = 5; -// protected int textY = 15; -// protected int arc = 5; + + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int arc = 5; protected String init = "i=0"; protected String condition = "i<5"; protected String increment = "i = i+1"; - // protected int stateOfError = 0; // Not yet checked + protected int stateOfError = 0; // Not yet checked public TMLADForLoop(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// width = 30; -// height = 20; -// minWidth = 30; + width = 30; + height = 20; + minWidth = 30; nbConnectingPoint = 3; connectingPoint = new TGConnectingPoint[3]; - connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop - connectingPoint[ INDEX_EXIT_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp -// -// moveable = true; -// editable = true; -// removable = true; + connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop + connectingPoint[2] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp + + moveable = true; + editable = true; + removable = true; makeValue(); name = "for loop"; - // myImageIcon = IconManager.imgic912; + myImageIcon = IconManager.imgic912; } - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -120,7 +110,7 @@ public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp //updateConnectingPoints(); } - if ( isEnabled() && stateOfError > 0 ) { + if (stateOfError > 0) { Color c = g.getColor(); switch(stateOfError) { case ErrorHighlight.OK: @@ -140,13 +130,13 @@ public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp g.drawString(value, x + (width - w) / 2 , y + textY); - // Info on loops - g.drawString(IN_LOOP, x+width+2, y+height/2); - //int wTmp = g.getFontMetrics().stringWidth(EXIT_LOOP); - g.drawString(EXIT_LOOP, x+width/2+2, y+height+10); + // Info on loops + g.drawString(IN_LOOP, x+width+2, y+height/2); + //int wTmp = g.getFontMetrics().stringWidth(EXIT_LOOP); + g.drawString(EXIT_LOOP, x+width/2+2, y+height+10); + } - @Override public boolean editOndoubleClick(JFrame frame) { String [] labels = new String[3]; String [] values = new String[3]; @@ -173,25 +163,26 @@ public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp } return false; + + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y-lineLength, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+width, y+height/2, x+width +lineLength, y+height/2, _x, _y)) < distanceSelected) { + return this; + } + + return null; } -// public TGComponent isOnMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+(width/2), y-lineLength, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+width, y+height/2, x+width +lineLength, y+height/2, _x, _y)) < distanceSelected) { -// return this; -// } -// -// return null; -// } - - private void makeValue() { + public void makeValue() { value = "for(" + init + ";" + condition + ";" + increment + ")"; } @@ -211,7 +202,6 @@ public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp return increment; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data init=\""); @@ -229,12 +219,16 @@ public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ // try { + NodeList nli; Node n1, n2; Element elt; // int k; // String s; + // + // + for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); // @@ -257,22 +251,23 @@ public class TMLADForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeValue(); } - @Override + public int getType() { return TGComponentManager.TMLAD_FOR_LOOP; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } -// -// public void setStateAction(int _stateAction) { -// stateOfError = _stateAction; -// } + + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } + + } diff --git a/src/main/java/ui/tmlad/TMLADForStaticLoop.java b/src/main/java/ui/tmlad/TMLADForStaticLoop.java index 5f38637077..1c85ff268f 100755 --- a/src/main/java/ui/tmlad/TMLADForStaticLoop.java +++ b/src/main/java/ui/tmlad/TMLADForStaticLoop.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; import ui.*; -import ui.ad.TADForLoop; import ui.util.IconManager; import javax.swing.*; @@ -54,51 +56,50 @@ import java.awt.geom.Line2D; * @version 1.0 21/11/2005 * @author Ludovic APVRILLE */ -public class TMLADForStaticLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { -// private final static String IN_LOOP = "inside loop"; -// private final static String EXIT_LOOP = "exit loop"; -// -// protected int lineLength = 5; -// protected int textX = 5; -// protected int textY = 15; -// protected int arc = 5; +public class TMLADForStaticLoop extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + private final static String IN_LOOP = "inside loop"; + private final static String EXIT_LOOP = "exit loop"; + + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int arc = 5; protected String valueLoop = ""; - //protected int stateOfError = 0; // Not yet checked + protected int stateOfError = 0; // Not yet checked public TMLADForStaticLoop(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// width = 30; -// height = 20; -// minWidth = 30; + width = 30; + height = 20; + minWidth = 30; nbConnectingPoint = 3; connectingPoint = new TGConnectingPoint[3]; - connectingPoint[ INDEX_ENTER_LOOP ] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[ INDEX_INSIDE_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop - connectingPoint[ INDEX_EXIT_LOOP ] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp + connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 1.0, 0.45); // loop + connectingPoint[2] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp -// moveable = true; -// editable = true; -// removable = true; + moveable = true; + editable = true; + removable = true; value = "10"; name = "for loop"; -// myImageIcon = IconManager.imgic912; + myImageIcon = IconManager.imgic912; } - private void makeValueLoop() { + public void makeValueLoop() { valueLoop = "Loop " + value + " times"; } - @Override public void internalDrawing(Graphics g) { + if (valueLoop.length() == 0) { makeValueLoop(); } - int w = g.getFontMetrics().stringWidth(valueLoop); int w1 = Math.max(minWidth, w + 2 * textX); if ((w1 != width) & (!tdp.isScaled())) { @@ -133,7 +134,6 @@ public class TMLADForStaticLoop extends TADForLoop /* Issue #69 TGCWithoutIntern } - @Override public boolean editOndoubleClick(JFrame frame) { String text = "Static for loop : "; String s = (String)JOptionPane.showInputDialog(frame, text, @@ -145,6 +145,8 @@ public class TMLADForStaticLoop extends TADForLoop /* Issue #69 TGCWithoutIntern s = s.trim(); } + // + if ((s != null) && (s.length() > 0) && (s.matches("\\d*"))) { setValue(s); makeValueLoop(); @@ -155,7 +157,6 @@ public class TMLADForStaticLoop extends TADForLoop /* Issue #69 TGCWithoutIntern return false; } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -172,17 +173,16 @@ public class TMLADForStaticLoop extends TADForLoop /* Issue #69 TGCWithoutIntern return null; } - @Override + public int getType() { return TGComponentManager.TMLAD_FOR_STATIC_LOOP; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } -// -// public void setStateAction(int _stateAction) { -// stateOfError = _stateAction; -// } + + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } } diff --git a/src/main/java/ui/tmlad/TMLADNotifiedEvent.java b/src/main/java/ui/tmlad/TMLADNotifiedEvent.java index 174ae7f502..c48a8ba848 100755 --- a/src/main/java/ui/tmlad/TMLADNotifiedEvent.java +++ b/src/main/java/ui/tmlad/TMLADNotifiedEvent.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; @@ -43,7 +46,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.ad.TADComponentWithoutSubcomponents; import ui.util.IconManager; import ui.window.JDialogMultiString; @@ -58,7 +60,7 @@ import java.awt.geom.Line2D; * @version 1.0 27/10/2006 * @author Ludovic APVRILLE */ -public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue #69TGCWithoutInternalComponent */ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADNotifiedEvent extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -92,7 +94,6 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue myImageIcon = IconManager.imgic904; } - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 3 * textX); @@ -146,7 +147,6 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue g.drawString(value, x + linebreak + textX1, y + textY); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -159,7 +159,7 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue return null; } - private void makeValue() { + public void makeValue() { value = result + "=?" + eventName + "()"; } @@ -180,7 +180,6 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue return value; } - @Override public boolean editOndoubleClick(JFrame frame) { String [] labels = new String[2]; String [] values = new String[2]; @@ -206,7 +205,6 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data eventName=\""); @@ -220,13 +218,18 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + // try { + NodeList nli; Node n1, n2; Element elt; // int k; // String s; + // + // + for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); // @@ -248,22 +251,23 @@ public class TMLADNotifiedEvent extends TADComponentWithoutSubcomponents/* Issue } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeValue(); } - @Override + public int getType() { return TGComponentManager.TMLAD_NOTIFIED_EVENT; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + + } diff --git a/src/main/java/ui/tmlad/TMLADRandom.java b/src/main/java/ui/tmlad/TMLADRandom.java index 45e41fe525..50879302ac 100755 --- a/src/main/java/ui/tmlad/TMLADRandom.java +++ b/src/main/java/ui/tmlad/TMLADRandom.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; @@ -43,7 +46,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.ad.TADComponentWithoutSubcomponents; import ui.util.IconManager; import ui.window.JDialogTMLADRandom; @@ -58,7 +60,7 @@ import java.awt.geom.Line2D; * @version 1.0 10/06/2008 * @author Ludovic APVRILLE */ -public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent */implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADRandom extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -95,12 +97,12 @@ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TG myImageIcon = IconManager.imgic912; } - private void makeValue() { + public void makeValue() { valueRandom = variable + " = RANDOM" + functionId + "(" + minValue + ", " + maxValue + ")"; } - @Override public void internalDrawing(Graphics g) { + if (valueRandom.length() == 0) { makeValue(); } @@ -134,7 +136,6 @@ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TG g.drawString(valueRandom, x + (width - w) / 2 , y + textY); } - @Override public boolean editOndoubleClick(JFrame frame) { boolean error = false; String errors = ""; @@ -190,7 +191,6 @@ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TG return true; } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -223,7 +223,6 @@ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TG return functionId; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data variable=\""); @@ -241,13 +240,18 @@ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TG @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + // try { + NodeList nli; Node n1, n2; Element elt; // int k; String s; + // + // + for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); // @@ -277,23 +281,23 @@ public class TMLADRandom extends TADComponentWithoutSubcomponents/* Issue #69 TG } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeValue(); } - @Override + public int getType() { return TGComponentManager.TMLAD_RANDOM; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + + } diff --git a/src/main/java/ui/tmlad/TMLADReadChannel.java b/src/main/java/ui/tmlad/TMLADReadChannel.java index 0e4ec24024..97b2a4358c 100755 --- a/src/main/java/ui/tmlad/TMLADReadChannel.java +++ b/src/main/java/ui/tmlad/TMLADReadChannel.java @@ -36,41 +36,26 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.tmlad; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.geom.Line2D; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.swing.JFrame; +package ui.tmlad; +import myutil.GraphicLib; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - -import myutil.GraphicLib; -import ui.AllowedBreakpoint; -import ui.BasicErrorHighlight; -import ui.CheckableAccessibility; -import ui.CheckableLatency; -import ui.ColorManager; -import ui.EmbeddedComment; -import ui.ErrorHighlight; -import ui.LinkedReference; -import ui.MalformedModelingException; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADComponentWithoutSubcomponents; +import ui.*; import ui.util.IconManager; +import ui.window.JDialogMultiString; +import myutil.*; import ui.window.JDialogMultiStringAndTabs; import ui.window.TabInfo; +import javax.swing.*; +import java.awt.*; +import java.awt.geom.Line2D; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; + /** * Class TMLADReadChannel * Action of writing data in channel @@ -79,8 +64,8 @@ import ui.window.TabInfo; * @author Ludovic APVRILLE * @version 1.0 21/11/2005 */ -public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements CheckableAccessibility, LinkedReference, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { - private Map<String, String> latencyVals; +public class TMLADReadChannel extends TGCWithoutInternalComponent implements CheckableAccessibility, LinkedReference, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + private ConcurrentHashMap<String, String> latencyVals; protected int lineLength = 5; protected int textX = 5; protected int textX0 = 2; @@ -132,17 +117,17 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # myImageIcon = IconManager.imgic906; latencyVals = new ConcurrentHashMap<String, String>(); //latencyVals.put("sendChannel: sensorData", "3"); + } /*public void addLatency(String name, String num){ latencyVals.put(name,num); }*/ - public Map<String, String> getLatencyMap() { + public ConcurrentHashMap<String, String> getLatencyMap() { return latencyVals; } - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -216,7 +201,7 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # } } - private void drawLatencyInformation(Graphics g) { + public void drawLatencyInformation(Graphics g) { int index = 1; for (String s : latencyVals.keySet()) { int w = g.getFontMetrics().stringWidth(s); @@ -228,8 +213,9 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # } } - private void drawReachabilityInformation(Graphics g) { + public void drawReachabilityInformation(Graphics g) { if (reachabilityInformation > 0) { + Color c = g.getColor(); Color c1; switch (reachabilityInformation) { @@ -256,7 +242,6 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # } } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -285,7 +270,6 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # return value; } - @Override public boolean editOndoubleClick(JFrame frame) { TabInfo tab1 = new TabInfo("Name and samples"); String[] labels = new String[2]; @@ -296,7 +280,7 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # values[1] = nbOfSamples; tab1.labels=labels; tab1.values = values; - List<String[]> help = new ArrayList<String[]>(); + ArrayList<String[]> help = new ArrayList<String[]>(); String[] allInChannels = tdp.getMGUI().getAllInChannels(); if (isAttacker) { allInChannels = tdp.getMGUI().getAllCompInChannels(); @@ -323,7 +307,7 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # tab2.values = values; tab2.help = help; - List<TabInfo> tabs = new ArrayList<>(); + ArrayList<TabInfo> tabs = new ArrayList<>(); tabs.add(tab1); tabs.add(tab2); @@ -344,6 +328,8 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # } return false; + + } public void setSamples(String sp) { @@ -351,7 +337,6 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # makeValue(); } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data channelName=\""); @@ -403,11 +388,12 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeValue(); } + public String getSecurityContext() { return securityContext; } @@ -420,22 +406,18 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # return isAttacker; } - @Override public int getType() { return TGComponentManager.TMLAD_READ_CHANNEL; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } - - public boolean getEncForm(){ + public boolean getEncForm(){ return isEncForm; } @@ -448,4 +430,5 @@ public class TMLADReadChannel extends TADComponentWithoutSubcomponents/* Issue # channelName = s; makeValue(); } + } diff --git a/src/main/java/ui/tmlad/TMLADReadRequestArg.java b/src/main/java/ui/tmlad/TMLADReadRequestArg.java index 89a6fd9601..f6d1b240b7 100755 --- a/src/main/java/ui/tmlad/TMLADReadRequestArg.java +++ b/src/main/java/ui/tmlad/TMLADReadRequestArg.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; @@ -43,7 +46,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.ad.TADComponentWithoutSubcomponents; import ui.util.IconManager; import ui.window.JDialogMultiString; @@ -58,7 +60,7 @@ import java.awt.geom.Line2D; * @version 1.0 11/02/201 * @author Ludovic APVRILLE */ -public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADReadRequestArg extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -150,8 +152,8 @@ public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issu return value; } - @Override public void internalDrawing(Graphics g) { + if (value.length() == 0) { makeValue(); } @@ -187,7 +189,6 @@ public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issu g.drawString(value, x + (width - w) / 2 , y + textY); } - @Override public boolean editOndoubleClick(JFrame frame) { String [] labels = new String[nParam]; String [] values = new String[nParam]; @@ -213,7 +214,6 @@ public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issu } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -255,6 +255,9 @@ public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issu int k; String s; + // + // + for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); // @@ -284,18 +287,18 @@ public class TMLADReadRequestArg extends TADComponentWithoutSubcomponents/* Issu makeValue(); } - @Override + public int getType() { return TGComponentManager.TMLAD_READ_REQUEST_ARG; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + + } diff --git a/src/main/java/ui/tmlad/TMLADSelectEvt.java b/src/main/java/ui/tmlad/TMLADSelectEvt.java index 693b65b583..8e48f75f1e 100755 --- a/src/main/java/ui/tmlad/TMLADSelectEvt.java +++ b/src/main/java/ui/tmlad/TMLADSelectEvt.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; import ui.*; -import ui.ad.TADComponentWithoutSubcomponents; import ui.util.IconManager; import java.awt.*; @@ -53,7 +55,7 @@ import java.awt.geom.Line2D; * @version 1.0 06/04/2007 * @author Ludovic APVRILLE */ -public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADSelectEvt extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { private int lineLength = 10; private int lineOutLength = 25; //private int textX1, textY1, textX2, textY2, textX3, textY3; @@ -94,8 +96,8 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 myImageIcon = IconManager.imgic208; } - @Override public void internalDrawing(Graphics g) { + if (stateOfError > 0) { Color c = g.getColor(); switch(stateOfError) { @@ -124,9 +126,9 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 //g.drawString("select", x, y + height/2 - 5); g.drawString("evt", x+7, y + height/2 + 3); + } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -151,27 +153,15 @@ public class TMLADSelectEvt extends TADComponentWithoutSubcomponents/* Issue #69 return null; } - @Override public int getType() { return TGComponentManager.TMLAD_SELECT_EVT; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } - - /* Issue #69 - * (non-Javadoc) - * @see ui.AbstractCDElement#canBeDisabled() - */ - @Override - public boolean canBeDisabled() { - return false; - } } diff --git a/src/main/java/ui/tmlad/TMLADSendEvent.java b/src/main/java/ui/tmlad/TMLADSendEvent.java index 9715bc1286..3d73447ce4 100755 --- a/src/main/java/ui/tmlad/TMLADSendEvent.java +++ b/src/main/java/ui/tmlad/TMLADSendEvent.java @@ -36,37 +36,22 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.tmlad; - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.geom.Line2D; -import java.util.ArrayList; -import java.util.List; -import javax.swing.JFrame; +package ui.tmlad; +import myutil.GraphicLib; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - -import myutil.GraphicLib; -import ui.AllowedBreakpoint; -import ui.BasicErrorHighlight; -import ui.CheckableAccessibility; -import ui.CheckableLatency; -import ui.ColorManager; -import ui.EmbeddedComment; -import ui.ErrorHighlight; -import ui.MalformedModelingException; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADComponentWithoutSubcomponents; +import ui.*; import ui.util.IconManager; import ui.window.JDialogMultiString; +import javax.swing.*; +import java.awt.*; +import java.awt.geom.Line2D; +import java.util.ArrayList; + /** * Class TMLADSendEvent * Action of sending an event @@ -75,7 +60,7 @@ import ui.window.JDialogMultiString; * @author Ludovic APVRILLE * @version 1.0 21/11/2005 */ -public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADSendEvent extends TGCWithoutInternalComponent implements CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -121,8 +106,8 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements myImageIcon = IconManager.imgic904; } - @Override public void internalDrawing(Graphics g) { + int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); if ((w1 != width) & (!tdp.isScaled())) { @@ -131,8 +116,7 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements } - // Issue #69 - if ( isEnabled() && stateOfError > 0) { + if (stateOfError > 0) { Color c = g.getColor(); switch (stateOfError) { case ErrorHighlight.OK: @@ -163,12 +147,7 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements int y1 = y + 1; int height1 = height; int width1 = width; - - // Issue #69 - if ( isEnabled() ) { - g.setColor(ColorManager.TML_PORT_EVENT); - } - + g.setColor(ColorManager.TML_PORT_EVENT); g.drawLine(x1, y1, x1 + width1 - linebreak, y1); g.drawLine(x1, y1 + height1, x1 + width1 - linebreak, y1 + height1); g.drawLine(x1, y1, x1, y1 + height1); @@ -187,9 +166,10 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements g.drawString(value, x + (width - w) / 2, y + textY); drawReachabilityInformation(g); + } - private void drawReachabilityInformation(Graphics g) { + public void drawReachabilityInformation(Graphics g) { if (reachabilityInformation > 0) { Color c = g.getColor(); @@ -214,7 +194,6 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements } } - // @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -227,7 +206,7 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements return null; } - private void makeValue() { + public void makeValue() { boolean first = true; value = eventName + "("; for (int i = 0; i < nParam; i++) { @@ -290,7 +269,6 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements return value; } - @Override public boolean editOndoubleClick(JFrame frame) { String[] labels = new String[nParam + 1]; String[] values = new String[nParam + 1]; @@ -300,8 +278,7 @@ public class TMLADSendEvent extends TADComponentWithoutSubcomponents implements labels[i + 1] = "Param #" + (i + 1); values[i + 1] = params[i]; } - - List<String[]> help = new ArrayList<String[]>(); + ArrayList<String[]> help = new ArrayList<String[]>(); String[] allOutEvents = tdp.getMGUI().getAllOutEvents(); help.add(allOutEvents); diff --git a/src/main/java/ui/tmlad/TMLADSendRequest.java b/src/main/java/ui/tmlad/TMLADSendRequest.java index 8bb62a0d90..4d1a9033b7 100755 --- a/src/main/java/ui/tmlad/TMLADSendRequest.java +++ b/src/main/java/ui/tmlad/TMLADSendRequest.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; @@ -43,17 +46,13 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.ad.TADComponentWithoutSubcomponents; import ui.util.IconManager; import ui.window.JDialogMultiString; import javax.swing.*; - -import java.awt.Color; -import java.awt.Graphics; +import java.awt.*; import java.awt.geom.Line2D; import java.util.ArrayList; -import java.util.List; /** * Class TMLADSendRequest @@ -62,7 +61,7 @@ import java.util.List; * @version 1.0 18/11/2005 * @author Ludovic APVRILLE */ -public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue #69TGCWithoutInternalComponent*/ implements CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADSendRequest extends TGCWithoutInternalComponent implements CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -108,7 +107,6 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # myImageIcon = IconManager.imgic902; } - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -159,11 +157,11 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # g.drawString("req", x+(width-w) / 2, y); g.drawString(value, x + (width - w) / 2 , y + textY); - drawReachabilityInformation(g); + drawReachabilityInformation(g); } - - private void drawReachabilityInformation(Graphics g) { + public void drawReachabilityInformation(Graphics g) { if (reachabilityInformation > 0) { + Color c = g.getColor(); Color c1; switch(reachabilityInformation) { @@ -183,10 +181,9 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # g.fillRect(x-12, y-7, 9, 7); g.setColor(c); g.drawRect(x-12, y-7, 9, 7); + } } - - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -221,6 +218,7 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # return requestName; } + public void setRequestName(String name){ requestName = name; makeValue(); @@ -265,7 +263,6 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # return value; } - @Override public boolean editOndoubleClick(JFrame frame) { String [] labels = new String[nParam + 1]; String [] values = new String[nParam + 1]; @@ -276,9 +273,9 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # values[i+1] = params[i]; } - List<String []> help = new ArrayList<String []>(); - String[] allOutRequests = tdp.getMGUI().getAllOutRequests(); - help.add(allOutRequests); + ArrayList<String []> help = new ArrayList<String []>(); + String[] allOutRequests = tdp.getMGUI().getAllOutRequests(); + help.add(allOutRequests); JDialogMultiString jdms = new JDialogMultiString(frame, "Setting request's properties", nParam+1, labels, values, help); // jdms.setSize(350, 300); @@ -296,9 +293,9 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # } return false; + } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data requestName=\""); @@ -329,6 +326,9 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # int k; String s; + // + // + for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); // @@ -354,23 +354,22 @@ public class TMLADSendRequest extends TADComponentWithoutSubcomponents/* Issue # } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeValue(); } - @Override + public int getType() { return TGComponentManager.TMLAD_SEND_REQUEST; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + } diff --git a/src/main/java/ui/tmlad/TMLADSequence.java b/src/main/java/ui/tmlad/TMLADSequence.java index c29c9d814c..ce9d380867 100755 --- a/src/main/java/ui/tmlad/TMLADSequence.java +++ b/src/main/java/ui/tmlad/TMLADSequence.java @@ -36,15 +36,16 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; -import ui.AllowedBreakpoint; -import ui.EmbeddedComment; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADSequence; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; /** * Class TMLADSequence @@ -53,71 +54,66 @@ import ui.ad.TADSequence; * @version 1.0 13/03/2006 * @author Ludovic APVRILLE */ -public class TMLADSequence extends TADSequence /* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint { - // private int lineLength = 0; - //private int textX, textY; +public class TMLADSequence extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint { + private int lineLength = 0; + private int textX, textY; public TMLADSequence(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// width = 150; -// height = 5; -// -// textX = width - 6; -// textY = height + 2; -// -// nbConnectingPoint = 6; -// connectingPoint = new TGConnectingPoint[6]; -// connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.167, 1.0); -// connectingPoint[2] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.333, 1.0); -// connectingPoint[3] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); -// connectingPoint[4] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.667, 1.0); -// connectingPoint[5] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.833, 1.0); -// -// nbInternalTGComponent = 1; -// tgcomponent = new TGComponent[nbInternalTGComponent]; -// -// TGCOneLineText tgc = new TGCOneLineText(x+textX + 10, y+textY, textX +10 , textX + 10 , textY, textY, true, this, _tdp); -// tgc.setValue(">>"); -// tgc.setName("Sequence"); -// tgc.setEditable(false); -// -// tgcomponent[0] = tgc; -// -// moveable = true; -// editable = false; -// removable = true; -// -// name = "sequence"; -// -// myImageIcon = IconManager.imgic206; - } - - @Override - protected void createConnectingPoints() { + + width = 150; + height = 5; + + textX = width - 6; + textY = height + 2; + nbConnectingPoint = 6; connectingPoint = new TGConnectingPoint[6]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.167, 1.0); + connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.167, 1.0); connectingPoint[2] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.333, 1.0); connectingPoint[3] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); connectingPoint[4] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.667, 1.0); connectingPoint[5] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.833, 1.0); + + nbInternalTGComponent = 1; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGCOneLineText tgc = new TGCOneLineText(x+textX + 10, y+textY, textX +10 , textX + 10 , textY, textY, true, this, _tdp); + tgc.setValue(">>"); + tgc.setName("Sequence"); + tgc.setEditable(false); + + tgcomponent[0] = tgc; + + moveable = true; + editable = false; + removable = true; + + name = "sequence"; + + myImageIcon = IconManager.imgic206; } -// public void internalDrawing(Graphics g) { -// g.drawRect(x, y, width, height); -// g.fillRect(x, y, width, height); -// } + public void internalDrawing(Graphics g) { + g.drawRect(x, y, width, height); + g.fillRect(x, y, width, height); + } - @Override + public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + return null; + } + public int getType() { return TGComponentManager.TMLAD_SEQUENCE; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } + } diff --git a/src/main/java/ui/tmlad/TMLADStartState.java b/src/main/java/ui/tmlad/TMLADStartState.java index 0fa07b1319..5e0e06b9d5 100755 --- a/src/main/java/ui/tmlad/TMLADStartState.java +++ b/src/main/java/ui/tmlad/TMLADStartState.java @@ -36,14 +36,17 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; -import ui.EmbeddedComment; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADStartState; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; +import java.awt.geom.Line2D; /** * Class TMLADStartState @@ -52,61 +55,53 @@ import ui.ad.TADStartState; * @version 1.0 28/10/2005 * @author Ludovic APVRILLE */ -public class TMLADStartState extends TADStartState /* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment{ +public class TMLADStartState extends TGCWithoutInternalComponent implements EmbeddedComment{ private int lineLength = 5; public TMLADStartState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// -// width = 15; -// height = 15; -// -// nbConnectingPoint = 1; -// connectingPoint = new TGConnectingPoint[1]; -// connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); -// -// nbInternalTGComponent = 0; -// -// moveable = true; -// editable = false; -// removable = true; -// -// name = "start state"; -// -// myImageIcon = IconManager.imgic222; - } - - @Override - protected void createConnectingPoints() { + + width = 15; + height = 15; + nbConnectingPoint = 1; connectingPoint = new TGConnectingPoint[1]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); + + nbInternalTGComponent = 0; + + moveable = true; + editable = false; + removable = true; + + name = "start state"; + + myImageIcon = IconManager.imgic222; } -// public void internalDrawing(Graphics g) { -// g.fillOval(x, y, width, height); -// g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); -// } -// -// public TGComponent isOnMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+(width/2), y+height, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { -// return this; -// } -// -// return null; -// } + public void internalDrawing(Graphics g) { + g.fillOval(x, y, width, height); + g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y+height, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { + return this; + } + + return null; + } - @Override public int getType() { return TGComponentManager.TMLAD_START_STATE; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } + } diff --git a/src/main/java/ui/tmlad/TMLADStopState.java b/src/main/java/ui/tmlad/TMLADStopState.java index 516a2dcdda..09cecbfca2 100755 --- a/src/main/java/ui/tmlad/TMLADStopState.java +++ b/src/main/java/ui/tmlad/TMLADStopState.java @@ -36,15 +36,16 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; -import ui.AllowedBreakpoint; -import ui.EmbeddedComment; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADStopState; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; /** * Class TMLADStopState @@ -53,59 +54,59 @@ import ui.ad.TADStopState; * @version 1.0 28/10/2005 * @author Ludovic APVRILLE */ -public class TMLADStopState extends TADStopState /* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint { -// private int internalCircleSize = 16; -// private int lineLength = 5; +public class TMLADStopState extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint { + private int internalCircleSize = 16; + private int lineLength = 5; public TMLADStopState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// -// width = 20; -// height = 20; -// -// nbConnectingPoint = 1; -// connectingPoint = new TGConnectingPoint[1]; -// connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, - lineLength, true, false, 0.5, 0.0); -// -// nbInternalTGComponent = 0; -// -// moveable = true; -// editable = false; -// removable = true; -// -// name = "stop state"; -// -// myImageIcon = IconManager.imgic210; + + width = 20; + height = 20; + + nbConnectingPoint = 1; + connectingPoint = new TGConnectingPoint[1]; + connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, - lineLength, true, false, 0.5, 0.0); + + nbInternalTGComponent = 0; + + moveable = true; + editable = false; + removable = true; + + name = "stop state"; + + myImageIcon = IconManager.imgic210; } - @Override - protected void createConnectingPoints() { - nbConnectingPoint = 1; - connectingPoint = new TGConnectingPoint[1]; - connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, - lineLength, true, false, 0.5, 0.0); + public void internalDrawing(Graphics g) { + ColorManager.setColor(g, state, 0); + g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); + g.drawOval(x, y, width, height); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + } + + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; } -// public void internalDrawing(Graphics g) { -// ColorManager.setColor(g, state, 0); -// g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); -// g.drawOval(x, y, width, height); -// g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); -// } -// -// -// public TGComponent isOnMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// return null; -// } - @Override public int getType() { return TGComponentManager.TMLAD_STOP_STATE; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } + } + + + + + + + diff --git a/src/main/java/ui/tmlad/TMLADUnorderedSequence.java b/src/main/java/ui/tmlad/TMLADUnorderedSequence.java index 0df1f8d927..aca4f9bd32 100755 --- a/src/main/java/ui/tmlad/TMLADUnorderedSequence.java +++ b/src/main/java/ui/tmlad/TMLADUnorderedSequence.java @@ -36,15 +36,16 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; -import ui.AllowedBreakpoint; -import ui.EmbeddedComment; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADSequence; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; /** * Class TMLADUnorderedSequence @@ -53,77 +54,66 @@ import ui.ad.TADSequence; * @version 1.0 07/07/2010 * @author Ludovic APVRILLE */ -public class TMLADUnorderedSequence extends TADSequence/* Issue #69 TGCWithInternalComponent*/ implements EmbeddedComment, AllowedBreakpoint { -// private int lineLength = 0; -// private int textX, textY; +public class TMLADUnorderedSequence extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint { + private int lineLength = 0; + private int textX, textY; public TMLADUnorderedSequence(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// width = 150; -// height = 5; -// -// textX = width - 6; -// textY = height + 2; -// -// nbConnectingPoint = 6; -// connectingPoint = new TGConnectingPoint[6]; -// connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.167, 1.0); -// connectingPoint[2] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.333, 1.0); -// connectingPoint[3] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); -// connectingPoint[4] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.667, 1.0); -// connectingPoint[5] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.833, 1.0); -// -// nbInternalTGComponent = 1; -// tgcomponent = new TGComponent[nbInternalTGComponent]; -// -// TGCOneLineText tgc = new TGCOneLineText(x+textX + 10, y+textY, textX +10 , textX + 10 , textY, textY, true, this, _tdp); -// tgc.setValue("<>"); -// tgc.setName("Random sequence"); -// tgc.setEditable(false); -// -// tgcomponent[0] = tgc; -// -// moveable = true; -// editable = false; -// removable = true; -// -// name = "random sequence"; -// -// myImageIcon = IconManager.imgic206; - } - - @Override - protected void createConnectingPoints() { + + width = 150; + height = 5; + + textX = width - 6; + textY = height + 2; + nbConnectingPoint = 6; connectingPoint = new TGConnectingPoint[6]; connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.167, 1.0); + connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.167, 1.0); connectingPoint[2] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.333, 1.0); connectingPoint[3] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.5, 1.0); connectingPoint[4] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.667, 1.0); connectingPoint[5] = new TGConnectingPointTMLAD(this, 0, lineLength, false, true, 0.833, 1.0); + + nbInternalTGComponent = 1; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGCOneLineText tgc = new TGCOneLineText(x+textX + 10, y+textY, textX +10 , textX + 10 , textY, textY, true, this, _tdp); + tgc.setValue("<>"); + tgc.setName("Random sequence"); + tgc.setEditable(false); + + tgcomponent[0] = tgc; + + moveable = true; + editable = false; + removable = true; + + name = "random sequence"; + + myImageIcon = IconManager.imgic206; + } + + public void internalDrawing(Graphics g) { + g.drawRect(x, y, width, height); + g.fillRect(x, y, width, height); } -// public void internalDrawing(Graphics g) { -// g.drawRect(x, y, width, height); -// g.fillRect(x, y, width, height); -// } -// public TGComponent isOnOnlyMe(int x1, int y1) { -// if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { -// return this; -// } -// return null; -// } + public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + return null; + } - @Override public int getType() { return TGComponentManager.TMLAD_UNORDERED_SEQUENCE; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLAD; + return TGComponentManager.CONNECTOR_TMLAD; } + } diff --git a/src/main/java/ui/tmlad/TMLADWaitEvent.java b/src/main/java/ui/tmlad/TMLADWaitEvent.java index ae17151b2d..91da01c216 100755 --- a/src/main/java/ui/tmlad/TMLADWaitEvent.java +++ b/src/main/java/ui/tmlad/TMLADWaitEvent.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlad; import myutil.GraphicLib; @@ -43,17 +46,13 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; -import ui.ad.TADComponentWithoutSubcomponents; import ui.util.IconManager; import ui.window.JDialogMultiString; import javax.swing.*; - -import java.awt.Color; -import java.awt.Graphics; +import java.awt.*; import java.awt.geom.Line2D; import java.util.ArrayList; -import java.util.List; /** * Class TMLADWaitEvent @@ -62,7 +61,7 @@ import java.util.List; * @version 1.0 21/11/2005 * @author Ludovic APVRILLE */ -public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADWaitEvent extends TGCWithoutInternalComponent implements CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -108,7 +107,6 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 myImageIcon = IconManager.imgic904; } - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -118,8 +116,7 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 //updateConnectingPoints(); } - // Issue #69 - if ( isEnabled() && stateOfError > 0) { + if (stateOfError > 0) { Color c = g.getColor(); switch(stateOfError) { case ErrorHighlight.OK: @@ -144,12 +141,7 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 int y1 = y + 1; int height1 = height; int width1 = width; - - // Issue #69 - if ( isEnabled() ) { - g.setColor(ColorManager.TML_PORT_EVENT); - } - + g.setColor(ColorManager.TML_PORT_EVENT); g.drawLine(x1, y1, x1+width1, y1); g.drawLine(x1+width1, y1, x1+width1, y1+height1); g.drawLine(x1, y1+height1, x1+width1, y1+height1); @@ -166,12 +158,12 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 g.drawString("evt", x+(width-w) / 2, y); g.drawString(value, x + linebreak + textX1, y + textY); - drawReachabilityInformation(g); + drawReachabilityInformation(g); + } + public void drawReachabilityInformation(Graphics g) { + if (reachabilityInformation > 0) { - private void drawReachabilityInformation(Graphics g) { - // Issue #69 - if ( isEnabled() && reachabilityInformation > 0 ) { Color c = g.getColor(); Color c1; switch(reachabilityInformation) { @@ -194,8 +186,6 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 } } - - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -226,6 +216,8 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 } + + public String getEventName() { return eventName; } @@ -276,7 +268,6 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 return value; } - @Override public boolean editOndoubleClick(JFrame frame) { String [] labels = new String[nParam + 1]; String [] values = new String[nParam + 1]; @@ -287,9 +278,9 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 values[i+1] = params[i]; } - List<String []> help = new ArrayList<String []>(); - String[] allInEvents = tdp.getMGUI().getAllInEvents(); - help.add(allInEvents); + ArrayList<String []> help = new ArrayList<String []>(); + String[] allInEvents = tdp.getMGUI().getAllInEvents(); + help.add(allInEvents); JDialogMultiString jdms = new JDialogMultiString(frame, "Setting event's properties", nParam+1, labels, values, help); // jdms.setSize(450, 300); @@ -310,7 +301,6 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data eventName=\""); @@ -369,23 +359,22 @@ public class TMLADWaitEvent extends TADComponentWithoutSubcomponents/* Issue #69 } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeValue(); } - @Override + public int getType() { return TGComponentManager.TMLAD_WAIT_EVENT; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + } diff --git a/src/main/java/ui/tmlad/TMLADWriteChannel.java b/src/main/java/ui/tmlad/TMLADWriteChannel.java index f38f4dedba..3eb3ca19ac 100755 --- a/src/main/java/ui/tmlad/TMLADWriteChannel.java +++ b/src/main/java/ui/tmlad/TMLADWriteChannel.java @@ -36,42 +36,26 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.tmlad; - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.geom.Line2D; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import javax.swing.JFrame; +package ui.tmlad; +import myutil.Conversion; +import myutil.GraphicLib; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - -import myutil.Conversion; -import myutil.GraphicLib; -import ui.AllowedBreakpoint; -import ui.BasicErrorHighlight; -import ui.CheckableAccessibility; -import ui.CheckableLatency; -import ui.ColorManager; -import ui.EmbeddedComment; -import ui.ErrorHighlight; -import ui.LinkedReference; -import ui.MalformedModelingException; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADComponentWithoutSubcomponents; +import ui.*; import ui.util.IconManager; +import ui.window.JDialogMultiString; import ui.window.JDialogMultiStringAndTabs; import ui.window.TabInfo; +import javax.swing.*; +import java.awt.*; +import java.awt.geom.Line2D; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; + /** * Class TMLADWriteChannel * Action of writting data in channel @@ -80,7 +64,7 @@ import ui.window.TabInfo; * @author Ludovic APVRILLE * @version 1.0 17/11/2005 */ -public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue #69 TGCWithoutInternalComponent*/ implements CheckableAccessibility, LinkedReference, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { +public class TMLADWriteChannel extends TGCWithoutInternalComponent implements CheckableAccessibility, LinkedReference, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -88,13 +72,15 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue protected int linebreak = 10; protected int decSec = 4; - private Map<String, String> latencyVals; + + private ConcurrentHashMap<String, String> latencyVals; protected int latencyX = 30; protected int latencyY = 25; protected int textWidth = 10; protected int textHeight = 20; + protected String channelName = "ch"; protected String nbOfSamples = "1"; protected String securityContext = ""; @@ -134,11 +120,10 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue latencyVals = new ConcurrentHashMap<String, String>(); } - public Map<String, String> getLatencyMap() { + public ConcurrentHashMap<String, String> getLatencyMap() { return latencyVals; } - @Override public void internalDrawing(Graphics g) { int w = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, w + 2 * textX); @@ -212,7 +197,7 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue drawReachabilityInformation(g); } - private void drawLatencyInformation(Graphics g) { + public void drawLatencyInformation(Graphics g) { int index = 1; for (String s : latencyVals.keySet()) { int w = g.getFontMetrics().stringWidth(s); @@ -224,11 +209,12 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue } } + public void addLatency(String name, String num) { latencyVals.put(name, num); } - private void drawReachabilityInformation(Graphics g) { + public void drawReachabilityInformation(Graphics g) { if (reachabilityInformation > 0) { Color c = g.getColor(); @@ -257,7 +243,6 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue } } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -297,7 +282,6 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue return value; } - @Override public boolean editOndoubleClick(JFrame frame) { TabInfo tab1 = new TabInfo("Name and samples"); String[] labels = new String[2]; @@ -311,7 +295,7 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue values[2] = securityContext; labels[3] = "Attacker?"; values[3] = isAttacker ? "Yes" : "No"; */ - List<String []> help = new ArrayList<String []>(); + ArrayList<String []> help = new ArrayList<String []>(); String[] allOutChannels = tdp.getMGUI().getAllOutChannels(); if (isAttacker){ allOutChannels =tdp.getMGUI().getAllCompOutChannels(); @@ -344,7 +328,7 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue tab2.values = values; tab2.help = help; - List<TabInfo> tabs = new ArrayList<>(); + ArrayList<TabInfo> tabs = new ArrayList<>(); tabs.add(tab1); tabs.add(tab2); @@ -363,13 +347,15 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue isEncForm = jdmsat.getString(1, 2).equals("Yes"); makeValue(); + + return true; } return false; + } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data channelName=\""); @@ -389,11 +375,16 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + // try { + NodeList nli; Node n1, n2; Element elt; + // + // + for (int i = 0; i < nl.getLength(); i++) { n1 = nl.item(i); // @@ -422,17 +413,16 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeValue(); } - @Override + public int getType() { return TGComponentManager.TMLAD_WRITE_CHANNEL; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLAD; } @@ -459,6 +449,7 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue securityContext = sc; } + public boolean isAttacker() { return isAttacker; } @@ -472,8 +463,8 @@ public class TMLADWriteChannel extends TADComponentWithoutSubcomponents/* Issue isEncForm=encForm; } - @Override public void setStateAction(int _stateAction) { stateOfError = _stateAction; } + } diff --git a/src/main/java/ui/tmlcompd/TMLCCompositeComponent.java b/src/main/java/ui/tmlcompd/TMLCCompositeComponent.java index 8c54b56633..3358c81e3f 100755 --- a/src/main/java/ui/tmlcompd/TMLCCompositeComponent.java +++ b/src/main/java/ui/tmlcompd/TMLCCompositeComponent.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlcompd; import myutil.GraphicLib; @@ -46,12 +49,8 @@ import ui.*; import ui.util.IconManager; import javax.swing.*; - -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics; +import java.awt.*; import java.util.ArrayList; -import java.util.List; import java.util.ListIterator; /** @@ -112,7 +111,6 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp myImageIcon = IconManager.imgic1200; } - @Override public void internalDrawing(Graphics g) { int w; int c; @@ -160,6 +158,7 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp currentFontSize = maxCurrentFontSize; displayText = currentFontSize >= minFontSize; + } // Zoom is assumed to be computed @@ -192,7 +191,6 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp } } - @Override public void rescale(double scaleFactor){ dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor; textX = (int)(dtextX); @@ -201,7 +199,6 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp super.rescale(scaleFactor); } - @Override public TGComponent isOnOnlyMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -209,7 +206,7 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp return null; } - @Override + public boolean editOndoubleClick(JFrame frame) { String s = (String)JOptionPane.showInputDialog(frame, "Name:", "Setting component name", JOptionPane.PLAIN_MESSAGE, IconManager.imgic100, @@ -236,27 +233,25 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp return false; } - @Override + public int getType() { return TGComponentManager.TMLCTD_CCOMPONENT; } - @Override public void wasSwallowed() { myColor = null; } - @Override public void wasUnswallowed() { myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + } - @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { - if (tgc instanceof TMLCCompositeComponent) { + if (tgc instanceof TMLCCompositeComponent) { return true; } @@ -273,9 +268,9 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp } return tgc instanceof TMLCCompositePort; + } - @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { boolean swallowed = false; @@ -337,7 +332,6 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp return true; } - @Override public void removeSwallowedTGComponent(TGComponent tgc) { // if (tgc instanceof TMLCCompositePort) { @@ -366,7 +360,8 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp } } - @Override + + public void hasBeenResized() { rescaled = true; for(int i=0; i<nbInternalTGComponent; i++) { @@ -392,7 +387,6 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp } } - @Override public void resizeWithFather() { if ((father != null) && ((father instanceof TMLCCompositeComponent) ||(father instanceof TMLCPrimitiveComponent))) { // Too large to fit in the father? -> resize it! @@ -403,8 +397,8 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp } } - public List<TMLCPrimitiveComponent> getAllPrimitiveComponents() { - List<TMLCPrimitiveComponent> ll = new ArrayList<TMLCPrimitiveComponent>(); + public java.util.List<TMLCPrimitiveComponent> getAllPrimitiveComponents() { + ArrayList<TMLCPrimitiveComponent> ll = new ArrayList<TMLCPrimitiveComponent>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLCCompositeComponent) { ll.addAll(((TMLCCompositeComponent)tgcomponent[i]).getAllPrimitiveComponents()); @@ -421,8 +415,8 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp return ll; } - public List<TMLCRecordComponent> getAllRecordComponents() { - List<TMLCRecordComponent> ll = new ArrayList<TMLCRecordComponent>(); + public ArrayList<TMLCRecordComponent> getAllRecordComponents() { + ArrayList<TMLCRecordComponent> ll = new ArrayList<TMLCRecordComponent>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLCCompositeComponent) { ll.addAll(((TMLCCompositeComponent)tgcomponent[i]).getAllRecordComponents()); @@ -439,7 +433,7 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp return ll; } - public void getAllCompositeComponents( List<String> list, String _name) { + public void getAllCompositeComponents(ArrayList<String> list, String _name) { String s; TMLCCompositeComponent tmlcc; for(int i=0; i<nbInternalTGComponent; i++) { @@ -452,8 +446,8 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp } } - public List<TMLCCompositePort> getAllInternalCompositePorts() { - List<TMLCCompositePort> list = new ArrayList<TMLCCompositePort>(); + public ArrayList<TMLCCompositePort> getAllInternalCompositePorts() { + ArrayList<TMLCCompositePort> list = new ArrayList<TMLCCompositePort>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLCCompositeComponent) { list.addAll(((TMLCCompositeComponent)tgcomponent[i]).getAllInternalCompositePorts()); @@ -469,8 +463,8 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp return list; } - public List<TMLCCompositePort> getAllReferencedCompositePorts() { - List<TMLCCompositePort> list = new ArrayList<TMLCCompositePort>(); + public ArrayList<TMLCCompositePort> getAllReferencedCompositePorts() { + ArrayList<TMLCCompositePort> list = new ArrayList<TMLCCompositePort>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLCCompositeComponent) { list.addAll(((TMLCCompositeComponent)tgcomponent[i]).getAllReferencedCompositePorts()); @@ -483,8 +477,8 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp return list; } - public List<TMLCCompositePort> getFirstLevelCompositePorts() { - List<TMLCCompositePort> list = new ArrayList<TMLCCompositePort>(); + public ArrayList<TMLCCompositePort> getFirstLevelCompositePorts() { + ArrayList<TMLCCompositePort> list = new ArrayList<TMLCCompositePort>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLCCompositePort) { list.add((TMLCCompositePort)(tgcomponent[i])); @@ -494,8 +488,8 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp return list; } - public List<TMLCPrimitivePort> getAllInternalPrimitivePorts() { - List<TMLCPrimitivePort> list = new ArrayList<TMLCPrimitivePort>(); + public ArrayList<TMLCPrimitivePort> getAllInternalPrimitivePorts() { + ArrayList<TMLCPrimitivePort> list = new ArrayList<TMLCPrimitivePort>(); for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLCCompositeComponent) { @@ -546,7 +540,6 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp return null; } - @Override public void setInternalsHidden(boolean hide) { hiddeni = hide; for(int i=0; i<nbInternalTGComponent; i++) { @@ -560,22 +553,20 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp } } - @Override public boolean areInternalsHidden() { return hiddeni; } -// -// private void drawInternalComponentsWhenHidden(Graphics g) { -// // -// for(int i=0; i<nbInternalTGComponent; i++) { -// if (tgcomponent[i] instanceof TMLCCompositePort) { -// //ColorManager.setColor(g, tgcomponent[i].getState(), 0); -// tgcomponent[i].draw(g); -// } -// } -// } + + public void drawInternalComponentsWhenHidden(Graphics g) { + // + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof TMLCCompositePort) { + //ColorManager.setColor(g, tgcomponent[i].getState(), 0); + tgcomponent[i].draw(g); + } + } + } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<info hiddeni=\"" + hiddeni + "\" "); @@ -586,7 +577,9 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + // try { + NodeList nli; Node n1, n2; Element elt; @@ -614,11 +607,10 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } } - @Override public void drawTGConnectingPoint(Graphics g, int type) { // for (int i=0; i<nbConnectingPoint; i++) { @@ -708,4 +700,5 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp return false; } + } diff --git a/src/main/java/ui/tmlcompd/TMLCRemoteCompositeComponent.java b/src/main/java/ui/tmlcompd/TMLCRemoteCompositeComponent.java index 0eb38b932d..64474151ca 100755 --- a/src/main/java/ui/tmlcompd/TMLCRemoteCompositeComponent.java +++ b/src/main/java/ui/tmlcompd/TMLCRemoteCompositeComponent.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlcompd; import myutil.GraphicLib; @@ -48,12 +51,8 @@ import ui.util.IconManager; import ui.window.JDialogTMLRemoteCompositeComponent; import javax.swing.*; - -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics; +import java.awt.*; import java.util.ArrayList; -import java.util.List; /** * Class TMLCRemoteCompositeComponent @@ -138,7 +137,6 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone } } - @Override public void internalDrawing(Graphics g) { int w; int c; @@ -260,7 +258,6 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone } } - @Override public void rescale(double scaleFactor){ dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor; textX = (int)(dtextX); @@ -273,7 +270,6 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone super.rescale(scaleFactor); } - @Override public TGComponent isOnOnlyMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -281,7 +277,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone return null; } - @Override + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { // On the icon? @@ -320,7 +316,6 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone return false; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); @@ -359,7 +354,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone TMLCRemotePortCompositeComponent pcc; TGConnectingPoint[] old = null; - List<TMLCCompositePort> tmp = null; + ArrayList<TMLCCompositePort> tmp = null; //ArrayList<TMLCReferencePortConnectingPoint> points = new ArrayList<TMLCReferencePortConnectingPoint>(); for(int i=0; i<nl.getLength(); i++) { @@ -463,30 +458,29 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone ((TMLComponentTaskDiagramPanel)getTDiagramPanel()).makePaths(); } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } } - @Override + public int getType() { return TGComponentManager.TMLCTD_CREMOTECOMPONENT; } - @Override public void wasSwallowed() { myColor = null; } - @Override public void wasUnswallowed() { myColor = null; setFather(null); TDiagramPanel tdp = getTDiagramPanel(); setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + } - @Override + public void hasBeenResized() { rescaled = true; /*for(int i=0; i<nbInternalTGComponent; i++) { @@ -506,7 +500,6 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone } } - @Override public void resizeWithFather() { if ((father != null) && ((father instanceof TMLCCompositeComponent) ||(father instanceof TMLCPrimitiveComponent))) { // Too large to fit in the father? -> resize it! @@ -517,30 +510,30 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone } } - public List<TMLCPrimitiveComponent> getAllPrimitiveComponents() { + public java.util.List<TMLCPrimitiveComponent> getAllPrimitiveComponents() { if (tmlcc == null) { return new ArrayList<TMLCPrimitiveComponent>(); } return tmlcc.getAllPrimitiveComponents(); } - public List<TMLCRecordComponent> getAllRecordComponents() { + public java.util.List<TMLCRecordComponent> getAllRecordComponents() { if (tmlcc == null) { return new ArrayList<TMLCRecordComponent>(); } return tmlcc.getAllRecordComponents(); } - public List<TMLCCompositePort> getAllInternalCompositePorts() { - List<TMLCCompositePort> list = new ArrayList<TMLCCompositePort>(); + public java.util.List<TMLCCompositePort> getAllInternalCompositePorts() { + java.util.List<TMLCCompositePort> list = new ArrayList<TMLCCompositePort>(); if (tmlcc == null) { return list; } return tmlcc.getAllInternalCompositePorts(); } - public List<TMLCPrimitivePort> getAllInternalPrimitivePorts() { - List<TMLCPrimitivePort> list = new ArrayList<TMLCPrimitivePort>(); + public ArrayList<TMLCPrimitivePort> getAllInternalPrimitivePorts() { + ArrayList<TMLCPrimitivePort> list = new ArrayList<TMLCPrimitivePort>(); if (tmlcc == null) { return list; } @@ -580,7 +573,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone // to a list of those points, keep that list, and then, generate a array of those points. public void updatePorts() { //TraceManager.addDev("Update my ports"); - List<TMLCCompositePort> list = tmlcc.getFirstLevelCompositePorts(); + ArrayList<TMLCCompositePort> list = tmlcc.getFirstLevelCompositePorts(); int cpt=0; /*TraceManager.addDev("list size:" + list.size()); @@ -611,7 +604,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone if (change) { TraceManager.addDev("change on ports!"); // Delete unused ports and - List<TMLCReferencePortConnectingPoint> points = new ArrayList<TMLCReferencePortConnectingPoint>(); + ArrayList<TMLCReferencePortConnectingPoint> points = new ArrayList<TMLCReferencePortConnectingPoint>(); cpt=0; for(i=0; i<ports.size(); i++) { @@ -706,6 +699,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone int i; //TraceManager.addDev("name= " + name + " nbCP=" + nbConnectingPoint + " num=" + num + "id=" + id); try { + if (connectingPoint == null) { nbConnectingPoint = num + 1; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; @@ -787,13 +781,11 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone } }*/ - @Override public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof TMLCRemotePortCompositeComponent; } - @Override public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { if (!acceptSwallowedTGComponent(tgc)) { return false; @@ -807,7 +799,6 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone return true; } - @Override public void removeSwallowedTGComponent(TGComponent tgc) { } @@ -825,4 +816,5 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone public TMLCCompositeComponent getReference() { return tmlcc; } + } diff --git a/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java b/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java index 6bff480451..58a7adaf1d 100755 --- a/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java +++ b/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java @@ -37,8 +37,10 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.tmlcompd; + import myutil.TraceManager; import org.w3c.dom.Element; import ui.*; @@ -64,7 +66,6 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi //setAttributesVisible(true); } - @Override public boolean actionOnDoubleClick(TGComponent tgc) { /*TraceManager.addDev("Action on double click!"); if (tgc instanceof TMLCPrimitiveComponent) { @@ -76,7 +77,6 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi return false; } - @Override public boolean actionOnAdd(TGComponent tgc) { //TraceManager.addDev("Action on add! value=" + tgc.getValue()); if (tgc instanceof TMLCPrimitiveComponent) { @@ -98,7 +98,6 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi return true; } - @Override public boolean actionOnRemove(TGComponent tgc) { //TraceManager.addDev("Action on remove tgc=" + tgc + " value=" + tgc.getValue()); if (tgc instanceof TMLCPrimitiveComponent) { @@ -168,7 +167,6 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi return ports; } - @Override public boolean actionOnValueChanged(TGComponent tgc) { //TraceManager.addDev("Action on value changed on component:" + tgc); if (tgc instanceof TMLCPrimitiveComponent) { @@ -197,6 +195,21 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi return ko ? ko : nameAllRecordComponentInUse(oldValue, newValue); } + /** + * Check if newvalue is already a name of a component. + * + * @param newvalue + * @return true if the name is used + * @author Fabien Tessier + */ + public boolean isCompositeNameUsed(String newvalue) { + for (TGComponent tgc : this.componentList) { + if (tgc.getValue().equals(newvalue)) + return true; + } + return false; + } + public boolean nameAllRecordComponentInUse(String oldValue, String newValue) { // LinkedList ll = getRecordComponentList(); Iterator<TMLCRecordComponent> iterator = getRecordComponentList().listIterator(); @@ -213,8 +226,8 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi return false; } - public List<TMLCRecordComponent> getRecordComponentList() { - List<TMLCRecordComponent> ll = new LinkedList<TMLCRecordComponent>(); + public LinkedList<TMLCRecordComponent> getRecordComponentList() { + LinkedList<TMLCRecordComponent> ll = new LinkedList<TMLCRecordComponent>(); TGComponent tgc; Iterator<TGComponent> iterator = componentList.listIterator(); @@ -459,6 +472,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi return al; } + public void getAllPortsConnectedTo(List<TGComponent> ll, TMLCPrimitivePort _port) { List<TGComponent> components = getMGUI().getAllTMLComponents(); Iterator<TGComponent> iterator = components.listIterator(); @@ -500,40 +514,36 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi } } - @Override public String getXMLHead() { return "<TMLComponentTaskDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + zoomParam() + " >"; } - @Override public String getXMLTail() { return "</TMLComponentTaskDiagramPanel>"; } - @Override public String getXMLSelectedHead() { return "<TMLComponentTaskDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } - @Override public String getXMLSelectedTail() { return "</TMLComponentTaskDiagramPanelCopy>"; } - @Override public String getXMLCloneHead() { return "<TMLComponentTaskDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } - @Override public String getXMLCloneTail() { return "</TMLComponentTaskDiagramPanelCopy>"; } + public boolean areAttributesVisible() { return attributesVisible; } + public boolean areChannelVisible() { return synchroVisible; } @@ -542,6 +552,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi attributesVisible = b; } + public void setChannelVisible(boolean b) { channelVisible = b; } @@ -601,8 +612,8 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi } } - public List<String> getAllCompositeComponent(String _name) { - List<String> list = new ArrayList<String>(); + public ArrayList<String> getAllCompositeComponent(String _name) { + ArrayList<String> list = new ArrayList<String>(); TGComponent tgc1; String s; TMLCCompositeComponent tmlcc; @@ -639,7 +650,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi TGComponent tgc; Iterator<TGComponent> iterator = componentList.listIterator(); // List<String> list = new ArrayList<String>(); - //TMLCPrimitiveComponent tmp; + TMLCPrimitiveComponent tmp; while (iterator.hasNext()) { tgc = iterator.next(); @@ -663,7 +674,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi TGComponent tgc; Iterator<TGComponent> iterator = componentList.listIterator(); // List<String> list = new ArrayList<String>(); - //TMLCPrimitiveComponent tmp; + TMLCPrimitiveComponent tmp; while (iterator.hasNext()) { tgc = iterator.next(); @@ -682,6 +693,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi return chlArray; } + public TMLCPrimitiveComponent getPrimitiveComponentByName(String _name) { TGComponent tgc; Iterator<TGComponent> iterator = componentList.listIterator(); @@ -981,10 +993,10 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi } // Returns the faulty paths - public List<TMLCPath> updatePorts() { + public ArrayList<TMLCPath> updatePorts() { //TraceManager.addDev("Making paths"); List<TMLCPath> paths = makePaths(); - List<TMLCPath> faultyPaths = new ArrayList<TMLCPath>(); + ArrayList<TMLCPath> faultyPaths = new ArrayList<TMLCPath>(); //String error = ""; // Checking rules of paths, and setting colors accordingly @@ -1067,7 +1079,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi } // We take each primitive ports individually and we go thru the graph - List<TMLCChannelFacility> mets = new ArrayList<TMLCChannelFacility>(); + ArrayList<TMLCChannelFacility> mets = new ArrayList<TMLCChannelFacility>(); TGConnector connector; TGConnectingPoint tp; String conflictMessage; @@ -1092,7 +1104,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi } } - public String propagate(TMLCPrimitivePort pport, TGConnectingPoint tp, TGConnector connector, List<TMLCChannelFacility> mets) { + public String propagate(TMLCPrimitivePort pport, TGConnectingPoint tp, TGConnector connector, ArrayList<TMLCChannelFacility> mets) { TGConnectingPoint tp2; TMLCChannelFacility cp = null; //boolean conflict = false; @@ -1271,7 +1283,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi return conflictMessage; } - public String explore(TMLCPrimitivePort pport, TGConnectingPoint _tp, TMLCChannelFacility cp, List<TMLCChannelFacility> mets) { + public String explore(TMLCPrimitivePort pport, TGConnectingPoint _tp, TMLCChannelFacility cp, ArrayList<TMLCChannelFacility> mets) { String conflictMessage = null; String conflictMessageTmp; TGConnectingPoint tp; @@ -1293,7 +1305,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi return conflictMessage; } - public void analysePorts(TMLCPrimitivePort pport, List<TMLCChannelFacility> mets, boolean conflict, String message) { + public void analysePorts(TMLCPrimitivePort pport, ArrayList<TMLCChannelFacility> mets, boolean conflict, String message) { if (mets.size() == 0) { return; } @@ -1520,9 +1532,11 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi for (TDiagramPanel panel : panels) { iterator = panel.getComponentList().listIterator(); + List<TMLCCompositePort> listcp; List<TMLCPrimitivePort> listpp; + while (iterator.hasNext()) { tgc = iterator.next(); @@ -1632,6 +1646,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi return paths; + } public TMLCPath getPathOf(List<TMLCPath> paths, TGComponent tgc) { @@ -1660,7 +1675,8 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi paths.add(ph); } - public void getPanelsUsingAComponent(TMLCCompositeComponent tmlcc, List<TMLComponentTaskDiagramPanel> panels) { + + public void getPanelsUsingAComponent(TMLCCompositeComponent tmlcc, ArrayList<TMLComponentTaskDiagramPanel> panels) { //TraceManager.addDev("Update from " + tmlcc.getValue()); Iterator<TGComponent> iterator = componentList.listIterator(); TGComponent tgc; @@ -1683,6 +1699,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi } } + public String[] getAllOutEvents(String nameOfComponent) { TMLCPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent); if (comp == null) { @@ -1690,7 +1707,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi } List<TMLCPrimitivePort> ll = comp.getAllEventsOriginPorts(); - List<String> lString = new LinkedList<>(); + LinkedList<String> lString = new LinkedList<>(); //String[] terms = new String[ll.size()]; diff --git a/src/main/java/ui/tmlcp/TGConnectingPointTMLCP.java b/src/main/java/ui/tmlcp/TGConnectingPointTMLCP.java index 7e071398c9..311de473ad 100755 --- a/src/main/java/ui/tmlcp/TGConnectingPointTMLCP.java +++ b/src/main/java/ui/tmlcp/TGConnectingPointTMLCP.java @@ -36,8 +36,12 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlcp; + import ui.CDElement; import ui.TGComponentManager; import ui.TGConnectingPointWidthHeight; @@ -50,12 +54,13 @@ import ui.TGConnectingPointWidthHeight; * @author Ludovic APVRILLE */ public class TGConnectingPointTMLCP extends TGConnectingPointWidthHeight{ + + public TGConnectingPointTMLCP(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); } - @Override public boolean isCompatibleWith(int type) { // if (type == TGComponentManager.CONNECTOR_TMLCP) { diff --git a/src/main/java/ui/tmlcp/TGConnectorTMLCP.java b/src/main/java/ui/tmlcp/TGConnectorTMLCP.java index 4bcca5ef62..71b38e664c 100755 --- a/src/main/java/ui/tmlcp/TGConnectorTMLCP.java +++ b/src/main/java/ui/tmlcp/TGConnectorTMLCP.java @@ -36,11 +36,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlcp; import myutil.GraphicLib; import ui.*; -import ui.ad.TADConnector; import ui.util.IconManager; import java.awt.*; @@ -54,7 +56,7 @@ import java.util.Vector; * @version 1.0 17/02/2014 * @author Ludovic APVRILLE */ -public class TGConnectorTMLCP extends TADConnector /* Issue #69 TGConnector*/ { +public class TGConnectorTMLCP extends TGConnector { protected int arrowLength = 10; protected String guard = ""; @@ -63,12 +65,12 @@ public class TGConnectorTMLCP extends TADConnector /* Issue #69 TGConnector*/ { myImageIcon = IconManager.imgic202; name = "connector"; - _p1.setReferenceToConnector( this ); - _p2.setReferenceToConnector( this ); + _p1.setReferenceToConnector( this ); + _p2.setReferenceToConnector( this ); + //editable = true; } - @Override protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { g.drawLine(x1, y1, x2, y2); @@ -77,7 +79,6 @@ public class TGConnectorTMLCP extends TADConnector /* Issue #69 TGConnector*/ { } } - @Override public int getType() { return TGComponentManager.CONNECTOR_TMLCP; } @@ -94,4 +95,5 @@ public class TGConnectorTMLCP extends TADConnector /* Issue #69 TGConnector*/ { } return "noGuard"; } + }//End of class diff --git a/src/main/java/ui/tmlcp/TMLCPChoice.java b/src/main/java/ui/tmlcp/TMLCPChoice.java index 9e9ea5db97..8b55369d70 100755 --- a/src/main/java/ui/tmlcp/TMLCPChoice.java +++ b/src/main/java/ui/tmlcp/TMLCPChoice.java @@ -37,13 +37,18 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlcp; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADChoice; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; +import java.awt.geom.Line2D; +import java.util.ArrayList; /** * Class TMLCPChoice @@ -52,10 +57,10 @@ import ui.ad.TADChoice; * @version 1.0 17/02/2014 * @author Ludovic APVRILLE, Andrea ENRICI */ -public class TMLCPChoice extends TADChoice /* Issue #69 TGCWithInternalComponent*/ { -// private int lineLength = 10; -// private int lineOutLength = 25; -// private int textX1, textY1, textX2, textY2, textX3, textY3; +public class TMLCPChoice extends TGCWithInternalComponent { + private int lineLength = 10; + private int lineOutLength = 25; + private int textX1, textY1, textX2, textY2, textX3, textY3; private static int instanceCounter = 0; private int counter = 0; @@ -63,161 +68,151 @@ public class TMLCPChoice extends TADChoice /* Issue #69 TGCWithInternalComponent public TMLCPChoice(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// width = 30; -// height = 30; -// textX1 = -lineOutLength; -// textY1 = height/2 - 5; -// textX2 = width + 5; -// textY2 = height/2 - 5; -// textX3 = width /2 + 5; -// textY3 = height + 15; -// -// nbConnectingPoint = 4; -// connectingPoint = new TGConnectingPoint[nbConnectingPoint]; -// connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); -// connectingPoint[1] = new TGConnectingPointTMLCP(this, -lineOutLength, 0, false, true, 0.0, 0.5); -// connectingPoint[2] = new TGConnectingPointTMLCP(this, lineOutLength, 0, false, true, 1.0, 0.5); -// connectingPoint[3] = new TGConnectingPointTMLCP(this, 0, lineOutLength, false, true, 0.5, 1.0); + width = 30; + height = 30; + textX1 = -lineOutLength; + textY1 = height/2 - 5; + textX2 = width + 5; + textY2 = height/2 - 5; + textX3 = width /2 + 5; + textY3 = height + 15; + + nbConnectingPoint = 4; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointTMLCP(this, -lineOutLength, 0, false, true, 0.0, 0.5); + connectingPoint[2] = new TGConnectingPointTMLCP(this, lineOutLength, 0, false, true, 1.0, 0.5); + connectingPoint[3] = new TGConnectingPointTMLCP(this, 0, lineOutLength, false, true, 0.5, 1.0); addTGConnectingPointsComment(); //nbInternalTGComponent = 0; -// nbInternalTGComponent = 3; -// tgcomponent = new TGComponent[nbInternalTGComponent]; -// -// TGCOneLineText tgc = new TGCOneLineText(x+textX1, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 1"); -// tgcomponent[0] = tgc; -// -// tgc = new TGCOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 2"); -// tgcomponent[1] = tgc; -// -// tgc = new TGCOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, _tdp); -// tgc.setValue("[ ]"); -// tgc.setName("guard 3"); -// tgcomponent[2] = tgc; -// -// moveable = true; -// editable = false; -// removable = true; + nbInternalTGComponent = 3; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGCOneLineText tgc = new TGCOneLineText(x+textX1, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 1"); + tgcomponent[0] = tgc; + + tgc = new TGCOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 2"); + tgcomponent[1] = tgc; + + tgc = new TGCOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 3"); + tgcomponent[2] = tgc; + + moveable = true; + editable = false; + removable = true; instanceCounter++; counter = instanceCounter; name = "choice" + Integer.toString(counter); - // myImageIcon = IconManager.imgic208; + myImageIcon = IconManager.imgic208; + } + + public void internalDrawing(Graphics g) { + g.drawLine(x+(width/2), y, x+width, y + height/2); + g.drawLine(x, y + height / 2, x+width/2, y + height); + g.drawLine(x + width/2, y, x, y + height/2); + g.drawLine(x + width, y + height/2, x + width/2, y + height); + + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x, y + height/2, x-lineOutLength, y + height/2); + g.drawLine(x + width, y + height/2, x+ width + lineOutLength, y + height/2); + g.drawLine(x+(width/2), y + height, x+(width/2), y + height + lineOutLength); + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + // horizontal line + if ((int)(Line2D.ptSegDistSq(x+(width/2), y + height, x+(width/2), y + height + lineOutLength, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x + width, y + height/2, x+ width + lineOutLength, y + height/2, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x, y + height/2, x-lineOutLength, y + height/2, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y, x+(width/2), y - lineLength, _x, _y)) < distanceSelected) { + return this; + } + + return null; } - - @Override - protected void createConnectingPoints() { - nbConnectingPoint = 4; - connectingPoint = new TGConnectingPoint[nbConnectingPoint]; - connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); - connectingPoint[1] = new TGConnectingPointTMLCP(this, -lineOutLength, 0, false, true, 0.0, 0.5); - connectingPoint[2] = new TGConnectingPointTMLCP(this, lineOutLength, 0, false, true, 1.0, 0.5); - connectingPoint[3] = new TGConnectingPointTMLCP(this, 0, lineOutLength, false, true, 0.5, 1.0); - } -// -// public void internalDrawing(Graphics g) { -// g.drawLine(x+(width/2), y, x+width, y + height/2); -// g.drawLine(x, y + height / 2, x+width/2, y + height); -// g.drawLine(x + width/2, y, x, y + height/2); -// g.drawLine(x + width, y + height/2, x + width/2, y + height); -// -// g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); -// g.drawLine(x, y + height/2, x-lineOutLength, y + height/2); -// g.drawLine(x + width, y + height/2, x+ width + lineOutLength, y + height/2); -// g.drawLine(x+(width/2), y + height, x+(width/2), y + height + lineOutLength); -// } -// -// public TGComponent isOnOnlyMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// -// // horizontal line -// if ((int)(Line2D.ptSegDistSq(x+(width/2), y + height, x+(width/2), y + height + lineOutLength, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x + width, y + height/2, x+ width + lineOutLength, y + height/2, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x, y + height/2, x-lineOutLength, y + height/2, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+(width/2), y, x+(width/2), y - lineLength, _x, _y)) < distanceSelected) { -// return this; -// } -// -// return null; -// } - - @Override + public int getType() { return TGComponentManager.TMLCP_CHOICE; } -// -// public String getGuard(int i) { -// if ((i>=0) && (i<nbInternalTGComponent)) { -// // -// return tgcomponent[i].getValue(); -// } -// return ""; -// } -// -// public ArrayList<String> getGuards() { -// -// ArrayList<String> guards = new ArrayList<String>(); -// for( int i = 0; i < nbInternalTGComponent; i++ ) { -// guards.add( getGuard(i) ); -// } -// return guards; -// } -// -// public boolean hasUnvalidGuards() { -// return (getUnvalidGuards() != null); -// } -// -// public String getUnvalidGuards() { -// String s, g; -// int index; -// for(int i=0; i<nbInternalTGComponent; i++) { -// s = getGuard(i); -// g = s; -// if ((s.compareTo("[]") != 0) && (s.compareTo("[ ]") != 0)) { -// index = s.indexOf('/'); -// if (index == -1) { -// return g; -// } -// s = s.substring(1, index); -// s = s.trim(); -// // -// if (!TAttribute.isAValidId(s, false, false)) { -// //if (!s.matches("(\\w)+*(\\s)*")) { -// return g; -// } -// } -// } -// -// return null; -// } - - @Override + + public String getGuard(int i) { + if ((i>=0) && (i<nbInternalTGComponent)) { + // + return tgcomponent[i].getValue(); + } + return ""; + } + + public ArrayList<String> getGuards() { + + ArrayList<String> guards = new ArrayList<String>(); + for( int i = 0; i < nbInternalTGComponent; i++ ) { + guards.add( getGuard(i) ); + } + return guards; + } + + public boolean hasUnvalidGuards() { + return (getUnvalidGuards() != null); + } + + public String getUnvalidGuards() { + String s, g; + int index; + for(int i=0; i<nbInternalTGComponent; i++) { + s = getGuard(i); + g = s; + if ((s.compareTo("[]") != 0) && (s.compareTo("[ ]") != 0)) { + index = s.indexOf('/'); + if (index == -1) { + return g; + } + s = s.substring(1, index); + s = s.trim(); + // + if (!TAttribute.isAValidId(s, false, false)) { + //if (!s.matches("(\\w)+*(\\s)*")) { + return g; + } + } + } + + return null; + } + public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLCP; } -// -// public TGConnectingPoint[] getConnectingPoints() { -// return connectingPoint; -// } -// -// public TGComponent[] getTGComponents() { -// return tgcomponent; -// } + + + + public TGConnectingPoint[] getConnectingPoints() { + return connectingPoint; + } + + public TGComponent[] getTGComponents() { + return tgcomponent; + } } diff --git a/src/main/java/ui/tmlcp/TMLCPForLoop.java b/src/main/java/ui/tmlcp/TMLCPForLoop.java index 5a2e19156d..923246f4b9 100755 --- a/src/main/java/ui/tmlcp/TMLCPForLoop.java +++ b/src/main/java/ui/tmlcp/TMLCPForLoop.java @@ -36,31 +36,21 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.tmlcp; - -import java.awt.Color; -import java.awt.Graphics; -import javax.swing.JFrame; +package ui.tmlcp; +import myutil.GraphicLib; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - -import myutil.GraphicLib; -import ui.BasicErrorHighlight; -import ui.ColorManager; -import ui.EmbeddedComment; -import ui.ErrorHighlight; -import ui.GTURTLEModeling; -import ui.MalformedModelingException; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADForLoop; +import ui.*; +import ui.util.IconManager; import ui.window.JDialogMultiString; +import javax.swing.*; +import java.awt.*; +import java.awt.geom.Line2D; + /** * Class TMLCPForLoop * For loop of a TML activity diagram @@ -69,24 +59,24 @@ import ui.window.JDialogMultiString; * @author Ludovic APVRILLE * @version 1.0 03/06/2015 */ -public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComponent*/ implements EmbeddedComment, BasicErrorHighlight { -// protected int lineLength = 5; -// protected int textX = 5; -// protected int textY = 15; -// protected int arc = 5; +public class TMLCPForLoop extends TGCWithoutInternalComponent implements EmbeddedComment, BasicErrorHighlight { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int arc = 5; protected String init = "i=0"; protected String condition = "i<5"; protected String increment = "i = i+1"; - // protected int stateOfError = 0; // Not yet checked + protected int stateOfError = 0; // Not yet checked public TMLCPForLoop(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// width = 30; -// height = 20; -// minWidth = 30; + width = 30; + height = 20; + minWidth = 30; nbConnectingPoint = 3; connectingPoint = new TGConnectingPoint[3]; @@ -94,18 +84,17 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp connectingPoint[1] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 1.0, 0.45); // loop connectingPoint[2] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp -// moveable = true; -// editable = true; -// removable = true; + moveable = true; + editable = true; + removable = true; makeValue(); name = "for loop"; -// myImageIcon = IconManager.imgic912; + myImageIcon = IconManager.imgic912; } - @Override public void internalDrawing(Graphics g) { final int textWidth = g.getFontMetrics().stringWidth(value); int w1 = Math.max(minWidth, textWidth + 2 * textX); @@ -136,7 +125,6 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp g.drawString(value, x + (width - textWidth) / 2, y + textY); } - @Override public boolean editOndoubleClick(JFrame frame) { String[] labels = new String[3]; String[] values = new String[3]; @@ -147,6 +135,7 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp labels[2] = "Increment at each loop"; values[2] = increment; + JDialogMultiString jdms = new JDialogMultiString(frame, "Setting loop's properties", 3, labels, values); // jdms.setSize(400, 300); GraphicLib.centerOnParent(jdms, 400, 300); @@ -162,23 +151,24 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp } return false; + } -// public TGComponent isOnMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// -// if ((int) (Line2D.ptSegDistSq(x + (width / 2), y - lineLength, x + (width / 2), y + lineLength + height, _x, _y)) < distanceSelected) { -// return this; -// } -// -// if ((int) (Line2D.ptSegDistSq(x + width, y + height / 2, x + width + lineLength, y + height / 2, _x, _y)) < distanceSelected) { -// return this; -// } -// -// return null; -// } + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int) (Line2D.ptSegDistSq(x + (width / 2), y - lineLength, x + (width / 2), y + lineLength + height, _x, _y)) < distanceSelected) { + return this; + } + + if ((int) (Line2D.ptSegDistSq(x + width, y + height / 2, x + width + lineLength, y + height / 2, _x, _y)) < distanceSelected) { + return this; + } + + return null; + } public void makeValue() { value = "for(" + init + ";" + condition + ";" + increment + ")"; @@ -200,7 +190,6 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp return increment; } - @Override protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); sb.append("<Data init=\""); @@ -216,12 +205,18 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + // try { + NodeList nli; Node n1, n2; Element elt; // int k; // String s; + + // + // + for (int i = 0; i < nl.getLength(); i++) { n1 = nl.item(i); // @@ -244,22 +239,23 @@ public class TMLCPForLoop extends TADForLoop /* Issue #69 TGCWithoutInternalComp } } catch (Exception e) { - throw new MalformedModelingException( e ); + throw new MalformedModelingException(); } makeValue(); } - @Override + public int getType() { return TGComponentManager.TMLCP_FOR_LOOP; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLCP; } -// public void setStateAction(int _stateAction) { -// stateOfError = _stateAction; -// } + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } + + } diff --git a/src/main/java/ui/tmlcp/TMLCPFork.java b/src/main/java/ui/tmlcp/TMLCPFork.java index eeb8146e7a..4e98d86590 100755 --- a/src/main/java/ui/tmlcp/TMLCPFork.java +++ b/src/main/java/ui/tmlcp/TMLCPFork.java @@ -37,18 +37,17 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.tmlcp; -import java.awt.Graphics; -import java.util.Arrays; -import java.util.List; + + +package ui.tmlcp; import myutil.GraphicLib; import ui.*; -import ui.ad.EnablingADConnectorVisitor; -import ui.ad.TADComponentWithoutSubcomponents; import ui.util.IconManager; +import java.awt.*; + /** * Class TMLCPFork * Fork operator. The incoming activity is split into several outgoing activities @@ -57,7 +56,7 @@ import ui.util.IconManager; * @version 1.0 17/02/2014 * @author Ludovic APVRILLE */ -public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGCWithoutInternalComponent*/ { +public class TMLCPFork extends TGCWithoutInternalComponent{ private int lineLength = 0; private static int instanceCounter = 0; @@ -82,7 +81,7 @@ public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGC connectingPoint[4] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.833, 1.0); connectingPoint[5] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.5, 0.0); - addTGConnectingPointsComment(); + addTGConnectingPointsComment(); nbInternalTGComponent = 0; @@ -97,13 +96,11 @@ public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGC myImageIcon = IconManager.imgic206; } - @Override public void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); } - @Override public TGComponent isOnMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -115,36 +112,11 @@ public class TMLCPFork extends TADComponentWithoutSubcomponents /* Issue #69 TGC return tgcomponent[0].getValue(); } - @Override public int getType() { return TGComponentManager.TMLCP_FORK; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLCP; } - - public TGConnectingPoint getEnterConnectingPoint() { - return connectingPoint[ 5 ]; - } - - public List<TGConnectingPoint> getExitConnectingPoints() { - return Arrays.asList( Arrays.copyOfRange( connectingPoint, 0, connectingPoint.length - 1 ) ); - } - - /** - * Issue #69 - * @param _enabled - */ - @Override - public void setEnabled( final boolean _enabled ) { - super.setEnabled( _enabled ); - - for ( final TGConnectingPoint point : connectingPoint ) { - if ( point != getEnterConnectingPoint() ) { - point.acceptForward( new EnablingADConnectorVisitor( _enabled ) ); - } - } - } } diff --git a/src/main/java/ui/tmlcp/TMLCPJoin.java b/src/main/java/ui/tmlcp/TMLCPJoin.java index 341f896cde..74a4ae5498 100755 --- a/src/main/java/ui/tmlcp/TMLCPJoin.java +++ b/src/main/java/ui/tmlcp/TMLCPJoin.java @@ -37,16 +37,17 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.tmlcp; -import java.awt.Graphics; -import java.util.Arrays; -import java.util.List; + + +package ui.tmlcp; import myutil.GraphicLib; import ui.*; import ui.util.IconManager; +import java.awt.*; + /** * Class TMLCPJoin * Join operator. All incoming activities join in one remaining activity @@ -80,7 +81,8 @@ public class TMLCPJoin extends TGCWithoutInternalComponent{ connectingPoint[4] = new TGConnectingPointTMLCP(this, 0, -lineLength, true, false, 0.833, 0.0); connectingPoint[5] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0); - addTGConnectingPointsComment(); + + addTGConnectingPointsComment(); nbInternalTGComponent = 0; @@ -95,13 +97,11 @@ public class TMLCPJoin extends TGCWithoutInternalComponent{ myImageIcon = IconManager.imgic206; } - @Override public void internalDrawing(Graphics g) { g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); } - @Override public TGComponent isOnMe(int x1, int y1) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { return this; @@ -113,21 +113,11 @@ public class TMLCPJoin extends TGCWithoutInternalComponent{ return tgcomponent[0].getValue(); } - @Override public int getType() { return TGComponentManager.TMLCP_JOIN; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLCP; - } - - public List<TGConnectingPoint> getEnterConnectingPoints() { - return Arrays.asList( Arrays.copyOfRange( connectingPoint, 0, connectingPoint.length - 1 ) ); - } - - public TGConnectingPoint getExitConnectingPoint() { - return connectingPoint[ 5 ]; + return TGComponentManager.CONNECTOR_TMLCP; } } diff --git a/src/main/java/ui/tmlcp/TMLCPPanel.java b/src/main/java/ui/tmlcp/TMLCPPanel.java index cb458388dd..94bdaf07d1 100755 --- a/src/main/java/ui/tmlcp/TMLCPPanel.java +++ b/src/main/java/ui/tmlcp/TMLCPPanel.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlcp; import ui.*; @@ -57,7 +60,6 @@ public class TMLCPPanel extends TDiagramPanel { } - @Override public boolean actionOnDoubleClick(TGComponent tgc) { // /*if (tgc instanceof TCDTClass) { @@ -78,7 +80,6 @@ public class TMLCPPanel extends TDiagramPanel { return false; } - @Override public boolean actionOnAdd(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -88,7 +89,6 @@ public class TMLCPPanel extends TDiagramPanel { return false; } - @Override public boolean actionOnRemove(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { TCDTClass tgcc = (TCDTClass)(tgc); @@ -99,7 +99,6 @@ public class TMLCPPanel extends TDiagramPanel { return false; } - @Override public boolean actionOnValueChanged(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { return actionOnDoubleClick(tgc); @@ -107,32 +106,26 @@ public class TMLCPPanel extends TDiagramPanel { return false; } - @Override public String getXMLHead() { return "<CommunicationPatternDiagramPanel name=\"" + name + "\"" + sizeParam() + " >"; } - @Override public String getXMLTail() { return "</CommunicationPatternDiagramPanel>"; } - @Override public String getXMLSelectedHead() { return "<CommunicationPatternDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } - @Override public String getXMLSelectedTail() { return "</CommunicationPatternDiagramPanelCopy>"; } - @Override public String getXMLCloneHead() { return "<CommunicationPatternDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } - @Override public String getXMLCloneTail() { return "</CommunicationPatternDiagramPanelCopy>"; } @@ -190,7 +183,7 @@ public class TMLCPPanel extends TDiagramPanel { }*/ public void makePostLoadingProcessing() throws MalformedModelingException { - // TGComponent tgc; + TGComponent tgc; /*for(int i=0; i<componentList.size(); i++) { tgc = (TGComponent)(componentList.elementAt(i)); @@ -232,7 +225,7 @@ public class TMLCPPanel extends TDiagramPanel { // Vector<TGComponent> v = new Vector<>(); Object o; - Iterator<TGComponent> iterator = componentList.listIterator(); + Iterator iterator = componentList.listIterator(); while(iterator.hasNext()) { o = iterator.next(); @@ -250,6 +243,8 @@ public class TMLCPPanel extends TDiagramPanel { TGConnector tgcon; int i; + // + if (tgc == null) { return; } @@ -280,8 +275,8 @@ public class TMLCPPanel extends TDiagramPanel { } } - @Override public boolean hasAutoConnect() { return true; } + } diff --git a/src/main/java/ui/tmlcp/TMLCPRefAD.java b/src/main/java/ui/tmlcp/TMLCPRefAD.java index 5e07d71601..621a6c6772 100755 --- a/src/main/java/ui/tmlcp/TMLCPRefAD.java +++ b/src/main/java/ui/tmlcp/TMLCPRefAD.java @@ -37,11 +37,13 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlcp; import myutil.GraphicLib; import ui.*; -import ui.ad.TADOneLineText; import ui.util.IconManager; import javax.swing.*; @@ -57,7 +59,7 @@ import java.awt.geom.Line2D; * @version 1.0 17/02/2014 * @author Ludovic APVRILLE, Andrea ENRICI */ -public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { +public class TMLCPRefAD extends TGCOneLineText { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; @@ -87,7 +89,6 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { myImageIcon = IconManager.imgic400; } - @Override public void internalDrawing(Graphics g) { //int w2 = g.getFontMetrics().stringWidth("ref"); int w = g.getFontMetrics().stringWidth(value) /*+ w2*/; @@ -118,7 +119,6 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -136,13 +136,12 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { } - @Override public int getType() { return TGComponentManager.TMLCP_REF_CP; } - @Override public void addActionToPopupMenu( JPopupMenu componentMenu, ActionListener menuAL, int x, int y ) { + componentMenu.addSeparator(); boolean b = ( (TMLCPPanel)tdp ).isTMLCPCreated( name ); JMenuItem isCPCreated; @@ -158,8 +157,8 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { componentMenu.add( isCPCreated ); } - @Override public boolean eventOnPopup( ActionEvent e ) { + boolean b = ( (TMLCPPanel)tdp ).isTMLCPCreated( name ); if (b) { ( (TMLCPPanel)tdp ).openTMLCPDiagram( name ); @@ -171,13 +170,13 @@ public class TMLCPRefAD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { return true; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLCP; } - @Override - public boolean editOndoubleClick( JFrame frame ) { + @Override public boolean editOndoubleClick( JFrame frame ) { + + // String text = "Reference to AD: "; if( hasFather() ) { text = getTopLevelName() + " / " + text; diff --git a/src/main/java/ui/tmlcp/TMLCPRefSD.java b/src/main/java/ui/tmlcp/TMLCPRefSD.java index dc6bb9e846..da3776579b 100755 --- a/src/main/java/ui/tmlcp/TMLCPRefSD.java +++ b/src/main/java/ui/tmlcp/TMLCPRefSD.java @@ -36,28 +36,22 @@ * knowledge of the CeCILL license and that you accept its terms. */ -package ui.tmlcp; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.geom.Line2D; -import javax.swing.JFrame; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPopupMenu; + +package ui.tmlcp; import myutil.GraphicLib; -import ui.ColorManager; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADOneLineText; +import ui.*; +import ui.tmlsd.TMLSDPanel; import ui.util.IconManager; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Line2D; + /** * Class TMLCPRefSD * Reference to an SD in a communication pattern diagram @@ -65,12 +59,12 @@ import ui.util.IconManager; * @version 1.0 17/02/2014 * @author Ludovic APVRILLE */ -public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { +public class TMLCPRefSD extends TGCOneLineText { protected int lineLength = 5; protected int textX = 5; protected int textY = 15; protected int arc = 5; - // private TMLSDPanel refToSD; + private TMLSDPanel refToSD; // private TGConnectorTMLCP[] connectors = new TGConnectorTMLCP[2]; //private int index = 0; @@ -93,12 +87,11 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { removable = true; value = "Reference to a SD"; name = "SequenceDiagram"; - // refToSD = null; + refToSD = null; myImageIcon = IconManager.imgic400; } - @Override public void internalDrawing(Graphics g) { //int w2 = g.getFontMetrics().stringWidth("ref"); int w = g.getFontMetrics().stringWidth(value) /*+ w2*/; @@ -125,7 +118,6 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { g.drawLine(x+15, y+15, x+25, y+8); } - @Override public TGComponent isOnMe(int _x, int _y) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; @@ -142,42 +134,41 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { return value; } - @Override + public int getType() { return TGComponentManager.TMLCP_REF_SD; } - @Override public void addActionToPopupMenu( JPopupMenu componentMenu, ActionListener menuAL, int x, int y ) { - componentMenu.addSeparator(); - boolean b = ((TMLCPPanel)tdp).isTMLCPSDCreated( name ); - JMenuItem isSDCreated; - - if( b ) { - isSDCreated = new JMenuItem("Open diagram"); - } - else { - isSDCreated = new JMenuItem( "Create Sequence Diagram" ); - } - - isSDCreated.addActionListener( menuAL ); - componentMenu.add( isSDCreated ); + + componentMenu.addSeparator(); + boolean b = ((TMLCPPanel)tdp).isTMLCPSDCreated( name ); + JMenuItem isSDCreated; + + if( b ) { + isSDCreated = new JMenuItem("Open diagram"); + } + else { + isSDCreated = new JMenuItem( "Create Sequence Diagram" ); + } + + isSDCreated.addActionListener( menuAL ); + componentMenu.add( isSDCreated ); } - @Override public boolean eventOnPopup(ActionEvent e) { - boolean b = ((TMLCPPanel)tdp).isTMLCPSDCreated( name ); - if( b ) { - ( (TMLCPPanel)tdp ).openTMLCPSequenceDiagram( name ); - } - else { - ( (TMLCPPanel)tdp ).createTMLCPSequenceDiagram( name ); - } - tdp.getMouseManager().setSelection(-1, -1); - return true; + + boolean b = ((TMLCPPanel)tdp).isTMLCPSDCreated( name ); + if( b ) { + ( (TMLCPPanel)tdp ).openTMLCPSequenceDiagram( name ); + } + else { + ( (TMLCPPanel)tdp ).createTMLCPSequenceDiagram( name ); + } + tdp.getMouseManager().setSelection(-1, -1); + return true; } - @Override public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLCP; } @@ -186,26 +177,28 @@ public class TMLCPRefSD extends TADOneLineText /* Issue #69 TGCOneLineText*/ { refToSD = _panel; }*/ - @Override - public boolean editOndoubleClick(JFrame frame) { - String text = "Reference to a SD: "; - if( hasFather() ) { + @Override public boolean editOndoubleClick(JFrame frame) { + + // + String text = "Reference to a SD: "; + if( hasFather() ) { text = getTopLevelName() + " / " + text; - } - String s = (String) JOptionPane.showInputDialog(frame, text, - "Setting Name", JOptionPane.PLAIN_MESSAGE, IconManager.imgic100, null, getName() ); - if( (s != null) && (s.length() > 0) ) { - if (nameUsed(s)) { - JOptionPane.showMessageDialog(frame, - "Error: the name is already in use", - "Name modification", - JOptionPane.ERROR_MESSAGE); - return false; - } - renameTab(s); + } + String s = (String) JOptionPane.showInputDialog(frame, text, + "Setting Name", JOptionPane.PLAIN_MESSAGE, IconManager.imgic100, null, getName() ); + if( (s != null) && (s.length() > 0) ) { + if (nameUsed(s)) { + JOptionPane.showMessageDialog(frame, + "Error: the name is already in use", + "Name modification", + JOptionPane.ERROR_MESSAGE); + return false; + } + renameTab(s); setName(s); return true; } - return false; + return false; } + } //End of Class diff --git a/src/main/java/ui/tmlcp/TMLCPStartState.java b/src/main/java/ui/tmlcp/TMLCPStartState.java index 03816840c1..d7eadfa554 100755 --- a/src/main/java/ui/tmlcp/TMLCPStartState.java +++ b/src/main/java/ui/tmlcp/TMLCPStartState.java @@ -36,13 +36,17 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlcp; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADStartState; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; +import java.awt.geom.Line2D; /** * Class TMLCPStartState @@ -51,61 +55,52 @@ import ui.ad.TADStartState; * @version 1.0 17/02/2014 * @author Ludovic APVRILLE */ -public class TMLCPStartState extends TADStartState /* Issue #69 TGCWithoutInternalComponent*/{ +public class TMLCPStartState extends TGCWithoutInternalComponent{ private int lineLength = 5; public TMLCPStartState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// width = 15; -// height = 15; -// -// nbConnectingPoint = 1; -// connectingPoint = new TGConnectingPoint[1]; -// connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0); -// -// nbInternalTGComponent = 0; -// -// moveable = true; -// editable = false; -// removable = true; -// -// name = "start state"; -// -// myImageIcon = IconManager.imgic222; - } + width = 15; + height = 15; - @Override - protected void createConnectingPoints() { nbConnectingPoint = 1; connectingPoint = new TGConnectingPoint[1]; connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, lineLength, false, true, 0.5, 1.0); + + nbInternalTGComponent = 0; + + moveable = true; + editable = false; + removable = true; + + name = "start state"; + + myImageIcon = IconManager.imgic222; } -// public void internalDrawing(Graphics g) { -// g.fillOval(x, y, width, height); -// g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); -// } + public void internalDrawing(Graphics g) { + g.fillOval(x, y, width, height); + g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + } -// public TGComponent isOnMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// -// if ((int)(Line2D.ptSegDistSq(x+(width/2), y+height, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { -// return this; -// } -// -// return null; -// } + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y+height, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { + return this; + } + + return null; + } - @Override public int getType() { return TGComponentManager.TMLCP_START_STATE; } - @Override public int getDefaultConnector() { - return TGComponentManager.CONNECTOR_TMLCP; + return TGComponentManager.CONNECTOR_TMLCP; } } \ No newline at end of file diff --git a/src/main/java/ui/tmlcp/TMLCPStopState.java b/src/main/java/ui/tmlcp/TMLCPStopState.java index 238b27a331..f5f6bdc4be 100755 --- a/src/main/java/ui/tmlcp/TMLCPStopState.java +++ b/src/main/java/ui/tmlcp/TMLCPStopState.java @@ -35,14 +35,17 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlcp; -import ui.TDiagramPanel; -import ui.TGComponent; -import ui.TGComponentManager; -import ui.TGConnectingPoint; -import ui.ad.TADStopState; +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; /** * Class TMLCPStopState @@ -51,55 +54,55 @@ import ui.ad.TADStopState; * @version 1.0 30/09/2004 * @author Ludovic APVRILLE */ -public class TMLCPStopState extends TADStopState /* Issue #69 TGCWithoutInternalComponent*/{ -// private int internalCircleSize = 16; -// private int lineLength = 5; +public class TMLCPStopState extends TGCWithoutInternalComponent{ + private int internalCircleSize = 16; + private int lineLength = 5; public TMLCPStopState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); -// width = 20; -// height = 20; -// -// nbConnectingPoint = 1; -// connectingPoint = new TGConnectingPoint[1]; -// connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, - lineLength, true, false, 0.5, 0.0); -// -// nbInternalTGComponent = 0; -// -// moveable = true; -// editable = false; -// removable = true; -// -// name = "stop state"; -// -// myImageIcon = IconManager.imgic210; - } + width = 20; + height = 20; - @Override - protected void createConnectingPoints() { nbConnectingPoint = 1; connectingPoint = new TGConnectingPoint[1]; connectingPoint[0] = new TGConnectingPointTMLCP(this, 0, - lineLength, true, false, 0.5, 0.0); + + nbInternalTGComponent = 0; + + moveable = true; + editable = false; + removable = true; + + name = "stop state"; + + myImageIcon = IconManager.imgic210; + } + + public void internalDrawing(Graphics g) { + ColorManager.setColor(g, state, 0); + g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); + g.drawOval(x, y, width, height); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); } -// public void internalDrawing(Graphics g) { -// ColorManager.setColor(g, state, 0); -// g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); -// g.drawOval(x, y, width, height); -// g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); -// } -// -// -// public TGComponent isOnMe(int _x, int _y) { -// if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { -// return this; -// } -// return null; -// } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } - @Override public int getType() { return TGComponentManager.TMLCP_STOP_STATE; } + } + + + + + + + diff --git a/src/main/java/ui/tmlcp/TMLCPToolBar.java b/src/main/java/ui/tmlcp/TMLCPToolBar.java index aca7bcf04a..a75922b2cf 100755 --- a/src/main/java/ui/tmlcp/TMLCPToolBar.java +++ b/src/main/java/ui/tmlcp/TMLCPToolBar.java @@ -37,6 +37,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.tmlcp; import ui.MainGUI; @@ -45,6 +48,9 @@ import ui.TToolBar; import javax.swing.*; +//import java.awt.*; +//import java.awt.event.*; + /** * Class TMLCPToolBar * Implements the toolbar to be used in conjunction with the panel of an interaction overview diagram @@ -57,9 +63,9 @@ public class TMLCPToolBar extends TToolBar { public TMLCPToolBar(MainGUI _mgui) { super(_mgui); + } - @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.TMLCP_EDIT].setEnabled(b); mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); @@ -73,7 +79,7 @@ public class TMLCPToolBar extends TToolBar { mgui.actions[TGUIAction.TMLCP_START].setEnabled(b); mgui.actions[TGUIAction.TMLCP_STOP].setEnabled(b); //mgui.actions[TGUIAction.TMLCP_JUNCTION].setEnabled(b); - mgui.actions[TGUIAction.TMLCP_FOR_LOOP].setEnabled(b); + mgui.actions[TGUIAction.TMLCP_FOR_LOOP].setEnabled(b); mgui.actions[TGUIAction.ACT_ENHANCE].setEnabled(b); mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); @@ -84,7 +90,6 @@ public class TMLCPToolBar extends TToolBar { } - @Override protected void setButtons() { JButton button; @@ -124,7 +129,7 @@ public class TMLCPToolBar extends TToolBar { button.addMouseListener(mgui.mouseHandler); button = this.add(mgui.actions[TGUIAction.TMLCP_JOIN]); - button.addMouseListener(mgui.mouseHandler); + button.addMouseListener(mgui.mouseHandler); button = this.add(mgui.actions[TGUIAction.TMLCP_CHOICE]); @@ -133,12 +138,14 @@ public class TMLCPToolBar extends TToolBar { /*button = this.add(mgui.actions[TGUIAction.TMLCP_JUNCTION]); button.addMouseListener(mgui.mouseHandler);*/ - button = this.add(mgui.actions[TGUIAction.TMLCP_FOR_LOOP]); - button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.TMLCP_FOR_LOOP]); + button.addMouseListener(mgui.mouseHandler); this.addSeparator(); button = this.add(mgui.actions[TGUIAction.ACT_ENHANCE]); button.addMouseListener(mgui.mouseHandler); + } + } // Class diff --git a/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java b/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java index 1d1c8571b4..e4ba382344 100755 --- a/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java +++ b/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java @@ -69,7 +69,6 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener super(_mgui); } - @Override protected void setActive(boolean b) { mgui.actions[TGUIAction.TMLARCHI_EDIT].setEnabled(b); mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); @@ -101,7 +100,6 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener mgui.updateZoomInfo(); } - @Override protected void setButtons() { JButton button; diff --git a/src/main/java/ui/window/JBirdPanel.java b/src/main/java/ui/window/JBirdPanel.java index 9c37bc6b7f..5b0265f9fc 100644 --- a/src/main/java/ui/window/JBirdPanel.java +++ b/src/main/java/ui/window/JBirdPanel.java @@ -36,6 +36,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.window; import ui.ColorManager; @@ -48,6 +51,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; + /** * Class JbirdPanel * Panel for displaying bird'eyes view of panels @@ -56,8 +60,7 @@ import java.awt.event.MouseMotionListener; * @author Ludovic APVRILLE */ public class JBirdPanel extends JPanel implements MouseListener, MouseMotionListener { - - private MainGUI mgui; + private MainGUI mgui; private int w, h, wc, wh; //private Image image, scaledImage; //private Graphics graphics; @@ -81,7 +84,6 @@ public class JBirdPanel extends JPanel implements MouseListener, MouseMotionList startProcess(); } - @Override protected void paintComponent(Graphics g) { if (isShowing()) { super.paintComponent(g); @@ -107,7 +109,8 @@ public class JBirdPanel extends JPanel implements MouseListener, MouseMotionList } } - private void centerRectangle(int x, int y) { + + public void centerRectangle(int x, int y) { if (rect != null) { x = (int)(x - rect.width*wratio/2); y = (int)(y - rect.height*hratio/2); @@ -124,7 +127,6 @@ public class JBirdPanel extends JPanel implements MouseListener, MouseMotionList } } - @Override public void mousePressed(MouseEvent e) { // //startX = e.getX(); @@ -143,27 +145,28 @@ public class JBirdPanel extends JPanel implements MouseListener, MouseMotionList } } - @Override - public void mouseReleased(MouseEvent e) { + public void mouseReleased(MouseEvent e) { + } - @Override public void mouseEntered(MouseEvent e) { + } - @Override public void mouseExited(MouseEvent e) { + } - @Override public void mouseClicked(MouseEvent e) { + } - @Override + public void mouseMoved(MouseEvent e) { + + } - @Override public void mouseDragged(MouseEvent e) { centerRectangle(e.getX(), e.getY()); } @@ -180,4 +183,5 @@ public class JBirdPanel extends JPanel implements MouseListener, MouseMotionList public boolean getGo() { return go; } + } diff --git a/src/main/java/ui/window/JDialogAvatarSignal.java b/src/main/java/ui/window/JDialogAvatarSignal.java index 611cfe791b..555e36aa46 100644 --- a/src/main/java/ui/window/JDialogAvatarSignal.java +++ b/src/main/java/ui/window/JDialogAvatarSignal.java @@ -61,6 +61,7 @@ import myutil.TraceManager; import ui.AvatarSignal; import ui.TGComponent; + /** * Class JDialogAvatarSignal * Dialog for managing several string components @@ -91,6 +92,7 @@ public class JDialogAvatarSignal extends JDialogBase implements ActionListener /** Creates new form */ public JDialogAvatarSignal(Frame _f, String _title, String _currentSignal, List<AvatarSignal> _signals, boolean _isOut, TGComponent _reference, Vector<TGComponent> _refs) { + super(_f, _title, true); signals = _signals; @@ -99,10 +101,11 @@ public class JDialogAvatarSignal extends JDialogBase implements ActionListener reference=_reference; refs=_refs; + makeSignals(); initComponents(); -// myInitComponents(); + myInitComponents(); pack(); } @@ -118,8 +121,11 @@ public class JDialogAvatarSignal extends JDialogBase implements ActionListener } } -// private void myInitComponents() { -// } + + + private void myInitComponents() { + } + private void initComponents() { Container c = getContentPane(); @@ -190,7 +196,6 @@ public class JDialogAvatarSignal extends JDialogBase implements ActionListener c.add(buttons, BorderLayout.SOUTH); } - @Override public void actionPerformed(ActionEvent evt) { //String command = evt.getActionCommand(); @@ -222,6 +227,7 @@ public class JDialogAvatarSignal extends JDialogBase implements ActionListener return (TGComponent) refChecks.getSelectedItem(); } + public boolean hasValidString() { return signal.getText().length() > 0; } diff --git a/src/main/java/ui/window/JDialogAvatarTransition.java b/src/main/java/ui/window/JDialogAvatarTransition.java index ff423d54bd..e1847f538c 100644 --- a/src/main/java/ui/window/JDialogAvatarTransition.java +++ b/src/main/java/ui/window/JDialogAvatarTransition.java @@ -47,12 +47,9 @@ import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Vector; -import javax.swing.DefaultCellEditor; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; @@ -60,22 +57,12 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTabbedPane; -import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField; -import javax.swing.ListSelectionModel; -import javax.swing.SwingConstants; -import javax.swing.border.TitledBorder; -import javax.swing.event.CellEditorListener; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.table.DefaultTableModel; -import javax.swing.text.BadLocationException; +import myutil.Conversion; import myutil.GraphicLib; import ui.AvatarMethod; -import ui.Expression; import ui.TAttribute; /** @@ -87,36 +74,25 @@ import ui.TAttribute; */ public class JDialogAvatarTransition extends JDialogBase implements ActionListener { - private Vector<Vector<Expression>> actionRows; - //private Vector<String> actions; - private String guard, afterMin, afterMax, /*computeMin, computeMax,*/ probability; + private Vector<String> actions; + private String guard, afterMin, afterMax, computeMin, computeMax, probability; private List<TAttribute> myAttributes; private List<AvatarMethod> myMethods; private Vector<String> allElements, insertElements; -// protected String [] filesToInclude; -// protected String [] codeToInclude; + protected String [] filesToInclude; + protected String [] codeToInclude; private boolean cancelled = true; - private JPanel pnlTransitionInfo; -// private JPanel panel1; -// private JPanel panel2; + private JPanel panel1; + private JPanel panel2; // Panel1 - private JTextField guardT, afterMinT, afterMaxT, /*computeMinT, computeMaxT,*/ probabilityT; - - private JTable actionsTable; -// private JTextArea actionsT; - private final Vector<String> actionsListHeader; - - private JComboBox<String> codeElements; - //private JButton insertElement; - private JButton insertCodeButton; - private JButton addButton; - private JButton upButton; - private JButton downButton; - private JButton removeButton; + private JTextField guardT, afterMinT, afterMaxT, computeMinT, computeMaxT, probabilityT; + private JTextArea actionsT; + private JComboBox<String> elements; + private JButton insertElement; // Panel of code and files protected JTextArea jtaCode, jtaFiles; @@ -124,45 +100,26 @@ public class JDialogAvatarTransition extends JDialogBase implements ActionListen /** Creates new form */ // arrayDelay: [0] -> minDelay ; [1] -> maxDelay - public JDialogAvatarTransition( Frame _f, - String _title, - String _guard, - String _afterMin, - String _afterMax, - /* String _computeMin, String _computeMax,*/ - Vector<Expression> _actions, - List<TAttribute> _myAttributes, - List<AvatarMethod> _myMethods, -// String[] _filesToInclude, -// String[] _codeToInclude, - String _probability) { + public JDialogAvatarTransition(Frame _f, String _title, String _guard, String _afterMin, String _afterMax, + String _computeMin, String _computeMax, Vector<String> _actions, + List<TAttribute> _myAttributes, List<AvatarMethod> _myMethods, + String[] _filesToInclude, String[] _codeToInclude, String _probability) { super(_f, _title, true); guard = _guard; afterMin = _afterMin; afterMax = _afterMax; -// computeMin = _computeMin; -// computeMax = _computeMax; - - actionRows = new Vector<Vector<Expression>>(); - - for ( final Expression actionExpr : _actions ) { - final Vector<Expression> row = new Vector<Expression>(); - row.add( actionExpr ); - actionRows.add( row ); - } - - actionsListHeader = new Vector<String>(); - - //actions = _actions; + computeMin = _computeMin; + computeMax = _computeMax; + actions = _actions; probability = _probability; myAttributes = _myAttributes; myMethods = _myMethods; -// filesToInclude = _filesToInclude; -// codeToInclude = _codeToInclude; + filesToInclude = _filesToInclude; + codeToInclude = _codeToInclude; makeElements(); @@ -193,15 +150,15 @@ public class JDialogAvatarTransition extends JDialogBase implements ActionListen // } // private void initComponents() { - // int i; + int i; Container c = getContentPane(); -// GridBagLayout gridbag0 = new GridBagLayout(); -// GridBagLayout gridbag1 = new GridBagLayout(); -// GridBagLayout gridbag2 = new GridBagLayout(); -// GridBagConstraints c0 = new GridBagConstraints(); -// GridBagConstraints c1 = new GridBagConstraints(); -// GridBagConstraints c2 = new GridBagConstraints(); + 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); @@ -209,72 +166,38 @@ public class JDialogAvatarTransition extends JDialogBase implements ActionListen setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - pnlTransitionInfo = new JPanel(); - pnlTransitionInfo.setLayout( new GridBagLayout() ); + panel1 = new JPanel(); + panel1.setLayout(gridbag1); - pnlTransitionInfo.setBorder(new TitledBorder("Transition parameters")); -// panel1 = new JPanel(); -// panel1.setLayout(gridbag1); - -// panel1.setBorder(new javax.swing.border.TitledBorder("Transition parameters")); + panel1.setBorder(new javax.swing.border.TitledBorder("Transition parameters")); //panel1.setPreferredSize(new Dimension(350, 350)); - final int defaultMargin = 3; // guard - final GridBagConstraints constraintsLabels = new GridBagConstraints(); - constraintsLabels.weighty = 0.0; - constraintsLabels.weightx = 0.0; - constraintsLabels.gridwidth = 1; - constraintsLabels.gridheight = 1; - constraintsLabels.fill = GridBagConstraints.BOTH; - constraintsLabels.insets = new Insets( defaultMargin, defaultMargin, 0, 0 ); - pnlTransitionInfo.add( new JLabel( "guard = ", SwingConstants.RIGHT ), constraintsLabels ); - -// c1.weighty = 1.0; -// c1.weightx = 1.0; -// c1.gridwidth = 1; -// c1.gridheight = 1; -// c1.fill = GridBagConstraints.BOTH; -// c1.gridheight = 1; -// panel1.add(new JLabel("guard = "), c1); -// c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.gridwidth = 1; + c1.gridheight = 1; + c1.fill = GridBagConstraints.BOTH; + c1.gridheight = 1; + panel1.add(new JLabel("guard = "), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row guardT = new JTextField(guard); - final GridBagConstraints constraintsFields = new GridBagConstraints(); - constraintsFields.weighty = 0.0; - constraintsFields.weightx = 1.0; - constraintsFields.gridwidth = GridBagConstraints.REMAINDER; //end row; - constraintsFields.gridheight = 1; - constraintsFields.fill = GridBagConstraints.BOTH; - constraintsFields.insets = new Insets( defaultMargin, 0, 0, defaultMargin ); - - pnlTransitionInfo.add( guardT, constraintsFields ); - //panel1.add(guardT, c1); + panel1.add(guardT, c1); // After - pnlTransitionInfo.add(new JLabel("after ( ", SwingConstants.RIGHT ), constraintsLabels ); -// c1.gridwidth = 1; -// c1.gridheight = 1; -// c1.weighty = 1.0; -// c1.weightx = 1.0; -// panel1.add(new JLabel("after ("), c1); + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + panel1.add(new JLabel("after ("), c1); afterMinT = new JTextField(afterMin, 10); - constraintsFields.gridwidth = 1; - constraintsFields.insets.right = 0; - pnlTransitionInfo.add(afterMinT, constraintsFields ); - constraintsLabels.insets.left = 0; - pnlTransitionInfo.add(new JLabel( ", " ), constraintsLabels ); -// panel1.add(afterMinT, c1); - // panel1.add(new JLabel(","), c1); + panel1.add(afterMinT, c1); + panel1.add(new JLabel(","), c1); afterMaxT = new JTextField(afterMax, 10); - pnlTransitionInfo.add(afterMaxT, constraintsFields ); - constraintsLabels.gridwidth = GridBagConstraints.REMAINDER; - constraintsLabels.insets.right = defaultMargin; - pnlTransitionInfo.add(new JLabel( " )" ), constraintsLabels ); - constraintsLabels.gridwidth = 1; -// panel1.add(afterMaxT, c1); -// c1.gridwidth = GridBagConstraints.REMAINDER; //end row -// panel1.add(new JLabel(")"), c1); + panel1.add(afterMaxT, c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + panel1.add(new JLabel(")"), c1); // Compute /*c1.gridwidth = 1; @@ -291,257 +214,108 @@ public class JDialogAvatarTransition extends JDialogBase implements ActionListen panel1.add(new JLabel(")"), c1);*/ // probability - pnlTransitionInfo.add( new JLabel("weight in [0...1000] (default = 1) = "), constraintsLabels ); -// c1.weighty = 1.0; -// c1.weightx = 1.0; -// c1.gridwidth = 1; -// c1.gridheight = 1; -// c1.fill = GridBagConstraints.BOTH; -// c1.gridheight = 1; - //panel1.add(new JLabel("weight in [0...1000] (default = 1) = "), c1); - // c1.gridwidth = GridBagConstraints.REMAINDER; //end row - constraintsFields.gridwidth = GridBagConstraints.REMAINDER; //end row; - probabilityT = new JTextField(probability); - pnlTransitionInfo.add( probabilityT, constraintsFields ); -// panel1.add(probabilityT, c1); + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.gridwidth = 1; + c1.gridheight = 1; + c1.fill = GridBagConstraints.BOTH; + c1.gridheight = 1; + panel1.add(new JLabel("weight in [0...1000] (default = 1) = "), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + probabilityT = new JTextField(probability); + panel1.add(probabilityT, c1); // actions - constraintsFields.gridwidth = GridBagConstraints.REMAINDER; - - codeElements = new JComboBox<String>(allElements); - pnlTransitionInfo.add(codeElements, constraintsFields ); - - insertCodeButton = new JButton( "Insert Code" ); - insertCodeButton.addActionListener( new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - insertCodeAction(); - } - } ); - pnlTransitionInfo.add( insertCodeButton, constraintsFields ); - - actionsTable = new JTable( new DefaultTableModel() { - - /** - * - */ - private static final long serialVersionUID = 1L; - - @Override - public Object getValueAt(int row, int column) { - final Expression expression = (Expression) super.getValueAt( row, column ); - - return expression.getText(); - } - - @Override - public void setValueAt(Object aValue, int row, int column) { - final Expression expression = (Expression) super.getValueAt( row, column ); - - expression.setText( String.valueOf( aValue ) ); - - fireTableCellUpdated(row, column); - } - } ); - - actionsTable.setShowGrid( false ); - - final ListSelectionModel selectionModel = actionsTable.getSelectionModel(); - selectionModel.addListSelectionListener( new ListSelectionListener() { - - @Override - public void valueChanged( ListSelectionEvent e ) { - manageButtonsEnablement(); - } - } ); - - actionsTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - actionsListHeader.addElement(""); - - final DefaultCellEditor defaultCellEditor = (DefaultCellEditor) actionsTable.getDefaultEditor( Object.class ); - defaultCellEditor.setClickCountToStart( 1 ); - defaultCellEditor.addCellEditorListener( new CellEditorListener() { - - @Override - public void editingStopped(ChangeEvent e) { - manageButtonsEnablement(); - } - - @Override - public void editingCanceled(ChangeEvent e) { - manageButtonsEnablement(); - } - }); - - ( (DefaultTableModel) actionsTable.getModel() ).setDataVector( actionRows, actionsListHeader ); - //actionsT.getCellRenderer().sEditable(true); - //actionsT.setMargin(new Insets(10, 10, 10, 10))); - //actionsT.setTabSize(3); - //actionsT.setFont(new Font("times", Font.PLAIN, 12)); + elements = new JComboBox<String>(allElements); + panel1.add(elements, c1); + + insertElement = new JButton("Insert"); + insertElement.setEnabled(allElements.size() > 0); + insertElement.addActionListener(this); + panel1.add(insertElement, c1); + + c1.gridheight = 10; + c1.weighty = 10.0; + c1.weightx = 10.0; + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.fill = GridBagConstraints.BOTH; + actionsT = new JTextArea(); + actionsT.setEditable(true); + actionsT.setMargin(new Insets(10, 10, 10, 10)); + actionsT.setTabSize(3); + actionsT.setFont(new Font("times", Font.PLAIN, 12)); //actionsT.setPreferredSize(new Dimension(350, 250)); - JScrollPane jsp = new JScrollPane(actionsTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - -// for( int i=0; i<actions.size(); i++) { -// actionsT.append(actions.get(i) + "\n"); -// } - - final GridBagConstraints constraintsList = new GridBagConstraints(); - constraintsList.weighty = 1.0; - constraintsList.weightx = 1.0; - constraintsList.gridwidth = GridBagConstraints.REMAINDER; //end row; - constraintsList.gridheight = 1; - constraintsList.fill = GridBagConstraints.BOTH; - - pnlTransitionInfo.add(jsp, constraintsList ); - -// c1.weighty = 0.0; - - final GridBagConstraints constraintsButtons = new GridBagConstraints(); - constraintsButtons.weighty = 0.0; - constraintsButtons.weightx = 1.0; - constraintsButtons.gridwidth = GridBagConstraints.REMAINDER; //end row; - constraintsButtons.gridheight = 1; - constraintsButtons.fill = GridBagConstraints.BOTH; - - upButton = new JButton( "Up" ); - upButton.addActionListener( new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - upAction(); - } - }); - - constraintsFields.gridwidth = GridBagConstraints.REMAINDER; - constraintsFields.weightx = 1.0; - pnlTransitionInfo.add(upButton, constraintsButtons ); - - downButton = new JButton("Down"); - downButton.addActionListener( new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - downAction(); - } - } ); - - pnlTransitionInfo.add( downButton, constraintsButtons ); - - removeButton = new JButton("Remove"); - removeButton.addActionListener( new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - removeAction(); - } - } ); - - pnlTransitionInfo.add( removeButton, constraintsButtons ); - - addButton = new JButton( "Add" ); - addButton.addActionListener( new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - addAction(); - } - } ); - pnlTransitionInfo.add( addButton, constraintsButtons ); - - manageButtonsEnablement(); - -// elements = new JComboBox<String>(allElements); -// panel1.add(elements, c1); -// -// insertElement = new JButton("Insert"); -// insertElement.setEnabled(allElements.size() > 0); -// insertElement.addActionListener(this); -// panel1.add(insertElement, c1); -// -// c1.gridheight = 10; -// c1.weighty = 10.0; -// c1.weightx = 10.0; -// c1.gridwidth = GridBagConstraints.REMAINDER; //end row -// c1.fill = GridBagConstraints.BOTH; -// actionsT = new JTextArea(); -// actionsT.setEditable(true); -// actionsT.setMargin(new Insets(10, 10, 10, 10)); -// actionsT.setTabSize(3); -// actionsT.setFont(new Font("times", Font.PLAIN, 12)); -// //actionsT.setPreferredSize(new Dimension(350, 250)); -// JScrollPane jsp = new JScrollPane(actionsT, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); -// for(i=0; i<actions.size(); i++) { -// actionsT.append(actions.get(i) + "\n"); -// } -// panel1.add(jsp, c1); - - -// panel2 = new JPanel(); -// panel2.setLayout(gridbag2); -// -// panel2.setBorder(new javax.swing.border.TitledBorder("Code")); -// // guard -// c2.weighty = 1.0; -// c2.weightx = 1.0; -// c2.gridwidth = 1; -// c2.gridheight = 1; -// c2.fill = GridBagConstraints.BOTH; -// c2.gridwidth = GridBagConstraints.REMAINDER; -// c2.gridheight = 1; -// panel2.add(new JLabel("Files to include:"), c2); -// jtaFiles = new JTextArea(); -// jtaFiles.setEditable(true); -// jtaFiles.setMargin(new Insets(10, 10, 10, 10)); -// jtaFiles.setTabSize(3); -// String files = ""; -// if (filesToInclude != null) { -// for(i=0; i<filesToInclude.length; i++) { -// files += filesToInclude[i] + "\n"; -// } -// } -// jtaFiles.append(files); -// jtaFiles.setFont(new Font("times", Font.PLAIN, 12)); -// jsp = new JScrollPane(jtaFiles, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); -// //jsp.setPreferredSize(new Dimension(300, 300)); -// panel2.add(jsp, c2); -// panel2.add(new JLabel("Code to execute at the end of the transition"), c2); -// jtaCode = new JTextArea(); -// jtaCode.setEditable(true); -// jtaCode.setMargin(new Insets(10, 10, 10, 10)); -// jtaCode.setTabSize(3); -// String code = ""; -// if (codeToInclude != null) { -// for(i=0; i<codeToInclude.length; i++) { -// code += codeToInclude[i] + "\n"; -// } -// } -// jtaCode.append(code); -// jtaCode.setFont(new Font("times", Font.PLAIN, 12)); -// jsp = new JScrollPane(jtaCode, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); -// //jsp.setPreferredSize(new Dimension(300, 300)); -// panel2.add(jsp, c2); + JScrollPane jsp = new JScrollPane(actionsT, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + for(i=0; i<actions.size(); i++) { + actionsT.append(actions.get(i) + "\n"); + } + panel1.add(jsp, c1); + + + panel2 = new JPanel(); + panel2.setLayout(gridbag2); + + panel2.setBorder(new javax.swing.border.TitledBorder("Code")); + // guard + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.gridwidth = 1; + c2.gridheight = 1; + c2.fill = GridBagConstraints.BOTH; + c2.gridwidth = GridBagConstraints.REMAINDER; + c2.gridheight = 1; + panel2.add(new JLabel("Files to include:"), c2); + jtaFiles = new JTextArea(); + jtaFiles.setEditable(true); + jtaFiles.setMargin(new Insets(10, 10, 10, 10)); + jtaFiles.setTabSize(3); + String files = ""; + if (filesToInclude != null) { + for(i=0; i<filesToInclude.length; i++) { + files += filesToInclude[i] + "\n"; + } + } + jtaFiles.append(files); + jtaFiles.setFont(new Font("times", Font.PLAIN, 12)); + jsp = new JScrollPane(jtaFiles, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + //jsp.setPreferredSize(new Dimension(300, 300)); + panel2.add(jsp, c2); + panel2.add(new JLabel("Code to execute at the end of the transition"), c2); + jtaCode = new JTextArea(); + jtaCode.setEditable(true); + jtaCode.setMargin(new Insets(10, 10, 10, 10)); + jtaCode.setTabSize(3); + String code = ""; + if (codeToInclude != null) { + for(i=0; i<codeToInclude.length; i++) { + code += codeToInclude[i] + "\n"; + } + } + jtaCode.append(code); + jtaCode.setFont(new Font("times", Font.PLAIN, 12)); + jsp = new JScrollPane(jtaCode, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + //jsp.setPreferredSize(new Dimension(300, 300)); + panel2.add(jsp, c2); // button panel; -// c0.gridwidth = 1; -// c0.gridheight = 10; -// c0.weighty = 1.0; -// c0.weightx = 1.0; -// c0.gridwidth = GridBagConstraints.REMAINDER; //end row + c0.gridwidth = 1; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row // Issue #41 Ordering of tabbed panes JTabbedPane jtp = GraphicLib.createTabbedPane();//new JTabbedPane(); - jtp.add( "General", pnlTransitionInfo ); + jtp.add("General", panel1); //jtp.add("Prototyping", panel2); //c.add(jtp, c0); c.add(jtp, BorderLayout.CENTER); JPanel buttons = new JPanel(); - buttons.setLayout( new GridBagLayout() ); + buttons.setLayout(gridbag0); - final GridBagConstraints c0 = new GridBagConstraints(); c0.gridwidth = 1; c0.gridheight = 1; c0.fill = GridBagConstraints.HORIZONTAL; @@ -550,53 +324,6 @@ public class JDialogAvatarTransition extends JDialogBase implements ActionListen c.add(buttons, BorderLayout.SOUTH); } - - private void downAction() { - final int selectedActionIndex = actionsTable.getSelectedRow(); - - if ( selectedActionIndex > -1 ) { - saveCurrentActionEditing(); - - final int newIndex = selectedActionIndex + 1; - Collections.swap( actionRows, selectedActionIndex, newIndex ); - ( (DefaultTableModel) actionsTable.getModel() ).setDataVector( actionRows, actionsListHeader ); - actionsTable.getSelectionModel().setSelectionInterval( newIndex, newIndex ); - - manageButtonsEnablement(); - } - } - - private void upAction() { - final int selectedActionIndex = actionsTable.getSelectedRow(); - - if ( selectedActionIndex > 0 ) { - saveCurrentActionEditing(); - - final int newIndex = selectedActionIndex - 1; - Collections.swap( actionRows, selectedActionIndex, newIndex ); - ( (DefaultTableModel) actionsTable.getModel() ).setDataVector( actionRows, actionsListHeader ); - actionsTable.setRowSelectionInterval( newIndex, newIndex ); - - manageButtonsEnablement(); - } - } - - private void manageButtonsEnablement() { - final int selectedActionIndex = actionsTable.getSelectedRow(); - - if ( selectedActionIndex < 0 ) { - insertCodeButton.setEnabled( false ); - upButton.setEnabled( false ); - downButton.setEnabled( false ); - removeButton.setEnabled( false ); - } - else { - insertCodeButton.setEnabled( codeElements.getSelectedIndex() > -1 ); - removeButton.setEnabled( true ); - upButton.setEnabled( selectedActionIndex > 0 ); - downButton.setEnabled( selectedActionIndex < actionsTable.getRowCount() - 1 ); - } - } @Override public void actionPerformed(ActionEvent evt) { @@ -607,114 +334,37 @@ public class JDialogAvatarTransition extends JDialogBase implements ActionListen closeDialog(); } else if (evt.getSource() == cancelButton) { cancelDialog(); -// } else if (evt.getSource() == insertElement) { -// insertElements(); + } else if (evt.getSource() == insertElement) { + insertElements(); } } - - private JTextField getEditingField() { - // TODO: Generalize for other fields so that code completion also works for them - - if ( actionsTable.getSelectedRow() > -1 ) { - DefaultCellEditor cellEditor = (DefaultCellEditor) actionsTable.getCellEditor(); - - if ( cellEditor == null ) { - actionsTable.editCellAt( actionsTable.getSelectedRow(), 0 ); - cellEditor = (DefaultCellEditor) actionsTable.getCellEditor(); - } - - return (JTextField) cellEditor.getComponent(); - } - - return null; - } - private void insertCodeAction() { - int selectedCodeIndex = codeElements.getSelectedIndex(); - - if ( selectedCodeIndex > -1 ) { - final JTextField editingField = getEditingField(); - - if ( editingField != null ) { - final int caretPos = editingField.getCaretPosition(); - final String elementName = insertElements.get( codeElements.getSelectedIndex() ); - - try { - editingField.getDocument().insertString( caretPos, elementName, null ); - } - catch (BadLocationException e) { - e.printStackTrace(); - } - } - } + public void insertElements() { + int index = elements.getSelectedIndex(); + int caretPos = actionsT.getCaretPosition (); + String str = insertElements.get(index); + String text = actionsT.getText (); + if (caretPos > 0 && text.charAt (caretPos-1) != ' ' && text.charAt (caretPos-1) != '(') + str = " " + str; + if (caretPos == text.length () || (text.charAt (caretPos) != ' ' && text.charAt (caretPos) != ')')) + str = str + " "; + actionsT.insert (str, caretPos); + actionsT.setCaretPosition (caretPos + str.length ()); + actionsT.requestFocusInWindow (); } - - private void saveCurrentActionEditing() { - if ( actionsTable.isEditing() ) { - actionsTable.getCellEditor().stopCellEditing(); - } - } - - private void addAction() { - saveCurrentActionEditing(); - - final int addingIndex = actionsTable.getSelectedRow() >= 0 ? actionsTable.getSelectedRow() + 1 : actionRows.size(); - final Expression newAction = new Expression( "" ); - final Vector<Expression> newActionRow = new Vector<Expression>(); - newActionRow.add( newAction ); - actionRows.add( addingIndex, newActionRow ); - ( (DefaultTableModel) actionsTable.getModel() ).setDataVector( actionRows, actionsListHeader ); - actionsTable.setRowSelectionInterval( addingIndex, addingIndex ); - - manageButtonsEnablement(); - } - - private void removeAction() { - int selectedIndex = actionsTable.getSelectedRow(); - - if ( selectedIndex > -1 ) { - actionRows.remove( selectedIndex ); - ( (DefaultTableModel) actionsTable.getModel() ).setDataVector( actionRows, actionsListHeader ); - - selectedIndex = Math.min( selectedIndex, actionRows.size() - 1 ); - - if ( selectedIndex > -1 ) { - actionsTable.setRowSelectionInterval( selectedIndex, selectedIndex ); - } - - manageButtonsEnablement(); - } - } -// -// public void insertElements() { -// int index = elements.getSelectedIndex(); -// int caretPos = actionsT.getCaretPosition (); -// String str = insertElements.get(index); -// String text = actionsT.getText (); -// if (caretPos > 0 && text.charAt (caretPos-1) != ' ' && text.charAt (caretPos-1) != '(') -// str = " " + str; -// if (caretPos == text.length () || (text.charAt (caretPos) != ' ' && text.charAt (caretPos) != ')')) -// str = str + " "; -// actionsT.insert (str, caretPos); -// actionsT.setCaretPosition (caretPos + str.length ()); -// actionsT.requestFocusInWindow (); -// } public void closeDialog() { -// actions.removeAllElements(); -// String[] act = actionsT.getText().split("\n"); -// for(int i=0; i<act.length; i++) { -// if (act[0].length() > 0) { -// actions.add(act[i]); -// } -// } -// filesToInclude = Conversion.wrapText(jtaFiles.getText()); -// codeToInclude = Conversion.wrapText(jtaCode.getText()); + actions.removeAllElements(); + String[] act = actionsT.getText().split("\n"); + for(int i=0; i<act.length; i++) { + if (act[0].length() > 0) { + actions.add(act[i]); + } + } + filesToInclude = Conversion.wrapText(jtaFiles.getText()); + codeToInclude = Conversion.wrapText(jtaCode.getText()); cancelled = false; - - saveCurrentActionEditing(); - dispose(); } @@ -734,29 +384,19 @@ public class JDialogAvatarTransition extends JDialogBase implements ActionListen return afterMaxT.getText(); } -// public String getComputeMin() { -// if (computeMinT == null) { -// return ""; -// } -// -// return computeMinT.getText(); -// } -// -// public String getComputeMax() { -// if (computeMaxT == null) { -// return ""; -// } -// return computeMaxT.getText(); -// } - - public List<Expression> getActions() { - final List<Expression> actions = new ArrayList<Expression>(); - - for ( final Vector<Expression> actionVect : actionRows ) { - actions.add( actionVect.get( 0 ) ); - } - - return actions; + public String getComputeMin() { + if (computeMinT == null) { + return ""; + } + + return computeMinT.getText(); + } + + public String getComputeMax() { + if (computeMaxT == null) { + return ""; + } + return computeMaxT.getText(); } public String getProbability() { @@ -770,12 +410,12 @@ public class JDialogAvatarTransition extends JDialogBase implements ActionListen public void cancelDialog() { dispose(); } -// -// public String[] getFilesToInclude() { -// return filesToInclude; -// } -// -// public String[] getCodeToInclude() { -// return codeToInclude; -// } + + public String[] getFilesToInclude() { + return filesToInclude; + } + + public String[] getCodeToInclude() { + return codeToInclude; + } } diff --git a/src/main/java/ui/window/JDialogMultiString.java b/src/main/java/ui/window/JDialogMultiString.java index b69246503d..102f2ca047 100644 --- a/src/main/java/ui/window/JDialogMultiString.java +++ b/src/main/java/ui/window/JDialogMultiString.java @@ -36,25 +36,15 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.window; -import java.awt.Container; -import java.awt.Font; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; /** * Class JDialogMultiString @@ -78,9 +68,9 @@ public class JDialogMultiString extends JDialogBase implements ActionListener { // Panel1 private JTextField[] texts; private JButton inserts[]; - private Map<Integer, JComboBox<String>> helps; + private HashMap<Integer, JComboBox<String>> helps; - private List<String[]> possibleValues = null; + private ArrayList<String[]> possibleValues = null; /** @@ -99,11 +89,11 @@ public class JDialogMultiString extends JDialogBase implements ActionListener { texts = new JTextField[nbString]; initComponents(); - // myInitComponents(); + myInitComponents(); pack(); } - public JDialogMultiString(Frame f, String title, int _nbString, String[] _labels, String[] _values, List<String[]> _possibleValues) { + public JDialogMultiString(Frame f, String title, int _nbString, String[] _labels, String[] _values, ArrayList<String[]> _possibleValues) { super(f, title, true); @@ -115,12 +105,13 @@ public class JDialogMultiString extends JDialogBase implements ActionListener { texts = new JTextField[nbString]; initComponents(); - // myInitComponents(); + myInitComponents(); pack(); } -// private void myInitComponents() { -// } + + private void myInitComponents() { + } private void initComponents() { inserts = new JButton[labels.length]; @@ -201,7 +192,6 @@ public class JDialogMultiString extends JDialogBase implements ActionListener { initButtons(c0, c, this); } - @Override public void actionPerformed(ActionEvent evt) { String command = evt.getActionCommand(); @@ -219,6 +209,7 @@ public class JDialogMultiString extends JDialogBase implements ActionListener { } } + public void closeDialog() { set = true; dispose(); diff --git a/src/main/java/ui/window/JDialogMultiStringAndTabs.java b/src/main/java/ui/window/JDialogMultiStringAndTabs.java index c7b59926e6..33bc0d40ee 100644 --- a/src/main/java/ui/window/JDialogMultiStringAndTabs.java +++ b/src/main/java/ui/window/JDialogMultiStringAndTabs.java @@ -36,26 +36,15 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.window; -import java.awt.Container; -import java.awt.Font; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import javax.swing.JTextField; /** * Class JDialogMultiStringAndTabs @@ -67,7 +56,7 @@ import javax.swing.JTextField; */ public class JDialogMultiStringAndTabs extends JDialogBase implements ActionListener { - private List<TabInfo> tabs; + private ArrayList<TabInfo> tabs; private int totalNbOfStrings; private boolean set = false; @@ -75,16 +64,16 @@ public class JDialogMultiStringAndTabs extends JDialogBase implements ActionList // Panel1 private JTextField[] texts; private JButton inserts[]; - private Map<Integer, JComboBox<String>> helps; + private HashMap<Integer, JComboBox<String>> helps; - // private List<String[]> possibleValues = null; + private ArrayList<String[]> possibleValues = null; /** * Creates new form */ // arrayDelay: [0] -> minDelay ; [1] -> maxDelay - public JDialogMultiStringAndTabs(Frame f, String title, List<TabInfo> _tabs) { + public JDialogMultiStringAndTabs(Frame f, String title, ArrayList<TabInfo> _tabs) { super(f, title, true); @@ -98,13 +87,13 @@ public class JDialogMultiStringAndTabs extends JDialogBase implements ActionList texts = new JTextField[totalNbOfStrings]; initComponents(); - //myInitComponents(); + myInitComponents(); pack(); } -// private void myInitComponents() { -// } + private void myInitComponents() { + } private void initComponents() { inserts = new JButton[totalNbOfStrings]; @@ -172,10 +161,15 @@ public class JDialogMultiStringAndTabs extends JDialogBase implements ActionList } + + //panel1.setBorder(new javax.swing.border.TitledBorder("Properties")); //panel1.setPreferredSize(new Dimension(600, 300)); + + + // main panel; c0.gridwidth = 1; c0.gridheight = 10; @@ -192,7 +186,6 @@ public class JDialogMultiStringAndTabs extends JDialogBase implements ActionList initButtons(c0, c, this); } - @Override public void actionPerformed(ActionEvent evt) { String command = evt.getActionCommand(); @@ -210,6 +203,7 @@ public class JDialogMultiStringAndTabs extends JDialogBase implements ActionList } } + public void closeDialog() { set = true; dispose(); @@ -238,6 +232,7 @@ public class JDialogMultiStringAndTabs extends JDialogBase implements ActionList return texts[i].getText().length() > 0; } + public boolean hasBeenSet() { return set; } diff --git a/src/main/java/ui/window/JDialogNCRoute.java b/src/main/java/ui/window/JDialogNCRoute.java index cdeca43774..abea3c8950 100644 --- a/src/main/java/ui/window/JDialogNCRoute.java +++ b/src/main/java/ui/window/JDialogNCRoute.java @@ -36,32 +36,22 @@ * knowledge of the CeCILL license and that you accept its terms. */ + + + package ui.window; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.List; -import java.util.Vector; +import ui.util.IconManager; +import ui.ncdd.NCRoute; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; +import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; - -import ui.ncdd.NCRoute; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Vector; /** @@ -73,7 +63,7 @@ import ui.ncdd.NCRoute; */ public class JDialogNCRoute extends JDialogBase implements ActionListener, ListSelectionListener { private Vector<NCRoute> routes; - private List<String> inputInterfaces, traffics, outputInterfaces; + private ArrayList<String> inputInterfaces, traffics, outputInterfaces; protected String value; @@ -92,7 +82,7 @@ public class JDialogNCRoute extends JDialogBase implements ActionListener, ListS private JTextField valueText; /** Creates new form */ - public JDialogNCRoute(Frame _f, String _title, String _value, Vector<NCRoute> _routes, List<String> _inputInterfaces, List<String> _traffics, List<String> _outputInterfaces) { + public JDialogNCRoute(Frame _f, String _title, String _value, Vector<NCRoute> _routes, ArrayList<String> _inputInterfaces, ArrayList<String> _traffics, ArrayList<String> _outputInterfaces) { super(_f, _title, true); value = _value; @@ -286,8 +276,8 @@ public class JDialogNCRoute extends JDialogBase implements ActionListener, ListS initButtons(c0, c, this); } - @Override public void actionPerformed(ActionEvent evt) { + String command = evt.getActionCommand(); // Compare the action command to the known actions. @@ -330,6 +320,7 @@ public class JDialogNCRoute extends JDialogBase implements ActionListener, ListS } } + private void addRoute() { String s0 = (String)(inputInterfaceBox.getSelectedItem()); String s1 = (String)(trafficBox.getSelectedItem()); @@ -395,7 +386,6 @@ public class JDialogNCRoute extends JDialogBase implements ActionListener, ListS return hasBeenCancelled; } - @Override public void valueChanged(ListSelectionEvent e) { int i = listRoute.getSelectedIndex() ; if (i == -1) { @@ -420,4 +410,6 @@ public class JDialogNCRoute extends JDialogBase implements ActionListener, ListS public String getValue() { return valueText.getText(); } + + } diff --git a/src/main/java/ui/window/JDialogPerformancePragma.java b/src/main/java/ui/window/JDialogPerformancePragma.java index ba2dc8421e..f204f13efe 100644 --- a/src/main/java/ui/window/JDialogPerformancePragma.java +++ b/src/main/java/ui/window/JDialogPerformancePragma.java @@ -36,6 +36,7 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.window; import ui.util.IconManager; @@ -77,7 +78,7 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe protected JMenuBar menuBar; protected JMenu help; protected JPopupMenu helpPopup; - public Map<String, List<String>> blockAttributeMap = new HashMap<String, List<String>>(); + public Map<String, List<String>> blockAttributeMap = new HashMap<String, java.util.List<String>>(); /** * Creates new form @@ -160,6 +161,7 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe return list; } + public boolean insertSelection() { //Note that it will not add if the selection will not fit on the current line if (!popupMenu.isVisible()) { @@ -402,6 +404,7 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe } else if (evt.getSource() == close) { close(); } + } public void cancel() { @@ -424,4 +427,6 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe public String getText() { return text; } + + } diff --git a/src/main/java/ui/window/JDialogPragma.java b/src/main/java/ui/window/JDialogPragma.java index 04d1b1fd37..21d864dcef 100644 --- a/src/main/java/ui/window/JDialogPragma.java +++ b/src/main/java/ui/window/JDialogPragma.java @@ -78,8 +78,8 @@ public class JDialogPragma extends JDialogBase implements ActionListener { protected JButton cancel; protected JMenu help; private JPopupMenu helpPopup; - public Map<String, List<String>> blockAttributeMap = new HashMap<>(); - public Map<String, List<String>> blockStateMap = new HashMap<>(); + public Map<String, java.util.List<String>> blockAttributeMap = new HashMap<>(); + public Map<String, java.util.List<String>> blockStateMap = new HashMap<>(); /** * Creates new form @@ -395,7 +395,6 @@ public class JDialogPragma extends JDialogBase implements ActionListener { } - @Override public void actionPerformed(ActionEvent evt) { String command = evt.getActionCommand(); @@ -405,6 +404,7 @@ public class JDialogPragma extends JDialogBase implements ActionListener { } else if (command.equals("Ok")) { close(); } + } public void cancel() { @@ -427,4 +427,6 @@ public class JDialogPragma extends JDialogBase implements ActionListener { public String getText() { return text; } + + } diff --git a/src/main/java/ui/window/JDialogSafetyPragma.java b/src/main/java/ui/window/JDialogSafetyPragma.java index 6bb6c760e3..bb9afff2fe 100644 --- a/src/main/java/ui/window/JDialogSafetyPragma.java +++ b/src/main/java/ui/window/JDialogSafetyPragma.java @@ -36,6 +36,7 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.window; import ui.util.IconManager; @@ -77,7 +78,7 @@ public class JDialogSafetyPragma extends JDialogBase implements ActionListener { protected JMenuBar menuBar; protected JMenu help; protected JPopupMenu helpPopup; - public Map<String, List<String>> blockAttributeMap = new HashMap<String, List<String>>(); + public Map<String, List<String>> blockAttributeMap = new HashMap<String, java.util.List<String>>(); /** * Creates new form diff --git a/src/main/java/ui/window/JDialogSelectAvatarBlock.java b/src/main/java/ui/window/JDialogSelectAvatarBlock.java index 6881282a33..2e7eef1348 100644 --- a/src/main/java/ui/window/JDialogSelectAvatarBlock.java +++ b/src/main/java/ui/window/JDialogSelectAvatarBlock.java @@ -36,6 +36,7 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.window; import ui.avatarbd.AvatarBDStateMachineOwner; @@ -68,8 +69,7 @@ import java.util.List; * @version 1.0 18/05/2010 */ public class JDialogSelectAvatarBlock extends JDialogBase implements ActionListener, ListSelectionListener { - - public List<AvatarBDStateMachineOwner> validated, ignored; + public List<AvatarBDStateMachineOwner> validated, ignored; private boolean optimized = true; private List<AvatarBDStateMachineOwner> val, ign, back; @@ -282,6 +282,8 @@ public class JDialogSelectAvatarBlock extends JDialogBase implements ActionListe return; } + + // Compare the action command to the known actions. switch (command) { case "addOneIgnored": @@ -299,6 +301,7 @@ public class JDialogSelectAvatarBlock extends JDialogBase implements ActionListe } } + private void addOneIgnored() { for (AvatarBDStateMachineOwner o : this.listValidated.getSelectedValuesList()) { ign.add(o); diff --git a/src/main/java/ui/window/TabInfo.java b/src/main/java/ui/window/TabInfo.java index c2f65e93c7..e2cfa09b8b 100644 --- a/src/main/java/ui/window/TabInfo.java +++ b/src/main/java/ui/window/TabInfo.java @@ -36,9 +36,15 @@ * knowledge of the CeCILL license and that you accept its terms. */ + package ui.window; -import java.util.List; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; /** * Class TabInfo @@ -53,7 +59,7 @@ public class TabInfo { public String identifier; public String[] labels; public String[] values; - public List<String[]> help; + public ArrayList<String[]> help; public TabInfo(String _identifier) { identifier = _identifier; diff --git a/ttool/src/test/java/avatartranslator/AvatarPragmaTests.java b/ttool/src/test/java/avatartranslator/AvatarPragmaTests.java index 3e47f9cfbf..b9b7c0e8e3 100644 --- a/ttool/src/test/java/avatartranslator/AvatarPragmaTests.java +++ b/ttool/src/test/java/avatartranslator/AvatarPragmaTests.java @@ -45,30 +45,47 @@ package avatartranslator; -import static org.junit.Assert.assertEquals; +import org.junit.Test; +import org.junit.*; + +import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; + +import java.util.LinkedList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; -import java.util.Map; -import org.junit.Before; -import org.junit.Test; import ui.TAttribute; -import ui.avatarbd.AvatarBDPanel; import ui.avatarbd.AvatarBDPragma; +import ui.avatarbd.AvatarBDPanel; + +import avatartranslator.ErrorAccumulator; +import avatartranslator.AvatarStateMachine; +import avatartranslator.AvatarState; +import avatartranslator.AvatarAttribute; +import avatartranslator.AvatarType; +import avatartranslator.AvatarBlock; +import avatartranslator.AvatarPragma; +import avatartranslator.AvatarPragmaSecret; +import avatartranslator.AvatarPragmaSecrecyAssumption; +import avatartranslator.AvatarPragmaInitialKnowledge; +import avatartranslator.AvatarPragmaPrivatePublicKey; +import avatartranslator.AvatarPragmaPublic; +import avatartranslator.AvatarPragmaAuthenticity; +import avatartranslator.AvatarPragmaConstant; public class AvatarPragmaTests { List<AvatarPragma> res; ErrorAccumulator errorAcc; - Map<String, List<TAttribute>> typeAttributesMap = new HashMap<>(); - Map<String, String> nameTypeMap = new HashMap<String, String>(); - List<AvatarBlock> blocks; + HashMap<String, List<TAttribute>> typeAttributesMap = new HashMap<>(); + HashMap<String, String> nameTypeMap = new HashMap<String, String>(); + LinkedList<AvatarBlock> blocks; AvatarBDPragma bdpragma; - - public AvatarPragmaTests() { + public AvatarPragmaTests () { // } @@ -110,8 +127,8 @@ public class AvatarPragmaTests { this.nameTypeMap.put("C.m", "T1"); this.nameTypeMap.put("B.m", "T1"); this.nameTypeMap.put("C.d", "T2"); - List<TAttribute> t1s = new LinkedList<TAttribute>(); - List<TAttribute> t2s = new LinkedList<TAttribute>(); + LinkedList<TAttribute> t1s = new LinkedList<TAttribute>(); + LinkedList<TAttribute> t2s = new LinkedList<TAttribute>(); t1s.add(attr_a); t1s.add(attr_b); t2s.add(attr_c); @@ -125,6 +142,9 @@ public class AvatarPragmaTests { } //protected void test () { + + + @Test public void testBadKeywordNoPragmaCreated(){ //Test Bad keyword -- GitLab