List of usage examples for com.vaadin.ui Button addStyleName
@Override public void addStyleName(String style)
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 w w w . ja 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);/*ww w. j a va2 s.com*/ 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.CitationLinkGenerator.java
License:Apache License
@Override public Object generateCell(Table source, Object itemId, Object columnId) { Button btLink = new Button(); btLink.addStyleName(ValoTheme.BUTTON_BORDERLESS); btLink.setIcon(FontAwesome.SHARE_ALT); btLink.setDescription("Share query reference link"); btLink.addClickListener(this); if (itemId instanceof DisplayedResultQuery) { btLink.addClickListener(new LinkClickListener((DisplayedResultQuery) itemId)); } else if (itemId instanceof Query) { final CitationProvider citationProvider = new CitationProviderForQuery((Query) itemId); btLink.addClickListener(new LinkClickListener(citationProvider)); } else if (itemId instanceof CitationProvider) { final CitationProvider citationProvider = (CitationProvider) itemId; btLink.addClickListener(new LinkClickListener(citationProvider)); }/*from w w w . j a v a 2s .c o m*/ return btLink; }
From source file:annis.gui.components.HelpButton.java
License:Apache License
public HelpButton(Field<T> field) { Validate.notNull(field);/* w ww . j a v a 2 s .com*/ this.field = field; CssLayout layout = new CssLayout(); setCompositionRoot(layout); Button btHelp = new Button(""); btHelp.setIcon(FontAwesome.QUESTION); btHelp.addStyleName(ChameleonTheme.BUTTON_BORDERLESS); btHelp.addStyleName("helpbutton"); btHelp.addClickListener((Button.ClickListener) this); setCaption(field.getCaption()); field.setCaption(null); layout.addComponent(field); layout.addComponent(btHelp); }
From source file:annis.gui.controlpanel.CorpusListPanel.java
License:Apache License
public CorpusListPanel(InstanceConfig instanceConfig, ExampleQueriesPanel autoGenQueries, final AnnisUI ui) { this.instanceConfig = instanceConfig; this.autoGenQueries = autoGenQueries; this.ui = ui; final CorpusListPanel finalThis = this; setSizeFull();//from ww w .j a v a 2s . c o m selectionLayout = new HorizontalLayout(); selectionLayout.setWidth("100%"); selectionLayout.setHeight("-1px"); selectionLayout.setVisible(false); Label lblVisible = new Label("Visible: "); lblVisible.setSizeUndefined(); selectionLayout.addComponent(lblVisible); cbSelection = new ComboBox(); cbSelection.setDescription("Choose corpus selection set"); cbSelection.setWidth("100%"); cbSelection.setHeight("-1px"); cbSelection.addStyleName(ValoTheme.COMBOBOX_SMALL); cbSelection.setInputPrompt("Add new corpus selection set"); cbSelection.setNullSelectionAllowed(false); cbSelection.setNewItemsAllowed(true); cbSelection.setNewItemHandler((AbstractSelect.NewItemHandler) this); cbSelection.setImmediate(true); cbSelection.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateCorpusTable(); updateAutoGeneratedQueriesPanel(); } }); selectionLayout.addComponent(cbSelection); selectionLayout.setExpandRatio(cbSelection, 1.0f); selectionLayout.setSpacing(true); selectionLayout.setComponentAlignment(cbSelection, Alignment.MIDDLE_RIGHT); selectionLayout.setComponentAlignment(lblVisible, Alignment.MIDDLE_LEFT); addComponent(selectionLayout); txtFilter = new TextField(); txtFilter.setVisible(false); txtFilter.setInputPrompt("Filter"); txtFilter.setImmediate(true); txtFilter.setTextChangeTimeout(500); txtFilter.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { BeanContainer<String, AnnisCorpus> availableCorpora = ui.getQueryState().getAvailableCorpora(); if (textFilter != null) { // remove the old filter availableCorpora.removeContainerFilter(textFilter); textFilter = null; } if (event.getText() != null && !event.getText().isEmpty()) { Set<String> selectedIDs = ui.getQueryState().getSelectedCorpora().getValue(); textFilter = new SimpleStringFilter("name", event.getText(), true, false); availableCorpora.addContainerFilter(textFilter); // select the first item List<String> filteredIDs = availableCorpora.getItemIds(); Set<String> selectedAndFiltered = new HashSet<>(selectedIDs); selectedAndFiltered.retainAll(filteredIDs); Set<String> selectedAndOutsideFilter = new HashSet<>(selectedIDs); selectedAndOutsideFilter.removeAll(filteredIDs); for (String id : selectedAndOutsideFilter) { tblCorpora.unselect(id); } if (selectedAndFiltered.isEmpty() && !filteredIDs.isEmpty()) { for (String id : selectedIDs) { tblCorpora.unselect(id); } tblCorpora.select(filteredIDs.get(0)); } } } }); txtFilter.setWidth("100%"); txtFilter.setHeight("-1px"); txtFilter.addStyleName(ValoTheme.TEXTFIELD_SMALL); addComponent(txtFilter); pbLoadCorpora = new ProgressBar(); pbLoadCorpora.setCaption("Loading corpus list..."); pbLoadCorpora.setIndeterminate(true); addComponent(pbLoadCorpora); tblCorpora = new Table(); addComponent(tblCorpora); tblCorpora.setVisible(false); // don't show list before it was not loaded tblCorpora.setContainerDataSource(ui.getQueryState().getAvailableCorpora()); tblCorpora.setMultiSelect(true); tblCorpora.setPropertyDataSource(ui.getQueryState().getSelectedCorpora()); tblCorpora.addGeneratedColumn("info", new InfoGenerator()); tblCorpora.addGeneratedColumn("docs", new DocLinkGenerator()); tblCorpora.setVisibleColumns("name", "textCount", "tokenCount", "info", "docs"); tblCorpora.setColumnHeaders("Name", "Texts", "Tokens", "", ""); tblCorpora.setHeight("100%"); tblCorpora.setWidth("100%"); tblCorpora.setSelectable(true); tblCorpora.setNullSelectionAllowed(false); tblCorpora.setColumnExpandRatio("name", 0.6f); tblCorpora.setColumnExpandRatio("textCount", 0.15f); tblCorpora.setColumnExpandRatio("tokenCount", 0.25f); tblCorpora.addStyleName(ValoTheme.TABLE_SMALL); tblCorpora.addActionHandler((Action.Handler) this); tblCorpora.setImmediate(true); tblCorpora.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { Set selections = (Set) tblCorpora.getValue(); if (selections.size() == 1 && event.isCtrlKey() && tblCorpora.isSelected(event.getItemId())) { tblCorpora.setValue(null); } } }); tblCorpora.setItemDescriptionGenerator(new TooltipGenerator()); tblCorpora.addValueChangeListener(new CorpusTableChangedListener(finalThis)); Button btReload = new Button(); btReload.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { updateCorpusSetList(false, false); Notification.show("Reloaded corpus list", Notification.Type.HUMANIZED_MESSAGE); } }); btReload.setIcon(FontAwesome.REFRESH); btReload.setDescription("Reload corpus list"); btReload.addStyleName(ValoTheme.BUTTON_ICON_ONLY); selectionLayout.addComponent(btReload); selectionLayout.setComponentAlignment(btReload, Alignment.MIDDLE_RIGHT); tblCorpora.setSortContainerPropertyId("name"); setExpandRatio(tblCorpora, 1.0f); updateCorpusSetList(true, true); }
From source file:annis.gui.controlpanel.QueryPanel.java
License:Apache License
public QueryPanel(final AnnisUI ui) { super(4, 5);//from w w w.j a va2 s .co m this.ui = ui; this.lastPublicStatus = "Welcome to ANNIS! " + "A tutorial is available on the right side."; this.state = ui.getQueryState(); setSpacing(true); setMargin(false); setRowExpandRatio(0, 1.0f); setColumnExpandRatio(0, 0.0f); setColumnExpandRatio(1, 0.1f); setColumnExpandRatio(2, 0.0f); setColumnExpandRatio(3, 0.0f); txtQuery = new AqlCodeEditor(); txtQuery.setPropertyDataSource(state.getAql()); txtQuery.setInputPrompt("Please enter AQL query"); txtQuery.addStyleName("query"); if (ui.getInstanceFont() == null) { txtQuery.addStyleName("default-query-font"); txtQuery.setTextareaStyle("default-query-font"); } else { txtQuery.addStyleName(Helper.CORPUS_FONT); txtQuery.setTextareaStyle(Helper.CORPUS_FONT); } txtQuery.addStyleName("keyboardInput"); txtQuery.setWidth("100%"); txtQuery.setHeight(15f, Unit.EM); txtQuery.setTextChangeTimeout(500); final VirtualKeyboardCodeEditor virtualKeyboard; if (ui.getInstanceConfig().getKeyboardLayout() == null) { virtualKeyboard = null; } else { virtualKeyboard = new VirtualKeyboardCodeEditor(); virtualKeyboard.setKeyboardLayout(ui.getInstanceConfig().getKeyboardLayout()); virtualKeyboard.extend(txtQuery); } txtStatus = new TextArea(); txtStatus.setValue(this.lastPublicStatus); txtStatus.setWidth("100%"); txtStatus.setHeight(4.0f, Unit.EM); txtStatus.addStyleName("border-layout"); txtStatus.setReadOnly(true); piCount = new ProgressBar(); piCount.setIndeterminate(true); piCount.setEnabled(false); piCount.setVisible(false); btShowResult = new Button("Search"); btShowResult.setIcon(FontAwesome.SEARCH); btShowResult.setWidth("100%"); btShowResult.addClickListener(new ShowResultClickListener()); btShowResult.setDescription("<strong>Show Result</strong><br />Ctrl + Enter"); btShowResult.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL); btShowResult.setDisableOnClick(true); VerticalLayout historyListLayout = new VerticalLayout(); historyListLayout.setSizeUndefined(); lstHistory = new ListSelect(); lstHistory.setWidth("200px"); lstHistory.setNullSelectionAllowed(false); lstHistory.setValue(null); lstHistory.addValueChangeListener((ValueChangeListener) this); lstHistory.setImmediate(true); lstHistory.setContainerDataSource(historyContainer); lstHistory.setItemCaptionPropertyId("query"); lstHistory.addStyleName(Helper.CORPUS_FONT); Button btShowMoreHistory = new Button("Show more details", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (historyWindow == null) { historyWindow = new Window("History"); historyWindow.setModal(false); historyWindow.setWidth("400px"); historyWindow.setHeight("250px"); } historyWindow.setContent(new HistoryPanel(state.getHistory(), ui.getQueryController())); if (UI.getCurrent().getWindows().contains(historyWindow)) { historyWindow.bringToFront(); } else { UI.getCurrent().addWindow(historyWindow); } } }); btShowMoreHistory.setWidth("100%"); historyListLayout.addComponent(lstHistory); historyListLayout.addComponent(btShowMoreHistory); historyListLayout.setExpandRatio(lstHistory, 1.0f); historyListLayout.setExpandRatio(btShowMoreHistory, 0.0f); btHistory = new PopupButton("History"); btHistory.setContent(historyListLayout); btHistory.setDescription("<strong>Show History</strong><br />" + "Either use the short overview (arrow down) or click on the button " + "for the extended view."); Button btShowKeyboard = null; if (virtualKeyboard != null) { btShowKeyboard = new Button(); btShowKeyboard.setWidth("100%"); btShowKeyboard.setDescription("Click to show a virtual keyboard"); btShowKeyboard.addStyleName(ValoTheme.BUTTON_ICON_ONLY); btShowKeyboard.addStyleName(ValoTheme.BUTTON_SMALL); btShowKeyboard.setIcon(new ClassResource(VirtualKeyboardCodeEditor.class, "keyboard.png")); btShowKeyboard.addClickListener(new ShowKeyboardClickListener(virtualKeyboard)); } Button btShowQueryBuilder = new Button("Query<br />Builder"); btShowQueryBuilder.setHtmlContentAllowed(true); btShowQueryBuilder.addStyleName(ValoTheme.BUTTON_SMALL); btShowQueryBuilder.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); btShowQueryBuilder.setIcon(new ThemeResource("images/tango-icons/32x32/document-properties.png")); btShowQueryBuilder.addClickListener(new ShowQueryBuilderClickListener(ui)); VerticalLayout moreActionsLayout = new VerticalLayout(); moreActionsLayout.setWidth("250px"); btMoreActions = new PopupButton("More"); btMoreActions.setContent(moreActionsLayout); // btShowResultNewTab = new Button("Search (open in new tab)"); // btShowResultNewTab.setWidth("100%"); // btShowResultNewTab.addClickListener(new ShowResultInNewTabClickListener()); // btShowResultNewTab.setDescription("<strong>Show Result and open result in new tab</strong><br />Ctrl + Shift + Enter"); // btShowResultNewTab.setDisableOnClick(true); // btShowResultNewTab.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL, ModifierKey.SHIFT); // moreActionsLayout.addComponent(btShowResultNewTab); Button btShowExport = new Button("Export", new ShowExportClickListener(ui)); btShowExport.setIcon(FontAwesome.DOWNLOAD); btShowExport.setWidth("100%"); moreActionsLayout.addComponent(btShowExport); Button btShowFrequency = new Button("Frequency Analysis", new ShowFrequencyClickListener(ui)); btShowFrequency.setIcon(FontAwesome.BAR_CHART_O); btShowFrequency.setWidth("100%"); moreActionsLayout.addComponent(btShowFrequency); /* * We use the grid layout for a better rendering efficiency, but this comes * with the cost of some complexity when defining the positions of the * elements in the layout. * * This grid hopefully helps a little bit in understanding the "magic" * numbers better. * * Q: Query text field * QB: Button to toggle query builder // TODO * KEY: Button to show virtual keyboard * SEA: "Search" button * MOR: "More actions" button * HIST: "History" button * STAT: Text field with the real status * PROG: indefinite progress bar (spinning circle) * * \ 0 | 1 | 2 | 3 * --+-----+---+---+---+----- * 0 | Q | Q | Q | QB * --+-----+-----+-----+----- * 1 | Q | Q | Q | KEY * --+-----+-----+-----+----- * 2 | SEA | MOR | HIST| * --+-----+-----+-----+----- * 3 | STAT| STAT| STAT| PROG */ addComponent(txtQuery, 0, 0, 2, 1); addComponent(txtStatus, 0, 3, 2, 3); addComponent(btShowResult, 0, 2); addComponent(btMoreActions, 1, 2); addComponent(btHistory, 2, 2); addComponent(piCount, 3, 3); addComponent(btShowQueryBuilder, 3, 0); if (btShowKeyboard != null) { addComponent(btShowKeyboard, 3, 1); } // alignment setRowExpandRatio(0, 0.0f); setRowExpandRatio(1, 1.0f); setColumnExpandRatio(0, 1.0f); setColumnExpandRatio(1, 0.0f); setColumnExpandRatio(2, 0.0f); setColumnExpandRatio(3, 0.0f); //setComponentAlignment(btShowQueryBuilder, Alignment.BOTTOM_CENTER); }
From source file:annis.gui.ReportBugWindow.java
License:Apache License
private void addScreenshotPreview(Layout layout, final byte[] rawImage, String mimeType) { StreamResource res = new StreamResource(new ScreenDumpStreamSource(rawImage), "screendump_" + UUID.randomUUID().toString() + ".png"); res.setMIMEType(mimeType);//from w w w . j a v a 2 s . c o m final Image imgScreenshot = new Image("Attached screenshot", res); imgScreenshot.setAlternateText( "Screenshot of the ANNIS browser window, " + "no other window or part of the desktop is captured."); imgScreenshot.setVisible(false); imgScreenshot.setWidth("100%"); Button btShowScreenshot = new Button("Show attached screenshot", new ShowScreenshotClickListener(imgScreenshot)); btShowScreenshot.addStyleName(BaseTheme.BUTTON_LINK); btShowScreenshot.setIcon(FontAwesome.PLUS_SQUARE_O); layout.addComponent(btShowScreenshot); layout.addComponent(imgScreenshot); }
From source file:annis.gui.SearchUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { super.init(request); this.instanceConfig = getInstanceConfig(request); getPage().setTitle(instanceConfig.getInstanceDisplayName() + " (ANNIS Corpus Search)"); queryController = new QueryController(this); refresh = new Refresher(); // deactivate refresher by default refresh.setRefreshInterval(-1);//from ww w . j a v a2 s . c om refresh.addListener(queryController); addExtension(refresh); // always get the resize events directly setImmediate(true); VerticalLayout mainLayout = new VerticalLayout(); setContent(mainLayout); mainLayout.setSizeFull(); mainLayout.setMargin(false); final ScreenshotMaker screenshot = new ScreenshotMaker(this); addExtension(screenshot); css = new CSSInject(this); HorizontalLayout layoutToolbar = new HorizontalLayout(); layoutToolbar.setWidth("100%"); layoutToolbar.setHeight("-1px"); mainLayout.addComponent(layoutToolbar); layoutToolbar.addStyleName("toolbar"); layoutToolbar.addStyleName("border-layout"); Button btAboutAnnis = new Button("About ANNIS"); btAboutAnnis.addStyleName(ChameleonTheme.BUTTON_SMALL); btAboutAnnis.setIcon(new ThemeResource("info.gif")); btAboutAnnis.addClickListener(new AboutClickListener()); btBugReport = new Button("Report Bug"); btBugReport.addStyleName(ChameleonTheme.BUTTON_SMALL); btBugReport.setDisableOnClick(true); btBugReport.setIcon(new ThemeResource("../runo/icons/16/email.png")); btBugReport.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { screenshot.makeScreenshot(); btBugReport.setCaption("bug report is initialized..."); } }); String bugmail = (String) VaadinSession.getCurrent().getAttribute("bug-e-mail"); if (bugmail != null && !bugmail.isEmpty() && !bugmail.startsWith("${") && new EmailValidator("").isValid(bugmail)) { this.bugEMailAddress = bugmail; } btBugReport.setVisible(this.bugEMailAddress != null); lblUserName = new Label("not logged in"); lblUserName.setWidth("-1px"); lblUserName.setHeight("-1px"); lblUserName.addStyleName("right-aligned-text"); btLoginLogout = new Button("Login", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (isLoggedIn()) { // logout Helper.setUser(null); Notification.show("Logged out", Notification.Type.TRAY_NOTIFICATION); updateUserInformation(); } else { showLoginWindow(); } } }); btLoginLogout.setSizeUndefined(); btLoginLogout.setStyleName(ChameleonTheme.BUTTON_SMALL); btLoginLogout.setIcon(new ThemeResource("../runo/icons/16/user.png")); Button btOpenSource = new Button("Help us to make ANNIS better!"); btOpenSource.setStyleName(BaseTheme.BUTTON_LINK); btOpenSource.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Window w = new HelpUsWindow(); w.setCaption("Help us to make ANNIS better!"); w.setModal(true); w.setResizable(true); w.setWidth("600px"); w.setHeight("500px"); addWindow(w); w.center(); } }); layoutToolbar.addComponent(btAboutAnnis); layoutToolbar.addComponent(btBugReport); layoutToolbar.addComponent(btOpenSource); layoutToolbar.addComponent(lblUserName); layoutToolbar.addComponent(btLoginLogout); layoutToolbar.setSpacing(true); layoutToolbar.setComponentAlignment(btAboutAnnis, Alignment.MIDDLE_LEFT); layoutToolbar.setComponentAlignment(btBugReport, Alignment.MIDDLE_LEFT); layoutToolbar.setComponentAlignment(btOpenSource, Alignment.MIDDLE_CENTER); layoutToolbar.setComponentAlignment(lblUserName, Alignment.MIDDLE_RIGHT); layoutToolbar.setComponentAlignment(btLoginLogout, Alignment.MIDDLE_RIGHT); layoutToolbar.setExpandRatio(btOpenSource, 1.0f); //HorizontalLayout hLayout = new HorizontalLayout(); final HorizontalSplitPanel hSplit = new HorizontalSplitPanel(); hSplit.setSizeFull(); mainLayout.addComponent(hSplit); mainLayout.setExpandRatio(hSplit, 1.0f); AutoGeneratedQueries autoGenQueries = new AutoGeneratedQueries("example queries", this); controlPanel = new ControlPanel(queryController, instanceConfig, autoGenQueries); controlPanel.setWidth(100f, Layout.Unit.PERCENTAGE); controlPanel.setHeight(100f, Layout.Unit.PERCENTAGE); hSplit.setFirstComponent(controlPanel); tutorial = new TutorialPanel(); tutorial.setHeight("99%"); mainTab = new TabSheet(); mainTab.setSizeFull(); mainTab.addTab(autoGenQueries, "example queries"); mainTab.addTab(tutorial, "Tutorial"); queryBuilder = new QueryBuilderChooser(queryController, this, instanceConfig); mainTab.addTab(queryBuilder, "Query Builder"); hSplit.setSecondComponent(mainTab); hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS); hSplit.addSplitterClickListener(new AbstractSplitPanel.SplitterClickListener() { @Override public void splitterClick(AbstractSplitPanel.SplitterClickEvent event) { if (event.isDoubleClick()) { if (hSplit.getSplitPosition() == CONTROL_PANEL_WIDTH) { // make small hSplit.setSplitPosition(0.0f, Unit.PIXELS); } else { // reset to default width hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS); } } } }); // hLayout.setExpandRatio(mainTab, 1.0f); addAction(new ShortcutListener("^Query builder") { @Override public void handleAction(Object sender, Object target) { mainTab.setSelectedTab(queryBuilder); } }); addAction(new ShortcutListener("Tutor^eial") { @Override public void handleAction(Object sender, Object target) { mainTab.setSelectedTab(tutorial); } }); getPage().addUriFragmentChangedListener(this); getSession().addRequestHandler(new RequestHandler() { @Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { checkCitation(request); if (request.getPathInfo() != null && request.getPathInfo().startsWith("/vis-iframe-res/")) { String uuidString = StringUtils.removeStart(request.getPathInfo(), "/vis-iframe-res/"); UUID uuid = UUID.fromString(uuidString); IFrameResourceMap map = VaadinSession.getCurrent().getAttribute(IFrameResourceMap.class); if (map == null) { response.setStatus(404); } else { IFrameResource res = map.get(uuid); if (res != null) { response.setStatus(200); response.setContentType(res.getMimeType()); response.getOutputStream().write(res.getData()); } } return true; } return false; } }); getSession().setAttribute(MediaController.class, new MediaControllerImpl()); getSession().setAttribute(PDFController.class, new PDFControllerImpl()); loadInstanceFonts(); checkCitation(request); lastQueriedFragment = ""; evaluateFragment(getPage().getUriFragment()); updateUserInformation(); }
From source file:annis.visualizers.component.rst.RSTPanel.java
License:Apache License
RSTPanel(VisualizerInput visInput) { String btWidth = "30px"; HorizontalLayout grid = new HorizontalLayout(); final int scrollStep = 200; // the calculation of the output json is done here. final RSTImpl rstView = new RSTImpl(visInput); rstView.setId(UUID.randomUUID().toString()); this.setHeight("-1px"); this.setWidth("100%"); grid.setHeight("-1px"); grid.setWidth("100%"); final Button buttonLeft = new Button(); buttonLeft.setWidth(btWidth);/*from w ww .ja va 2 s. co m*/ buttonLeft.setHeight("100%"); buttonLeft.addStyleName("left-button"); buttonLeft.setEnabled(false); final Button buttonRight = new Button(); buttonRight.setWidth(btWidth); buttonRight.setHeight("100%"); buttonRight.addStyleName("right-button"); buttonLeft.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (rstView.getScrollLeft() < scrollStep) { buttonLeft.setEnabled(false); rstView.setScrollLeft(0); } else { //if the right button was deactivated set it back rstView.setScrollLeft(rstView.getScrollLeft() - scrollStep); } buttonRight.setEnabled(true); } }); buttonRight.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { renderInfo.calculate("#" + rstView.getId() + " canvas"); } }); renderInfo = new CssRenderInfo(new CssRenderInfo.Callback() { @Override public void renderInfoReceived(int width, int height) { if (width - rstView.getScrollLeft() > scrollStep) { buttonLeft.setEnabled(true); rstView.setScrollLeft(rstView.getScrollLeft() + scrollStep); } else { rstView.setScrollLeft(rstView.getScrollLeft() - (width - rstView.getScrollLeft())); buttonLeft.setEnabled(true); buttonRight.setEnabled(false); } } }); rstView.addExtension(renderInfo); grid.addComponent(buttonLeft); grid.addComponent(rstView); grid.addComponent(buttonRight); setContent(grid); grid.setExpandRatio(rstView, 1.0f); }
From source file:at.peppol.webgui.app.LoginWindow.java
License:Mozilla Public License
private void init() { HorizontalLayout h1 = new HorizontalLayout(); h1.setSizeFull();// w ww . j a v a 2 s. c o m FormLayout fl = new FormLayout(); fl.setSizeUndefined(); usernameField = new TextField("Username:"); usernameField.setImmediate(true); fl.addComponent(usernameField); passwordField = new PasswordField("Password:"); passwordField.setImmediate(true); fl.addComponent(passwordField); Button loginButton = new Button("Login"); loginButton.addStyleName("default"); loginButton.addListener(this); fl.addComponent(loginButton); loginButton.setClickShortcut(KeyCode.ENTER); h1.addComponent(fl); h1.setComponentAlignment(fl, Alignment.MIDDLE_CENTER); addComponent(h1); }