List of usage examples for com.vaadin.ui Window center
public void 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//ww w. ja v a 2 s . 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 showMessage(String message, String width, String height, String caption) { Window window = new Window(); window.setCaption(caption);/* w w w . ja v a2 s . c o m*/ window.setWidth(width); window.setHeight(height); window.center(); Panel panel = new Panel(); panel.getContent().addComponent(new Label(message)); window.getContent().addComponent(panel); getWindow().addWindow(window); }
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/*w w w . java2 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 . j ava 2 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.controlpanel.CorpusListPanel.java
License:Apache License
public void initCorpusBrowser(String topLevelCorpusName, final Button l) { AnnisCorpus c = ui.getQueryState().getAvailableCorpora().getItem(topLevelCorpusName).getBean(); MetaDataPanel meta = new MetaDataPanel(c.getName()); CorpusBrowserPanel browse = new CorpusBrowserPanel(c, ui.getQueryController()); GridLayout infoLayout = new GridLayout(2, 2); infoLayout.setSizeFull();//from w w w. j a v a 2 s. com String corpusURL = Helper.generateCorpusLink(Sets.newHashSet(topLevelCorpusName)); Label lblLink = new Label("Link to corpus: <a href=\"" + corpusURL + "\">" + corpusURL + "</a>", ContentMode.HTML); lblLink.setHeight("-1px"); lblLink.setWidth("-1px"); infoLayout.addComponent(meta, 0, 0); infoLayout.addComponent(browse, 1, 0); infoLayout.addComponent(lblLink, 0, 1, 1, 1); infoLayout.setRowExpandRatio(0, 1.0f); infoLayout.setColumnExpandRatio(0, 0.5f); infoLayout.setColumnExpandRatio(1, 0.5f); infoLayout.setComponentAlignment(lblLink, Alignment.MIDDLE_CENTER); Window window = new Window("Corpus information for " + c.getName() + " (ID: " + c.getId() + ")", infoLayout); window.setWidth(70, UNITS_EM); window.setHeight(45, UNITS_EM); window.setResizable(true); window.setModal(false); window.setResizeLazy(true); window.addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { l.setEnabled(true); } }); UI.getCurrent().addWindow(window); window.center(); }
From source file:annis.gui.docbrowser.DocBrowserTable.java
License:Apache License
public Button generateInfoButtonCell(final String docName) { Button btn = new Button(); btn.setStyleName(ChameleonTheme.BUTTON_BORDERLESS); btn.setIcon(INFO_ICON);/* ww w.ja v a2 s . c o m*/ btn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { List<Annotation> annos = getDocMetaData(docName); /** * Transforms to a list of key value pairs. The values concates the * namespace and ordinary value. Namespaces "NULL" are ignored. */ // create datasource and bind it to a table BeanItemContainer<Annotation> metaContainer = new BeanItemContainer<>(Annotation.class); metaContainer.addAll(annos); metaContainer.sort(new Object[] { "namespace", "name" }, new boolean[] { true, true }); Table metaTable = new Table(); metaTable.setContainerDataSource(metaContainer); metaTable.addGeneratedColumn("genname", new MetaDataPanel.MetaTableNameGenerator(metaContainer)); metaTable.addGeneratedColumn("genvalue", new MetaDataPanel.MetaTableValueGenerator(metaContainer)); metaTable.setVisibleColumns("genname", "genvalue"); metaTable.setColumnHeaders(new String[] { "Name", "Value" }); metaTable.setSizeFull(); metaTable.setColumnWidth("genname", -1); metaTable.setColumnExpandRatio("genvalue", 1.0f); metaTable.addStyleName(ChameleonTheme.TABLE_STRIPED); // create and style the extra window for the metadata table Window metaWin = new Window(); metaWin.setContent(metaTable); metaWin.setCaption("metadata doc " + docName); metaWin.center(); metaWin.setWidth(400, Unit.PIXELS); metaWin.setHeight(400, Unit.PIXELS); // paint the window docBrowserPanel.getUI().addWindow(metaWin); } catch (UniformInterfaceException ex) { log.error("can not retrieve metadata for document " + docName, ex); } } }); return btn; }
From source file:annis.gui.MainToolbar.java
License:Apache License
public MainToolbar() { String bugmail = (String) VaadinSession.getCurrent().getAttribute(BUG_MAIL_KEY); if (bugmail != null && !bugmail.isEmpty() && !bugmail.startsWith("${") && new EmailValidator("").isValid(bugmail)) { this.bugEMailAddress = bugmail; } else {//from w ww . jav a2 s . c om this.bugEMailAddress = null; } UI ui = UI.getCurrent(); if (ui instanceof CommonUI) { ((CommonUI) ui).getSettings().addedLoadedListener(MainToolbar.this); } setWidth("100%"); setHeight("-1px"); addStyleName("toolbar"); addStyleName("border-layout"); btAboutAnnis = new Button("About ANNIS"); btAboutAnnis.addStyleName(ValoTheme.BUTTON_SMALL); btAboutAnnis.setIcon(new ThemeResource("images/annis_16.png")); btAboutAnnis.addClickListener(new AboutClickListener()); btSidebar = new Button(); btSidebar.setDisableOnClick(true); btSidebar.addStyleName(ValoTheme.BUTTON_SMALL); btSidebar.setDescription("Show and hide search sidebar"); btSidebar.setIconAlternateText(btSidebar.getDescription()); btBugReport = new Button("Report Problem"); btBugReport.addStyleName(ValoTheme.BUTTON_SMALL); btBugReport.setDisableOnClick(true); btBugReport.setIcon(FontAwesome.ENVELOPE_O); btBugReport.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { reportBug(); } }); btBugReport.setVisible(this.bugEMailAddress != null); btNavigate = new Button(); btNavigate.setVisible(false); btNavigate.setDisableOnClick(true); btNavigate.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { btNavigate.setEnabled(true); if (navigationTarget != null) { UI.getCurrent().getNavigator().navigateTo(navigationTarget.state); } } }); lblUserName = new Label("not logged in"); lblUserName.setWidth("-1px"); lblUserName.setHeight("-1px"); lblUserName.addStyleName("right-aligned-text"); btLogin = new Button("Login", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { showLoginWindow(false); } }); btLogout = new Button("Logout", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // logout Helper.setUser(null); for (LoginListener l : loginListeners) { l.onLogout(); } Notification.show("Logged out", Notification.Type.TRAY_NOTIFICATION); updateUserInformation(); } }); btLogin.setSizeUndefined(); btLogin.setStyleName(ValoTheme.BUTTON_SMALL); btLogin.setIcon(FontAwesome.USER); btLogout.setSizeUndefined(); btLogout.setStyleName(ValoTheme.BUTTON_SMALL); btLogout.setIcon(FontAwesome.USER); btOpenSource = new Button("Help us to make ANNIS better!"); btOpenSource.setStyleName(BaseTheme.BUTTON_LINK); btOpenSource.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.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"); UI.getCurrent().addWindow(w); w.center(); } }); addComponent(btSidebar); setComponentAlignment(btSidebar, Alignment.MIDDLE_LEFT); addComponent(btAboutAnnis); addComponent(btBugReport); addComponent(btNavigate); addComponent(btOpenSource); setSpacing(true); setComponentAlignment(btAboutAnnis, Alignment.MIDDLE_LEFT); setComponentAlignment(btBugReport, Alignment.MIDDLE_LEFT); setComponentAlignment(btNavigate, Alignment.MIDDLE_LEFT); setComponentAlignment(btOpenSource, Alignment.MIDDLE_CENTER); setExpandRatio(btOpenSource, 1.0f); addLoginButton(); btSidebar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { btSidebar.setEnabled(true); // decide new state switch (sidebarState) { case VISIBLE: if (event.isCtrlKey()) { sidebarState = SidebarState.AUTO_VISIBLE; } else { sidebarState = SidebarState.HIDDEN; } break; case HIDDEN: if (event.isCtrlKey()) { sidebarState = SidebarState.AUTO_HIDDEN; } else { sidebarState = SidebarState.VISIBLE; } break; case AUTO_VISIBLE: if (event.isCtrlKey()) { sidebarState = SidebarState.VISIBLE; } else { sidebarState = SidebarState.AUTO_HIDDEN; } break; case AUTO_HIDDEN: if (event.isCtrlKey()) { sidebarState = SidebarState.HIDDEN; } else { sidebarState = SidebarState.AUTO_VISIBLE; } break; } updateSidebarState(); } }); screenshotExtension = new ScreenshotMaker(this); JavaScript.getCurrent().addFunction("annis.gui.logincallback", new LoginCloseCallback()); updateSidebarState(); MainToolbar.this.updateUserInformation(); }
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);/*w w w .ja va2s . 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: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();/* w w w. j a v a 2s . co 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.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();//from w ww .j av a 2s . 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); }