List of usage examples for com.vaadin.ui VerticalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:annis.gui.admin.CorpusAdminPanel.java
License:Apache License
public CorpusAdminPanel() { corpusContainer.setBeanIdProperty("name"); final Grid corporaGrid = new Grid(corpusContainer); corporaGrid.setSizeFull();//w w w . ja v a 2 s.c o m corporaGrid.setSelectionMode(Grid.SelectionMode.MULTI); corporaGrid.setColumns("name", "textCount", "tokenCount", "sourcePath"); corporaGrid.getColumn("textCount").setHeaderCaption("Texts"); corporaGrid.getColumn("tokenCount").setHeaderCaption("Tokens"); corporaGrid.getColumn("sourcePath").setHeaderCaption("Source Path"); Button btDelete = new Button("Delete selected"); btDelete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Set<String> selection = new TreeSet<>(); for (Object o : corporaGrid.getSelectedRows()) { selection.add((String) o); } corporaGrid.getSelectionModel().reset(); if (!selection.isEmpty()) { for (CorpusListView.Listener l : listeners) { l.deleteCorpora(selection); } } } }); VerticalLayout layout = new VerticalLayout(btDelete, corporaGrid); layout.setSizeFull(); layout.setExpandRatio(corporaGrid, 1.0f); layout.setSpacing(true); layout.setMargin(new MarginInfo(true, false, false, false)); layout.setComponentAlignment(btDelete, Alignment.MIDDLE_CENTER); setContent(layout); setSizeFull(); }
From source file:annis.gui.admin.GroupManagementPanel.java
License:Apache License
public GroupManagementPanel() { groupsContainer.setBeanIdProperty("name"); progress = new ProgressBar(); progress.setCaption("Loading group list"); progress.setIndeterminate(true);/*from www . ja v a 2s. co 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.EmbeddedVisUI.java
License:Apache License
private void generateVisFromRemoteURL(final String visName, final String rawUri, Map<String, String[]> args) { try {//from ww w .j a va 2s . co m // find the matching visualizer final VisualizerPlugin visPlugin = this.getVisualizer(visName); if (visPlugin == null) { displayMessage("Unknown visualizer \"" + visName + "\"", "This ANNIS instance does not know the given visualizer."); return; } URI uri = new URI(rawUri); // fetch content of the URI Client client = null; AnnisUser user = Helper.getUser(); if (user != null) { client = user.getClient(); } if (client == null) { client = Helper.createRESTClient(); } final WebResource saltRes = client.resource(uri); displayLoadingIndicator(); // copy the arguments for using them later in the callback final Map<String, String[]> argsCopy = new LinkedHashMap<>(args); Background.runWithCallback(new Callable<SaltProject>() { @Override public SaltProject call() throws Exception { return saltRes.get(SaltProject.class); } }, new FutureCallback<SaltProject>() { @Override public void onFailure(Throwable t) { displayMessage("Could not query the result.", t.getMessage()); } @Override public void onSuccess(SaltProject p) { // TODO: allow to display several visualizers when there is more than one document SCorpusGraph firstCorpusGraph = null; SDocument doc = null; if (p.getCorpusGraphs() != null && !p.getCorpusGraphs().isEmpty()) { firstCorpusGraph = p.getCorpusGraphs().get(0); if (firstCorpusGraph.getDocuments() != null && !firstCorpusGraph.getDocuments().isEmpty()) { doc = firstCorpusGraph.getDocuments().get(0); } } if (doc == null) { displayMessage("No documents found in provided URL.", ""); return; } if (argsCopy.containsKey(KEY_INSTANCE)) { Map<String, InstanceConfig> allConfigs = loadInstanceConfig(); InstanceConfig newConfig = allConfigs.get(argsCopy.get(KEY_INSTANCE)[0]); if (newConfig != null) { setInstanceConfig(newConfig); } } // now it is time to load the actual defined instance fonts loadInstanceFonts(); // generate the visualizer VisualizerInput visInput = new VisualizerInput(); visInput.setDocument(doc); if (getInstanceConfig() != null && getInstanceConfig().getFont() != null) { visInput.setFont(getInstanceFont()); } Properties mappings = new Properties(); for (Map.Entry<String, String[]> e : argsCopy.entrySet()) { if (!KEY_SALT.equals(e.getKey()) && e.getValue().length > 0) { mappings.put(e.getKey(), e.getValue()[0]); } } visInput.setMappings(mappings); String[] namespace = argsCopy.get(KEY_NAMESPACE); if (namespace != null && namespace.length > 0) { visInput.setNamespace(namespace[0]); } else { visInput.setNamespace(null); } String baseText = null; if (argsCopy.containsKey(KEY_BASE_TEXT)) { String[] value = argsCopy.get(KEY_BASE_TEXT); if (value.length > 0) { baseText = value[0]; } } List<SNode> segNodes = CommonHelper.getSortedSegmentationNodes(baseText, doc.getDocumentGraph()); if (argsCopy.containsKey(KEY_MATCH)) { String[] rawMatch = argsCopy.get(KEY_MATCH); if (rawMatch.length > 0) { // enhance the graph with match information from the arguments Match match = Match.parseFromString(rawMatch[0]); addMatchToDocumentGraph(match, doc); } } Map<String, String> markedColorMap = new HashMap<>(); Map<String, String> exactMarkedMap = Helper.calculateColorsForMarkedExact(doc); Map<String, Long> markedAndCovered = Helper.calculateMarkedAndCoveredIDs(doc, segNodes, baseText); Helper.calulcateColorsForMarkedAndCovered(doc, markedAndCovered, markedColorMap); visInput.setMarkedAndCovered(markedAndCovered); visInput.setMarkableMap(markedColorMap); visInput.setMarkableExactMap(exactMarkedMap); visInput.setContextPath(Helper.getContext()); String template = Helper.getContext() + "/Resource/" + visName + "/%s"; visInput.setResourcePathTemplate(template); visInput.setSegmentationName(baseText); // TODO: which other thing do we have to provide? Component c = visPlugin.createComponent(visInput, null); // add the styles c.addStyleName("corpus-font"); c.addStyleName("vis-content"); Link link = new Link(); link.setCaption("Show in ANNIS search interface"); link.setIcon(ANNISFontIcon.LOGO); link.setVisible(false); link.addStyleName("dontprint"); link.setTargetName("_blank"); if (argsCopy.containsKey(KEY_SEARCH_INTERFACE)) { String[] interfaceLink = argsCopy.get(KEY_SEARCH_INTERFACE); if (interfaceLink.length > 0) { link.setResource(new ExternalResource(interfaceLink[0])); link.setVisible(true); } } VerticalLayout layout = new VerticalLayout(link, c); layout.setComponentAlignment(link, Alignment.TOP_LEFT); layout.setSpacing(true); layout.setMargin(true); setContent(layout); IDGenerator.assignID(link); } }); } catch (URISyntaxException ex) { displayMessage("Invalid URL", "The provided URL is malformed:<br />" + ex.getMessage()); } catch (LoginDataLostException ex) { displayMessage("LoginData Lost", "No login data available any longer in the session:<br /> " + ex.getMessage()); } catch (UniformInterfaceException ex) { if (ex.getResponse().getStatus() == Response.Status.FORBIDDEN.getStatusCode()) { displayMessage("Corpus access forbidden", "You are not allowed to access this corpus. " + "Please login at the <a target=\"_blank\" href=\"" + Helper.getContext() + "\">main application</a> first and then reload this page."); } else { displayMessage("Service error", ex.getMessage()); } } catch (ClientHandlerException ex) { displayMessage("Could not generate the visualization because the ANNIS service reported an error.", ex.getMessage()); } catch (Throwable ex) { displayMessage("Could not generate the visualization.", ex.getMessage() == null ? ("An unknown error of type " + ex.getClass().getSimpleName()) + " occured." : ex.getMessage()); } }
From source file:annis.gui.HelpUsWindow.java
License:Apache License
public HelpUsWindow() { setSizeFull();//from ww w .j a v a2 s . co m layout = new VerticalLayout(); setContent(layout); layout.setSizeFull(); layout.setMargin(new MarginInfo(false, false, true, false)); HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSizeFull(); hLayout.setMargin(false); VerticalLayout labelLayout = new VerticalLayout(); labelLayout.setMargin(true); labelLayout.setSizeFull(); Label lblOpenSource = new Label(); lblOpenSource.setValue("<h1>ANNIS is <a href=\"http://opensource.org/osd\">Open Source</a> " + "software.</h1>" + "<p>This means you are free to download the source code and add new " + "features or make other adjustments to ANNIS on your own.<p/>" + "Here are some examples how you can help ANNIS:" + "<ul>" + "<li>Fix or report problems (bugs) you encounter when using the ANNIS software.</li>" + "<li>Add new features.</li>" + "<li>Enhance the documentation</li>" + "</ul>" + "<p>Feel free to visit our GitHub page for more information: <a href=\"https://github.com/korpling/ANNIS\" target=\"_blank\">https://github.com/korpling/ANNIS</a></p>"); lblOpenSource.setContentMode(ContentMode.HTML); lblOpenSource.setStyleName("opensource"); lblOpenSource.setWidth("100%"); lblOpenSource.setHeight("-1px"); labelLayout.addComponent(lblOpenSource); Link lnkFork = new Link(); lnkFork.setResource(new ExternalResource("https://github.com/korpling/ANNIS")); lnkFork.setIcon( new ExternalResource("https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png")); lnkFork.setTargetName("_blank"); hLayout.addComponent(labelLayout); hLayout.addComponent(lnkFork); hLayout.setComponentAlignment(labelLayout, Alignment.TOP_LEFT); hLayout.setComponentAlignment(lnkFork, Alignment.TOP_RIGHT); hLayout.setExpandRatio(labelLayout, 1.0f); layout.addComponent(hLayout); final HelpUsWindow finalThis = this; btClose = new Button("Close"); btClose.addClickListener(new OkClickListener(finalThis)); layout.addComponent(btClose); layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER); layout.setExpandRatio(hLayout, 1.0f); }
From source file:annis.gui.querybuilder.EdgeWindow.java
License:Apache License
public EdgeWindow(final TigerQueryBuilderCanvas parent, NodeWindow source, NodeWindow target) { this.parent = parent; this.source = source; this.target = target; setSizeFull();/* w ww . j a v a 2 s .co m*/ // HACK: use our own border since the one from chameleon does not really work addStyleName(ValoTheme.PANEL_BORDERLESS); addStyleName("border-layout"); addStyleName("white-panel"); VerticalLayout vLayout = new VerticalLayout(); setContent(vLayout); vLayout.setMargin(false); HorizontalLayout toolbar = new HorizontalLayout(); toolbar.addStyleName("toolbar"); toolbar.setWidth("100%"); toolbar.setHeight("-1px"); vLayout.addComponent(toolbar); Label lblTitle = new Label("AQL Operator"); lblTitle.setWidth("100%"); toolbar.addComponent(lblTitle); toolbar.setComponentAlignment(lblTitle, Alignment.MIDDLE_LEFT); toolbar.setExpandRatio(lblTitle, 1.0f); btClose = new Button(); btClose.addStyleName(ValoTheme.BUTTON_ICON_ONLY); btClose.addStyleName(ValoTheme.BUTTON_SMALL); btClose.setIcon(FontAwesome.TIMES_CIRCLE); btClose.setWidth("-1px"); btClose.addListener((Button.ClickListener) this); toolbar.addComponent(btClose); toolbar.setComponentAlignment(btClose, Alignment.MIDDLE_RIGHT); toolbar.setExpandRatio(btClose, 0.0f); cbOperator = new ComboBox(); cbOperator.setNewItemsAllowed(false); cbOperator.setTextInputAllowed(false); cbOperator.setNullSelectionAllowed(true); cbOperator.addItem(CUSTOM); cbOperator.setItemCaption(CUSTOM, "custom"); cbOperator.setNullSelectionItemId(CUSTOM); cbOperator.setNewItemHandler(new SimpleNewItemHandler(cbOperator)); cbOperator.setImmediate(true); vLayout.addComponent(cbOperator); for (AQLOperator o : AQLOperator.values()) { cbOperator.addItem(o); cbOperator.setItemCaption(o, o.getDescription() + " (" + o.getOp() + ")"); } cbOperator.setValue(AQLOperator.DIRECT_PRECEDENCE); cbOperator.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { Object val = event.getProperty().getValue(); if (val instanceof AQLOperator) { txtOperator.setValue(((AQLOperator) val).getOp()); } } }); cbOperator.setWidth("100%"); cbOperator.setHeight("20px"); txtOperator = new TextField(); txtOperator.setValue("."); txtOperator.setInputPrompt("select operator definition"); txtOperator.setSizeFull(); txtOperator.addValueChangeListener(new OperatorValueChangeListener(parent)); txtOperator.setImmediate(true); vLayout.addComponent(txtOperator); vLayout.setExpandRatio(cbOperator, 1.0f); }
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 v a2s.co m 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 ww w. j a v a 2 s .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: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 ww .j a v a 2 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.peppol.webgui.app.components.InvoiceLineWindow.java
License:Mozilla Public License
public InvoiceLineWindow(final TabInvoiceLine parent) { this.parent = parent; invln = new InvoiceLineAdapter(); // line = new Line(); // BeanItem<InvoiceLineAdapter> invoiceLine = new BeanItem<InvoiceLineAdapter>(invln); // parent.setItemDataSource(invoiceLine); // BeanItem<Line> invoiceLine = new BeanItem<Line>(line); // parent.setItemDataSource(invoiceLine); subwindow = new Window("Invoice Line"); subwindow.setModal(true);//from w w w. java 2s . c o m VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); Button btnClose = new Button("Close", new Button.ClickListener() { public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); Button btnSave = new Button("Save", new Button.ClickListener() { public void buttonClick(ClickEvent event) { //update GUI table !! ///parent.getTable().addInvoiceLine (invln); //update actual invoice line item ///parent.items.add (invln); //close popup (subwindow.getParent()).removeWindow(subwindow); } }); try { layout.addComponent(createInvoiceLineForm()); } catch (Exception e) { e.printStackTrace(); } layout.addComponent(btnSave); layout.addComponent(btnClose); layout.setComponentAlignment(btnClose, Alignment.BOTTOM_RIGHT); }
From source file:at.peppol.webgui.app.components.PartyDetailForm.java
License:Mozilla Public License
private void initElements() { setCaption(party + " Party"); //setStyleName("light"); final VerticalLayout outerLayout = new VerticalLayout(); outerLayout.setSpacing(true);/*from w w w . j av a 2 s . c o m*/ outerLayout.setMargin(true); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true); hiddenContent.setMargin(true); PropertysetItem partyItemSet = new PropertysetItem(); PartyIdentificationType supplierPartyID; if (partyBean.getPartyIdentification().size() == 0) { supplierPartyID = new PartyIdentificationType(); supplierPartyID.setID(new IDType()); partyBean.getPartyIdentification().add(supplierPartyID); } else { supplierPartyID = partyBean.getPartyIdentification().get(0); } partyItemSet.addItemProperty("Party ID", new NestedMethodProperty(supplierPartyID, "ID.value")); EndpointIDType endPointID; if (partyBean.getEndpointID() == null) { endPointID = new EndpointIDType(); partyBean.setEndpointID(endPointID); } else { endPointID = partyBean.getEndpointID(); } partyItemSet.addItemProperty("Endpoint ID", new NestedMethodProperty(endPointID, "SchemeAgencyID")); PartyNameType partyName; if (partyBean.getPartyName().size() == 0) { partyName = new PartyNameType(); partyName.setName(new NameType()); partyBean.getPartyName().add(partyName); } else { partyName = partyBean.getPartyName().get(0); } partyItemSet.addItemProperty("Party Name", new NestedMethodProperty(partyName, "name.value")); /* partyItemSet.addItemProperty("Agency Name", new NestedMethodProperty(supplierPartyID, "ID.SchemeAgencyID") ); */ /* final AddressType partyrAddress = new AddressType(); partyBean.setPostalAddress(partyrAddress); partyrAddress.setStreetName(new StreetNameType()); partyrAddress.setCityName(new CityNameType()); partyrAddress.setPostalZone(new PostalZoneType()); partyrAddress.setCountry(new CountryType()); partyrAddress.getCountry().setIdentificationCode(new IdentificationCodeType()); partyItemSet.addItemProperty("Street Name", new NestedMethodProperty(partyrAddress, "streetName.value")); partyItemSet.addItemProperty("City", new NestedMethodProperty(partyrAddress, "cityName.value")); partyItemSet.addItemProperty("Postal Zone", new NestedMethodProperty(partyrAddress, "postalZone.value")); partyItemSet.addItemProperty("Country", new NestedMethodProperty(partyrAddress, "country.identificationCode.value")); */ AddressDetailForm partyAddressForm; AddressType address; if (partyBean.getPostalAddress() == null) { address = new AddressType(); } else { address = partyBean.getPostalAddress(); } partyAddressForm = new AddressDetailForm(party, address); partyBean.setPostalAddress(address); PartyTaxSchemeType taxScheme; if (partyBean.getPartyTaxScheme().size() == 0) { taxScheme = new PartyTaxSchemeType(); taxScheme.setCompanyID(new CompanyIDType()); //partyItemSet.addItemProperty(taxSchemeCompanyID, // new NestedMethodProperty(taxScheme.getCompanyID(),"value")); // TODO: Hardcoded ShemeID etc for TaxScheme. Should be from a codelist? taxScheme.setTaxScheme(new TaxSchemeType()); taxScheme.getTaxScheme().setID(new IDType()); taxScheme.getTaxScheme().getID().setValue("VAT"); taxScheme.getTaxScheme().getID().setSchemeID("UN/ECE 5153"); taxScheme.getTaxScheme().getID().setSchemeAgencyID("6"); partyBean.getPartyTaxScheme().add(taxScheme); } else { taxScheme = partyBean.getPartyTaxScheme().get(0); } partyItemSet.addItemProperty(taxSchemeCompanyID, new NestedMethodProperty(taxScheme.getCompanyID(), "value")); partyItemSet.addItemProperty(taxSchemeID, new NestedMethodProperty(taxScheme.getTaxScheme().getID(), "value")); final Form partyForm = new Form(); partyForm.setFormFieldFactory(new PartyFieldFactory()); partyForm.setItemDataSource(partyItemSet); partyForm.setImmediate(true); final Button addLegalEntityBtn = new Button("Add Legal Entity"); final Button removeLegalEntityBtn = new Button("Remove Legal Entity"); //removeLegalEntityBtn.setVisible(false); addLegalEntityBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { //add the legal entity component Panel panel = createLegalEntityPanel(removeLegalEntityBtn); outerLayout.addComponent(panel); panel.setWidth("90%"); addLegalEntityBtn.setVisible(false); //removeLegalEntityBtn.setVisible(true); //outerLayout.replaceComponent(removeLegalEntityBtn, panel); } }); removeLegalEntityBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { //remove the legal entity component for (int i = 0; i < outerLayout.getComponentCount(); i++) { Component c = outerLayout.getComponent(i); if (c instanceof Panel) { if (c.getCaption().equals("Legal Entity")) { outerLayout.removeComponent(c); if (partyBean.getPartyLegalEntity().size() > 0) { partyBean.getPartyLegalEntity().clear(); ValidatorsList.removeListeners(Utils.getFieldListeners(legalEntityForm)); } } } } //removeLegalEntityBtn.setVisible(false); addLegalEntityBtn.setVisible(true); } }); outerLayout.addComponent(partyForm); partyForm.setWidth("90%"); outerLayout.addComponent(partyAddressForm); partyAddressForm.setWidth("90%"); outerLayout.addComponent(addLegalEntityBtn); if (partyBean.getPartyLegalEntity().size() > 0) addLegalEntityBtn.click(); //outerLayout.addComponent(removeLegalEntityBtn); //outerLayout.addComponent(createLegalEntityPanel()); setContent(outerLayout); }