Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TULIP-CPS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NUI
TULIP-CPS
Commits
764c0e36
Commit
764c0e36
authored
Dec 22, 2017
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified VariableHtmlBox to make use of HtmlTemplate helper class.
parent
594515b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
43 deletions
+16
-43
CPS/src/lu/list/itis/dkd/tui/utility/HtmlTemplate.java
CPS/src/lu/list/itis/dkd/tui/utility/HtmlTemplate.java
+6
-0
CPS/src/lu/list/itis/dkd/tui/widget/corona/VariableHtmlBox.java
...c/lu/list/itis/dkd/tui/widget/corona/VariableHtmlBox.java
+10
-43
No files found.
CPS/src/lu/list/itis/dkd/tui/utility/HtmlTemplate.java
View file @
764c0e36
...
...
@@ -62,6 +62,12 @@ public class HtmlTemplate implements VariableBased {
// ---------------------------------------------------------------------------
public
boolean
dependsOnVariables
()
{
return
!
this
.
identifiers
.
isEmpty
();
}
// ---------------------------------------------------------------------------
public
String
render
()
{
return
Interpolator
.
render
(
chunks
);
}
...
...
CPS/src/lu/list/itis/dkd/tui/widget/corona/VariableHtmlBox.java
View file @
764c0e36
...
...
@@ -17,14 +17,9 @@ import lu.list.itis.dkd.tui.cps.InputChangeListener;
import
lu.list.itis.dkd.tui.cps.InputEvent
;
import
lu.list.itis.dkd.tui.cps.system.VariableBased
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.utility.interpolation.Chunk
;
import
lu.list.itis.dkd.tui.utility.interpolation.Interpolator
;
import
lu.list.itis.dkd.tui.utility.HtmlTemplate
;
import
lu.list.itis.dkd.tui.widget.corona.builder.BaseVariableHtmlBoxBuilder
;
import
org.python.google.common.base.Strings
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -41,10 +36,7 @@ import java.util.Map;
public
class
VariableHtmlBox
extends
HtmlBox
implements
VariableBased
,
InputChangeListener
{
private
String
htmlTemplate
;
private
List
<
Chunk
<?>>
htmlChunks
;
private
List
<
String
>
identifiers
;
private
Map
<
String
,
Variable
<?>>
parameters
;
private
HtmlTemplate
htmlTemplate
;
// ---------------------------------------------------------------------------
// ***************************************************************************
...
...
@@ -58,16 +50,9 @@ public class VariableHtmlBox extends HtmlBox implements VariableBased, InputChan
public
VariableHtmlBox
(
BaseVariableHtmlBoxBuilder
<?>
builder
)
{
super
(
builder
);
htmlTemplate
=
builder
.
htmlTemplate
;
this
.
parameters
=
new
HashMap
<>();
if
(!
Strings
.
isNullOrEmpty
(
this
.
htmlTemplate
))
{
identifiers
=
Interpolator
.
extractVariableIdentifiers
(
this
.
htmlTemplate
);
if
(
identifiers
.
isEmpty
())
{
this
.
htmlContent
=
this
.
htmlTemplate
;
this
.
setInformation
(
this
.
htmlContent
);
}
htmlTemplate
=
new
HtmlTemplate
(
builder
.
htmlTemplate
);
if
(!
htmlTemplate
.
dependsOnVariables
())
{
this
.
setInformation
(
builder
.
htmlTemplate
);
}
}
...
...
@@ -87,21 +72,7 @@ public class VariableHtmlBox extends HtmlBox implements VariableBased, InputChan
@Override
public
List
<
Variable
<?>>
connectWithSystemVariables
(
Map
<
String
,
Variable
<?>>
systemVariables
)
{
List
<
Variable
<?>>
connected
=
new
ArrayList
<>();
for
(
String
identifier
:
identifiers
)
{
if
((
systemVariables
!=
null
)
&&
systemVariables
.
containsKey
(
identifier
))
{
Variable
<?>
variable
=
systemVariables
.
get
(
identifier
);
this
.
parameters
.
put
(
identifier
,
variable
);
connected
.
add
(
variable
);
variable
.
addListener
(
this
);
}
}
if
(!
connected
.
isEmpty
())
{
htmlChunks
=
Interpolator
.
decompose
(
this
.
htmlTemplate
,
this
.
parameters
);
}
return
connected
;
return
htmlTemplate
.
connectWithSystemVariables
(
systemVariables
);
}
// ---------------------------------------------------------------------------
...
...
@@ -110,9 +81,9 @@ public class VariableHtmlBox extends HtmlBox implements VariableBased, InputChan
@Override
public
void
inputChanged
(
InputEvent
input
)
{
if
(
parameters
.
containsKey
(
input
.
getSource
().
getName
()))
{
this
.
htmlContent
=
Interpolator
.
render
(
htmlChunks
);
this
.
setInformation
(
this
.
htmlContent
);
String
identifier
=
input
.
getSource
().
getName
();
if
(
htmlTemplate
.
dependsOn
(
identifier
))
{
this
.
setInformation
(
htmlTemplate
.
render
()
);
}
}
...
...
@@ -122,11 +93,7 @@ public class VariableHtmlBox extends HtmlBox implements VariableBased, InputChan
@Override
public
List
<
Variable
<?>>
getDeclaredVariables
()
{
List
<
Variable
<?>>
declared
=
new
ArrayList
<>();
for
(
Variable
<?>
parameter
:
this
.
parameters
.
values
())
{
declared
.
add
(
parameter
);
}
return
declared
;
return
htmlTemplate
.
getDeclaredVariables
();
}
// ---------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment