Example usage for com.vaadin.ui Alignment MIDDLE_CENTER

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

Introduction

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

Prototype

Alignment MIDDLE_CENTER

To view the source code for com.vaadin.ui Alignment MIDDLE_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  . ja va  2 s .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

public void appendImportMenu(CustomMenuBar.MenuItem parent, CustomMenuBar.MenuItem beforeItem) {
    final Window importWindow = new Window() {
        private static final long serialVersionUID = -397373017493034496L;

        @Override//  w  w w .ja va  2s  .  c  o m
        public void close() {
            setVisible(false);
        }
    };
    importWindow.setCaption("Import from sequence");
    importWindow.setResizable(false);

    final CanvasImport canvasImport = new CanvasImport();
    importWindow.getContent().addComponent(canvasImport);
    importWindow.center();
    importWindow.setVisible(false);

    @SuppressWarnings("unused")
    CustomMenuBar.MenuItem importMenu = parent.addItemBefore("Import", null, new CustomMenuBar.Command() {
        private static final long serialVersionUID = -6735134306275926140L;

        @Override
        public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
            if (!importWindow.isVisible()) {
                if (getWindow().getChildWindows().contains(importWindow) == false) {
                    getWindow().addWindow(importWindow);
                }

                importWindow.setVisible(true);
            }
        }
    }, beforeItem);

    importWindow.setSizeUndefined();
    importWindow.getContent().setSizeUndefined();

    final Window importFromStringWindow = new Window() {
        private static final long serialVersionUID = 7035248961169308096L;

        @Override
        public void close() {
            setVisible(false);
        }
    };

    importFromStringWindow.setCaption("Import sequence from string");
    importFromStringWindow.setWidth("400px");

    final ImportStructureFromStringDialog importStructureStringDialog = new ImportStructureFromStringDialog(
            theCanvas);

    importStructureStringDialog.addListener(new UserInputEndedListener() {
        @Override
        public void done(boolean cancelled) {
            if (!cancelled) {
                if (!theCanvas.theDoc.importFromString(importStructureStringDialog.getSequenceString(),
                        theCanvas
                                .getImportFormatShortFormat(importStructureStringDialog.getSequenceFormat()))) {
                    IGGApplication.reportMessage(LogUtils.getLastError());

                    LogUtils.clearLastError();
                }
            }
        }
    });

    WeeLayout layout = new WeeLayout(Direction.VERTICAL);
    layout.setSizeFull();
    importFromStringWindow.setContent(layout);
    layout.addComponent(importStructureStringDialog, Alignment.MIDDLE_CENTER);

    importFromStringWindow.center();
    importFromStringWindow.setVisible(false);

    @SuppressWarnings("unused")
    CustomMenuBar.MenuItem importFromStringMenu = parent.addItemBefore("Import from string", null,
            new CustomMenuBar.Command() {
                private static final long serialVersionUID = 1586089744665899803L;

                @Override
                public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
                    if (!importFromStringWindow.isVisible()) {
                        if (getWindow().getChildWindows().contains(importFromStringWindow) == false) {
                            getWindow().addWindow(importFromStringWindow);
                        }

                        importFromStringWindow.setVisible(true);
                    }
                }
            }, beforeItem);
}

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

License:Open Source License

public void appendNotationMenu(CustomMenuBar.MenuItem parent) {
    final HashMap<String, String> notationIndex = new HashMap<String, String>();

    CustomMenuBar.Command notationChangeCommand = new CustomMenuBar.Command() {
        private static final long serialVersionUID = 5081687058270283137L;

        @Override//from w  ww.ja  v a  2  s .  c o m
        public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
            String notation = notationIndex.get(selectedItem.getText());
            theCanvas.setNotation(notation);
        }
    };

    parent.addItem("CFG notation", notationChangeCommand);
    notationIndex.put("CFG notation", GraphicOptions.NOTATION_CFG);

    parent.addItem("CFG black and white notation", notationChangeCommand);
    notationIndex.put("CFG black and white notation", GraphicOptions.NOTATION_CFGBW);

    parent.addItem("CFG with linkage placement notation", notationChangeCommand);
    notationIndex.put("CFG with linkage placement notation", GraphicOptions.NOTATION_CFGLINK);

    parent.addItem("UOXF notation", notationChangeCommand);
    notationIndex.put("UOXF notation", GraphicOptions.NOTATION_UOXF);

    parent.addItem("UOXFCOL notation", notationChangeCommand);
    notationIndex.put("UOXFCOL notation", GraphicOptions.NOTATION_UOXFCOL);

    parent.addItem("Text only notation", notationChangeCommand);
    notationIndex.put("Text only notation", GraphicOptions.NOTATION_TEXT);

    parent.addItem("Show Masses", new ThemeResource("icons/uncheckedbox.png"), new CustomMenuBar.Command() {
        private static final long serialVersionUID = 6140157670134115820L;

        @Override
        public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
            //selectedItem.setIcon(arg0);

            boolean showMasses = theCanvas.theWorkspace.getGraphicOptions().SHOW_MASSES_CANVAS;

            if (showMasses) {
                theCanvas.theWorkspace.getGraphicOptions().SHOW_MASSES_CANVAS = false;
                selectedItem.setIcon(new ThemeResource("icons/uncheckedbox.png"));
            } else {
                theCanvas.theWorkspace.getGraphicOptions().SHOW_MASSES_CANVAS = true;
                selectedItem.setIcon(new ThemeResource("icons/checkbox.png"));
            }

            theCanvas.documentUpdated();
        }
    });

    parent.addItem("Show reducing end symbol", new ThemeResource("icons/uncheckedbox.png"),
            new CustomMenuBar.Command() {
                private static final long serialVersionUID = -5209359926737326181L;

                @Override
                public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
                    boolean showRedEnd = theCanvas.theWorkspace.getGraphicOptions().SHOW_REDEND_CANVAS;

                    if (showRedEnd) {
                        theCanvas.theWorkspace.getGraphicOptions().SHOW_REDEND_CANVAS = false;
                        selectedItem.setIcon(new ThemeResource("icons/uncheckedbox.png"));
                    } else {
                        theCanvas.theWorkspace.getGraphicOptions().SHOW_REDEND_CANVAS = true;
                        selectedItem.setIcon(new ThemeResource("icons/checkbox.png"));
                    }

                    theCanvas.documentUpdated();
                }
            });

    final Window massOptionsDialog = new Window() {
        private static final long serialVersionUID = -5094399884130705221L;

        @Override
        public void close() {
            setVisible(false);
        }
    };

    massOptionsDialog.setResizable(false);
    //massOptionsDialog.setIcon(new ThemeResource("icons/massoptions.png"));

    massOptionsDialog.setCaption("Mass options");

    MassOptionsDialog dialog = new MassOptionsDialog(theCanvas.theDoc.getStructures(),
            theCanvas.theWorkspace.getDefaultMassOptions());

    dialog.addMassOptionListener(this);

    massOptionsDialog.addComponent(dialog);

    ((VerticalLayout) massOptionsDialog.getContent()).setComponentAlignment(dialog, Alignment.MIDDLE_CENTER);

    massOptionsDialog.setVisible(false);

    massOptionsDialog.center();

    parent.addItem("Mass options", new CustomMenuBar.Command() {
        private static final long serialVersionUID = -589321392382766804L;

        @Override
        public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
            if (massOptionsDialog.getParent() == null) {
                getWindow().addWindow(massOptionsDialog);
            }

            massOptionsDialog.setVisible(true);
        }
    });

    massOptionsDialog.setSizeUndefined();
    massOptionsDialog.getContent().setSizeUndefined();
}

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.ja  v a  2 s . com*/
        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:ac.uk.icl.dell.vaadin.MessageDialogBox.java

License:Open Source License

public void init(String title, String message, Window parent) {
    Label messageLabel = new Label(message);

    Panel panel = new Panel();

    panel.getContent().addComponent(messageLabel);
    ((VerticalLayout) panel.getContent()).setComponentAlignment(messageLabel, Alignment.MIDDLE_CENTER);

    getContent().addComponent(panel);/*from  w  w  w  .  j  a  v a 2 s  . co m*/

    setCaption(title);

    parent.addWindow(this);

    getContent().setWidth("400px");

    center();
}

From source file:annis.gui.AboutWindow.java

License:Apache License

public AboutWindow() {
    setSizeFull();//from w  w w . j  a v a2 s  . c o  m

    layout = new VerticalLayout();
    setContent(layout);
    layout.setSizeFull();
    layout.setMargin(true);

    HorizontalLayout hLayout = new HorizontalLayout();

    Embedded logoAnnis = new Embedded();
    logoAnnis.setSource(new ThemeResource("images/annis-logo-128.png"));
    logoAnnis.setType(Embedded.TYPE_IMAGE);
    hLayout.addComponent(logoAnnis);

    Embedded logoSfb = new Embedded();
    logoSfb.setSource(new ThemeResource("images/sfb-logo.jpg"));
    logoSfb.setType(Embedded.TYPE_IMAGE);
    hLayout.addComponent(logoSfb);

    Link lnkFork = new Link();
    lnkFork.setResource(new ExternalResource("https://github.com/korpling/ANNIS"));
    lnkFork.setIcon(
            new ExternalResource("https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"));
    lnkFork.setTargetName("_blank");
    hLayout.addComponent(lnkFork);

    hLayout.setComponentAlignment(logoAnnis, Alignment.MIDDLE_LEFT);
    hLayout.setComponentAlignment(logoSfb, Alignment.MIDDLE_RIGHT);
    hLayout.setComponentAlignment(lnkFork, Alignment.TOP_RIGHT);

    layout.addComponent(hLayout);

    layout.addComponent(new Label(
            "ANNIS is a project of the " + "<a href=\"http://www.sfb632.uni-potsdam.de/\">SFB632</a>.",
            Label.CONTENT_XHTML));
    layout.addComponent(new Label("Homepage: " + "<a href=\"http://corpus-tools.org/annis/\">"
            + "http://corpus-tools.org/annis/</a>.", Label.CONTENT_XHTML));
    layout.addComponent(new Label("Version: " + VersionInfo.getVersion()));
    layout.addComponent(new Label("Vaadin-Version: " + Version.getFullVersion()));

    TextArea txtThirdParty = new TextArea();
    txtThirdParty.setSizeFull();

    StringBuilder sb = new StringBuilder();

    sb.append("The ANNIS team wants to thank these third party software that "
            + "made the ANNIS GUI possible:\n");

    File thirdPartyFolder = new File(VaadinService.getCurrent().getBaseDirectory(), "THIRD-PARTY");
    if (thirdPartyFolder.isDirectory()) {
        for (File c : thirdPartyFolder.listFiles((FileFilter) new WildcardFileFilter("*.txt"))) {
            if (c.isFile()) {
                try {
                    sb.append(FileUtils.readFileToString(c)).append("\n");
                } catch (IOException ex) {
                    log.error("Could not read file", ex);
                }
            }
        }
    }

    txtThirdParty.setValue(sb.toString());
    txtThirdParty.setReadOnly(true);
    txtThirdParty.addStyleName("shared-text");
    txtThirdParty.setWordwrap(false);

    layout.addComponent(txtThirdParty);

    btClose = new Button("Close");
    final AboutWindow finalThis = this;
    btClose.addClickListener(new OkClickListener(finalThis));
    layout.addComponent(btClose);

    layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER);
    layout.setExpandRatio(txtThirdParty, 1.0f);

}

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

License:Apache License

public CorpusAdminPanel() {
    corpusContainer.setBeanIdProperty("name");

    final Grid corporaGrid = new Grid(corpusContainer);
    corporaGrid.setSizeFull();//  w ww  . ja  v a 2  s . c  o m
    corporaGrid.setSelectionMode(Grid.SelectionMode.MULTI);
    corporaGrid.setColumns("name", "textCount", "tokenCount", "sourcePath");

    corporaGrid.getColumn("textCount").setHeaderCaption("Texts");
    corporaGrid.getColumn("tokenCount").setHeaderCaption("Tokens");
    corporaGrid.getColumn("sourcePath").setHeaderCaption("Source Path");

    Button btDelete = new Button("Delete selected");
    btDelete.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<String> selection = new TreeSet<>();
            for (Object o : corporaGrid.getSelectedRows()) {
                selection.add((String) o);
            }
            corporaGrid.getSelectionModel().reset();
            if (!selection.isEmpty()) {

                for (CorpusListView.Listener l : listeners) {
                    l.deleteCorpora(selection);
                }
            }
        }
    });

    VerticalLayout layout = new VerticalLayout(btDelete, corporaGrid);
    layout.setSizeFull();
    layout.setExpandRatio(corporaGrid, 1.0f);
    layout.setSpacing(true);
    layout.setMargin(new MarginInfo(true, false, false, false));

    layout.setComponentAlignment(btDelete, Alignment.MIDDLE_CENTER);

    setContent(layout);
    setSizeFull();
}

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);/*from   ww w  .  j a  v  a 2  s.com*/
    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   www.  j  a  va 2s . c om*/
    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.components.NavigateableSinglePage.java

License:Apache License

public NavigateableSinglePage(File localFile, URI externalURI) {
    iframe.setSizeFull();/*  w  ww  .  j a va 2  s . com*/

    setSpacing(true);

    btPrint = new Button("Print");
    btPrint.setStyleName(ValoTheme.BUTTON_LINK);
    btPrint.setEnabled(false);
    btPrint.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            iframe.printFrame();
        }
    });

    this.toolLayout = new HorizontalLayout(btPrint);
    this.toolLayout.setComponentAlignment(btPrint, Alignment.MIDDLE_CENTER);

    addComponent(toolLayout);
    addComponent(iframe);

    setExpandRatio(iframe, 1.0f);

    setSource(localFile, externalURI);
}