Example usage for com.vaadin.ui Button addShortcutListener

List of usage examples for com.vaadin.ui Button addShortcutListener

Introduction

In this page you can find the example usage for com.vaadin.ui Button addShortcutListener.

Prototype

public Registration addShortcutListener(ShortcutListener shortcut) 

Source Link

Usage

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Build login view/* ww w .  jav  a  2 s. c om*/
 *
 * @param exit
 */
private void buildLoginView(final boolean exit) {
    if (exit) {
        root.removeAllComponents();
    }
    notifierService.closeAll();

    addStyleName("login");

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setId("webconsole_loginlayout_id");
    loginLayout.setSizeFull();
    loginLayout.addStyleName("login-layout");
    root.addComponent(loginLayout);

    final CssLayout loginPanel = new CssLayout();
    loginPanel.addStyleName("login-panel");

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth(MAX_WIDTH);
    labels.setMargin(true);
    loginPanel.addComponent(labels);

    Label welcome = new Label("Welcome");
    welcome.addStyleName("h4");
    labels.addComponent(welcome);
    labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT);

    Label title = new Label(consoleName);
    //title.setSizeUndefined();
    title.addStyleName("h2");
    title.addStyleName("light");
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);

    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.setMargin(true);
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.focus();
    username.setId("webconsole_login_username");
    fields.addComponent(username);

    final PasswordField password = new PasswordField("Password");
    password.setId("webconsole_login_password");
    fields.addComponent(password);

    final Button signin = new Button("Sign In");
    signin.setId("webconsole_login_signin");
    signin.addStyleName("default");
    fields.addComponent(signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    final ShortcutListener enter = new ShortcutListener("Sign In", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            signin.click();
        }
    };

    signin.addShortcutListener(enter);
    loginPanel.addComponent(fields);

    HorizontalLayout bottomRow = new HorizontalLayout();
    bottomRow.setWidth(MAX_WIDTH);
    bottomRow.setMargin(new MarginInfo(false, true, false, true));
    final CheckBox keepLoggedIn = new CheckBox("Keep me logged in");
    bottomRow.addComponent(keepLoggedIn);
    bottomRow.setComponentAlignment(keepLoggedIn, Alignment.MIDDLE_LEFT);
    // Add new error message
    final Label error = new Label("Wrong username or password.", ContentMode.HTML);
    error.setId("webconsole_login_error");
    error.addStyleName("error");
    error.setSizeUndefined();
    error.addStyleName("light");
    // Add animation
    error.addStyleName("v-animate-reveal");
    error.setVisible(false);
    bottomRow.addComponent(error);
    bottomRow.setComponentAlignment(error, Alignment.MIDDLE_RIGHT);
    loginPanel.addComponent(bottomRow);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (authenticate(username.getValue(), password.getValue())) {
                //                    if (keepLoggedIn.getValue()) {
                //                        //Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME);
                //                       if (getCookieByName(PEERGREEN_USER_COOKIE_NAME) == null) {
                //                            // Get a token for this user and create a cooki
                //                            Page.getCurrent().getJavaScript().execute( String.format("document.cookie = '%s=%s; path=%s'",
                //                                    PEERGREEN_USER_COOKIE_NAME, token, VaadinService.getCurrentRequest().getContextPath()));
                //                        } else {
                //                            // update token
                //                            userCookie.setValue(token);
                //                            userCookie.setPath(VaadinService.getCurrentRequest().getContextPath());
                //                        }
                //                    }

                buildMainView();
            } else {
                error.setVisible(true);
            }
        }
    });

    loginLayout.addComponent(loginPanel);
    loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

From source file:org.lucidj.browser.BrowserView.java

License:Apache License

private Button createButton(Layout parent, String id, Resource icon, String caption, int kc, int mk) {
    final Button new_button = new Button();

    if (caption != null) {
        new_button.setCaption(caption);
    }/*from   w ww .j ava2 s  . co m*/
    new_button.setIcon(icon);
    new_button.addStyleName("tiny");
    new_button.addStyleName("toolbar");
    new_button.setId(id);

    new_button.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            handle_button_click(new_button);
        }
    });

    parent.addComponent(new_button);

    if (kc != 0) {
        new_button.addShortcutListener(new AbstractField.FocusShortcut(new_button, kc, mk) {
            @Override
            public void handleAction(Object sender, Object target) {
                handle_button_click(new_button);
            }
        });
    }

    return (new_button);
}

From source file:org.lucidj.html_renderer.HtmlRenderer.java

License:Apache License

private void init_toolbar() {
    editor_toolbar = new CssLayout();

    CssLayout group = new CssLayout();
    group.addStyleName("v-component-group");

    Button output_view = new Button();
    output_view.setHtmlContentAllowed(true);
    String ico2 = "<path d=\"M249.649 792.806l-107.776 166.4 11.469 54.426 54.272-11.622 107.725-166.298c-11.469-6.144-22.835-12.698-33.843-19.968-11.162-7.219-21.811-14.95-31.846-22.938zM705.943 734.694c0.717-1.485 1.178-3.123 1.843-4.71 2.714-5.99 5.12-11.981 7.066-18.278 0.307-1.126 0.461-2.253 0.819-3.277 1.997-6.963 3.686-13.824 5.018-20.89 0-0.358 0-0.614 0-1.075 9.984-59.853-7.424-126.618-47.258-186.931l56.832-87.757c65.485 8.346 122.112-8.141 149.35-50.278 47.258-72.858-10.24-194.15-128.256-271.002-118.118-76.902-252.058-80.128-299.213-7.373-27.341 42.189-19.354 100.71 15.002 157.338l-56.934 87.757c-71.117-11.93-139.059-0.819-189.594 32.768-0.307 0.102-0.666 0.205-0.87 0.41-5.888 3.994-11.622 8.397-16.998 13.005-0.87 0.717-1.894 1.382-2.611 2.099-5.018 4.301-9.523 9.114-13.875 13.926-1.024 1.229-2.458 2.304-3.43 3.584-5.427 6.195-10.445 12.749-14.848 19.712-70.861 109.21-10.394 274.483 134.81 369.101 145.306 94.618 320.512 82.637 391.219-26.573 4.454-6.912 8.55-14.131 11.93-21.555zM664.215 224.845c-45.414-29.542-67.584-76.134-49.408-104.243 18.125-28.006 69.683-26.726 114.995 2.816 45.517 29.542 67.482 76.237 49.408 104.243s-69.53 26.726-114.995-2.816z\"></path>";
    output_view.setCaption(//www.  j a  v  a  2 s . com
            "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">"
                    + ico2 + "</svg>");
    output_view.addStyleName("tiny");
    group.addComponent(output_view);

    output_view.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            show_hide_rich_text();
        }
    });

    Button run = new Button();
    run.setHtmlContentAllowed(true);
    String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>";
    run.setCaption(
            "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">"
                    + ico3 + "</svg>");
    run.addStyleName("tiny");
    group.addComponent(run);

    run.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            render_html_from_rich_text();
        }
    });

    run.addShortcutListener(new AbstractField.FocusShortcut(run, ShortcutAction.KeyCode.ENTER,
            ShortcutAction.ModifierKey.SHIFT) {
        @Override
        public void handleAction(Object sender, Object target) {
            render_html_from_rich_text();
        }
    });

    editor_toolbar.addComponent(group);
}

From source file:org.lucidj.markdown_renderer.MarkdownRenderer.java

License:Apache License

private void init_toolbar() {
    editor_toolbar = new CssLayout();

    CssLayout group = new CssLayout();
    group.addStyleName("v-component-group");

    Button output_view = new Button();
    output_view.setHtmlContentAllowed(true);
    String ico2 = "<path d=\"M249.649 792.806l-107.776 166.4 11.469 54.426 54.272-11.622 107.725-166.298c-11.469-6.144-22.835-12.698-33.843-19.968-11.162-7.219-21.811-14.95-31.846-22.938zM705.943 734.694c0.717-1.485 1.178-3.123 1.843-4.71 2.714-5.99 5.12-11.981 7.066-18.278 0.307-1.126 0.461-2.253 0.819-3.277 1.997-6.963 3.686-13.824 5.018-20.89 0-0.358 0-0.614 0-1.075 9.984-59.853-7.424-126.618-47.258-186.931l56.832-87.757c65.485 8.346 122.112-8.141 149.35-50.278 47.258-72.858-10.24-194.15-128.256-271.002-118.118-76.902-252.058-80.128-299.213-7.373-27.341 42.189-19.354 100.71 15.002 157.338l-56.934 87.757c-71.117-11.93-139.059-0.819-189.594 32.768-0.307 0.102-0.666 0.205-0.87 0.41-5.888 3.994-11.622 8.397-16.998 13.005-0.87 0.717-1.894 1.382-2.611 2.099-5.018 4.301-9.523 9.114-13.875 13.926-1.024 1.229-2.458 2.304-3.43 3.584-5.427 6.195-10.445 12.749-14.848 19.712-70.861 109.21-10.394 274.483 134.81 369.101 145.306 94.618 320.512 82.637 391.219-26.573 4.454-6.912 8.55-14.131 11.93-21.555zM664.215 224.845c-45.414-29.542-67.584-76.134-49.408-104.243 18.125-28.006 69.683-26.726 114.995 2.816 45.517 29.542 67.482 76.237 49.408 104.243s-69.53 26.726-114.995-2.816z\"></path>";
    output_view.setCaption(/*ww  w .jav a2  s. c  om*/
            "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">"
                    + ico2 + "</svg>");
    output_view.addStyleName("tiny");
    group.addComponent(output_view);

    output_view.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            show_hide_rich_text();
        }
    });

    Button run = new Button();
    run.setHtmlContentAllowed(true);
    String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>";
    run.setCaption(
            "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">"
                    + ico3 + "</svg>");
    run.addStyleName("tiny");
    group.addComponent(run);

    run.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            render_html_from_markdown();
        }
    });

    run.addShortcutListener(new AbstractField.FocusShortcut(run, ShortcutAction.KeyCode.ENTER,
            ShortcutAction.ModifierKey.SHIFT) {
        @Override
        public void handleAction(Object sender, Object target) {
            render_html_from_markdown();
        }
    });

    editor_toolbar.addComponent(group);
}

From source file:org.lucidj.smartbox_renderer.SmartBoxRenderer.java

License:Apache License

private void init_toolbar() {
    cell_toolbar = new CssLayout();

    CssLayout group = new CssLayout();
    group.addStyleName("v-component-group");
    group.addStyleName("ui-toolbar-spacer");

    Button run = new Button();
    run.setHtmlContentAllowed(true);//www .  j  a v  a 2 s. co  m
    String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>";
    run.setCaption(
            "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">"
                    + ico3 + "</svg>");
    run.addStyleName("tiny");
    group.addComponent(run);

    run.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            source.fireEvent(this, "run");
        }
    });

    run.addShortcutListener(new ShortcutListener("Run", ShortcutAction.KeyCode.ENTER,
            new int[] { ShortcutAction.ModifierKey.CTRL }) {
        @Override
        public void handleAction(Object sender, Object target) {
            // The shortcuts (while active on toolbar) are global, however for
            // Ctrl+Enter this becomes counter-intuitive. This way, we filter
            // it to avoid running things from outside the edition field.
            if (target == commands) {
                source.fireEvent(this, "run");
            }
        }
    });

    Button stop = new Button();
    stop.setIcon(FontAwesome.STOP);
    stop.addStyleName("tiny");
    group.addComponent(stop);

    stop.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            source.fireEvent(this, "stop");
        }
    });

    cell_toolbar.addComponent(group);
}

From source file:org.lunifera.example.vaadin.osgi.contentprovider.ContentProvider_1.java

License:Apache License

@SuppressWarnings("serial")
@Override//w w  w  .ja v  a2s .com
public Component getContent() {
    main = new AbsoluteLayout();
    main.setSizeFull();

    AbsoluteLayout buttonPanel = new AbsoluteLayout();
    buttonPanel.setWidth("320px");
    buttonPanel.setHeight("270px");

    final Button left = new Button("left");
    final Button top = new Button("top");
    final Button right = new Button("right");
    final Button bottom = new Button("bottom");
    final Button stop = new Button("STOP");
    final IntensityBar leftIntensity = new IntensityBar();
    final IntensityBar topIntensity = new IntensityBar();
    final IntensityBar rightIntensity = new IntensityBar();
    final IntensityBar bottomIntensity = new IntensityBar();

    speed = new Slider(0, 10);
    speed.setOrientation(SliderOrientation.VERTICAL);

    left.addShortcutListener(new ShortcutListener("Left", ShortcutAction.KeyCode.ARROW_LEFT, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            left();
        }
    });

    top.addShortcutListener(new ShortcutListener("Top", ShortcutAction.KeyCode.ARROW_UP, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            top();
        }
    });

    right.addShortcutListener(new ShortcutListener("Right", ShortcutAction.KeyCode.ARROW_RIGHT, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            right();
        }
    });

    left.addShortcutListener(new ShortcutListener("Bottom", ShortcutAction.KeyCode.ARROW_DOWN, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            bottom();
        }
    });

    stop.addShortcutListener(new ShortcutListener("STOP", ShortcutAction.KeyCode.ESCAPE, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            stop();
        }
    });

    speed.addShortcutListener(new ShortcutListener("Speed up", ShortcutAction.KeyCode.W, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            speed.setValue(speed.getValue().doubleValue() + 1);
        }
    });

    speed.addShortcutListener(new ShortcutListener("Speed down", ShortcutAction.KeyCode.Y, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            speed.setValue(speed.getValue().doubleValue() - 1);
        }
    });

    left.setWidth("75px");
    leftIntensity.setWidth("75px");
    leftIntensity.setValue(0.3f);
    top.setWidth("75px");
    topIntensity.setWidth("75px");
    topIntensity.setValue(0.3f);
    right.setWidth("75px");
    rightIntensity.setWidth("75px");
    rightIntensity.setValue(0.3f);
    bottom.setWidth("75px");
    bottomIntensity.setWidth("75px");
    bottomIntensity.setValue(0.3f);
    stop.setWidth("60px");
    speed.setHeight("180px");

    left.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            left();
        }
    });

    top.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            top();
        }
    });

    right.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            right();
        }
    });

    bottom.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            bottom();
        }
    });

    stop.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            stop();
        }
    });

    speed.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            foreward();
        }
    });

    buttonPanel.addComponent(left, "top:100px;left:0px");
    buttonPanel.addComponent(leftIntensity, "top:130px;left:0px");

    buttonPanel.addComponent(top, "top:10px;left:100px");
    buttonPanel.addComponent(topIntensity, "top:40px;left:100px");

    buttonPanel.addComponent(right, "top:100px;left:200px");
    buttonPanel.addComponent(rightIntensity, "top:130px;left:200px");

    buttonPanel.addComponent(bottom, "top:200px;left:100px");
    buttonPanel.addComponent(bottomIntensity, "top:230px;left:100px");

    buttonPanel.addComponent(stop, "top:100px;left:107px");

    buttonPanel.addComponent(speed, "top:20px;right:10px");

    main.addComponent(buttonPanel, "top:100px;left:100px");
    return main;
}

From source file:ru.codeinside.gses.webui.supervisor.TaskFilter.java

License:Mozilla Public License

private void buildMainLayout() {
    final ServiceQueryDefinition administrativeServiceQueryDefinition = new ServiceQueryDefinition(
            ProcedureType.Administrative);
    final LazyQueryContainer administrativeServiceQueryContainer = new LazyQueryContainer(
            administrativeServiceQueryDefinition, new ServiceQueryFactory(true));
    final ProcedureQueryDefinition administrativeProcedureQueryDefinition = new ProcedureQueryDefinition(
            ProcedureType.Administrative);
    final LazyQueryContainer administrativeProcedureQueryContainer = new LazyQueryContainer(
            administrativeProcedureQueryDefinition, new ProcedureQueryFactory(Flash.login(), true));
    final ProcedureQueryDefinition interdepartmentalProcedureQueryDefinition = new ProcedureQueryDefinition(
            ProcedureType.Interdepartmental);
    final LazyQueryContainer interdepartmentalProcedureQueryContainer = new LazyQueryContainer(
            interdepartmentalProcedureQueryDefinition, new ProcedureQueryFactory(Flash.login(), true));
    final ServiceQueryDefinition interdepartmentalServiceQueryDefinition = new ServiceQueryDefinition(
            ProcedureType.Interdepartmental);
    final LazyQueryContainer interdepartmentalQueryContainer = new LazyQueryContainer(
            interdepartmentalServiceQueryDefinition, new ServiceQueryFactory(true));
    final GroupsQueryDefinition orgGroupsQueryDefinition = new GroupsQueryDefinition(Flash.login(),
            GroupsQueryDefinition.Mode.ORG);
    final LazyQueryContainer orgGroupsQueryContainer = new LazyQueryContainer(orgGroupsQueryDefinition,
            new GroupsQueryFactory());
    final GroupsQueryDefinition empGroupsQueryDefinition = new GroupsQueryDefinition(Flash.login(),
            GroupsQueryDefinition.Mode.EMP);
    final LazyQueryContainer empGroupsQueryContainer = new LazyQueryContainer(empGroupsQueryDefinition,
            new GroupsQueryFactory());
    //    LazyLoadingContainer2 orgGroupsQueryContainer = new LazyLoadingContainer2(new GroupsQuery(GroupsQueryDefinition.Mode.ORG, Flash.login()));
    //    LazyLoadingContainer2 empGroupsQueryContainer = new LazyLoadingContainer2(new GroupsQuery(GroupsQueryDefinition.Mode.EMP, Flash.login()));

    final String comboBoxWidth = "250px";

    PopupDateField popupFromDate = getFromDateField();
    PopupDateField popupToDate = getToDateField();
    ComboBox procedureTypeBox = getProcedureTypeField(comboBoxWidth);
    final ComboBox serviceBox = getServiceField(administrativeServiceQueryContainer, comboBoxWidth);
    final ComboBox procedureBox = getProcedureField(administrativeProcedureQueryContainer, comboBoxWidth);
    final ComboBox taskBox = getTaskField(comboBoxWidth);
    final ComboBox declarantTypeBox = getDeclarantTypeField(comboBoxWidth);
    CheckBox overdueBox = getOverdueField(comboBoxWidth);
    TextField numberTextField = getBidNumberField(comboBoxWidth);
    TextField requesterTextField = getRequesterLoginField(comboBoxWidth);
    final ListSelect orgGroups = getControlledOrgGroups(orgGroupsQueryContainer, comboBoxWidth);
    final ListSelect empGroups = getControlledEmployeeGroups(empGroupsQueryContainer, comboBoxWidth);
    orgGroups.setVisible(mode == Mode.Supervisor);
    empGroups.setVisible(mode == Mode.Supervisor);

    addField("fromDate", popupFromDate);
    addField("toDate", popupToDate);
    addField("procedureType", procedureTypeBox);
    addField("serviceId", serviceBox);
    addField("procedureName", procedureBox);
    addField("taskName", taskBox);
    addField("declarantType", declarantTypeBox);
    addField("bidId", numberTextField);
    addField("requester", requesterTextField);
    addField("overdue", overdueBox);
    addField("controlledOrgGroups", orgGroups);
    addField("controlledEmpGroups", empGroups);

    /* ? ?  ??*///from   w  w w .j a v a2  s . com
    procedureTypeBox.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            final Property prop = event.getProperty();
            if (prop.getValue() == null || prop.getValue().equals(ADMINISTRATIVE_PROCEDURE)) {
                serviceBox.setContainerDataSource(administrativeServiceQueryContainer);
                procedureBox.setContainerDataSource(administrativeProcedureQueryContainer);
                serviceBox.select(null);
                procedureBox.select(null);
                taskBox.select(null);
                declarantTypeBox.select(null);
            } else {
                serviceBox.setContainerDataSource(interdepartmentalQueryContainer);
                procedureBox.setContainerDataSource(interdepartmentalProcedureQueryContainer);
                procedureBox.select(null);
                procedureBox.select(null);
                taskBox.select(null);
                declarantTypeBox.select(null);
            }
        }
    });

    serviceBox.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            final Property prop = event.getProperty();
            if (prop.getValue() == null) {
                administrativeProcedureQueryDefinition.setServiceId(-1);
            } else {
                administrativeProcedureQueryDefinition.setServiceId((Long) administrativeServiceQueryContainer
                        .getItem(prop.getValue()).getItemProperty("id").getValue());
            }
            procedureBox.select(null);
            administrativeProcedureQueryContainer.refresh();
        }
    });

    procedureBox.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            final Property prop = event.getProperty();
            if (prop.getValue() == null) {
                taskBox.setEnabled(false);
            } else {
                taskBox.setEnabled(true);
                String id = procedureBox.getItem(prop.getValue()).getItemProperty("id").toString();
                final ProcessTaskQueryDefinition tSQ = new ProcessTaskQueryDefinition(Long.parseLong(id));
                final LazyQueryContainer tSC = new LazyQueryContainer(tSQ, new ProcessTaskQueryFactory());
                taskBox.setContainerDataSource(tSC);
                taskBox.setItemCaptionPropertyId("name");
            }
        }
    });

    Button actionFilter = new Button("");
    actionFilter.addShortcutListener(new Button.ClickShortcut(actionFilter, ShortcutAction.KeyCode.ENTER));
    actionFilter.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = 7234774931167363716L;

        @Override
        public void buttonClick(Button.ClickEvent event) {

            Object overdue = getField("overdue").getValue();
            controlledTasksQuery.setOverdue(Boolean.TRUE.equals(overdue));

            Object fromDate = getField("fromDate").getValue();
            controlledTasksQuery.setFromDate(fromDate != null ? (Date) fromDate : null);

            Object toDate = getField("toDate").getValue();
            controlledTasksQuery.setToDate(toDate != null ? (Date) toDate : null);

            Object requester = getField("requester").getValue();
            controlledTasksQuery.setRequester(requester != null ? requester.toString() : null);

            Object bidId = getField("bidId").getValue();
            String bidIdString = null;
            if (bidId != null) {
                bidIdString = bidId.toString();
                try {
                    Long.parseLong(bidIdString);
                } catch (NumberFormatException e) {
                    bidIdString = null;
                }
            }
            controlledTasksQuery.setBidId(bidIdString);

            Object type = getField("procedureType").getValue();
            controlledTasksQuery.setProcedureType(type != null ? type.toString() : null);

            Object serviceIdValue = getField("serviceId").getValue();
            Item serviceItem = serviceIdValue != null ? serviceBox.getItem(serviceIdValue) : null;
            String serviceId = null;
            if (serviceItem != null && serviceItem.getItemProperty("id") != null) {
                serviceId = serviceItem.getItemProperty("id").toString();
            }
            controlledTasksQuery.setServiceId(serviceId);

            Object procedureValue = getField("procedureName").getValue();
            Item procedureItem = procedureValue != null ? procedureBox.getItem(procedureValue) : null;
            String procedureId = null;
            if (procedureItem != null && procedureItem.getItemProperty("id") != null) {
                procedureId = procedureItem.getItemProperty("id").toString();
            }
            controlledTasksQuery.setProcedureId(procedureId);

            Object taskValue = getField("taskName").getValue();
            Item taskValueItem = taskValue != null ? taskBox.getItem(taskValue) : null;
            String taskKey = null;
            if (taskValue != null) {
                taskKey = taskValueItem.getItemProperty("taskDefKey") != null
                        ? taskValueItem.getItemProperty("taskDefKey").toString()
                        : null;
            }
            controlledTasksQuery.setTaskKey(taskKey);

            Object declarantTypeValue = getField("declarantType").getValue();
            Item declarantTypeValueItem = declarantTypeValue != null
                    ? declarantTypeBox.getItem(declarantTypeValue)
                    : null;
            String name = null;
            String val = null;
            if (declarantTypeValue != null) {
                name = declarantTypeValueItem.getItemProperty("name") != null
                        ? declarantTypeValueItem.getItemProperty("name").toString()
                        : null;
                val = declarantTypeValueItem.getItemProperty("value") != null
                        ? declarantTypeValueItem.getItemProperty("value").toString()
                        : null;
            }
            controlledTasksQuery.setDeclarantTypeName(name);
            controlledTasksQuery.setDeclarantTypeValue(val);

            Collection controlledOrgGroups = (Collection) getField("controlledOrgGroups").getValue();
            List<String> selectedOrgGroups = new ArrayList<String>();
            if (controlledOrgGroups.size() > 0) {
                Iterator iterator = controlledOrgGroups.iterator();
                while (iterator.hasNext()) {
                    selectedOrgGroups
                            .add(orgGroups.getItem(iterator.next()).getItemProperty("name").toString());
                }
            }
            if (mode == Mode.Supervisor) {
                controlledTasksQuery
                        .setControlledOrgGroups(controlledOrgGroups.size() != 0 ? selectedOrgGroups : null);
            }

            Collection controlledEmpGroups = (Collection) getField("controlledEmpGroups").getValue();
            List<String> selectedEmpGroups = new ArrayList<String>();
            if (controlledEmpGroups.size() > 0) {
                Iterator iterator = controlledEmpGroups.iterator();
                while (iterator.hasNext()) {
                    selectedEmpGroups
                            .add(empGroups.getItem(iterator.next()).getItemProperty("name").toString());
                }
            }
            if (mode == Mode.Supervisor) {
                controlledTasksQuery
                        .setControlledEmpGroups(controlledEmpGroups.size() != 0 ? selectedEmpGroups : null);
            }
            controlledTasksTable.refresh();

            if (executionTasksQuery != null) {
                executionTasksQuery.setFromDate(fromDate != null ? (Date) fromDate : null);
                executionTasksQuery.setToDate(toDate != null ? (Date) toDate : null);
                executionTasksQuery.setRequester(requester != null ? requester.toString() : null);
                executionTasksQuery.setBidId(bidIdString);
                executionTasksQuery.setProcedureType(type != null ? type.toString() : null);
                executionTasksQuery.setServiceId(serviceId);
                executionTasksQuery.setProcedureId(procedureId);
                executionTasksQuery.setTaskKey(taskKey);
                executionTasksQuery.setDeclarantTypeName(name);
                executionTasksQuery.setDeclarantTypeValue(val);
                executionTasksQuery.setOverdue(Boolean.TRUE.equals(overdue));
            }
            if (executionTasksTable != null) {
                executionTasksTable.refresh();
            }
        }
    });

    Button resetFilter = new Button("? ");
    resetFilter.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = 7234774931167363717L;

        @Override
        public void buttonClick(Button.ClickEvent event) {

            Field overdue = getField("overdue");
            overdue.setValue(false);
            controlledTasksQuery.setOverdue(false);

            Field fromDate = getField("fromDate");
            fromDate.setValue(null);
            controlledTasksQuery.setFromDate(null);

            Field toDate = getField("toDate");
            toDate.setValue(null);
            controlledTasksQuery.setToDate(null);

            getField("requester").setValue("");
            controlledTasksQuery.setRequester(null);

            getField("bidId").setValue("");
            controlledTasksQuery.setBidId(null);

            getField("procedureType").setValue(null);
            controlledTasksQuery.setProcedureType(null);

            getField("serviceId").setValue(null);
            controlledTasksQuery.setServiceId(null);

            getField("procedureName").setValue(null);
            controlledTasksQuery.setProcedureId(null);

            getField("taskName").setValue(null);
            controlledTasksQuery.setTaskKey(null);

            getField("declarantType").setValue(null);
            controlledTasksQuery.setDeclarantTypeName(null);
            controlledTasksQuery.setDeclarantTypeValue(null);

            getField("controlledOrgGroups").setValue(null);
            if (mode == Mode.Supervisor) {
                controlledTasksQuery.setControlledOrgGroups(null);
            }

            getField("controlledEmpGroups").setValue(null);
            if (mode == Mode.Supervisor) {
                controlledTasksQuery.setControlledEmpGroups(null);
            }
            controlledTasksTable.refresh();
            if (executionTasksQuery != null) {
                executionTasksQuery.setFromDate(null);
                executionTasksQuery.setToDate(null);
                executionTasksQuery.setRequester(null);
                executionTasksQuery.setBidId(null);
                executionTasksQuery.setProcedureType(null);
                executionTasksQuery.setServiceId(null);
                executionTasksQuery.setProcedureId(null);
                executionTasksQuery.setTaskKey(null);
                executionTasksQuery.setDeclarantTypeName(null);
                executionTasksQuery.setDeclarantTypeValue(null);
                executionTasksQuery.setOverdue(false);
            }
            if (executionTasksTable != null) {
                executionTasksTable.refresh();
            }
        }
    });

    final HorizontalLayout footer = (HorizontalLayout) getFooter();
    footer.setSpacing(true);
    Button refreshLists = new Button(" ?? ?", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Flash.fire(new TaskChanged(TaskFilter.this, ""));
        }
    });
    refreshLists.setImmediate(true);
    footer.addComponent(refreshLists);
    footer.addComponent(actionFilter);
    footer.addComponent(resetFilter);
}