List of usage examples for com.vaadin.ui Window setWidth
@Override public void setWidth(String width)
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//from ww w .j a 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);//from w w w.ja v a 2 s . c om 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:annis.gui.admin.GroupManagementPanel.java
License:Apache License
public GroupManagementPanel() { groupsContainer.setBeanIdProperty("name"); progress = new ProgressBar(); progress.setCaption("Loading group list"); progress.setIndeterminate(true);//w w w . ja v a 2 s. c om 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 ww w . j av a2s. 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.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 {// ww w . ja v a 2 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.resultview.SingleResultPanel.java
License:Apache License
@Override public void buttonClick(ClickEvent event) { if (event.getButton() == btInfo && result != null) { Window infoWindow = new Window("Info for " + result.getId()); infoWindow.setModal(false);/*from ww w . j a v a 2s. c om*/ MetaDataPanel meta = new MetaDataPanel(path.get(0), path.get(path.size() - 1)); infoWindow.setContent(meta); infoWindow.setWidth("400px"); infoWindow.setHeight("400px"); UI.getCurrent().addWindow(infoWindow); } }
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. j a va2s . com 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.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 w w . j a v a 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); }
From source file:at.jku.ce.adaptivetesting.vaadin.ui.VaadinResultView.java
License:LGPL
public VaadinResultView(ResultFiredArgs args, String title) { setSpacing(true);/* w w w . j a va 2 s .c o m*/ addComponent(new HtmlLabel(title)); //addComponent(HtmlLabel.getCenteredLabel("h2", "Test abgeschlossen")); addComponent(HtmlLabel.getCenteredLabel( "Der Test wurde beendet, da " + (args.outOfQuestions ? "keine weiteren Fragen verfgbar sind." : "dein Kompetenzniveau bestimmt wurde."))); addComponent(HtmlLabel.getCenteredLabel( "Im Folgenden siehst du die Fragen und die gegebenen Antworten in zeitlich absteigender Reihenfolge.")); addComponent(HtmlLabel.getCenteredLabel( "Die Zahl in der ersten Spalte bezieht sich auf die Schwierigkeit der jeweiligen Frage. Negative Zahlen stehen fr leichtere Fragen, positive Zahlen kennzeichnen schwierigere Fragen.")); // Create HTML table of the history Table table = new Table(); final String solution = "Korrekte Antwort", userAnswer = "Ihre Antwort"; table.addContainerProperty("Schwierigkeitsgrad", Float.class, null); table.addContainerProperty("Resultat", String.class, null); table.addContainerProperty(userAnswer, Button.class, null); table.addContainerProperty(solution, Button.class, null); //List<HistoryEntry> entries = Lists.reverse(args.history); List<HistoryEntry> entries = new ArrayList<HistoryEntry>(args.history); Collections.reverse(entries); for (HistoryEntry entry : entries) { Button qAnswer = null, qSolution = null; if (entry.question instanceof Component && entry.question != null) { try { Class<? extends AnswerStorage> dataStorageClass = entry.question.getSolution().getClass(); Constructor<? extends IQuestion> constructor = entry.question.getClass() .getConstructor(dataStorageClass, dataStorageClass, float.class, String.class); // The following casts can not fail, because the question is // a component as well Component iQuestionSolution = (Component) constructor.newInstance(entry.question.getSolution(), entry.question.getSolution(), entry.question.getDifficulty(), entry.question.getQuestionText()); Component iQuestionUser = (Component) constructor.newInstance(entry.question.getSolution(), entry.question.getUserAnswer(), entry.question.getDifficulty(), entry.question.getQuestionText()); // Create the 2 needed click listeners ClickListener clickListenerSol = event -> { Window window = new Window(solution); event.getButton().setEnabled(false); window.addCloseListener(e -> event.getButton().setEnabled(true)); window.setContent(iQuestionSolution); window.center(); window.setWidth("90%"); window.setHeight("50%"); if (iQuestionSolution instanceof Sizeable) { Sizeable sizeable = iQuestionSolution; sizeable.setSizeFull(); } getUI().addWindow(window); }; ClickListener clickListenerUA = event -> { Window window = new Window(userAnswer); event.getButton().setEnabled(false); window.addCloseListener(e -> event.getButton().setEnabled(true)); window.setContent(iQuestionUser); window.center(); window.setWidth("90%"); window.setHeight("50%"); if (iQuestionUser instanceof Sizeable) { Sizeable sizeable = iQuestionUser; sizeable.setSizeFull(); } getUI().addWindow(window); }; // Create the two buttons qAnswer = new Button(userAnswer, clickListenerUA); qSolution = new Button(solution, clickListenerSol); } catch (Exception e) { // Ignore this line in the table LogHelper.logInfo("1 entry's solution/ user answer are missing on the final screen." + entry.question.getClass().getName() + " does not implement the constructors required by" + IQuestion.class.getName()); } } table.addItem(new Object[] { entry.question.getDifficulty(), isCorrect(entry.points, entry.question.getMaxPoints()), qAnswer, qSolution }, null); } int size = table.size(); if (size > 10) { size = 10; } table.setPageLength(size); addComponent(table); setComponentAlignment(table, Alignment.MIDDLE_CENTER); addComponent(HtmlLabel.getCenteredLabel("h3", "Dein Kompetenzniveau ist: <b>" + args.skillLevel + "</b>")); addComponent(HtmlLabel.getCenteredLabel("Delta: " + args.delta)); storeResults(args); }
From source file:at.peppol.webgui.app.components.InvoiceTabForm.java
License:Mozilla Public License
private void initElements() { supplierForm = new PartyDetailForm("Supplier", supplier.getParty()); supplierForm.setImmediate(true);//from w ww . j ava 2s . c o m customerForm = new PartyDetailForm("Customer", customer.getParty()); customerForm.setImmediate(true); //supplierForm.setSizeFull (); //customerForm.setSizeFull (); final HorizontalLayout footerLayout = new HorizontalLayout(); footerLayout.setSpacing(true); footerLayout.setMargin(true); footerLayout.addComponent(new Button("Save Invoice", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { SetCommonCurrency(); ValidatorHandler vh = new ValidatorHandler(footerLayout); AbstractUBLDocumentMarshaller.setGlobalValidationEventHandler(vh); vh.clearErrors(); clearTabErrorStyles(); boolean invoiceHasErrors = false; List<ValidationError> errors = GlobalValidationsRegistry.runAll(); if (errors.size() > 0) { invoiceHasErrors = true; Window errorWindow = new Window("Errors"); //position and size of the window errorWindow.setPositionX(200); errorWindow.setPositionY(200); errorWindow.setWidth("600px"); errorWindow.setHeight("300px"); //add the error messages String errorMessage = "<ol>"; for (int i = 0; i < errors.size(); i++) { errorMessage += "<li style=\"margin-top: 4px;\"><b>" + errors.get(i).getRuleID() + "</b>: " + errors.get(i).getErrorInfo() + "</li>"; //mark the appropriate Tab as error Tab tab = invTabSheet.getTab(errors.get(i).getMainComponent()); if (tab != null) tab.setStyleName("test111"); } errorMessage += "</ol>"; errorWindow.addComponent(new Label(errorMessage, Label.CONTENT_XHTML)); //show the error window getParent().getWindow().addWindow(errorWindow); errors.clear(); } ValidatorsList.validateListenersNotify(); if (ValidatorsList.validateListeners() == false) { invoiceHasErrors = true; } if (invoiceHasErrors) { getWindow().showNotification("Validation error. Could not save invoice", Notification.TYPE_TRAY_NOTIFICATION); } else { try { if (invoiceFilePath.equals("")) { UBL20DocumentMarshaller.writeInvoice(invoice, new StreamResult(new File(um.getDrafts().getFolder().toString() + System.getProperty("file.separator") + "invoice" + System.currentTimeMillis() + ".xml"))); invoiceFilePath = um.getDrafts().getFolder().toString() + System.getProperty("file.separator") + "invoice" + System.currentTimeMillis() + ".xml"; } else { UBL20DocumentMarshaller.writeInvoice(invoice, new StreamResult(new File(invoiceFilePath))); } getWindow() .showNotification( "Validation passed. Invoice saved in " + um.getDrafts().getName().toUpperCase() + " folder", Notification.TYPE_TRAY_NOTIFICATION); } catch (Exception e) { getWindow().showNotification("Disk access error. Could not save invoice", Notification.TYPE_ERROR_MESSAGE); } } /*PEPPOL validation * final ValidationPyramid vp = new ValidationPyramid (EValidationDocumentType.INVOICE, ValidationTransaction.createUBLTransaction (ETransaction.T10)); final List <ValidationPyramidResultLayer> aResults = vp.applyValidation (new FileSystemResource ("invoice.xml")) .getAllValidationResultLayers (); if (aResults.isEmpty ()) System.out.println (" The document is valid!"); else for (final ValidationPyramidResultLayer aResultLayer : aResults) for (final IResourceError aError : aResultLayer.getValidationErrors ()) System.out.println (" " + aResultLayer.getValidationLevel () + " " + aError.getAsString (Locale.US)); */ /*ValidatorsList.validateListenersNotify(); if (ValidatorsList.validateListeners() == false) { getParent().getWindow().showNotification("Validation error... ",Notification.TYPE_TRAY_NOTIFICATION); } else getParent().getWindow().showNotification("Validation passed! ",Notification.TYPE_TRAY_NOTIFICATION); */ } })); /* footerLayout.addComponent (new Button ("Save Invoice", new Button.ClickListener () { @Override public void buttonClick (final Button.ClickEvent event) { try { SetCommonCurrency (); System.out.println (invoice.getDelivery ().get (0).getDeliveryAddress ().getStreetName ().getValue ()); } catch (final Exception ex) { LOGGER.error ("Error creating files. ", ex); } } })); */ footerLayout.addComponent(new Button("Read Invoice from disk", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { try { SetCommonCurrency(); InvoiceType inv = UBL20DocumentMarshaller .readInvoice(new StreamSource(new FileInputStream(new File("invoice.xml")))); } catch (final Exception ex) { LOGGER.error("Error creating files. ", ex); } } })); getFooter().addComponent(footerLayout); }