Revision 14fd703d
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java | ||
---|---|---|
116 | 116 |
* {@inheritDoc} |
117 | 117 |
*/ |
118 | 118 |
@Override |
119 |
public int getWindowPixelWidth() {
|
|
119 |
public int getWindowWidth() { |
|
120 | 120 |
return 800; |
121 | 121 |
} |
122 | 122 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/occurrence/CollectionPopupEditor.java | ||
---|---|---|
67 | 67 |
* {@inheritDoc} |
68 | 68 |
*/ |
69 | 69 |
@Override |
70 |
public int getWindowPixelWidth() {
|
|
70 |
public int getWindowWidth() { |
|
71 | 71 |
return 500; |
72 | 72 |
} |
73 | 73 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPopup.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.registration; |
10 | 10 |
|
11 |
import java.text.SimpleDateFormat; |
|
11 | 12 |
import java.util.Collection; |
12 | 13 |
import java.util.List; |
13 | 14 |
|
... | ... | |
25 | 26 |
import com.vaadin.ui.Panel; |
26 | 27 |
import com.vaadin.ui.TextArea; |
27 | 28 |
import com.vaadin.ui.VerticalLayout; |
29 |
import com.vaadin.ui.themes.ValoTheme; |
|
28 | 30 |
|
29 | 31 |
import eu.etaxonomy.cdm.ext.registration.messages.Message; |
30 | 32 |
import eu.etaxonomy.cdm.vaadin.event.error.DelegatingErrorHandler; |
... | ... | |
55 | 57 |
// popup window may have problems with automatic resizing of its |
56 | 58 |
// content. |
57 | 59 |
mainLayout.setSizeFull(); |
60 |
|
|
58 | 61 |
setCompositionRoot(mainLayout); |
59 | 62 |
} |
60 | 63 |
|
61 |
/** |
|
62 |
* {@inheritDoc} |
|
63 |
*/ |
|
64 |
|
|
64 | 65 |
@Override |
65 | 66 |
protected void initContent() { |
66 | 67 |
|
... | ... | |
71 | 72 |
newMessageField.addTextChangeListener(e -> { |
72 | 73 |
sendMessageButton.setEnabled(StringUtils.isNoneBlank(e.getText())); |
73 | 74 |
}); |
75 |
newMessageField.setHeight("64px"); // height of the Submit button when ValoTheme.BUTTON_HUGE |
|
76 |
newMessageField.setWidth("100%"); |
|
74 | 77 |
|
75 | 78 |
sendMessageButton = new Button(FontAwesome.SEND); |
76 | 79 |
sendMessageButton.addClickListener(e -> postNewMessage()); |
80 |
sendMessageButton.setStyleName(ValoTheme.BUTTON_HUGE + " " +ValoTheme.BUTTON_PRIMARY); |
|
77 | 81 |
|
78 | 82 |
HorizontalLayout sendMessagebar = new HorizontalLayout(newMessageField, sendMessageButton); |
79 | 83 |
sendMessagebar.setComponentAlignment(sendMessageButton, Alignment.MIDDLE_RIGHT); |
80 | 84 |
sendMessagebar.setExpandRatio(newMessageField, 1f); |
85 |
sendMessagebar.setWidth("100%"); |
|
81 | 86 |
|
82 | 87 |
mainLayout.addComponents(messagesPanel, sendMessagebar); |
83 | 88 |
|
84 | 89 |
mainLayout.setErrorHandler(errrorHandler); |
90 |
mainLayout.setComponentAlignment(sendMessagebar, Alignment.BOTTOM_CENTER); |
|
91 |
} |
|
92 |
|
|
93 |
|
|
94 |
@Override |
|
95 |
public int getWindowHeight() { |
|
96 |
// undefined |
|
97 |
return -1; |
|
98 |
} |
|
99 |
|
|
100 |
@Override |
|
101 |
public boolean isClosable() { |
|
102 |
return true; |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
public boolean isResizable() { |
|
107 |
return true; |
|
85 | 108 |
} |
86 | 109 |
|
87 | 110 |
/** |
... | ... | |
150 | 173 |
* {@inheritDoc} |
151 | 174 |
*/ |
152 | 175 |
@Override |
153 |
public void showMessages(List<Message> messages) { |
|
176 |
public void showMessages(String registrationLabel, List<Message> messages) {
|
|
154 | 177 |
|
155 | 178 |
VerticalLayout messagesList = new VerticalLayout(); |
156 | 179 |
|
180 |
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); |
|
181 |
|
|
157 | 182 |
for(Message message : messages){ |
158 |
Label item = new Label("<span class=\"date-time\">(" + message.getId() + ")</span> <span class=\"user-name\"><span class=\"user-name\">" + message.getFrom().getUsername() + "</span>: " + message.getText());
|
|
183 |
Label item = new Label("<span class=\"date-time\">(" + dateFormat.format(message.getCreatedOn()) + ")</span> <span class=\"user-name\"><span class=\"user-name\">" + message.getFrom().getUsername() + "</span>: " + message.getText());
|
|
159 | 184 |
item.setStyleName("message-item"); |
160 | 185 |
item.setContentMode(ContentMode.HTML); |
161 | 186 |
messagesList.addComponent(item); |
162 | 187 |
|
163 | 188 |
} |
189 |
messagesPanel.setCaption(registrationLabel); |
|
164 | 190 |
messagesPanel.setContent(messagesList); |
165 | 191 |
|
166 | 192 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPresenter.java | ||
---|---|---|
62 | 62 |
} |
63 | 63 |
try { |
64 | 64 |
List<Message> messages = messageService.listMessages(registration); |
65 |
getView().showMessages(messages); |
|
65 |
getView().showMessages("On Registration " + registration.getIdentifier(), messages);
|
|
66 | 66 |
} catch (ExternalServiceException e) { |
67 | 67 |
throw new RuntimeException(e); |
68 | 68 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesView.java | ||
---|---|---|
24 | 24 |
/** |
25 | 25 |
* @param messages |
26 | 26 |
*/ |
27 |
void showMessages(List<Message> messages); |
|
27 |
void showMessages(String registrationLabel, List<Message> messages);
|
|
28 | 28 |
|
29 | 29 |
DelegatingErrorHandler getErrrorHandler(); |
30 | 30 |
|
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupView.java | ||
---|---|---|
28 | 28 |
return false; |
29 | 29 |
} |
30 | 30 |
|
31 |
@Override |
|
32 |
public boolean isClosable(){ |
|
33 |
return false; |
|
34 |
} |
|
35 |
|
|
31 | 36 |
/** |
32 | 37 |
* {@inheritDoc} |
33 | 38 |
*/ |
34 | 39 |
@Override |
35 |
public int getWindowPixelWidth() {
|
|
40 |
public int getWindowWidth() { |
|
36 | 41 |
return -1; |
37 | 42 |
} |
38 | 43 |
|
44 |
/** |
|
45 |
* {@inheritDoc} |
|
46 |
*/ |
|
47 |
@Override |
|
48 |
public Unit getWindowWidthUnit() { |
|
49 |
return Unit.PIXELS; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* {@inheritDoc} |
|
54 |
* |
|
55 |
* <p> |
|
56 |
* <b>NOTE:</b> setting 100% as default height. If the height |
|
57 |
* would be undefined the window, will fit the size of |
|
58 |
* the content and will sometimes exceed the height of the |
|
59 |
* main window and will not get a scroll bar in this situation. |
|
60 |
* see #6843 |
|
61 |
* </p> |
|
62 |
*/ |
|
63 |
@Override |
|
64 |
public int getWindowHeight() { |
|
65 |
return 100; |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* {@inheritDoc} |
|
70 |
*/ |
|
71 |
@Override |
|
72 |
public Unit getWindowHeightUnit() { |
|
73 |
return Unit.PERCENTAGE; |
|
74 |
} |
|
75 |
|
|
76 |
|
|
39 | 77 |
/** |
40 | 78 |
* {@inheritDoc} |
41 | 79 |
*/ |
src/main/java/eu/etaxonomy/vaadin/ui/navigation/NavigationManagerBean.java | ||
---|---|---|
18 | 18 |
|
19 | 19 |
import com.vaadin.navigator.ViewChangeListener; |
20 | 20 |
import com.vaadin.navigator.ViewDisplay; |
21 |
import com.vaadin.server.Sizeable.Unit; |
|
22 | 21 |
import com.vaadin.spring.annotation.SpringView; |
23 | 22 |
import com.vaadin.spring.annotation.UIScope; |
24 | 23 |
import com.vaadin.spring.navigator.SpringNavigator; |
... | ... | |
186 | 185 |
//window.setModal(popupView.isModal()); |
187 | 186 |
window.setModal(true); |
188 | 187 |
window.setCaptionAsHtml(popupView.isWindowCaptionAsHtml()); |
189 |
window.setWidth(popupView.getWindowPixelWidth(), Unit.PIXELS); |
|
190 |
// setting 100% as default height. If the height |
|
191 |
// would be undefined the window, will fit the size of |
|
192 |
// the content and will sometimes exceed the height of the |
|
193 |
// main window and will not get a scroll bar in this situation. |
|
194 |
// see #6843 |
|
195 |
window.setHeight("100%"); |
|
188 |
window.setWidth(popupView.getWindowWidth(), popupView.getWindowWidthUnit()); |
|
189 |
window.setHeight(popupView.getWindowHeight(), popupView.getWindowHeightUnit()); |
|
196 | 190 |
window.setContent(popupView.asComponent()); |
197 | 191 |
// TODO need to disallow pressing the close [x] button: |
198 | 192 |
// since window.addCloseListener(e -> popupView.cancel()); will |
199 | 193 |
// cause sending cancel events even if save has been clicked |
200 |
window.setClosable(false);
|
|
194 |
window.setClosable(popupView.isClosable());
|
|
201 | 195 |
UI.getCurrent().addWindow(window); |
202 | 196 |
popupView.viewEntered(); |
203 | 197 |
popupView.focusFirst(); |
src/main/java/eu/etaxonomy/vaadin/ui/view/PopupView.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.vaadin.ui.view; |
2 | 2 |
|
3 |
import com.vaadin.ui.Window;
|
|
3 |
import com.vaadin.server.Sizeable.Unit;
|
|
4 | 4 |
|
5 | 5 |
import eu.etaxonomy.vaadin.ui.CanCastComponent; |
6 |
import eu.etaxonomy.vaadin.ui.navigation.NavigationManagerBean; |
|
7 | 6 |
|
8 | 7 |
/** |
9 | 8 |
* This interface defines the api used by the {@link NavigationManagerBean} to |
... | ... | |
15 | 14 |
*/ |
16 | 15 |
public interface PopupView extends CanCastComponent { |
17 | 16 |
|
18 |
String getWindowCaption(); |
|
19 |
|
|
20 | 17 |
boolean isResizable(); |
21 | 18 |
|
22 | 19 |
/** |
20 |
* Whether to show an activepopupView close button in the popup window header. |
|
21 |
*/ |
|
22 |
boolean isClosable(); |
|
23 |
|
|
24 |
boolean isModal(); |
|
25 |
|
|
26 |
/** |
|
27 |
* The initial width of the window. A value of <code>-1</code> |
|
28 |
* means undefined. |
|
29 |
* |
|
23 | 30 |
* @return a positive number to define the initial with of the windows. |
24 | 31 |
* A negative number implies <b>unspecified size</b> (terminal is free |
25 | 32 |
* to set the size). |
26 | 33 |
*/ |
27 |
int getWindowPixelWidth();
|
|
34 |
int getWindowWidth(); |
|
28 | 35 |
|
29 |
boolean isModal(); |
|
36 |
|
|
37 |
Unit getWindowWidthUnit(); |
|
38 |
|
|
39 |
int getWindowHeight(); |
|
30 | 40 |
|
31 | 41 |
/** |
32 | 42 |
* The initial width of the window. A value of <code>-1</code> |
33 | 43 |
* means undefined. |
34 | 44 |
* |
45 |
* @return a positive number to define the initial with of the windows. |
|
46 |
* A negative number implies <b>unspecified size</b> (terminal is free |
|
47 |
* to set the size). |
|
48 |
*/ |
|
49 |
Unit getWindowHeightUnit(); |
|
50 |
|
|
51 |
String getWindowCaption(); |
|
52 |
|
|
53 |
/** |
|
35 | 54 |
* @return |
36 | 55 |
*/ |
37 | 56 |
boolean isWindowCaptionAsHtml(); |
Also available in: Unified diff
ref #7269 layout improvements in messages popup window