List of usage examples for com.vaadin.ui HorizontalLayout setHeight
@Override public void setHeight(String height)
From source file:com.zklogtool.web.components.OpenTransactionLogFileDialog.java
License:Apache License
public OpenTransactionLogFileDialog(final TabSheet displayTabSheet, final Window windowHandle) { buildMainLayout();//from w w w. jav a 2s .co m setCompositionRoot(mainLayout); openButton.addClickListener(new ClickListener() { @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { File transactionLogFile = new File(transactionLogFileLabel.getValue()); File snapshotDir = new File(snapshotDirectoryLabel.getValue()); if (!transactionLogFile.isFile() && !transactionLogFile.isDirectory()) { transactionLogFileLabel.setComponentError(new UserError("IO problem")); return; } if (snapshotDirectoryLabel.getValue() != null && !snapshotDirectoryLabel.getValue().isEmpty() && !snapshotDir.isDirectory()) { snapshotDirectoryLabel.setComponentError(new UserError("IO problem")); return; } TransactionLogView transactionLogView = new TransactionLogView(transactionLogFile, snapshotDir, followCheckbox.getValue(), startFromLastCheckbox.getValue(), displayTabSheet, nameLabel.getValue()); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setCaption(nameLabel.getValue()); horizontalLayout.addComponent(transactionLogView); horizontalLayout.setWidth("100%"); horizontalLayout.setHeight("100%"); Tab transactionLogTab = displayTabSheet.addTab(horizontalLayout); transactionLogTab.setClosable(true); displayTabSheet.setSelectedTab(transactionLogTab); windowHandle.close(); } }); }
From source file:com.zklogtool.web.components.TransactionLogView.java
License:Apache License
public TransactionLogView(final File transactionLogFile, final File snapshotDir, final boolean follow, final boolean startFromLast, final TabSheet displayTabSheet, final String name) { buildMainLayout();// w w w .j av a 2 s . c o m setCompositionRoot(mainLayout); descriptionLabel.setContentMode(ContentMode.PREFORMATTED); final Container container = new IndexedContainer(); container.addContainerProperty("zxid", String.class, 0); container.addContainerProperty("cxid", String.class, 0); container.addContainerProperty("client id", String.class, 0); //container.addContainerProperty("time", Date.class, 0); container.addContainerProperty("operation", ZkOperations.class, ""); container.addContainerProperty("path", String.class, ""); reconstructDataTreeButton.setVisible(false); filterTable.setContainerDataSource(container); filterTable.setFilterBarVisible(true); filterTable.setFilterDecorator(new TransactionFilterDecoder()); filterTable.setSelectable(true); filterTable.setImmediate(true); final TransactionLog transactionLog; final Iterator<Transaction> iterator; final Map<String, Transaction> transactionMap = new HashMap<String, Transaction>(); filterTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (filterTable.getValue() == null) return; StringBuilder description = new StringBuilder(); TransactionPrinter printer = new TransactionPrinter(description, new UnicodeDecoder()); printer.print(transactionMap.get("0x" + filterTable.getValue().toString())); descriptionLabel.setValue(description.toString()); if (snapshotDir != null && transactionLogFile.isDirectory()) { reconstructDataTreeButton.setVisible(true); } } }); if (transactionLogFile.isFile()) { transactionLog = new TransactionLog(transactionLogFile, new TransactionLogReaderFactory()); } else { transactionLog = new TransactionLog(new DataDirTransactionLogFileList(transactionLogFile), new TransactionLogReaderFactory()); } iterator = transactionLog.iterator(); if (startFromLast) { while (iterator.hasNext()) { iterator.next(); } } final Runnable fillData = new Runnable() { @Override public void run() { // TODO Auto-generated method stub while (iterator.hasNext()) { Transaction t = iterator.next(); transactionMap.put(Util.longToHexString(t.getTxnHeader().getZxid()), t); Item item = container.addItem(Long.toHexString(t.getTxnHeader().getZxid())); item.getItemProperty("zxid").setValue(Util.longToHexString(t.getTxnHeader().getZxid())); item.getItemProperty("cxid").setValue(Util.longToHexString(t.getTxnHeader().getCxid())); item.getItemProperty("client id") .setValue(Util.longToHexString(t.getTxnHeader().getClientId())); /*item.getItemProperty("time").setValue( new Date(t.getTxnHeader().getTime()));*/ switch (t.getTxnHeader().getType()) { case OpCode.create: CreateTxn createTxn = (CreateTxn) t.getTxnRecord(); item.getItemProperty("operation").setValue(ZkOperations.CREATE); item.getItemProperty("path").setValue(createTxn.getPath()); break; case OpCode.delete: DeleteTxn deleteTxn = (DeleteTxn) t.getTxnRecord(); item.getItemProperty("operation").setValue(ZkOperations.DELTE); item.getItemProperty("path").setValue(deleteTxn.getPath()); break; case OpCode.setData: SetDataTxn setDataTxn = (SetDataTxn) t.getTxnRecord(); item.getItemProperty("operation").setValue(ZkOperations.SET_DATA); item.getItemProperty("path").setValue(setDataTxn.getPath()); break; case OpCode.setACL: SetACLTxn setACLTxn = (SetACLTxn) t.getTxnRecord(); item.getItemProperty("operation").setValue(ZkOperations.SET_ACL); item.getItemProperty("path").setValue(setACLTxn.getPath()); break; case OpCode.check: CheckVersionTxn checkVersionTxn = (CheckVersionTxn) t.getTxnRecord(); item.getItemProperty("operation").setValue(ZkOperations.CHECK); item.getItemProperty("path").setValue(checkVersionTxn.getPath()); break; case OpCode.multi: item.getItemProperty("operation").setValue(ZkOperations.MULTI); break; case OpCode.createSession: item.getItemProperty("operation").setValue(ZkOperations.CREATE_SESSION); break; case OpCode.closeSession: item.getItemProperty("operation").setValue(ZkOperations.CLOSE_SESSION); break; case OpCode.error: item.getItemProperty("operation").setValue(ZkOperations.ERROR); break; } } } }; fillData.run(); Thread monitorThread = new Thread(new Runnable() { @Override public void run() { while (true) { //push UI UI.getCurrent().access(fillData); try { Thread.sleep(250); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); if (follow) { monitorThread.start(); } reconstructDataTreeButton.addClickListener(new ClickListener() { @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { DataDirHelper dataDirHelper = new DataDirHelper(transactionLogFile, snapshotDir); List<File> snapshots = dataDirHelper.getSortedSnapshotList(); DataDirTransactionLogFileList l = new DataDirTransactionLogFileList(transactionLogFile); TransactionLog transactionLog = new TransactionLog(l, new TransactionLogReaderFactory()); File snapFile = null; DataState dataState = null; long currentZxid = Long.parseLong(filterTable.getValue().toString(), 16); int i = snapshots.size() - 1; while (i >= 0) { long snapZxid = Util.getZxidFromName(snapshots.get(i).getName()); if (snapZxid <= currentZxid) { if (i == 0) { snapFile = snapshots.get(0); } else { snapFile = snapshots.get(i - 1); } break; } i--; } if (snapFile == null) { dispalyNotEnoughDataErrorMessage(); return; } long TS = Util.getZxidFromName(snapFile.getName()); //catch this exception and print error SnapshotFileReader snapReader = new SnapshotFileReader(snapFile, TS); try { dataState = snapReader.restoreDataState(transactionLog.iterator()); } catch (Exception ex) { //dispay error dialog //not enough information dispalyNotEnoughDataErrorMessage(); return; } //set iterator to last zxid TransactionIterator iterator = transactionLog.iterator(); Transaction t; do { t = iterator.next(); } while (t.getTxnHeader().getZxid() < TS); while (iterator.nextTransactionState() == TransactionState.OK && dataState.getLastZxid() < currentZxid) { dataState.processTransaction(iterator.next()); } HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setCaption(name + " at zxid 0x" + Long.toString(currentZxid, 16)); horizontalLayout.addComponent(new SnapshotView(dataState)); horizontalLayout.setWidth("100%"); horizontalLayout.setHeight("100%"); Tab snapshotTab = displayTabSheet.addTab(horizontalLayout); snapshotTab.setClosable(true); displayTabSheet.setSelectedTab(snapshotTab); } void dispalyNotEnoughDataErrorMessage() { final Window window = new Window("Error"); window.setModal(true); final VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true); verticalLayout.addComponent(new Label("Not enough data to reconstruct data tree")); window.setContent(verticalLayout); UI.getCurrent().addWindow(window); } }); }
From source file:de.escidoc.admintool.view.admintask.reindex.ReindexView.java
License:Open Source License
@Override public void addView() { Label text = new H2(ViewConstants.REINDEX_RESOURCES_TITLE); text.setContentMode(Label.CONTENT_XHTML); cssLayout.addComponent(text);/*from w ww .ja va 2 s . c o m*/ cssLayout.addComponent(new Ruler()); text = new Label(ViewConstants.REINDEX_TEXT, Label.CONTENT_XHTML); cssLayout.addComponent(text); final HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setWidth("100%"); hLayout.setHeight("250px"); final ReindexResourceView reindexResourceView = new ReindexResourceViewImpl(services.getAdminService(), mainWindow, application); reindexResourceView.init(); hLayout.addComponent(reindexResourceView); cssLayout.addComponent(hLayout); }
From source file:de.escidoc.admintool.view.user.UserEditForm.java
License:Open Source License
private VerticalLayout createLayout(final String rolesLabel, final Table table, final int labelWidth, final int roleListHeight, final boolean b, final Button[] buttons) { final HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setHeight(roleListHeight + Constants.PX); hLayout.addComponent(new Label(" ")); final Label textLabel = new Label(Constants.P_ALIGN_RIGHT + rolesLabel + " " + Constants.P, Label.CONTENT_XHTML); textLabel.setSizeUndefined();//from w w w. jav a 2s. co m textLabel.setWidth(labelWidth + Constants.PX); hLayout.addComponent(textLabel); hLayout.setComponentAlignment(textLabel, Alignment.MIDDLE_RIGHT); hLayout.addComponent(new Label(" ", Label.CONTENT_XHTML)); hLayout.addComponent(table); hLayout.setComponentAlignment(table, Alignment.MIDDLE_RIGHT); hLayout.addComponent(new Label(" ", Label.CONTENT_XHTML)); final VerticalLayout vLayout = new VerticalLayout(); vLayout.addComponent(hLayout); final HorizontalLayout hl = new HorizontalLayout(); final Label la = new Label(" ", Label.CONTENT_XHTML); la.setSizeUndefined(); la.setWidth(labelWidth + Constants.PX); hl.addComponent(la); for (final Button button : buttons) { hl.addComponent(button); } vLayout.addComponent(hl); hLayout.setSpacing(false); return vLayout; }
From source file:de.escidoc.admintool.view.util.LayoutHelper.java
License:Open Source License
/** * Helper method. Puts a blank in front of a component. * /*from w w w.j ava 2 s . c om*/ * @param label * The label in front of the control. * @param comp * The component to display. * @param width * the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance. * @param required * should it be marked with an asterisk. * @return The component in an horizontal layout. A blank in front and afterwards is inserted. */ public static synchronized HorizontalLayout create(final String label, final Component comp, final int width, final boolean required) { final HorizontalLayout hor = new HorizontalLayout(); hor.setHeight(Constants.DEFAULT_HEIGHT); hor.addComponent(new Label(" ")); final String text = Constants.P_ALIGN_RIGHT + label + Constants.P; Label l; hor.addComponent(l = new Label(text, Label.CONTENT_XHTML)); l.setSizeUndefined(); l.setWidth(width + Constants.PX); hor.setComponentAlignment(l, Alignment.BOTTOM_RIGHT); if (required) { hor.addComponent(new Label(" <span style=\"color:red; position:relative; top:13px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hor.addComponent(comp); hor.setComponentAlignment(comp, Alignment.BOTTOM_RIGHT); hor.addComponent(new Label(" ")); hor.setSpacing(false); return hor; }
From source file:de.escidoc.admintool.view.util.LayoutHelper.java
License:Open Source License
/** * Helper method. Puts a blank in front of a component. * /*w w w. j av a 2 s .c om*/ * @param label * The label in front of the control. * @param comp * The component to display. * @param width * the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance. * @param required * should it be marked with an asterisk. * @return The component in an horizontal layout. A blank in front and afterwards is inserted. */ public static synchronized HorizontalLayout create(final String label, final CheckBox comp, final int width, final boolean required) { final HorizontalLayout hor = new HorizontalLayout(); hor.setHeight(Constants.DEFAULT_HEIGHT); hor.addComponent(new Label(" ")); final String text = Constants.P_ALIGN_RIGHT + label + Constants.P; Label l; hor.addComponent(l = new Label(text, Label.CONTENT_XHTML)); l.setSizeUndefined(); l.setWidth(width + Constants.PX); hor.setComponentAlignment(l, Alignment.MIDDLE_RIGHT); if (required) { hor.addComponent(new Label(" <span style=\"color:red; position:relative; top:13px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hor.addComponent(comp); hor.setComponentAlignment(comp, Alignment.BOTTOM_RIGHT); hor.addComponent(new Label(" ")); hor.setSpacing(false); return hor; }
From source file:de.escidoc.admintool.view.util.LayoutHelper.java
License:Open Source License
/** * Helper method. Puts a blank in front of a component. * /* www. j av a2 s. c o m*/ * @param label * The label in front of the control. * @param comp * The component to display. * @param width * the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance. * @param height * the height of the layout * @param required * should it be marked with an asterisk. * @return The component in an horizontal layout. A blank in front and afterwards is inserted. */ public static synchronized HorizontalLayout create(final String label, final Component comp, final int width, final int height, final boolean required) { final HorizontalLayout hor = new HorizontalLayout(); hor.setHeight(height + Constants.PX); hor.addComponent(new Label(" ")); final String text = Constants.P_ALIGN_RIGHT + label + Constants.P; Label l; hor.addComponent(l = new Label(text, Label.CONTENT_XHTML)); l.setSizeUndefined(); l.setWidth(width + Constants.PX); hor.setComponentAlignment(l, Alignment.MIDDLE_RIGHT); if (required) { hor.addComponent(new Label( " <span style=\"color:red; position:relative; top:" + (height / 2 - 13) + "px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hor.addComponent(comp); hor.setComponentAlignment(comp, Alignment.MIDDLE_RIGHT); hor.addComponent(new Label(" ")); hor.setSpacing(false); return hor; }
From source file:de.escidoc.admintool.view.util.LayoutHelper.java
License:Open Source License
/** * Helper method. Puts a blank in front of a component. * /*from w w w . j ava2s .c om*/ * @param label * The label in front of the control. * @param comp * The component to display. * @param labelWidth * the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance. * @param height * @param required * should it be marked with an asterisk. * @param buttons * @return The component in an horizontal layout. A blank in front and afterwards is inserted. */ public static synchronized VerticalLayout create(final String label, final Component comp, final int labelWidth, final int height, final boolean required, final Button[] buttons) { final HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSpacing(false); hLayout.setHeight(height + Constants.PX); hLayout.addComponent(new Label(" ")); final Label textLabel = new Label(Constants.P_ALIGN_RIGHT + label + Constants.P, Label.CONTENT_XHTML); hLayout.addComponent(textLabel); textLabel.setSizeUndefined(); textLabel.setWidth(labelWidth + Constants.PX); hLayout.setComponentAlignment(textLabel, Alignment.MIDDLE_RIGHT); if (required) { hLayout.addComponent(new Label( " <span style=\"color:red; position:relative; top:" + (height / 2 - 13) + "px;\">*</span>", Label.CONTENT_XHTML)); } else { hLayout.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hLayout.addComponent(comp); hLayout.setComponentAlignment(comp, Alignment.MIDDLE_RIGHT); hLayout.addComponent(new Label(" ", Label.CONTENT_XHTML)); final VerticalLayout vLayout = new VerticalLayout(); vLayout.addComponent(hLayout); final HorizontalLayout buttonLayout = new HorizontalLayout(); vLayout.addComponent(buttonLayout); final Label la = new Label(" ", Label.CONTENT_XHTML); la.setSizeUndefined(); la.setWidth(labelWidth + 7 + Constants.PX); buttonLayout.addComponent(la); for (final Button b : buttons) { buttonLayout.addComponent(b); } return vLayout; }
From source file:de.escidoc.admintool.view.util.LayoutHelper.java
License:Open Source License
/** * Helper method. Puts a blank in front of a component. * //from w w w .jav a 2 s .c o m * @param label * The label in front of the control. * @param accordion * The accordion to display. * @param width * the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance. * @param height * @param required * should it be marked with an asterisk. * @return The component in an horizontal layout. A blank in front and afterwards is inserted. */ public static synchronized HorizontalLayout create(final String label, final Accordion accordion, final int width, final int height, final boolean required) { final HorizontalLayout hor = new HorizontalLayout(); hor.setHeight(height + Constants.PX); hor.addComponent(new Label(" ")); final String text = Constants.P_ALIGN_RIGHT + label + Constants.P; Label l; hor.addComponent(l = new Label(text, Label.CONTENT_XHTML)); l.setSizeUndefined(); l.setWidth(width + Constants.PX); hor.setComponentAlignment(l, Alignment.MIDDLE_RIGHT); if (required) { hor.addComponent(new Label( " <span style=\"color:red; position:relative; top:" + (height / 2 - 13) + "px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } final Panel pan = new Panel(); pan.setSizeFull(); // Have it take all space available in the layout. accordion.setSizeFull(); // Some components to put in the Accordion. final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root>\n\t<X>\n\t\t<today>\n\t\t</today>\n\t\t<today/>\n\t\t<today/>\n\t</X>\n</root>"; for (int i = 0; i < 30; i++) { accordion.addTab(new Label(xml, Label.CONTENT_PREFORMATTED), "Tab" + i, null); } pan.addComponent(accordion); // pan.setSizeUndefined(); pan.setWidth(accordion.getWidth() + Constants.PX); // pan.setHeight("500px"); pan.setStyleName(Reindeer.PANEL_LIGHT); hor.addComponent(pan); hor.setComponentAlignment(pan, Alignment.MIDDLE_RIGHT); hor.addComponent(new Label(" ")); hor.setSpacing(false); return hor; }
From source file:de.escidoc.admintool.view.util.LayoutHelper.java
License:Open Source License
/** * Helper method. Puts a blank in front of a component. Two labels with different size in front of two components. * /*w w w . j a v a 2 s .c om*/ * @param labelLeft * the left (leading) label. * @param labelRight * the right (leading) label. * @param compLeft * the left component. * @param compRight * the right component. * @param widthLeft * the width of the left label. * @param widthRight * the width of the right label. * @param required * true if the component is required, otherwise false. * @return the customized component placed in a horizontal layout. */ public static synchronized HorizontalLayout create(final String labelLeft, final String labelRight, final Component compLeft, final Component compRight, final int widthLeft, final int widthRight, final boolean required) { // foo final HorizontalLayout hor = new HorizontalLayout(); hor.setHeight(Constants.DEFAULT_HEIGHT); hor.addComponent(new Label(" ")); final String text = Constants.P_ALIGN_RIGHT + labelLeft + Constants.P; Label ll, lr; hor.addComponent(ll = new Label(text, Label.CONTENT_XHTML)); ll.setSizeUndefined(); ll.setWidth(widthLeft + Constants.PX); hor.setComponentAlignment(ll, Alignment.MIDDLE_RIGHT); if (required) { hor.addComponent(new Label(" <span style=\"color:red; position:relative; top:13px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hor.addComponent(compLeft); hor.setComponentAlignment(compLeft, Alignment.BOTTOM_RIGHT); hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); final String text2 = Constants.P_ALIGN_RIGHT + labelRight + Constants.P; hor.addComponent(lr = new Label(text2, Label.CONTENT_XHTML)); lr.setSizeUndefined(); lr.setWidth(widthRight + Constants.PX); hor.setComponentAlignment(lr, Alignment.BOTTOM_RIGHT); if (required) { hor.addComponent(new Label(" <span style=\"color:red; position:relative; top:13px;\">*</span>", Label.CONTENT_XHTML)); } else { hor.addComponent(new Label(" ", Label.CONTENT_XHTML)); } hor.addComponent(compRight); hor.setComponentAlignment(compRight, Alignment.BOTTOM_RIGHT); hor.addComponent(new Label(" ")); hor.setSpacing(false); return hor; }