13 |
ddelon |
1 |
/*
|
|
|
2 |
* Copyright 2006 Google Inc.
|
|
|
3 |
*
|
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
|
5 |
* use this file except in compliance with the License. You may obtain a copy of
|
|
|
6 |
* the License at
|
|
|
7 |
*
|
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
9 |
*
|
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
12 |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
13 |
* License for the specific language governing permissions and limitations under
|
|
|
14 |
* the License.
|
|
|
15 |
*/
|
|
|
16 |
package org.tela_botanica.client;
|
|
|
17 |
|
|
|
18 |
|
14 |
ddelon |
19 |
import com.google.gwt.user.client.Window;
|
13 |
ddelon |
20 |
import com.google.gwt.user.client.ui.ClickListener;
|
|
|
21 |
import com.google.gwt.user.client.ui.Composite;
|
|
|
22 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
23 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
24 |
import com.google.gwt.user.client.ui.Label;
|
|
|
25 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget()
|
|
|
29 |
*/
|
|
|
30 |
|
|
|
31 |
public class ActionPanel extends Composite {
|
|
|
32 |
|
|
|
33 |
Mediator mediator=null;
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
public ActionPanel(final Mediator med) {
|
|
|
38 |
|
|
|
39 |
mediator=med;
|
|
|
40 |
|
|
|
41 |
HorizontalPanel outer = new HorizontalPanel();
|
14 |
ddelon |
42 |
HorizontalPanel buttons = new HorizontalPanel();
|
|
|
43 |
buttons.setSpacing(3);
|
|
|
44 |
|
13 |
ddelon |
45 |
|
14 |
ddelon |
46 |
// Transmission d'elements
|
|
|
47 |
|
|
|
48 |
HTML transButton=new HTML("Transmettre Tela Botanica");
|
|
|
49 |
transButton.setStyleName("html_button_long");
|
|
|
50 |
transButton.addClickListener(
|
|
|
51 |
new ClickListener() {
|
|
|
52 |
public void onClick(Widget sender) {
|
|
|
53 |
// TODO : une action dans le mediator
|
|
|
54 |
if (mediator.getConnected()) {
|
|
|
55 |
mediator.getInventoryItemList().transmitElement();
|
|
|
56 |
}
|
|
|
57 |
else {
|
|
|
58 |
Window.alert("Identifiez-vous pour transmettre");
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
}
|
|
|
62 |
);
|
|
|
63 |
|
|
|
64 |
buttons.add(transButton);
|
|
|
65 |
|
13 |
ddelon |
66 |
// Suppression d'elements
|
|
|
67 |
|
|
|
68 |
HTML delButton=new HTML("Suppression");
|
|
|
69 |
delButton.setStyleName("html_button");
|
|
|
70 |
delButton.addClickListener(
|
|
|
71 |
new ClickListener() {
|
|
|
72 |
public void onClick(Widget sender) {
|
|
|
73 |
// TODO : une action dans le mediator
|
|
|
74 |
mediator.getInventoryItemList().deleteElement();
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
);
|
|
|
78 |
|
14 |
ddelon |
79 |
buttons.add(delButton);
|
13 |
ddelon |
80 |
|
|
|
81 |
// Export de la totalité
|
|
|
82 |
|
14 |
ddelon |
83 |
HTML exportButton=new HTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" +mediator.getUser()+"\">"+"Tout exporter</a>");
|
|
|
84 |
buttons.add(exportButton);
|
13 |
ddelon |
85 |
exportButton.setStyleName("html_button");
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
// Selections de l'affichage
|
|
|
90 |
|
|
|
91 |
HorizontalPanel selections = new HorizontalPanel();
|
|
|
92 |
|
|
|
93 |
selections.setSpacing(3);
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
selections.add(new HTML("Sélection : "));
|
|
|
97 |
|
|
|
98 |
Label allLabel = new Label("Tous");
|
|
|
99 |
Label separatorLabel = new Label(",");
|
|
|
100 |
Label noneLabel = new Label("Aucun");
|
|
|
101 |
|
|
|
102 |
allLabel.setStyleName("selection_label");
|
|
|
103 |
noneLabel.setStyleName("selection_label");
|
|
|
104 |
|
|
|
105 |
selections.add(allLabel);
|
|
|
106 |
allLabel.addClickListener(
|
|
|
107 |
new ClickListener() {
|
|
|
108 |
public void onClick(Widget sender) {
|
|
|
109 |
// TODO : une action dans le mediator
|
|
|
110 |
mediator.getInventoryItemList().selectAll();
|
|
|
111 |
}
|
|
|
112 |
}
|
|
|
113 |
);
|
|
|
114 |
|
|
|
115 |
selections.add(separatorLabel);
|
|
|
116 |
|
|
|
117 |
selections.add(noneLabel);
|
|
|
118 |
noneLabel.addClickListener(
|
|
|
119 |
new ClickListener() {
|
|
|
120 |
public void onClick(Widget sender) {
|
|
|
121 |
// TODO : une action dans le mediator
|
|
|
122 |
mediator.getInventoryItemList().deselectAll();
|
|
|
123 |
}
|
|
|
124 |
}
|
|
|
125 |
);
|
|
|
126 |
|
|
|
127 |
|
14 |
ddelon |
128 |
outer.add(buttons);
|
13 |
ddelon |
129 |
outer.add(selections);
|
|
|
130 |
|
|
|
131 |
initWidget(outer);
|
|
|
132 |
this.setStyleName("action-Panel");
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
}
|
|
|
136 |
}
|