Control buttons in 'In List' filter condition component made non-focusable #PL-4794

This commit is contained in:
Maxim Gorbunkov 2015-02-02 14:39:58 +00:00
parent 6546a47872
commit 0cfaadbcd0
5 changed files with 50 additions and 4 deletions

View File

@ -7,6 +7,7 @@ package com.haulmont.cuba.desktop.gui.components;
import com.haulmont.cuba.core.entity.AbstractSearchFolder;
import com.haulmont.cuba.core.entity.Folder;
import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.components.LookupField;
import com.haulmont.cuba.gui.components.Table;
import com.haulmont.cuba.gui.components.Tree;
@ -19,10 +20,6 @@ import org.apache.commons.logging.LogFactory;
import javax.annotation.ManagedBean;
import javax.inject.Inject;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.Map;
import java.util.UUID;
@ -92,4 +89,14 @@ public class DesktopFilterHelper implements FilterHelper {
}
@Override
public void setFieldReadOnlyFocusable(com.haulmont.cuba.gui.components.TextField textField, boolean readOnlyFocusable) {
//do nothing
}
@Override
public void setComponentFocusable(Component component, boolean focusable) {
JComponent dComponent = DesktopComponentsHelper.unwrap(component);
dComponent.setFocusable(focusable);
}
}

View File

@ -9,6 +9,7 @@ import com.haulmont.cuba.core.entity.AbstractSearchFolder;
import com.haulmont.cuba.core.entity.Folder;
import com.haulmont.cuba.gui.components.LookupField;
import com.haulmont.cuba.gui.components.Table;
import com.haulmont.cuba.gui.components.TextField;
import com.haulmont.cuba.gui.components.Tree;
import com.haulmont.cuba.gui.presentations.Presentations;
@ -49,4 +50,8 @@ public interface FilterHelper {
void initTableFtsTooltips(Table table, Map<UUID, String> tooltips);
void removeTableFtsTooltips(Table table);
void setFieldReadOnlyFocusable(TextField textField, boolean readOnlyFocusable);
void setComponentFocusable(com.haulmont.cuba.gui.components.Component component, boolean focusable);
}

View File

@ -52,6 +52,8 @@ public class InListParamComponent {
field = componentsFactory.createComponent(TextField.NAME);
field.setEditable(false);
field.setWidth("100%");
FilterHelper filterHelper = AppBeans.get(FilterHelper.class);
filterHelper.setFieldReadOnlyFocusable(field, true);
pickerButton = componentsFactory.createComponent(Button.NAME);
pickerButton.setAction(new AbstractAction("") {
@ -79,6 +81,7 @@ public class InListParamComponent {
}
});
pickerButton.setIcon("components/pickerfield/images/lookup-btn.png");
filterHelper.setComponentFocusable(pickerButton, false);
clearButton = componentsFactory.createComponent(Button.NAME);
clearButton.setAction(new AbstractAction("") {
@ -92,6 +95,7 @@ public class InListParamComponent {
}
});
clearButton.setIcon("components/pickerfield/images/clear-btn.png");
filterHelper.setComponentFocusable(clearButton, false);
composition = componentsFactory.createComponent(BoxLayout.HBOX);
composition.setWidth("100%");

View File

@ -12,6 +12,7 @@ import com.haulmont.cuba.core.global.Messages;
import com.haulmont.cuba.core.global.Metadata;
import com.haulmont.cuba.gui.components.LookupField;
import com.haulmont.cuba.gui.components.Table;
import com.haulmont.cuba.gui.components.TextField;
import com.haulmont.cuba.gui.components.Tree;
import com.haulmont.cuba.gui.components.filter.ConditionsTree;
import com.haulmont.cuba.gui.components.filter.FilterHelper;
@ -23,6 +24,7 @@ import com.haulmont.cuba.web.AppUI;
import com.haulmont.cuba.web.app.folders.AppFolderEditWindow;
import com.haulmont.cuba.web.app.folders.FolderEditWindow;
import com.haulmont.cuba.web.app.folders.FoldersPane;
import com.haulmont.cuba.web.toolkit.ui.CubaTextField;
import com.vaadin.event.Transferable;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler;
@ -208,4 +210,18 @@ public class WebFilterHelper implements FilterHelper {
vTable.setItemDescriptionGenerator(null);
}
@Override
public void setFieldReadOnlyFocusable(TextField textField, boolean readOnlyFocusable) {
CubaTextField vTextField = WebComponentsHelper.unwrap(textField);
vTextField.setReadOnlyFocusable(readOnlyFocusable);
}
@Override
public void setComponentFocusable(com.haulmont.cuba.gui.components.Component component, boolean focusable) {
com.vaadin.ui.Component vComponent = WebComponentsHelper.unwrap(component);
if (vComponent instanceof Component.Focusable) {
((Component.Focusable) vComponent).setTabIndex(focusable ? 0 : -1);
}
}
}

View File

@ -13,6 +13,7 @@ import com.haulmont.cuba.core.global.Metadata;
import com.haulmont.cuba.core.global.UserSessionSource;
import com.haulmont.cuba.gui.components.LookupField;
import com.haulmont.cuba.gui.components.Table;
import com.haulmont.cuba.gui.components.TextField;
import com.haulmont.cuba.gui.components.Tree;
import com.haulmont.cuba.gui.components.filter.ConditionsTree;
import com.haulmont.cuba.gui.components.filter.FilterHelper;
@ -211,4 +212,17 @@ public class Web6FilterHelper implements FilterHelper {
vTable.setItemDescriptionGenerator(null);
}
@Override
public void setFieldReadOnlyFocusable(TextField textField, boolean readOnlyFocusable) {
com.haulmont.cuba.web.toolkit.ui.TextField vTextField = WebComponentsHelper.unwrap(textField);
vTextField.setAllowFocusReadonly(readOnlyFocusable);
}
@Override
public void setComponentFocusable(com.haulmont.cuba.gui.components.Component component, boolean focusable) {
com.vaadin.ui.Component vComponent = WebComponentsHelper.unwrap(component);
if (vComponent instanceof Component.Focusable) {
((Component.Focusable) vComponent).setTabIndex(focusable ? 0 : -1);
}
}
}