List of usage examples for com.vaadin.ui Button Button
public Button(Resource icon)
From source file:annis.gui.paging.PagingComponent.java
License:Apache License
public PagingComponent(int count, int pageSize) { if (pageSize <= 0) { pageSize = 1;//w ww. ja v a 2 s.c om } if (count < 0) { count = 0; } currentPage = 1; this.count = new AtomicInteger(pageSize); this.pageSize = pageSize; setWidth("100%"); setHeight("-1px"); addStyleName("toolbar"); callbacks = new HashSet<>(); layout = new HorizontalLayout(); layout.setSpacing(true); layout.setMargin(new MarginInfo(false, true, false, true)); setContent(layout); addStyleName(ChameleonTheme.PANEL_LIGHT); lblInfo = new Label(); lblInfo.setContentMode(ContentMode.HTML); lblInfo.addStyleName("right-aligned-text"); btShareQuery = new Button(FontAwesome.SHARE_ALT); btShareQuery.setDescription("Share query reference link"); btShareQuery.addStyleName(ValoTheme.BUTTON_BORDERLESS); layout.setWidth("100%"); layout.setHeight("-1px"); btFirst = new Button(); btFirst.setIcon(FIRST); btFirst.setDescription("jump to first page"); btFirst.addClickListener((Button.ClickListener) this); btFirst.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btFirst.addStyleName(ChameleonTheme.BUTTON_SMALL); btFirst.setDisableOnClick(true); btLast = new Button(); btLast.setIcon(LAST); btLast.setDescription("jump to last page"); btLast.addClickListener((Button.ClickListener) this); btLast.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btLast.addStyleName(ChameleonTheme.BUTTON_SMALL); btLast.setDisableOnClick(true); btNext = new Button(); btNext.setIcon(RIGHT_ARROW); btNext.setDescription("jump to next page"); btNext.addClickListener((Button.ClickListener) this); btNext.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btNext.addStyleName(ChameleonTheme.BUTTON_SMALL); btNext.setDisableOnClick(true); btPrevious = new Button(); btPrevious.setIcon(LEFT_ARROW); btPrevious.setDescription("jump to previous page"); btPrevious.addClickListener((Button.ClickListener) this); btPrevious.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btPrevious.addStyleName(ChameleonTheme.BUTTON_SMALL); btPrevious.setDisableOnClick(true); txtPage = new TextField(); txtPage.setDescription("current page"); txtPage.setHeight("-1px"); txtPage.setWidth(5.f, UNITS_EM); Validator pageValidator = new PageValidator("must be an integer greater than zero"); txtPage.addValidator(pageValidator); addActionHandler(new EnterHandler(txtPage)); lblMaxPages = new Label(); lblMaxPages.setDescription("maximal pages"); lblMaxPages.setSizeUndefined(); lblStatus = new Label(); lblStatus.setSizeUndefined(); layout.addComponent(btFirst); layout.addComponent(btPrevious); layout.addComponent(txtPage); layout.addComponent(lblMaxPages); layout.addComponent(btNext); layout.addComponent(btLast); layout.addComponent(lblStatus); layout.addComponent(lblInfo); layout.addComponent(btShareQuery); layout.setComponentAlignment(btFirst, Alignment.MIDDLE_LEFT); layout.setComponentAlignment(btPrevious, Alignment.MIDDLE_LEFT); layout.setComponentAlignment(lblStatus, Alignment.MIDDLE_LEFT); layout.setComponentAlignment(lblMaxPages, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(txtPage, Alignment.MIDDLE_RIGHT); layout.setComponentAlignment(btNext, Alignment.MIDDLE_RIGHT); layout.setComponentAlignment(btLast, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(lblStatus, 1.0f); layout.setComponentAlignment(lblInfo, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(lblInfo, 10.0f); update(false); }
From source file:annis.gui.resultview.VisualizerPanel.java
License:Apache License
/** * This Constructor should be used for {@link ComponentVisualizerPlugin} * Visualizer.// www.ja v a 2s . c o m * */ public VisualizerPanel(final ResolverEntry entry, SDocument result, String corpusName, String documentName, Set<String> visibleTokenAnnos, Map<String, Long> markedAndCovered, @Deprecated Map<String, String> markedAndCoveredMap, @Deprecated Map<String, String> markedExactMap, String htmlID, String resultID, SingleResultPanel parent, String segmentationName, PluginSystem ps, InstanceConfig instanceConfig) throws IOException { this.ps = ps; this.instanceConfig = instanceConfig; this.entry = entry; this.markersExact = markedExactMap; this.markersCovered = markedAndCoveredMap; this.visCtxChanger = parent; this.result = result; this.corpusName = corpusName; this.documentName = documentName; this.visibleTokenAnnos = visibleTokenAnnos; this.markedAndCovered = markedAndCovered; this.segmentationName = segmentationName; this.htmlID = htmlID; this.resultID = resultID; this.progress = new ProgressBar(); this.progress.setIndeterminate(true); this.progress.setVisible(false); this.progress.setEnabled(false); this.addStyleName(ChameleonTheme.PANEL_BORDERLESS); this.setWidth("100%"); if (entry != null && ps != null) { visPlugin = ps.getVisualizer(entry.getVisType()); if (visPlugin == null) { // fallback to default visualizer if original vis type was not found entry.setVisType(PluginSystem.DEFAULT_VISUALIZER); visPlugin = ps.getVisualizer(entry.getVisType()); } if (HIDDEN.equalsIgnoreCase(entry.getVisibility())) { // build button for visualizer btEntry = new Button(entry.getDisplayName()); btEntry.setIcon(ICON_EXPAND); btEntry.setStyleName(ChameleonTheme.BUTTON_BORDERLESS + " " + ChameleonTheme.BUTTON_SMALL); btEntry.addClickListener((Button.ClickListener) this); btEntry.setDisableOnClick(true); addComponent(btEntry); addComponent(progress); } else { if (ISVISIBLE.equalsIgnoreCase(entry.getVisibility()) || PRELOADED.equalsIgnoreCase(entry.getVisibility())) { // build button for visualizer btEntry = new Button(entry.getDisplayName()); btEntry.setIcon(ICON_COLLAPSE); btEntry.setStyleName(ChameleonTheme.BUTTON_BORDERLESS + " " + ChameleonTheme.BUTTON_SMALL); btEntry.addClickListener((Button.ClickListener) this); addComponent(btEntry); } addComponent(progress); // create the visualizer and calc input try { vis = createComponent(); if (vis != null) { vis.setVisible(true); addComponent(vis); } } catch (Exception ex) { Notification.show("Could not create visualizer " + visPlugin.getShortName(), ex.toString(), Notification.Type.TRAY_NOTIFICATION); log.error("Could not create visualizer " + visPlugin.getShortName(), ex); } if (btEntry != null && PRELOADED.equalsIgnoreCase(entry.getVisibility())) { btEntry.setIcon(ICON_EXPAND); if (vis != null) { vis.setVisible(false); } } } } // end if entry not null }
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);// www . ja v a 2s. 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.gui.ShareQueryReferenceWindow.java
License:Apache License
public ShareQueryReferenceWindow(DisplayedResultQuery query, boolean shorten) { super("Query reference link"); VerticalLayout wLayout = new VerticalLayout(); setContent(wLayout);//from w w w. ja va 2s .co m wLayout.setSizeFull(); wLayout.setMargin(true); Label lblInfo = new Label( "<p style=\"font-size: 18px\" >" + "<strong>Share your query:</strong> " + "1. Copy the generated link 2. Share this link with your peers. " + "</p>", ContentMode.HTML); wLayout.addComponent(lblInfo); wLayout.setExpandRatio(lblInfo, 0.0f); String shortURL = "ERROR"; if (query != null) { URI url = Helper.generateCitation(query.getQuery(), query.getCorpora(), query.getLeftContext(), query.getRightContext(), query.getSegmentation(), query.getBaseText(), query.getOffset(), query.getLimit(), query.getOrder(), query.getSelectedMatches()); if (shorten) { shortURL = Helper.shortenURL(url); } else { shortURL = url.toASCIIString(); } } TextArea txtCitation = new TextArea(); txtCitation.setWidth("100%"); txtCitation.setHeight("100%"); txtCitation.addStyleName(ValoTheme.TEXTFIELD_LARGE); txtCitation.addStyleName("shared-text"); txtCitation.setValue(shortURL); txtCitation.setWordwrap(true); txtCitation.setReadOnly(true); wLayout.addComponent(txtCitation); Button btClose = new Button("Close"); btClose.addClickListener((Button.ClickListener) this); btClose.setSizeUndefined(); wLayout.addComponent(btClose); wLayout.setExpandRatio(txtCitation, 1.0f); wLayout.setComponentAlignment(btClose, Alignment.BOTTOM_CENTER); setWidth("400px"); setHeight("300px"); }
From source file:annis.gui.ShareSingleMatchGenerator.java
License:Apache License
public ShareSingleMatchGenerator(List<ResolverEntry> visualizers, Match match, PagedResultQuery query, String segmentation, PluginSystem ps) { this.match = match; this.query = query; this.segmentation = segmentation; this.ps = ps; setResizeLazy(true);//w ww .j av a 2 s.c o m directURL = new ObjectProperty<>(""); iframeCode = new ObjectProperty<>(""); visContainer = new BeanItemContainer<>(ResolverEntry.class); visContainer.addAll(visualizers); txtDirectURL = new TextArea(directURL); txtDirectURL.setCaption("Link for publications"); txtDirectURL.setWidth("100%"); txtDirectURL.setHeight("-1px"); txtDirectURL.addStyleName(ValoTheme.TEXTFIELD_LARGE); txtDirectURL.addStyleName("shared-text"); txtDirectURL.setWordwrap(true); txtDirectURL.setReadOnly(true); txtIFrameCode = new TextArea(iframeCode); txtIFrameCode.setCaption("Code for embedding visualization into web page"); txtIFrameCode.setWidth("100%"); txtIFrameCode.setHeight("-1px"); txtIFrameCode.addStyleName(ValoTheme.TEXTFIELD_LARGE); txtIFrameCode.addStyleName("shared-text"); txtIFrameCode.setWordwrap(true); txtIFrameCode.setReadOnly(true); preview = new BrowserFrame(); preview.setCaption("Preview"); preview.addStyleName("shared-text"); preview.setSizeFull(); generatedLinks = new VerticalLayout(txtDirectURL, txtIFrameCode, preview); generatedLinks.setComponentAlignment(txtDirectURL, Alignment.TOP_LEFT); generatedLinks.setComponentAlignment(txtIFrameCode, Alignment.TOP_LEFT); generatedLinks.setExpandRatio(preview, 1.0f); visSelector = new Grid(visContainer); visSelector.setCaption("Select visualization"); visSelector.setHeight("100%"); visSelector.setColumns("displayName"); visSelector.setSelectionMode(Grid.SelectionMode.SINGLE); visSelector.addSelectionListener(ShareSingleMatchGenerator.this); visSelector.select(visContainer.getIdByIndex(0)); visSelector.setWidth("300px"); visSelector.getColumn("displayName").setSortable(false); generatedLinks.setSizeFull(); Label infoText = new Label( "<p style=\"font-size: 18px\" >" + "<strong>Share your match:</strong> " + "1. Choose the visualization to share. 2. Copy the generated link or code. " + "3. Share this link with your peers or include the code in your website. " + "</p>", ContentMode.HTML); HorizontalLayout hLayout = new HorizontalLayout(visSelector, generatedLinks); hLayout.setSizeFull(); hLayout.setSpacing(true); hLayout.setExpandRatio(generatedLinks, 1.0f); Button btClose = new Button("Close"); btClose.setSizeUndefined(); btClose.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { getUI().removeWindow(ShareSingleMatchGenerator.this); } }); layout = new VerticalLayout(infoText, hLayout, btClose); layout.setSizeFull(); layout.setExpandRatio(hLayout, 1.0f); layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER); setContent(layout); }
From source file:app.MyVaadinApplication.java
License:Apache License
@Override public void init() { window = new Window("My Vaadin Application"); setMainWindow(window);/* w w w .j a v a2s . com*/ Button button = new Button("Click Me"); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { window.addComponent(new Label("Thank you for clicking")); } }); window.addComponent(button); }
From source file:at.jku.ce.adaptivetesting.vaadin.ui.MainUI.java
License:LGPL
public MainUI() { // Make the web-app large setSizeFull();/*from w ww . j av a2s . c o m*/ // Set the layout for the bottom // Create a 3rd party licence button with a click listener final Button licences = new Button("Lizenzen"); licences.addClickListener(new ClickListener() { private static final long serialVersionUID = 32642854872179636L; @Override public void buttonClick(ClickEvent event) { LogHelper.logInfo("Opened LicenceWindow"); LicenceWindow licenceWindow = new LicenceWindow(); licenceWindow.addCloseListener(new CloseListener() { private static final long serialVersionUID = 7874342882437355680L; @Override public void windowClose(CloseEvent e) { event.getButton().setEnabled(true); } }); getUI().addWindow(licenceWindow); // Disable sender event.getButton().setEnabled(false); } }); Label copyright = new HtmlLabel( "<i> Reisisoft & JKU 2014 - " + new GregorianCalendar().get(Calendar.YEAR) + "</i>"); /* Button openLog = new Button("Open Log", (ClickListener) event -> { Navigator navigator = getUI().getNavigator(); assert navigator != null; navigator.navigateTo(Views.Log.toString()); });*/ // Add the flowLayout at position 1 (second element) -> centered // Add everthing to flowlayout GridLayout southLayout = new GridLayout(3, 1); southLayout.setWidth("100%"); southLayout.addComponent(licences, 0, 0); // southLayout.addComponent(openLog, 1, 0); southLayout.addComponent(copyright, 2, 0); // Add southlayout to the main Layout addComponent(southLayout); setComponentAlignment(southLayout, Alignment.BOTTOM_CENTER); }
From source file:at.jku.ce.adaptivetesting.vaadin.ui.MockQuestion.java
License:LGPL
public MockQuestion(Question question) { this.question = question; TextArea textArea = new TextArea("Question text"); textArea.setSizeFull();/*from ww w .ja v a2 s.c o m*/ // Download the result Button button = new Button("Display current user's solution"); button.setSizeFull(); button.addClickListener(e -> { Window window = new Window("Current user solution"); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); window.setContent(layout); // Update questionText textArea.addTextChangeListener(ev -> questionText = ev.getText()); textArea.setTextChangeEventMode(TextChangeEventMode.EAGER); Label label; try { label = new Label(toXML()); } catch (Exception e1) { label = new Label( "<h1>Error parsing XML</h1><p>" + e1.getMessage() + Arrays.toString(e1.getStackTrace()), ContentMode.HTML); LogHelper.logThrowable(e1); } layout.addComponent(label); window.center(); getUI().addWindow(window); }); // Add components to the UI addComponent(textArea); addComponent(question); addComponent(button); }
From source file:at.jku.ce.adaptivetesting.vaadin.ui.QuestionManager.java
License:LGPL
public QuestionManager(String quizName, IEngine engine) { setMargin(true);// ww w .j av a 2 s. c o m questionNo = 0; title = HtmlLabel.getCenteredLabel("h1", quizName); addComponent(title); addComponent(questionHolder); addComponent(southLayout); next = new Button("Nchste Frage"); next.addClickListener(e -> { e.getButton().setEnabled(false); try { iEngine.requestCalculation(); } catch (EngineException e1) { Notification.show("Die nchste Frage konnte nicht ausgewhlt werden.", "Bitte wende dich an den Lehrenden.", Type.ERROR_MESSAGE); LogHelper.logThrowable(e1); } }); southLayout.addComponent(next, 2, 0); southLayout.setSizeFull(); southLayout.setMargin(true); // Ensure we have an engine if (engine == null) { try { iEngine = new SimpleEngine(); } catch (EngineException e1) { Notification.show("Test-System konnte nicht gestartet werden", "Bitte wende dich an den Lehrenden.", Type.ERROR_MESSAGE); LogHelper.logThrowable(e1); } } else { iEngine = engine; } // Register to engine events iEngine.addQuestionChangeListener(this); iEngine.addResultFiredListener(this); setResultView(VaadinResultView.class); }
From source file:at.jku.ce.adaptivetesting.vaadin.ui.topic.accounting.AccountingQuestionManager.java
License:LGPL
public AccountingQuestionManager(String quizName) { super(quizName); Button openKontenplan = new Button("Kontenplan ffnen"); openKontenplan.addClickListener(e -> { openKontenplan.setEnabled(false); // Create Window with layout Window window = new Window("Kontenplan"); GridLayout layout = new GridLayout(1, 1); layout.addComponent(AccountingDataProvider.getInstance().toHtmlTable()); layout.setSizeFull();//w ww . j a va 2 s . c o m window.setContent(layout); window.center(); window.setWidth("60%"); window.setHeight("80%"); window.setResizable(false); window.addCloseListener(e1 -> openKontenplan.setEnabled(true)); getUI().addWindow(window); }); addHelpButton(openKontenplan); }