List of usage examples for com.vaadin.ui Window getParent
@Override
public HasComponents getParent()
From source file:org.escidoc.browser.ui.listeners.ResourceDeleteConfirmation.java
License:Open Source License
private void delete(final Container container, final ContainerRepository containerRepository, final Window mainWindow) { final Window subwindow = new Window(ViewConstants.DELETE_RESOURCE_WINDOW_NAME); subwindow.setModal(true);/* w ww . j a v a 2 s .c o m*/ final Label message = new Label(ViewConstants.QUESTION_DELETE_RESOURCE); subwindow.addComponent(message); @SuppressWarnings("serial") final Button okConfirmed = new Button("Yes", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); try { containerRepository.finalDelete(container); mainWindow.showNotification( new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION)); } catch (final EscidocClientException e) { mainWindow.showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); } } }); @SuppressWarnings("serial") final Button cancel = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); final HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(okConfirmed); hl.addComponent(cancel); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); }
From source file:org.escidoc.browser.ui.listeners.ResourceDeleteConfirmation.java
License:Open Source License
private void delete(final Item item, final ItemRepository itemRepository, final Window mainWindow) throws EscidocClientException { final Window subwindow = new Window(ViewConstants.DELETE_RESOURCE_WINDOW_NAME); subwindow.setModal(true);/*from w ww . j a v a 2s . c o m*/ Label message = new Label(ViewConstants.QUESTION_DELETE_RESOURCE); subwindow.addComponent(message); @SuppressWarnings("serial") Button okConfirmed = new Button("Yes", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); try { itemRepository.finalDelete(item); mainWindow.showNotification( new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION)); } catch (EscidocClientException e) { mainWindow.showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); } } }); @SuppressWarnings("serial") Button cancel = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(okConfirmed); hl.addComponent(cancel); subwindow.addComponent(hl); 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);// w w w .j ava2 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();/* w w w. j a v a 2 s .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 ww . j a v a 2 s . c o m*/ 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.ContextView.java
License:Open Source License
/** * Called in the reSwapComponents()/*from ww w .j a v a2s . c om*/ * * @return String */ public void addCommentWindow(final String status) { final Window subwindow = new Window(ViewConstants.SUBWINDOW_EDIT); subwindow.setModal(true); // Configure the windws layout; by default a VerticalLayout VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeUndefined(); final TextArea editor = new TextArea("Your Comment"); editor.setRequired(true); editor.setRequiredError("The Field may not be empty."); HorizontalLayout hl = new HorizontalLayout(); Button close = new Button("Update", new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") com.vaadin.ui.Button.ClickEvent event) { // close the window by removing it from the parent window String comment = editor.getValue().toString(); try { contextController.updatePublicStatus(status, resourceProxy.getId(), comment); mainWindow.showNotification("Context Status updated successfully", Notification.TYPE_TRAY_NOTIFICATION); } catch (EscidocClientException e) { mainWindow.showNotification( "Could not update Context Type, an error occurred" + e.getLocalizedMessage(), Notification.TYPE_ERROR_MESSAGE); } (subwindow.getParent()).removeWindow(subwindow); } }); Button cancel = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") com.vaadin.ui.Button.ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); hl.addComponent(close); hl.addComponent(cancel); subwindow.addComponent(editor); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); }
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);/*from w w w. j ava2 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); }
From source file:org.escidoc.browser.ui.maincontent.ParentsView.java
License:Open Source License
@SuppressWarnings("serial") private Component buildParentsList() { // ViewConstants.PARENTS final Panel panel = new Panel(); panel.setSizeFull();//from www . j a va 2 s . c o m panel.setStyleName(Runo.PANEL_LIGHT); VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); final CssLayout cssLayout = new CssLayout(); cssLayout.setHeight("20px"); buildPanelHeader(cssLayout, ViewConstants.PARENTS); ThemeResource ICON = new ThemeResource("images/assets/plus.png"); Button btnAdd = new Button(); btnAdd.setStyleName(BaseTheme.BUTTON_LINK); btnAdd.addStyleName("floatright paddingtop3"); btnAdd.setWidth("20px"); btnAdd.setIcon(ICON); btnAdd.addListener(new Button.ClickListener() { @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { final Window subwindow = new Window("Manage Organizational Unit Parents"); subwindow.setModal(true); subwindow.setWidth("650px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); try { subwindow.addComponent(new OrgUnitParentEditView(orgUnitProxy, orgUnitProxy.getParentList(), router, orgUnitController)); } catch (EscidocClientException e) { orgUnitController.showError(e); } Button close = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") com.vaadin.ui.Button.ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); mainWindow.addWindow(subwindow); } }); cssLayout.addComponent(btnAdd); vl.addComponent(cssLayout); List<ResourceModel> l = orgUnitProxy.getParentList(); OUParentTableVH parentTable = new OUParentTableVH(orgUnitProxy, router, orgUnitController); parentTable.buildTable(); vl.addComponent(parentTable); vl.setExpandRatio(parentTable, 9f); // TODO here comes table panel.setContent(vl); return panel; }
From source file:org.escidoc.browser.ui.navigation.ActionHandlerImpl.java
License:Open Source License
private void deleteResource(final ResourceModel target, final String id, final Object sender) { final Window subwindow = buildSubWindow(); final Button okConfirmed = new Button(ViewConstants.YES, new Button.ClickListener() { @Override//w ww . j a v a 2 s. co m public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); try { repositories.user().delete(id); router.getLayout().closeView(target, null, sender); mainWindow.showNotification( new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION)); } catch (final EscidocClientException e) { mainWindow.showNotification( new Window.Notification(ViewConstants.ERROR + " trying to delete user", e.getLocalizedMessage(), Notification.TYPE_ERROR_MESSAGE)); } } }); final Button cancel = new Button(ViewConstants.CANCEL, new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); final HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(okConfirmed); hl.addComponent(cancel); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); }
From source file:org.escidoc.browser.ui.navigation.ActionHandlerImpl.java
License:Open Source License
private void deleteContentModel(final ResourceModel model, final String cmId, final Object sender) { final Window subwindow = buildSubWindow(); final Button okConfirmed = new Button(ViewConstants.YES, new Button.ClickListener() { @Override// w w w. j av a 2 s.co m public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); try { repositories.contentModel().delete(cmId); router.getLayout().closeView(model, null, sender); mainWindow.showNotification( new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION)); } catch (final EscidocClientException e) { mainWindow.showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); } } }); final Button cancel = new Button(ViewConstants.CANCEL, new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); final HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(okConfirmed); hl.addComponent(cancel); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); }