List of usage examples for com.vaadin.ui Window setWidth
@Override public void setWidth(String width)
From source file:org.escidoc.browser.ui.listeners.OnAddContainerMetadata.java
License:Open Source License
public void showAddWindow() { final Window subwindow = new Window(ViewConstants.ADD_CONTAINER_S_METADATA); subwindow.setWidth("600px"); subwindow.setModal(true);// w w w .ja v a 2 s . co m receiver = new MetadataFileReceiver(); // Make uploading start immediately when file is selected upload = new Upload("", receiver); upload.setImmediate(true); upload.setButtonCaption("Select file"); progressLayout.setSpacing(true); progressLayout.setVisible(false); progressLayout.addComponent(pi); progressLayout.setComponentAlignment(pi, Alignment.MIDDLE_LEFT); /** * =========== Add needed listener for the upload component: start, progress, finish, success, fail =========== */ upload.addListener(new Upload.StartedListener() { @Override public void uploadStarted(final StartedEvent event) { upload.setVisible(false); progressLayout.setVisible(true); pi.setValue(Float.valueOf(0f)); pi.setPollingInterval(500); status.setValue("Uploading file \"" + event.getFilename() + "\""); } }); upload.addListener(new Upload.SucceededListener() { @Override public void uploadSucceeded(final SucceededEvent event) { // This method gets called when the upload finished successfully status.setValue("Uploading file \"" + event.getFilename() + "\" succeeded"); final String fileContent = receiver.getFileContent(); final boolean isWellFormed = XmlUtil.isWellFormed(fileContent); receiver.setWellFormed(isWellFormed); if (isWellFormed) { status.setValue(ViewConstants.XML_IS_WELL_FORMED); hl.setVisible(true); upload.setEnabled(false); } else { status.setValue(ViewConstants.XML_IS_NOT_WELL_FORMED); hl.setVisible(false); } } }); upload.addListener(new Upload.FailedListener() { @Override public void uploadFailed(@SuppressWarnings("unused") final FailedEvent event) { // This method gets called when the upload failed status.setValue("Uploading interrupted"); } }); upload.addListener(new Upload.FinishedListener() { @Override public void uploadFinished(final FinishedEvent event) { // This method gets called always when the upload finished, // either succeeding or failing progressLayout.setVisible(false); upload.setVisible(true); upload.setCaption("Select another file"); } }); mdName = new TextField("Metadata name"); mdName.setValue(""); mdName.setImmediate(true); mdName.setValidationVisible(false); hl = new HorizontalLayout(); hl.setMargin(true); final Button btnAdd = new Button("Save", new Button.ClickListener() { Container container; private boolean containSpace(final String text) { final Pattern pattern = Pattern.compile("\\s"); final Matcher matcher = pattern.matcher(text); return matcher.find(); } @Override public void buttonClick(final ClickEvent event) { if (mdName.getValue().equals("")) { mdName.setComponentError(new UserError("You have to add a name for your MetaData")); } else if (containSpace(((String) mdName.getValue()))) { mdName.setComponentError(new UserError("The name of MetaData can not contain space")); } else { mdName.setComponentError(null); if (receiver.getFileContent().isEmpty()) { upload.setComponentError( new UserError("Please select a well formed XML file as metadata.")); } else if (!receiver.isWellFormed()) { upload.setComponentError(new UserError(ViewConstants.XML_IS_NOT_WELL_FORMED)); } else { final MetadataRecord metadataRecord = new MetadataRecord(mdName.getValue().toString()); try { container = repositories.container().findContainerById(resourceProxy.getId()); metadataRecord.setContent(getMetadataContent()); repositories.container().addMetaData(metadataRecord, container); upload.setEnabled(true); subwindow.getParent().removeWindow(subwindow); } catch (final EscidocClientException e) { LOG.error(e.getLocalizedMessage()); mdName.setComponentError(new UserError( "Failed to add the new Metadata record" + e.getLocalizedMessage())); } catch (final SAXException e) { LOG.error(e.getLocalizedMessage()); mdName.setComponentError(new UserError( "Failed to add the new Metadata record" + e.getLocalizedMessage())); } catch (final IOException e) { LOG.error(e.getLocalizedMessage()); mdName.setComponentError(new UserError( "Failed to add the new Metadata record" + e.getLocalizedMessage())); } catch (final ParserConfigurationException e) { LOG.error(e.getLocalizedMessage()); mdName.setComponentError(new UserError( "Failed to add the new Metadata record" + e.getLocalizedMessage())); } } } } private Element getMetadataContent() throws SAXException, IOException, ParserConfigurationException { return XmlUtil.string2Dom(receiver.getFileContent()).getDocumentElement(); } }); final Button cnclAdd = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); hl.addComponent(btnAdd); hl.addComponent(cnclAdd); subwindow.addComponent(mdName); subwindow.addComponent(status); subwindow.addComponent(upload); subwindow.addComponent(progressLayout); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); }
From source file:org.escidoc.browser.ui.listeners.OnContextAdminDescriptor.java
License:Open Source License
@SuppressWarnings("serial") public void adminDescriptorForm() { final Window subwindow = new Window("A modal subwindow"); subwindow.setModal(true);//from ww w . jav a2s . co m subwindow.setWidth("650px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); final TextField txtName = new TextField("Name"); txtName.setImmediate(true); txtName.setValidationVisible(true); final TextArea txtContent = new TextArea("Content"); txtContent.setColumns(30); txtContent.setRows(40); Button addAdmDescButton = new Button("Add Description"); addAdmDescButton.addListener(new ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { if (txtName.getValue().toString() == null) { router.getMainWindow().showNotification(ViewConstants.PLEASE_ENTER_A_NAME, Notification.TYPE_ERROR_MESSAGE); } else if (!XmlUtil.isWellFormed(txtContent.getValue().toString())) { router.getMainWindow().showNotification(ViewConstants.XML_IS_NOT_WELL_FORMED, Notification.TYPE_ERROR_MESSAGE); } else { AdminDescriptor newAdmDesc = controller.addAdminDescriptor(txtName.getValue().toString(), txtContent.getValue().toString()); (subwindow.getParent()).removeWindow(subwindow); router.getMainWindow().showNotification("Addedd Successfully", Notification.TYPE_HUMANIZED_MESSAGE); } } }); subwindow.addComponent(txtName); subwindow.addComponent(txtContent); subwindow.addComponent(addAdmDescButton); Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); router.getMainWindow().addWindow(subwindow); }
From source file:org.escidoc.browser.ui.listeners.OnContextAdminDescriptor.java
License:Open Source License
/** * Editing since it has a parameter//from ww w. ja v a 2 s .c om * * @param adminDescriptor */ public void adminDescriptorForm(AdminDescriptor adminDescriptor) { // Editing final Window subwindow = new Window("A modal subwindow"); subwindow.setModal(true); subwindow.setWidth("650px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); final TextField txtName = new TextField("Name"); txtName.setValue(adminDescriptor.getName()); txtName.setImmediate(true); txtName.setValidationVisible(true); final TextArea txtContent = new TextArea("Content"); txtContent.setColumns(30); txtContent.setRows(40); try { txtContent.setValue(adminDescriptor.getContentAsString()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } txtContent.setColumns(30); Button addAdmDescButton = new Button("Add Description"); addAdmDescButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (txtName.getValue().toString() == null) { router.getMainWindow().showNotification(ViewConstants.PLEASE_ENTER_A_NAME, Notification.TYPE_ERROR_MESSAGE); } else if (!XmlUtil.isWellFormed(txtContent.getValue().toString())) { router.getMainWindow().showNotification(ViewConstants.XML_IS_NOT_WELL_FORMED, Notification.TYPE_ERROR_MESSAGE); } else { controller.addAdminDescriptor(txtName.getValue().toString(), txtContent.getValue().toString()); (subwindow.getParent()).removeWindow(subwindow); router.getMainWindow().showNotification("Addedd Successfully", Notification.TYPE_HUMANIZED_MESSAGE); } } }); subwindow.addComponent(txtName); subwindow.addComponent(txtContent); subwindow.addComponent(addAdmDescButton); Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); router.getMainWindow().addWindow(subwindow); }
From source file:org.escidoc.browser.ui.listeners.OnEditContainerMetadata.java
License:Open Source License
private static Window buildModalWindow() { final Window subwindow = new Window(ViewConstants.EDIT_METADATA); subwindow.setWidth("600px"); subwindow.setModal(true);/* w w w.j a v a 2 s. co m*/ return subwindow; }
From source file:org.escidoc.browser.ui.listeners.RelationsClickListener.java
License:Open Source License
@Override public void buttonClick(final ClickEvent event) { final Window subwindow = new Window("Relations"); subwindow.setWidth("600px"); subwindow.setModal(true);//from w ww. j a v a 2 s .c o m String id = ""; if (event.getButton().getCaption().equals("Container Content Relations")) { id = containerProxy.getId(); } else if (event.getButton().getCaption().equals("Item Content Relations")) { id = itemProxy.getId(); } else { throw new RuntimeException("Bug: unexpected event button: " + event.getButton()); } try { content = getRelations(itemOrContainerRepository, id, subwindow); } catch (final EscidocClientException e) { content = new HorizontalLayout(); content.addComponent(new Label("No information available")); } subwindow.addComponent(content); if (subwindow.getParent() != null) { mainWindow.showNotification("Window is already open"); } else { mainWindow.addWindow(subwindow); } }
From source file:org.escidoc.browser.ui.listeners.VersionHistoryClickListener.java
License:Open Source License
@Override public void buttonClick(final ClickEvent event) { final Window subwindow = new Window("Version History"); subwindow.setWidth("600px"); subwindow.setModal(true);//from ww w. j ava 2 s .c o m // if (event.getButton().getCaption().equals("Container Version History") // || event.getButton().getCaption().equals(" Has previous version")) { // id = containerProxy.getId(); // } // else if (event.getButton().getCaption().equals("Item Version History") // || event.getButton().getCaption().equals(" Has previous versions")) { // id = itemProxy.getId(); // } // else { // throw new RuntimeException("Bug: unexpected event button: " + event.getButton()); // } try { wndContent = getVersionHistory(repository, id); } catch (final EscidocClientException e) { wndContent = "No information ?" + e.getMessage(); } final Label msgWindow = new Label(wndContent, Label.CONTENT_RAW); subwindow.addComponent(msgWindow); if (subwindow.getParent() != null) { mainWindow.showNotification("Window is already open"); } else { mainWindow.addWindow(subwindow); } }
From source file:org.escidoc.browser.ui.maincontent.ContainerMetadataRecordsView.java
License:Open Source License
@SuppressWarnings("serial") private Panel lblAddtionalResources() { final Panel pnl = new Panel(); pnl.setSizeFull();/*from w ww .jav a 2s.co m*/ VerticalLayout hl = new VerticalLayout(); hl.setSizeFull(); final Button btnVersionHistoryContainer = new Button("Container Version History", new VersionHistoryClickListener(resourceProxy, mainWindow, repositories)); btnVersionHistoryContainer.setStyleName(BaseTheme.BUTTON_LINK); btnVersionHistoryContainer.setDescription("Show Version history in a Pop-up"); final CssLayout cssLayout = new CssLayout(); buildPanelHeader(cssLayout, "Additional Resources"); ThemeResource ICON = new ThemeResource("images/assets/plus.png"); final Button addResourceButton = new Button(); addResourceButton.setStyleName(BaseTheme.BUTTON_LINK); addResourceButton.addStyleName("floatright paddingtop3"); addResourceButton.setWidth("20px"); addResourceButton.setIcon(ICON); addResourceButton.addListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final Window subwindow = new Window("A modal subwindow"); subwindow.setModal(true); subwindow.setWidth("650px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); subwindow.addComponent(new Label("Not yet implemented")); Button close = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); router.getMainWindow().addWindow(subwindow); } }); cssLayout.addComponent(addResourceButton); hl.addComponent(cssLayout); hl.addComponent(btnVersionHistoryContainer); pnl.setContent(hl); return pnl; }
From source file:org.escidoc.browser.ui.maincontent.ContextRightPanel.java
License:Open Source License
@SuppressWarnings("serial") private Panel buildOrganizationUnit() { final Panel pnlOrgUnit = new Panel(); pnlOrgUnit.setSizeFull();//from w w w .jav a2 s .c om VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); final CssLayout cssLayout = new CssLayout(); buildPanelHeader(cssLayout, ViewConstants.ORGANIZATIONAL_UNIT); ThemeResource ICON = new ThemeResource("images/assets/plus.png"); if (contextController.canAddOUs()) { final Button addResourceButton = new Button(); addResourceButton.setStyleName(BaseTheme.BUTTON_LINK); addResourceButton.addStyleName("floatright paddingtop3"); addResourceButton.setWidth("20px"); addResourceButton.setIcon(ICON); addResourceButton.addListener(new ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) { final Window subwindow = new Window("A modal subwindow"); subwindow.setModal(true); subwindow.setWidth("650px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); try { subwindow.addComponent(new AddOrgUnitstoContext(router, resourceProxy, contextController, resourceProxy.getOrganizationalUnit())); } catch (EscidocClientException e) { contextController.showError(e); } Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { subwindow.getParent().removeWindow(subwindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); router.getMainWindow().addWindow(subwindow); } }); cssLayout.addComponent(addResourceButton); } vl.addComponent(cssLayout); OrganizationalUnitsTableVH orgUnitTable = new OrganizationalUnitsTableVH(contextController, resourceProxy.getOrganizationalUnit(), router, resourceProxy); orgUnitTable.buildTable(); vl.addComponent(orgUnitTable); vl.setComponentAlignment(orgUnitTable, Alignment.TOP_LEFT); vl.setExpandRatio(orgUnitTable, 9f); pnlOrgUnit.setContent(vl); return pnlOrgUnit; }
From source file:org.escidoc.browser.ui.maincontent.ItemContent.java
License:Open Source License
private void initView() { final CssLayout cssLayout = new CssLayout(); cssLayout.setHeight("20px"); buildPanelHeader(cssLayout, ViewConstants.COMPONENTS); ThemeResource ICON = new ThemeResource("images/assets/plus.png"); if (true) {/*from w w w.j av a 2s . com*/ final Button btnAddNew = new Button(); btnAddNew.addListener(new Button.ClickListener() { @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { Window modalWindow = new Window("Select a file to add."); modalWindow.setWidth("25%"); modalWindow.setHeight("20%"); modalWindow.setModal(true); modalWindow.addComponent(new ComponentUploadView(repositories, controller, itemProxy, ItemContent.this, mainWindow)); mainWindow.addWindow(modalWindow); } }); btnAddNew.setStyleName(BaseTheme.BUTTON_LINK); btnAddNew.addStyleName("floatright paddingtop3"); btnAddNew.setWidth("20px"); btnAddNew.setIcon(ICON); cssLayout.addComponent(btnAddNew); } verticalLayout.addComponent(cssLayout); wrap(verticalLayout); if (controller.hasComponents()) { verticalLayout.addComponent(buildTable()); } else { final Label lblNoComponents = new Label( "No components in this Item. You can drag n'drop some file from your computer to this box to add new components!"); lblNoComponents.setWidth("90%"); lblNoComponents.setStyleName("skybluetext"); verticalLayout.addComponent(lblNoComponents); } }
From source file:org.escidoc.browser.ui.maincontent.OnAddOrgUnitMetadata.java
License:Open Source License
public void showAddWindow() { final Window subwindow = new Window(ViewConstants.ADD_ORGANIZATIONAL_UNIT_S_METADATA); subwindow.setWidth("600px"); subwindow.setModal(true);// w ww .ja v a 2 s . co m // Make uploading start immediately when file is selected final Upload upload = new Upload("", receiver); upload.setImmediate(true); upload.setButtonCaption("Select file"); progressLayout.setSpacing(true); progressLayout.setVisible(false); final ProgressIndicator pi = new ProgressIndicator(); progressLayout.addComponent(pi); progressLayout.setComponentAlignment(pi, Alignment.MIDDLE_LEFT); /** * =========== Add needed listener for the upload component: start, progress, finish, success, fail =========== */ upload.addListener(new Upload.StartedListener() { @Override public void uploadStarted(final StartedEvent event) { upload.setVisible(false); progressLayout.setVisible(true); pi.setValue(Float.valueOf(0f)); pi.setPollingInterval(500); status.setValue("Uploading file \"" + event.getFilename() + "\""); } }); upload.addListener(new Upload.SucceededListener() { @Override public void uploadSucceeded(final SucceededEvent event) { // This method gets called when the upload finished successfully status.setValue("Uploading file \"" + event.getFilename() + "\" succeeded"); final String fileContent = receiver.getFileContent(); final boolean isWellFormed = XmlUtil.isWellFormed(fileContent); receiver.setWellFormed(isWellFormed); if (isWellFormed) { status.setValue(ViewConstants.XML_IS_WELL_FORMED); hl.setVisible(true); upload.setEnabled(false); } else { status.setValue(ViewConstants.XML_IS_NOT_WELL_FORMED); hl.setVisible(false); } } }); upload.addListener(new Upload.FailedListener() { @Override public void uploadFailed(final FailedEvent event) { // This method gets called when the upload failed status.setValue("Uploading interrupted"); } }); upload.addListener(new Upload.FinishedListener() { @Override public void uploadFinished(final FinishedEvent event) { // This method gets called always when the upload finished, // either succeeding or failing progressLayout.setVisible(false); upload.setVisible(true); upload.setCaption("Select another file"); } }); mdName = new TextField("Metadata name"); mdName.setValue(""); mdName.setImmediate(true); mdName.setValidationVisible(false); hl = new HorizontalLayout(); hl.setMargin(true); final Button btnAdd = new Button("Save", new Button.ClickListener() { private boolean containSpace(final String text) { final Pattern pattern = Pattern.compile("\\s"); final Matcher matcher = pattern.matcher(text); return matcher.find(); } @Override public void buttonClick(final ClickEvent event) { if (mdName.getValue().equals("")) { mdName.setComponentError(new UserError("You have to add a name for your MetaData")); } else if (containSpace(((String) mdName.getValue()))) { mdName.setComponentError(new UserError("The name of MetaData can not contain space")); } else { mdName.setComponentError(null); if (receiver.getFileContent().isEmpty()) { upload.setComponentError( new UserError("Please select a well formed XML file as metadata.")); } else if (!receiver.isWellFormed()) { upload.setComponentError(new UserError(ViewConstants.XML_IS_NOT_WELL_FORMED)); } else { final MetadataRecord metadataRecord = new MetadataRecord(mdName.getValue().toString()); try { metadataRecord.setContent(getMetadataContent()); controller.addMetaData(metadataRecord); controller.refreshView(); upload.setEnabled(true); subwindow.getParent().removeWindow(subwindow); } catch (final SAXException e) { LOG.error(e.getMessage()); mdName.setComponentError(new UserError( "Failed to add the new Metadata record" + e.getLocalizedMessage())); } catch (final IOException e) { LOG.error(e.getMessage()); mdName.setComponentError(new UserError( "Failed to add the new Metadata record" + e.getLocalizedMessage())); } catch (final ParserConfigurationException e) { LOG.error(e.getMessage()); mdName.setComponentError(new UserError( "Failed to add the new Metadata record" + e.getLocalizedMessage())); } } } } private Element getMetadataContent() throws SAXException, IOException, ParserConfigurationException { final String fileContent = receiver.getFileContent(); return XmlUtil.string2Dom(fileContent).getDocumentElement(); } }); final Button cnclAdd = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); hl.addComponent(btnAdd); hl.addComponent(cnclAdd); subwindow.addComponent(mdName); subwindow.addComponent(status); subwindow.addComponent(upload); subwindow.addComponent(progressLayout); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); }