In/Not in conditions and date in filter. #PL-2283

This commit is contained in:
Denis Hasanov 2013-07-30 08:32:05 +00:00
parent bbd0bb3a99
commit 1d1a64f458
6 changed files with 31 additions and 45 deletions

View File

@ -12,6 +12,7 @@ import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.core.entity.Entity; import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.core.global.AppBeans; import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.MessageProvider; import com.haulmont.cuba.core.global.MessageProvider;
import com.haulmont.cuba.core.global.Messages;
import com.haulmont.cuba.core.global.UserSessionSource; import com.haulmont.cuba.core.global.UserSessionSource;
import com.haulmont.cuba.desktop.App; import com.haulmont.cuba.desktop.App;
import com.haulmont.cuba.desktop.gui.components.*; import com.haulmont.cuba.desktop.gui.components.*;
@ -46,6 +47,7 @@ public class ListEditComponent extends Picker {
private Class itemClass; private Class itemClass;
private MetaClass metaClass; private MetaClass metaClass;
private Messages messages;
private CollectionDatasource collectionDatasource; private CollectionDatasource collectionDatasource;
private List<String> runtimeEnum; private List<String> runtimeEnum;
@ -58,6 +60,7 @@ public class ListEditComponent extends Picker {
protected UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.class); protected UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.class);
public ListEditComponent(Class itemClass) { public ListEditComponent(Class itemClass) {
messages = AppBeans.get(Messages.class);
setOpaque(false); setOpaque(false);
contentPanel.setOpaque(false); contentPanel.setOpaque(false);
actionsPanel.setOpaque(false); actionsPanel.setOpaque(false);
@ -108,7 +111,7 @@ public class ListEditComponent extends Picker {
listeners.add(listener); listeners.add(listener);
} }
public void setText(String text){ public void setText(String text) {
super.setValue(text); super.setValue(text);
} }
@ -140,7 +143,6 @@ public class ListEditComponent extends Picker {
private JPanel mainPanel = new JPanel(new MigLayout("fill")); private JPanel mainPanel = new JPanel(new MigLayout("fill"));
private JPanel listPanel; private JPanel listPanel;
private JPanel dateFieldPanel; private JPanel dateFieldPanel;
private Object date = null;
private JScrollPane pane; private JScrollPane pane;
private ListEditWindow(Map<Object, String> values) { private ListEditWindow(Map<Object, String> values) {
@ -155,7 +157,7 @@ public class ListEditComponent extends Picker {
addItemLayout(entry.getKey(), entry.getValue()); addItemLayout(entry.getKey(), entry.getValue());
} }
mainPanel.add(pane, "wrap, dock north, grow"); mainPanel.add(pane, "wrap, dock north, grow");
mainPanel.setPreferredSize(new Dimension(250,250)); mainPanel.setPreferredSize(new Dimension(250, 250));
final DesktopAbstractComponent field; final DesktopAbstractComponent field;
JButton addButton = null; JButton addButton = null;
@ -248,30 +250,22 @@ public class ListEditComponent extends Picker {
} else if (Date.class.isAssignableFrom(itemClass)) { } else if (Date.class.isAssignableFrom(itemClass)) {
field = new DesktopDateField(); field = new DesktopDateField();
dateFieldPanel = new JPanel(new MigLayout()); dateFieldPanel = new JPanel(new MigLayout());
addButton = new JButton("Add"); addButton = new JButton(messages.getMessage(getClass(), "addButton"));
addButton.addActionListener(new ActionListener() { addButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (date != null){ Date date = ((DesktopDateField) field).getValue();
String str = addDate((Date)date); if (date != null) {
String str = addDate(date);
addItemLayout(date, str); addItemLayout(date, str);
((DesktopDateField)field).setValue(null); ((DesktopDateField) field).setValue(null);
date = null;
} }
} }
} ); });
if (itemClass.equals(java.sql.Date.class)) if (itemClass.equals(java.sql.Date.class))
((DesktopDateField) field).setResolution(DateField.Resolution.DAY); ((DesktopDateField) field).setResolution(DateField.Resolution.DAY);
else else
((DesktopDateField) field).setResolution(DateField.Resolution.MIN); ((DesktopDateField) field).setResolution(DateField.Resolution.MIN);
((DesktopDateField) field).addListener(new ValueListener() {
@Override
public void valueChanged(Object source, String property, Object prevValue, Object value) {
if (value != null) {
date = value;
}
}
});
} else } else
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -306,13 +300,12 @@ public class ListEditComponent extends Picker {
bottomPanel.add(cancelBtn); bottomPanel.add(cancelBtn);
mainPanel.add(bottomPanel, "dock south"); mainPanel.add(bottomPanel, "dock south");
if (dateFieldPanel == null){ if (dateFieldPanel == null) {
mainPanel.add(field.getComposition(), "wrap, dock north, gapy 10px 10px"); mainPanel.add(field.getComposition(), "wrap, dock north, gapy 10px 10px");
} } else {
else {
dateFieldPanel.add(field.getComposition()); dateFieldPanel.add(field.getComposition());
dateFieldPanel.add(addButton); dateFieldPanel.add(addButton);
mainPanel.add(dateFieldPanel,"dock south"); mainPanel.add(dateFieldPanel, "dock south");
} }
pack(); pack();
@ -321,7 +314,7 @@ public class ListEditComponent extends Picker {
@Override @Override
public void windowClosed(WindowEvent e) { public void windowClosed(WindowEvent e) {
DesktopComponentsHelper.getTopLevelFrame(ListEditComponent.this).activate(); DesktopComponentsHelper.getTopLevelFrame(ListEditComponent.this).activate();
} }
}); });
} }

View File

@ -5,4 +5,5 @@ export.dataProviderError=Could not save file, data provider error
export.tempFileError=Could not create temp file for download export.tempFileError=Could not create temp file for download
export.openError=Could not open file, please check your installed software export.openError=Could not open file, please check your installed software
export.fileCaption=File export.fileCaption=File
upload.selectFiles=Upload upload.selectFiles=Upload
addButton=Add

View File

@ -6,3 +6,4 @@ export.saveError=Невозможно сохранить файл
export.dataProviderError=Невозможно сохранить файл, ошибка провайдера данных export.dataProviderError=Невозможно сохранить файл, ошибка провайдера данных
export.tempFileError=Невозможно создать временный файл export.tempFileError=Невозможно создать временный файл
upload.selectFiles=Добавить upload.selectFiles=Добавить
addButton=Добавить

View File

@ -343,12 +343,11 @@ public class ListEditComponent extends CustomField {
private VerticalLayout listLayout; private VerticalLayout listLayout;
private Map<Object, String> values; private Map<Object, String> values;
private Messages messages; private Messages messages;
private Object date = null;
private ListEditWindow(Map<Object, String> values) { private ListEditWindow(Map<Object, String> values) {
super(AppBeans.get(Messages.class).getMessage(MESSAGES_PACK, "ListEditWindow.caption")); super(AppBeans.get(Messages.class).getMessage(MESSAGES_PACK, "ListEditWindow.caption"));
setWidth(200, Unit.PIXELS); setWidth(200, Unit.PIXELS);
setHeight(200,Unit.PIXELS); setHeight(200, Unit.PIXELS);
setModal(true); setModal(true);
this.messages = AppBeans.get(Messages.class); this.messages = AppBeans.get(Messages.class);
@ -369,8 +368,8 @@ public class ListEditComponent extends CustomField {
editAreaPanel.setSizeFull(); editAreaPanel.setSizeFull();
editAreaPanel.setContent(listLayout); editAreaPanel.setContent(listLayout);
contentLayout.addComponent(editAreaPanel); contentLayout.addComponent(editAreaPanel);
contentLayout.setExpandRatio(editAreaPanel,1.0f); contentLayout.setExpandRatio(editAreaPanel, 1.0f);
contentLayout.setHeight(100,Unit.PERCENTAGE); contentLayout.setHeight(100, Unit.PERCENTAGE);
final Field field; final Field field;
Button addButton = null; Button addButton = null;
@ -468,20 +467,18 @@ public class ListEditComponent extends CustomField {
} else if (Date.class.isAssignableFrom(itemClass)) { } else if (Date.class.isAssignableFrom(itemClass)) {
final WebDateField dateField = new WebDateField(); final WebDateField dateField = new WebDateField();
field = dateField.getComponent(); field = dateField.getComponent();
dateFieldLayout = new HorizontalLayout(); dateFieldLayout = new HorizontalLayout();
dateFieldLayout.setHeight(-1,Unit.PIXELS);
this.setWidth(350, Unit.PIXELS); this.setWidth(350, Unit.PIXELS);
addButton = new Button("Add"); addButton = new Button(messages.getMessage(getClass(), "addButton"));
addButton.addClickListener(new Button.ClickListener() { addButton.addClickListener(new Button.ClickListener() {
@Override @Override
public void buttonClick(Button.ClickEvent event) { public void buttonClick(Button.ClickEvent event) {
if (date != null){ Date date = dateField.getValue();
String str = addDate((Date)date); if (date != null) {
String str = addDate(date);
addItemLayout(date, str); addItemLayout(date, str);
field.setValue(null); field.setValue(null);
date = null;
} }
} }
}); });
@ -496,15 +493,6 @@ public class ListEditComponent extends CustomField {
} }
dateField.setResolution(resolution); dateField.setResolution(resolution);
dateField.setDateFormat(dateFormat); dateField.setDateFormat(dateFormat);
dateField.addListener(new ValueListener() {
@Override
public void valueChanged(Object source, String property, Object prevValue, Object value) {
if (value != null) {
date = value;
}
}
});
} else } else
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -519,7 +507,6 @@ public class ListEditComponent extends CustomField {
} }
HorizontalLayout bottomLayout = new HorizontalLayout(); HorizontalLayout bottomLayout = new HorizontalLayout();
bottomLayout.setHeight(-1,Unit.PIXELS);
bottomLayout.setMargin(new MarginInfo(true, false, true, false)); bottomLayout.setMargin(new MarginInfo(true, false, true, false));
bottomLayout.setSpacing(true); bottomLayout.setSpacing(true);

View File

@ -37,4 +37,6 @@ warning.msg=Substitution is not set. This link must be opened on behalf of <b>%s
warning.userNotFound=User not found. warning.userNotFound=User not found.
searchSelect.notFound=Not found items for filter: %s searchSelect.notFound=Not found items for filter: %s
searchSelect.minimumLengthOfFilter=Minimum length of search string is %s searchSelect.minimumLengthOfFilter=Minimum length of search string is %s
addButton=Add

View File

@ -37,4 +37,6 @@ warning.msg=Отсутствуют права на замещение. Данн
warning.userNotFound=Пользователь, от имени которого Вы хотите открыть ссылку, не найден. warning.userNotFound=Пользователь, от имени которого Вы хотите открыть ссылку, не найден.
searchSelect.notFound=Не найдено записей для фильтра: %s searchSelect.notFound=Не найдено записей для фильтра: %s
searchSelect.minimumLengthOfFilter=Минимальная длина строки для поиска %s searchSelect.minimumLengthOfFilter=Минимальная длина строки для поиска %s
addButton=Добавить