Example usage for com.vaadin.ui Alignment TOP_CENTER

List of usage examples for com.vaadin.ui Alignment TOP_CENTER

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment TOP_CENTER.

Prototype

Alignment TOP_CENTER

To view the source code for com.vaadin.ui Alignment TOP_CENTER.

Click Source Link

Usage

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.ImportStructureFromStringDialog.java

License:Open Source License

private void layoutComponents() {
    layout.addComponent(sequenceInputField);
    layout.addComponent(importTypeSelectField);
    layout.addComponent(ok);//from   ww w  . j a v a  2s.  c o m

    layout.setComponentAlignment(sequenceInputField, Alignment.TOP_CENTER);
    layout.setComponentAlignment(importTypeSelectField, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(ok, Alignment.BOTTOM_CENTER);
}

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

@Override
public void recieveSelectionUpdate(double x, double y, double width, double height, boolean mouseMoved) {
    final Residue selectedResidue = theCanvas.getCurrentResidue();

    theCanvas.selectIntersectingRectangles(x, y, width, height, mouseMoved);

    if (theCanvas.getCurrentResidue() != null && selectedResidue == theCanvas.getCurrentResidue()
            && selectedResidue.isRepetition()) {
        final Window window = new Window("Repeatition options");

        WeeLayout layout = new WeeLayout(org.vaadin.weelayout.WeeLayout.Direction.VERTICAL);

        final TextField minRep = new TextField("Minimum");
        final TextField maxRep = new TextField("Maximum");
        NativeButton okBut = new NativeButton("Ok");
        NativeButton cancelBut = new NativeButton("Cancel");

        minRep.setImmediate(true);/*  w w  w . j ava2 s.  c om*/
        maxRep.setImmediate(true);

        minRep.setValue(String.valueOf(selectedResidue.getMinRepetitions()));
        maxRep.setValue(String.valueOf(selectedResidue.getMaxRepetitions()));

        okBut.addListener(new ClickListener() {
            private static final long serialVersionUID = -408364885359729326L;

            @Override
            public void buttonClick(ClickEvent event) {
                String minRepNum = (String) minRep.getValue();
                String maxRepNum = (String) maxRep.getValue();

                boolean valid = true;

                try {
                    Integer.parseInt(minRepNum);
                    Integer.parseInt(maxRepNum);
                } catch (NumberFormatException ex) {
                    valid = false;
                }

                if (valid) {
                    selectedResidue.setMinRepetitions((String) minRep.getValue());
                    selectedResidue.setMaxRepetitions((String) maxRep.getValue());

                    theCanvas.documentUpdated();
                }

                getWindow().removeWindow(window);
            }
        });

        cancelBut.addListener(new ClickListener() {
            private static final long serialVersionUID = -657746118918366530L;

            @Override
            public void buttonClick(ClickEvent event) {
                getWindow().removeWindow(window);
            }
        });

        layout.addComponent(minRep, Alignment.TOP_CENTER);
        layout.addComponent(maxRep, Alignment.MIDDLE_CENTER);

        WeeLayout buttonLayout = new WeeLayout(Direction.HORIZONTAL);
        buttonLayout.addComponent(okBut, Alignment.TOP_CENTER);
        buttonLayout.addComponent(cancelBut, Alignment.TOP_CENTER);

        layout.addComponent(buttonLayout, Alignment.BOTTOM_CENTER);

        window.center();
        window.getContent().addComponent(layout);

        window.getContent().setSizeUndefined();
        window.setSizeUndefined();

        getWindow().addWindow(window);
    }
}

From source file:annis.gui.admin.GroupManagementPanel.java

License:Apache License

public GroupManagementPanel() {
    groupsContainer.setBeanIdProperty("name");

    progress = new ProgressBar();
    progress.setCaption("Loading group list");
    progress.setIndeterminate(true);/*www.  j  a v  a 2  s.  c o m*/
    progress.setVisible(false);

    GeneratedPropertyContainer generated = new GeneratedPropertyContainer(groupsContainer);
    generated.addGeneratedProperty("edit", new PropertyValueGenerator<String>() {

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            return "Edit";
        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });
    groupsGrid.setContainerDataSource(generated);
    groupsGrid.setSelectionMode(Grid.SelectionMode.MULTI);
    groupsGrid.setSizeFull();
    groupsGrid.setColumns("name", "edit", "corpora");

    Grid.HeaderRow filterRow = groupsGrid.appendHeaderRow();
    TextField groupFilterField = new TextField();
    groupFilterField.setInputPrompt("Filter");
    groupFilterField.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            groupsContainer.removeContainerFilters("name");
            if (!event.getText().isEmpty()) {
                groupsContainer
                        .addContainerFilter(new SimpleStringFilter("name", event.getText(), true, false));
            }
        }
    });
    filterRow.getCell("name").setComponent(groupFilterField);

    TextField corpusFilterField = new TextField();
    corpusFilterField.setInputPrompt("Filter by corpus");
    corpusFilterField.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            groupsContainer.removeContainerFilters("corpora");
            if (!event.getText().isEmpty()) {
                groupsContainer.addContainerFilter(new StringPatternInSetFilter("corpora", event.getText()));
            }
        }
    });
    filterRow.getCell("corpora").setComponent(corpusFilterField);

    Grid.Column editColumn = groupsGrid.getColumn("edit");
    editColumn.setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() {

        @Override
        public void click(ClickableRenderer.RendererClickEvent event) {
            Group g = groupsContainer.getItem(event.getItemId()).getBean();

            FieldGroup fields = new FieldGroup(groupsContainer.getItem(event.getItemId()));
            fields.addCommitHandler(new GroupCommitHandler(g.getName()));

            EditSingleGroup edit = new EditSingleGroup(fields, corpusContainer);

            Window w = new Window("Edit group \"" + g.getName() + "\"");
            w.setContent(edit);
            w.setModal(true);
            w.setWidth("500px");
            w.setHeight("250px");
            UI.getCurrent().addWindow(w);
        }
    }));

    Grid.Column corporaColumn = groupsGrid.getColumn("corpora");
    ;
    corporaColumn.setConverter(new CommaSeperatedStringConverterSet());

    txtGroupName = new TextField();
    txtGroupName.setInputPrompt("New group name");

    Button btAddNewGroup = new Button("Add new group");
    btAddNewGroup.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            handleAdd();
        }
    });
    btAddNewGroup.addStyleName(ChameleonTheme.BUTTON_DEFAULT);

    Button btDeleteGroup = new Button("Delete selected group(s)");
    btDeleteGroup.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            // get selected groups
            Set<String> selectedGroups = new TreeSet<>();
            for (Object id : groupsGrid.getSelectedRows()) {
                selectedGroups.add((String) id);
            }
            groupsGrid.getSelectionModel().reset();
            for (GroupListView.Listener l : listeners) {
                l.deleteGroups(selectedGroups);
            }
        }
    });

    actionLayout = new HorizontalLayout(txtGroupName, btAddNewGroup, btDeleteGroup);

    VerticalLayout layout = new VerticalLayout(actionLayout, progress, groupsGrid);
    layout.setSizeFull();
    layout.setExpandRatio(groupsGrid, 1.0f);
    layout.setExpandRatio(progress, 1.0f);
    layout.setSpacing(true);
    layout.setMargin(new MarginInfo(true, false, false, false));

    layout.setComponentAlignment(actionLayout, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(progress, Alignment.TOP_CENTER);

    setContent(layout);
    setSizeFull();

    addActionHandler(new AddGroupHandler(txtGroupName));
}

From source file:annis.gui.admin.UserManagementPanel.java

License:Apache License

public UserManagementPanel() {

    userContainer = new BeanContainer<>(User.class);
    userContainer.setBeanIdProperty("name");

    progress = new ProgressBar();
    progress.setCaption("Loading user list");
    progress.setIndeterminate(true);//from   w  w  w  . jav a2 s.  c o  m
    progress.setVisible(false);

    GeneratedPropertyContainer generated = new GeneratedPropertyContainer(userContainer);
    generated.addGeneratedProperty("edit", new PropertyValueGenerator<String>() {

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            return "Edit";
        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });
    generated.addGeneratedProperty("changePassword", new PropertyValueGenerator<String>() {

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            return "Change password";
        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });

    userList = new Grid(generated);
    userList.setSizeFull();
    userList.setSelectionMode(Grid.SelectionMode.MULTI);
    userList.setColumns("name", "edit", "changePassword", "expires", "groups", "permissions");

    HeaderRow filterRow = userList.appendHeaderRow();
    TextField userFilterField = new TextField();
    userFilterField.setInputPrompt("Filter");
    userFilterField.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            userContainer.removeContainerFilters("name");
            if (!event.getText().isEmpty()) {
                userContainer.addContainerFilter(new SimpleStringFilter("name", event.getText(), true, false));
            }
        }
    });
    filterRow.getCell("name").setComponent(userFilterField);

    CheckBox expiredFilterField = new CheckBox("has expired");
    expiredFilterField.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            userContainer.removeContainerFilters("expires");
            if ((Boolean) event.getProperty().getValue() == true) {
                userContainer.addContainerFilter(new ExpiredUserFilter("expires"));
            }
        }
    });
    filterRow.getCell("expires").setComponent(expiredFilterField);

    TextField groupFilterField = new TextField();
    groupFilterField.setInputPrompt("Filter by groups");
    groupFilterField.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            userContainer.removeContainerFilters("groups");
            if (!event.getText().isEmpty()) {
                userContainer.addContainerFilter(
                        new GroupManagementPanel.StringPatternInSetFilter("groups", event.getText()));
            }
        }
    });
    filterRow.getCell("groups").setComponent(groupFilterField);

    Grid.Column editColum = userList.getColumn("edit");
    editColum.setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() {

        @Override
        public void click(ClickableRenderer.RendererClickEvent event) {

            User u = userContainer.getItem(event.getItemId()).getBean();

            FieldGroup group = new FieldGroup(userContainer.getItem(event.getItemId()));
            group.addCommitHandler(new UserCommitHandler(u.getName()));

            EditSingleUser edit = new EditSingleUser(group, groupsContainer, permissionsContainer);

            Window w = new Window("Edit user \"" + u.getName() + "\"");
            w.setContent(edit);
            w.setModal(true);
            w.setWidth("500px");
            w.setHeight("400px");
            UI.getCurrent().addWindow(w);
        }
    }));
    editColum.setHeaderCaption("");
    editColum.setExpandRatio(0);

    Grid.Column passwordColumn = userList.getColumn("changePassword");
    passwordColumn.setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() {

        @Override
        public void click(ClickableRenderer.RendererClickEvent event) {
            UserManagementPanel.this.askForPasswordChange((String) event.getItemId());
        }
    }));
    passwordColumn.setHeaderCaption("");
    passwordColumn.setExpandRatio(0);

    userList.getColumn("name").setHeaderCaption("Username");

    Grid.Column groupsColumm = userList.getColumn("groups");
    groupsColumm.setHeaderCaption("Groups");
    groupsColumm.setConverter(new CommaSeperatedStringConverterSet());
    groupsColumm.setExpandRatio(1);

    Grid.Column permissionsColumn = userList.getColumn("permissions");
    permissionsColumn.setHeaderCaption("Additional permissions");
    permissionsColumn.setConverter(new CommaSeperatedStringConverterSet());

    Grid.Column expiresColumn = userList.getColumn("expires");
    expiresColumn.setHeaderCaption("Expiration Date");
    expiresColumn.setConverter(new DateTimeStringConverter());

    txtUserName = new TextField();
    txtUserName.setInputPrompt("New user name");

    Button btAddNewUser = new Button("Add new user");
    btAddNewUser.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            handleAdd();
        }
    });
    btAddNewUser.addStyleName(ChameleonTheme.BUTTON_DEFAULT);

    Button btDeleteUser = new Button("Delete selected user(s)");
    btDeleteUser.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            // get selected users
            Set<String> selectedUsers = new TreeSet<>();
            for (Object id : userList.getSelectedRows()) {
                selectedUsers.add((String) id);
            }
            userList.getSelectionModel().reset();
            for (UserListView.Listener l : listeners) {
                l.deleteUsers(selectedUsers);
            }
        }
    });

    actionLayout = new HorizontalLayout(txtUserName, btAddNewUser, btDeleteUser);

    layout = new VerticalLayout(actionLayout, progress, userList);
    layout.setSizeFull();
    layout.setExpandRatio(userList, 1.0f);
    layout.setExpandRatio(progress, 1.0f);
    layout.setSpacing(true);
    layout.setMargin(new MarginInfo(true, false, false, false));

    layout.setComponentAlignment(actionLayout, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(progress, Alignment.TOP_CENTER);

    setContent(layout);
    setSizeFull();

    addActionHandler(new AddUserHandler(txtUserName));

}

From source file:annis.gui.frequency.FrequencyQueryPanel.java

License:Apache License

public FrequencyQueryPanel(final QueryController controller, QueryUIState state) {
    this.controller = controller;
    this.state = state;

    setWidth("99%");
    setHeight("99%");
    setMargin(true);/*w ww .  j av  a2s  .  c  o  m*/

    queryLayout = new VerticalLayout();
    queryLayout.setWidth("100%");
    queryLayout.setHeight("100%");

    HorizontalLayout queryDescriptionLayout = new HorizontalLayout();
    queryDescriptionLayout.setSpacing(true);
    queryDescriptionLayout.setWidth("100%");
    queryDescriptionLayout.setHeight("-1px");
    queryLayout.addComponent(queryDescriptionLayout);

    lblCorpusList = new Label("");
    lblCorpusList.setCaption("selected corpora:");
    lblCorpusList.setWidth("100%");

    lblAQL = new Label("");
    lblAQL.setCaption("query to analyze:");
    lblAQL.setWidth("100%");
    lblAQL.addStyleName(Helper.CORPUS_FONT_FORCE);

    queryDescriptionLayout.addComponent(lblCorpusList);
    queryDescriptionLayout.addComponent(lblAQL);

    queryDescriptionLayout.setComponentAlignment(lblCorpusList, Alignment.MIDDLE_LEFT);
    queryDescriptionLayout.setComponentAlignment(lblAQL, Alignment.MIDDLE_RIGHT);

    tblFrequencyDefinition = new Table();
    tblFrequencyDefinition.setImmediate(true);
    tblFrequencyDefinition.setSortEnabled(false);
    tblFrequencyDefinition.setSelectable(true);
    tblFrequencyDefinition.setMultiSelect(true);
    tblFrequencyDefinition.setTableFieldFactory(new FieldFactory());
    tblFrequencyDefinition.setEditable(true);
    tblFrequencyDefinition.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (tblFrequencyDefinition.getValue() == null
                    || ((Set<Object>) tblFrequencyDefinition.getValue()).isEmpty()) {
                btDeleteRow.setEnabled(false);
            } else {
                btDeleteRow.setEnabled(true);
            }
        }
    });

    lblErrorOrMsg = new Label("No node with explicit name in OR expression found! "
            + "When using OR expression you need to explicitly name the nodes "
            + "you want to include in the frequency analysis with \"#\", " + "like e.g. in <br />" + "<pre>"
            + "(n1#tok=\"fun\" | n1#tok=\"severity\")" + "</pre>");
    lblErrorOrMsg.setContentMode(ContentMode.HTML);
    lblErrorOrMsg.addStyleName("embedded-warning");
    lblErrorOrMsg.setWidth("100%");
    lblErrorOrMsg.setVisible(false);
    queryLayout.addComponent(lblErrorOrMsg);

    tblFrequencyDefinition.setWidth("100%");
    tblFrequencyDefinition.setHeight("100%");

    tblFrequencyDefinition.setContainerDataSource(state.getFrequencyTableDefinition());

    tblFrequencyDefinition.setColumnHeader("nr", "Node number/name");
    tblFrequencyDefinition.setColumnHeader("annotation", "Selected annotation of node");
    tblFrequencyDefinition.setColumnHeader("comment", "Comment");

    tblFrequencyDefinition.addStyleName(Helper.CORPUS_FONT_FORCE);

    tblFrequencyDefinition.setRowHeaderMode(Table.RowHeaderMode.INDEX);

    tblFrequencyDefinition.setColumnExpandRatio("nr", 0.15f);
    tblFrequencyDefinition.setColumnExpandRatio("annotation", 0.35f);
    tblFrequencyDefinition.setColumnExpandRatio("comment", 0.5f);
    tblFrequencyDefinition.setVisibleColumns("nr", "annotation", "comment");

    queryLayout.addComponent(tblFrequencyDefinition);

    metaNamesContainer = new IndexedContainer();
    PopupTwinColumnSelect metaSelect = new PopupTwinColumnSelect();
    metaSelect.setSelectableContainer(metaNamesContainer);
    metaSelect.setPropertyDataSource(state.getFrequencyMetaData());
    metaSelect.setCaption("Metadata");

    queryLayout.addComponent(metaSelect);

    if (controller != null) {
        createAutomaticEntriesForQuery(state.getAql().getValue());
        updateQueryInfo(state.getAql().getValue());
    }

    HorizontalLayout layoutButtons = new HorizontalLayout();

    btAdd = new Button("Add");
    btAdd.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            cbAutomaticMode.setValue(Boolean.FALSE);

            int nr = 1;
            // get the highest number of values from the existing defitions
            for (Object id : tblFrequencyDefinition.getItemIds()) {
                String textNr = (String) tblFrequencyDefinition.getItem(id).getItemProperty("nr").getValue();
                try {
                    nr = Math.max(nr, Integer.parseInt(textNr));
                } catch (NumberFormatException ex) {
                    // was not a number but a named node
                }
            }
            if (controller != null) {
                List<QueryNode> nodes = parseQuery(FrequencyQueryPanel.this.state.getAql().getValue());
                nr = Math.min(nr, nodes.size() - 1);
                int id = counter++;
                UserGeneratedFrequencyEntry entry = new UserGeneratedFrequencyEntry();
                entry.setAnnotation("tok");
                entry.setComment("");
                entry.setNr("" + (nr + 1));
                FrequencyQueryPanel.this.state.getFrequencyTableDefinition().addItem(id, entry);
            }
        }
    });
    layoutButtons.addComponent(btAdd);

    btDeleteRow = new Button("Delete selected row(s)");
    btDeleteRow.setEnabled(false);
    btDeleteRow.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Set<Object> selected = new HashSet((Set<Object>) tblFrequencyDefinition.getValue());
            for (Object o : selected) {
                cbAutomaticMode.setValue(Boolean.FALSE);
                tblFrequencyDefinition.removeItem(o);

            }
        }
    });
    layoutButtons.addComponent(btDeleteRow);

    cbAutomaticMode = new CheckBox("Automatic mode", true);
    cbAutomaticMode.setImmediate(true);
    cbAutomaticMode.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            btShowFrequencies.setEnabled(true);
            if (cbAutomaticMode.getValue()) {
                tblFrequencyDefinition.removeAllItems();
                if (controller != null) {
                    createAutomaticEntriesForQuery(FrequencyQueryPanel.this.state.getAql().getValue());
                }
            }
        }
    });
    layoutButtons.addComponent(cbAutomaticMode);

    btReset = new Button("Reset to default");
    btReset.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            cbAutomaticMode.setValue(Boolean.TRUE);
            btShowFrequencies.setEnabled(true);
            tblFrequencyDefinition.removeAllItems();
            if (controller != null) {
                createAutomaticEntriesForQuery(FrequencyQueryPanel.this.state.getAql().getValue());
            }
        }
    });
    //layoutButtons.addComponent(btReset);

    layoutButtons.setComponentAlignment(btAdd, Alignment.MIDDLE_LEFT);
    layoutButtons.setComponentAlignment(btDeleteRow, Alignment.MIDDLE_LEFT);
    layoutButtons.setComponentAlignment(cbAutomaticMode, Alignment.MIDDLE_RIGHT);
    layoutButtons.setExpandRatio(btAdd, 0.0f);
    layoutButtons.setExpandRatio(btDeleteRow, 0.0f);
    layoutButtons.setExpandRatio(cbAutomaticMode, 1.0f);

    layoutButtons.setMargin(true);
    layoutButtons.setSpacing(true);
    layoutButtons.setHeight("-1px");
    layoutButtons.setWidth("100%");

    queryLayout.addComponent(layoutButtons);

    btShowFrequencies = new Button("Perform frequency analysis");
    btShowFrequencies.setDisableOnClick(true);
    btShowFrequencies.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {

            if (controller != null) {
                try {
                    if (resultPanel != null) {
                        removeComponent(resultPanel);
                    }
                    queryLayout.setVisible(false);

                    pbQuery.setCaption("Please wait, the frequencies analysis can take some time");
                    pbQuery.setIndeterminate(true);
                    pbQuery.setEnabled(true);
                    pbQuery.setVisible(true);

                    controller.executeFrequency(FrequencyQueryPanel.this);
                } catch (Exception ex) {
                    btShowFrequencies.setEnabled(true);
                }
            }

        }
    });
    queryLayout.addComponent(btShowFrequencies);

    queryLayout.setComponentAlignment(tblFrequencyDefinition, Alignment.TOP_CENTER);
    queryLayout.setComponentAlignment(layoutButtons, Alignment.TOP_CENTER);
    queryLayout.setComponentAlignment(btShowFrequencies, Alignment.TOP_CENTER);

    queryLayout.setExpandRatio(tblFrequencyDefinition, 1.0f);
    queryLayout.setExpandRatio(layoutButtons, 0.0f);
    queryLayout.setExpandRatio(btShowFrequencies, 0.0f);

    queryLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            Component c = event.getClickedComponent();
            if (c instanceof Field) {
                Object itemID = getField2ItemID().get((Field) c);
                if (itemID != null) {
                    if (!event.isCtrlKey() && !event.isShiftKey()) {
                        // deselect everything else if no modifier key was clicked
                        tblFrequencyDefinition.setValue(null);
                    }
                    // select the item
                    tblFrequencyDefinition.select(itemID);
                }
            }
        }
    });

    btShowQuery = new Button("New Analysis", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            showQueryDefinitionPanel();
        }
    });
    btShowQuery.setVisible(false);

    pbQuery.setVisible(false);
    addComponent(pbQuery);

    addComponent(queryLayout);
    addComponent(btShowQuery);

    setComponentAlignment(btShowQuery, Alignment.TOP_CENTER);
    setComponentAlignment(pbQuery, Alignment.TOP_CENTER);

    if (controller != null) {
        state.getSelectedCorpora().addValueChangeListener(new Property.ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                if (cbAutomaticMode.getValue()) {
                    createAutomaticEntriesForQuery(FrequencyQueryPanel.this.state.getAql().getValue());
                }
                updateQueryInfo(FrequencyQueryPanel.this.state.getAql().getValue());
            }
        });
    }
}

From source file:annis.gui.querybuilder.NodeWindow.java

License:Apache License

public NodeWindow(int id, TigerQueryBuilderCanvas parent) {
    this.parent = parent;
    this.id = id;
    this.annoNames = new TreeSet<>();

    for (String a : parent.getAvailableAnnotationNames()) {
        annoNames.add(a.replaceFirst("^[^:]*:", ""));
    }//from  w w  w .  j a v a  2  s  . c  o m
    constraints = new ArrayList<>();

    setSizeFull();

    // HACK: use our own border since the one from chameleon does not really work
    addStyleName(ValoTheme.PANEL_WELL);
    //addStyleName("border-layout");

    prepareEdgeDock = false;

    vLayout = new VerticalLayout();
    setContent(vLayout);
    vLayout.setWidth("100%");
    vLayout.setHeight("-1px");
    vLayout.setMargin(false);
    vLayout.setSpacing(true);

    toolbar = new HorizontalLayout();
    toolbar.addStyleName("toolbar");
    toolbar.setWidth("100%");
    toolbar.setHeight("-1px");
    toolbar.setMargin(false);
    toolbar.setSpacing(false);
    vLayout.addComponent(toolbar);

    btMove = new Button();
    btMove.setWidth("100%");
    btMove.setIcon(FontAwesome.ARROWS);
    btMove.setDescription("<strong>Move node</strong><br />Click, hold and move mouse to move the node.");
    btMove.addStyleName(ValoTheme.BUTTON_SMALL);
    btMove.addStyleName("drag-source-enabled");
    toolbar.addComponent(btMove);

    btEdge = new Button("Edge");
    btEdge.setIcon(FontAwesome.EXTERNAL_LINK);
    btEdge.addClickListener((Button.ClickListener) this);
    btEdge.addStyleName(ValoTheme.BUTTON_SMALL);
    //btEdge.addStyleName(ChameleonTheme.BUTTON_LINK);
    btEdge.setDescription("<strong>Add Edge</strong><br />" + "To create a new edge between "
            + "two nodes click this button first. " + "Then define a destination node by clicking its \"Dock\" "
            + "button.<br>You can cancel the action by clicking this button " + "(\"Cancel\") again.");
    btEdge.setImmediate(true);
    toolbar.addComponent(btEdge);

    btAdd = new Button("Add");
    btAdd.setIcon(FontAwesome.PLUS);
    btAdd.addStyleName(ValoTheme.BUTTON_SMALL);
    //btAdd.addStyleName(ChameleonTheme.BUTTON_LINK);
    btAdd.addClickListener((Button.ClickListener) this);
    btAdd.setDescription("<strong>Add Node Condition</strong><br />"
            + "Every condition will constraint the node described by this window. "
            + "Most conditions limit the node by defining which annotations and which "
            + "values of the annotation a node needs to have.");
    toolbar.addComponent(btAdd);

    btClear = new Button("Clear");
    btClear.setIcon(FontAwesome.TRASH_O);
    btClear.addStyleName(ValoTheme.BUTTON_SMALL);
    //btClear.addStyleName(ChameleonTheme.BUTTON_LINK);
    btClear.addClickListener((Button.ClickListener) this);
    btClear.setDescription("<strong>Clear All Node Conditions</strong>");
    toolbar.addComponent(btClear);

    btClose = new Button();
    btClose.setIcon(FontAwesome.TIMES_CIRCLE);
    btClose.setDescription("<strong>Close</strong><br />Close this node description window");
    btClose.addStyleName(ValoTheme.BUTTON_SMALL);
    btClose.addClickListener((Button.ClickListener) this);
    toolbar.addComponent(btClose);

    toolbar.setComponentAlignment(btMove, Alignment.TOP_LEFT);
    toolbar.setExpandRatio(btMove, 1.0f);

    toolbar.setComponentAlignment(btEdge, Alignment.TOP_CENTER);
    toolbar.setComponentAlignment(btAdd, Alignment.TOP_CENTER);
    toolbar.setComponentAlignment(btClear, Alignment.TOP_CENTER);
    toolbar.setComponentAlignment(btClose, Alignment.TOP_RIGHT);

}

From source file:annis.gui.resultview.ResultSetPanel.java

License:Apache License

public ResultSetPanel(List<Match> matches, PluginSystem ps, InstanceConfig instanceConfig, int contextLeft,
        int contextRight, String segmentationName, ResultViewPanel parent, int firstMatchOffset) {
    this.ps = ps;
    this.segmentationName = segmentationName;
    this.contextLeft = contextLeft;
    this.contextRight = contextRight;
    this.parent = parent;
    this.matches = Collections.synchronizedList(matches);
    this.firstMatchOffset = firstMatchOffset;
    this.instanceConfig = instanceConfig;

    resultPanelList = Collections.synchronizedList(new LinkedList<SingleResultPanel>());
    cacheResolver = Collections//from w  ww .  j  a v  a 2s.c  o m
            .synchronizedMap(new HashMap<HashSet<SingleResolverRequest>, List<ResolverEntry>>());

    setSizeFull();

    layout = new CssLayout();
    setContent(layout);
    layout.addStyleName("result-view-css");

    addStyleName(ChameleonTheme.PANEL_BORDERLESS);
    addStyleName("result-view");

    indicatorLayout = new VerticalLayout();

    indicator = new ProgressIndicator();
    indicator.setIndeterminate(false);
    indicator.setValue(0f);
    indicator.setPollingInterval(250);
    indicator.setSizeUndefined();

    indicatorLayout.addComponent(indicator);
    indicatorLayout.setWidth("100%");
    indicatorLayout.setHeight("-1px");
    indicatorLayout.setComponentAlignment(indicator, Alignment.TOP_CENTER);
    indicatorLayout.setVisible(true);

    layout.addComponent(indicatorLayout);

    // enable indicator in order to get refresh GUI regulary
    indicator.setEnabled(true);

    ExecutorService singleExecutor = Executors.newSingleThreadExecutor();

    Callable<Boolean> run = new AllResultsFetcher();
    FutureTask<Boolean> task = new FutureTask<Boolean>(run) {
        @Override
        protected void done() {
            VaadinSession session = VaadinSession.getCurrent();
            session.lock();
            try {
                indicator.setEnabled(false);
                indicator.setVisible(false);
                indicatorLayout.setVisible(false);
            } finally {
                session.unlock();
            }
        }
    };
    singleExecutor.submit(task);
}

From source file:annis.gui.resultview.ResultViewPanel.java

License:Apache License

public ResultViewPanel(AnnisUI ui, PluginSystem ps, InstanceConfig instanceConfig,
        DisplayedResultQuery initialQuery) {
    this.sui = ui;
    this.tokenAnnoVisible = new TreeMap<>();
    this.ps = ps;
    this.controller = ui.getQueryController();
    this.initialQuery = initialQuery;

    cacheResolver = Collections/*from www  .  j a  va  2 s .c  o  m*/
            .synchronizedMap(new HashMap<HashSet<SingleResolverRequest>, List<ResolverEntry>>());

    resultPanelList = Collections.synchronizedList(new LinkedList<SingleResultPanel>());

    resultLayout = new CssLayout();
    resultLayout.addStyleName("result-view-css");
    Panel resultPanel = new Panel(resultLayout);
    resultPanel.setSizeFull();
    resultPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    resultPanel.addStyleName("result-view-panel");

    this.instanceConfig = instanceConfig;

    setSizeFull();
    setMargin(false);

    MenuBar mbResult = new MenuBar();
    mbResult.setWidth("100%");
    mbResult.addStyleName("menu-hover");
    addComponent(mbResult);

    miSegmentation = mbResult.addItem("Base text", null);
    miTokAnnos = mbResult.addItem("Token Annotations", null);

    addComponent(resultPanel);

    setExpandRatio(mbResult, 0.0f);
    setExpandRatio(resultPanel, 1.0f);

    paging = new PagingComponent();

    addComponent(paging, 1);

    setComponentAlignment(paging, Alignment.TOP_CENTER);
    setExpandRatio(paging, 0.0f);
}

From source file:by.bigvova.LoginUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("Vaadin Shared Security Demo Login");

    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();//from w  ww.j ava  2s .  com

    userName = new TextField("Username");
    passwordField = new PasswordField("Password");
    rememberMe = new CheckBox("Remember me");
    login = new Button("Login");
    Label label = new Label("Name: User / Password: password");
    loginForm.addComponent(userName);
    loginForm.addComponent(passwordField);
    loginForm.addComponent(rememberMe);
    loginForm.addComponent(login);
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            login();
        }
    });

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSpacing(true);
    loginLayout.setSizeUndefined();

    if (request.getParameter("logout") != null) {
        loggedOutLabel = new Label("You have been logged out!");
        loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS);
        loggedOutLabel.setSizeUndefined();
        loginLayout.addComponent(loggedOutLabel);
        loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER);
    }

    loginLayout.addComponent(loginFailedLabel = new Label());
    loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER);
    loginFailedLabel.setSizeUndefined();
    loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    loginFailedLabel.setVisible(false);

    loginLayout.addComponent(label);
    loginLayout.addComponent(loginForm);
    loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

    VerticalLayout rootLayout = new VerticalLayout(loginLayout);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER);
    setContent(rootLayout);
    setSizeFull();
}

From source file:ch.bfh.ti.soed.hs16.srs.black.view.reservationView.ReservationView.java

License:Open Source License

public ReservationView() {
    reservationMakeView = new ReservationMakeView();
    reservationTableView = new ReservationTableView();

    VerticalLayout makeViewLayoutVL = reservationMakeView.getMakeViewLayout();
    VerticalLayout listReservationsVL = reservationTableView.getListReservations();

    GridLayout grid = new GridLayout(2, 1);
    grid.addComponent(makeViewLayoutVL, 0, 0);
    grid.addComponent(listReservationsVL, 1, 0);
    grid.setComponentAlignment(makeViewLayoutVL, Alignment.TOP_CENTER);
    grid.setComponentAlignment(listReservationsVL, Alignment.TOP_CENTER);
    grid.setSizeUndefined();/*from  w  w w .j  a  v a  2s.  c o m*/

    setSizeFull();
    addComponent(grid);
    setComponentAlignment(grid, Alignment.TOP_CENTER);
}