Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mbe-tools
TTool
Commits
96cdc6dc
Commit
96cdc6dc
authored
6 years ago
by
Minh Hiep Pham
Browse files
Options
Downloads
Patches
Plain Diff
Update methods for checking valid port names 2
parent
f7984fc4
No related branches found
No related tags found
1 merge request
!101
checking the valid port names
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/tmltranslator/TMLSyntaxChecking.java
+15
-0
15 additions, 0 deletions
src/main/java/tmltranslator/TMLSyntaxChecking.java
src/main/java/ui/tmlcompd/TMLCPrimitivePort.java
+25
-8
25 additions, 8 deletions
src/main/java/ui/tmlcompd/TMLCPrimitivePort.java
with
40 additions
and
8 deletions
src/main/java/tmltranslator/TMLSyntaxChecking.java
+
15
−
0
View file @
96cdc6dc
...
@@ -45,6 +45,9 @@ import compiler.tmlparser.TMLExprParser;
...
@@ -45,6 +45,9 @@ import compiler.tmlparser.TMLExprParser;
import
compiler.tmlparser.TokenMgrError
;
import
compiler.tmlparser.TokenMgrError
;
import
myutil.Conversion
;
import
myutil.Conversion
;
import
myutil.TraceManager
;
import
myutil.TraceManager
;
import
ui.TAttribute
;
import
ui.tmlcompd.TMLCPrimitiveComponent
;
import
ui.tmlcompd.TMLCPrimitivePort
;
import
java.io.StringReader
;
import
java.io.StringReader
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -387,6 +390,18 @@ public class TMLSyntaxChecking {
...
@@ -387,6 +390,18 @@ public class TMLSyntaxChecking {
}
}
}
}
// Checking valid port names
// Minh Hiep
if
(
t
.
getReferenceObject
()
instanceof
TMLCPrimitiveComponent
)
{
TMLCPrimitiveComponent
tmlcpc
=
(
TMLCPrimitiveComponent
)
t
.
getReferenceObject
();
for
(
TMLCPrimitivePort
tmlcpp
:
tmlcpc
.
getAllInternalPrimitivePorts
())
{
String
s
=
tmlcpp
.
getPortName
();
if
(!
TAttribute
.
isAValidId
(
s
,
false
,
true
,
false
))
{
addError
(
t
,
null
,
WRONG_VARIABLE_IDENTIFIER
+
": invalid port name ("
+
s
+
")"
,
TMLError
.
ERROR_STRUCTURE
);
}
}
}
int
n
=
tactivity
.
nElements
();
int
n
=
tactivity
.
nElements
();
//TraceManager.addDev("Task" + t.getName());
//TraceManager.addDev("Task" + t.getName());
...
...
This diff is collapsed.
Click to expand it.
src/main/java/ui/tmlcompd/TMLCPrimitivePort.java
+
25
−
8
View file @
96cdc6dc
...
@@ -73,6 +73,8 @@ import ui.interactivesimulation.JFrameSimulationSDPanel;
...
@@ -73,6 +73,8 @@ import ui.interactivesimulation.JFrameSimulationSDPanel;
import
javax.swing.*
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Vector
;
import
java.util.Vector
;
/**
/**
...
@@ -159,6 +161,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
...
@@ -159,6 +161,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
public
int
verification
;
public
int
verification
;
public
String
oldName
;
public
TMLCPrimitivePort
(
int
_x
,
int
_y
,
int
_minX
,
int
_maxX
,
int
_minY
,
int
_maxY
,
boolean
_pos
,
TGComponent
_father
,
TDiagramPanel
_tdp
)
{
public
TMLCPrimitivePort
(
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
);
super
(
_x
,
_y
,
_minX
,
_maxX
,
_minY
,
_maxY
,
_pos
,
_father
,
_tdp
);
...
@@ -610,7 +613,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
...
@@ -610,7 +613,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
TraceManager
.
addDev
(
"The Data flow type is: "
+
dataFlowType
);
TraceManager
.
addDev
(
"The Data flow type is: "
+
dataFlowType
);
TraceManager
.
addDev
(
"The Associated event is: "
+
associatedEvent
);
TraceManager
.
addDev
(
"The Associated event is: "
+
associatedEvent
);
String
oldName
=
getPortName
();
oldName
=
getPortName
();
//TraceManager.addDev("old port name : " + oldName);
//TraceManager.addDev("old port name : " + oldName);
if
(
jda
.
hasNewData
())
{
if
(
jda
.
hasNewData
())
{
...
@@ -637,16 +640,16 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
...
@@ -637,16 +640,16 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
if
(!
TAttribute
.
isAValidId
(
s
,
false
,
true
,
false
))
{
if
(!
TAttribute
.
isAValidId
(
s
,
false
,
true
,
false
))
{
JOptionPane
.
showMessageDialog
(
frame
,
JOptionPane
.
showMessageDialog
(
frame
,
"Could not change the name of the port: the new name is not a valid name"
,
"Could not change the name of the port: the new name
("
+
s
+
")
is not a valid name"
,
"Error"
,
"Error"
,
JOptionPane
.
INFORMATION_MESSAGE
);
JOptionPane
.
INFORMATION_MESSAGE
);
return
false
;
return
false
;
}
}
if
(
oldName
.
compareTo
(
s
)
!=
0
)
{
if
(
oldName
.
compareTo
(
s
)
!=
0
)
{
if
(((
TMLComponentTaskDiagramPanel
)
(
tdp
)
)
.
namePrimitivePortInUse
(
this
,
s
))
{
if
(((
TMLComponentTaskDiagramPanel
)
tdp
).
namePrimitivePortInUse
(
this
,
s
))
{
JOptionPane
.
showMessageDialog
(
frame
,
JOptionPane
.
showMessageDialog
(
frame
,
"Error: the name is already in use"
,
"Error: the name
("
+
s
+
")
is already in use"
,
"Name modification"
,
"Name modification"
,
JOptionPane
.
ERROR_MESSAGE
);
JOptionPane
.
ERROR_MESSAGE
);
return
false
;
return
false
;
...
@@ -841,7 +844,24 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
...
@@ -841,7 +844,24 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
}
}
if
(
elt
.
getTagName
().
equals
(
"Prop"
))
{
if
(
elt
.
getTagName
().
equals
(
"Prop"
))
{
commName
=
elt
.
getAttribute
(
"commName"
);
// checking the valid port name
oldName
=
getPortName
();
String
s
=
elt
.
getAttribute
(
"commName"
);
//TraceManager.addDev("port name : " + s);
if
((
s
!=
null
)
&&
(
s
.
length
()
>
0
))
{
// Check whether this name is already in use, or not
if
(!
TAttribute
.
isAValidId
(
s
,
false
,
false
,
false
))
{
JOptionPane
.
showMessageDialog
(
null
,
"Could not change the name of the port: the new name ("
+
s
+
") is not a valid name"
,
"Error : "
+
s
,
JOptionPane
.
INFORMATION_MESSAGE
);
setPortName
(
s
);
makeValue
();
}
commName
=
s
;
}
try
{
try
{
//
//
typep
=
Integer
.
decode
(
elt
.
getAttribute
(
"commType"
)).
intValue
();
typep
=
Integer
.
decode
(
elt
.
getAttribute
(
"commType"
)).
intValue
();
...
@@ -1183,7 +1203,4 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
...
@@ -1183,7 +1203,4 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
typePort
=
2
;
typePort
=
2
;
return
typePort
;
return
typePort
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment