Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GoikLectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goik Martin
GoikLectures
Commits
9933509e
Commit
9933509e
authored
9 years ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
Working integer list example
parent
e7d5c455
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
P/Sda1/Jpa/Company/companyJpa1/src/main/java/de/hdm_stuttgart/mi/company/ui/HelloUi.java
+70
-46
70 additions, 46 deletions
...src/main/java/de/hdm_stuttgart/mi/company/ui/HelloUi.java
with
70 additions
and
46 deletions
P/Sda1/Jpa/Company/companyJpa1/src/main/java/de/hdm_stuttgart/mi/company/ui/HelloUi.java
+
70
−
46
View file @
9933509e
package
de.hdm_stuttgart.mi.company.ui
;
import
java.util.SortedSet
;
import
java.util.TreeSet
;
import
javax.servlet.annotation.WebServlet
;
import
com.vaadin.annotations.Theme
;
import
com.vaadin.annotations.Title
;
import
com.vaadin.annotations.VaadinServletConfiguration
;
import
com.vaadin.data.Property
;
import
com.vaadin.data.Property.ValueChangeEvent
;
import
com.vaadin.data.util.ObjectProperty
;
import
com.vaadin.server.VaadinRequest
;
import
com.vaadin.server.VaadinServlet
;
import
com.vaadin.ui.GridLayout
;
import
com.vaadin.ui.HorizontalLayout
;
import
com.vaadin.ui.Label
;
import
com.vaadin.ui.TextField
;
import
com.vaadin.ui.UI
;
import
com.vaadin.ui.VerticalLayout
;
...
...
@@ -20,51 +28,67 @@ import com.vaadin.ui.VerticalLayout;
@Theme
(
"valo"
)
public
class
HelloUi
extends
UI
{
private
static
final
long
serialVersionUID
=
-
307591917714387247L
;
@Override
protected
void
init
(
VaadinRequest
request
)
{
// The root of the component hierarchy
VerticalLayout
content
=
new
VerticalLayout
();
content
.
setSizeFull
();
// Use entire window
setContent
(
content
);
// Attach to the UI
// Add some component
content
.
addComponent
(
new
Label
(
"Hello!"
));
// Layout inside layout
HorizontalLayout
hor
=
new
HorizontalLayout
();
hor
.
setSizeFull
();
// Use all available space
// // Couple of horizontally laid out components
// Tree tree = new Tree("My Tree",
// TreeExample.createTreeContent());
// hor.addComponent(tree);
//
// Table table = new Table("My Table",
// TableExample.generateContent());
// table.setSizeFull();
// hor.addComponent(table);
// hor.setExpandRatio(table, 1); // Expand to fill
content
.
addComponent
(
hor
);
content
.
setExpandRatio
(
hor
,
1
);
// Expand to fill
}
/** Deployed as a Servlet or Portlet.
*
* You can specify additional servlet parameters like the URI and UI
* class name and turn on production mode when you have finished developing the application.
*/
@WebServlet
(
urlPatterns
=
"/*"
)
@VaadinServletConfiguration
(
ui
=
HelloUi
.
class
,
productionMode
=
false
)
public
static
class
MyUIServlet
extends
VaadinServlet
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
2771410633323765889L
;
}
private
static
final
long
serialVersionUID
=
-
307591917714387247L
;
static
String
convert
(
final
SortedSet
<
Integer
>
values
)
{
if
(
0
==
values
.
size
())
{
return
""
;
}
else
{
final
StringBuffer
ret
=
new
StringBuffer
(
values
.
first
().
toString
());
final
Integer
v
[]
=
values
.
toArray
(
new
Integer
[
values
.
size
()]);
for
(
int
i
=
1
;
i
<
v
.
length
;
i
++)
{
ret
.
append
(
", "
+
v
[
i
]);
}
return
ret
.
toString
();
}
}
final
SortedSet
<
Integer
>
values
=
new
TreeSet
<
Integer
>();
@Override
protected
void
init
(
VaadinRequest
request
)
{
final
GridLayout
grid
=
new
GridLayout
(
2
,
3
);
setContent
(
grid
);
// Attach to the UI
// Add or remove value
final
ObjectProperty
<
Integer
>
addInteger
=
new
ObjectProperty
<
Integer
>(
0
),
removeInteger
=
new
ObjectProperty
<
Integer
>(
0
);
final
TextField
addEditor
=
new
TextField
(
addInteger
),
removeEditor
=
new
TextField
(
removeInteger
);
final
Label
output
=
new
Label
();
grid
.
addComponents
(
new
Label
(
"Add value:"
),
addEditor
,
new
Label
(
"Remove value:"
),
removeEditor
,
new
Label
(
"Numbers:"
),
output
);
addEditor
.
addValueChangeListener
(
event
->
{
final
Integer
i
=
addInteger
.
getValue
();
if
(
null
!=
i
&&
values
.
add
(
i
))
{
output
.
setValue
(
convert
(
values
));
}
});
removeEditor
.
addValueChangeListener
(
event
->
{
final
Integer
i
=
removeInteger
.
getValue
();
if
(
null
!=
i
&&
values
.
remove
(
i
))
{
output
.
setValue
(
convert
(
values
));
}
});
}
/** Deployment description .
*
*/
@WebServlet
(
urlPatterns
=
"/*"
)
@VaadinServletConfiguration
(
ui
=
HelloUi
.
class
,
productionMode
=
false
)
public
static
class
MyUIServlet
extends
VaadinServlet
{
private
static
final
long
serialVersionUID
=
-
2771410633323765889L
;
}
}
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