List of usage examples for com.vaadin.ui Button addListener
@Override
public Registration addListener(Component.Listener listener)
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();// w w w. j a v a 2s.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.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) {/*w w w.j a v a 2 s . c om*/ 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.MetadataRecsItem.java
License:Open Source License
private Panel lblMetadaRecs() { pnl.setSizeFull();//from w w w . j a v a2s .co m VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); final CssLayout cssLayout = new CssLayout(); cssLayout.setHeight("20px"); buildPanelHeader(cssLayout, ViewConstants.METADATA); ThemeResource ICON = new ThemeResource("images/assets/plus.png"); ItemMetadataTable metadataItem = new ItemMetadataTable(itemController, router, resourceProxy, repositories); metadataItem.buildTable(); if (itemController.hasAccess()) { final Button btnAddNew = new Button(); btnAddNew.addListener(new AddMetaDataFileItemBehaviour(mainWindow, repositories, resourceProxy)); btnAddNew.setStyleName(BaseTheme.BUTTON_LINK); btnAddNew.addStyleName("floatright paddingtop3"); btnAddNew.setWidth("20px"); btnAddNew.setIcon(ICON); cssLayout.addComponent(btnAddNew); } vl.addComponent(cssLayout); vl.addComponent(metadataItem); vl.setExpandRatio(metadataItem, 9f); pnl.setContent(vl); return pnl; }
From source file:org.escidoc.browser.ui.maincontent.OrgUnitMetadataRecordsView.java
License:Open Source License
@SuppressWarnings("serial") private Component buildMetaDataTab() { Panel innerPanel = new Panel(); innerPanel.setSizeFull();/*ww w.j a v a 2s. co m*/ VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); final CssLayout cssLayout = new CssLayout(); cssLayout.setHeight("20px"); buildPanelHeader(cssLayout, ViewConstants.METADATA); ThemeResource ICON = new ThemeResource("images/assets/plus.png"); if (canAddMetadata()) { final Button addNewOrgUnitBtn = new Button(); addNewOrgUnitBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { OnAddOrgUnitMetadata view = new OnAddOrgUnitMetadata(controller, router.getMainWindow()); view.showAddWindow(); } }); addNewOrgUnitBtn.setStyleName(BaseTheme.BUTTON_LINK); addNewOrgUnitBtn.addStyleName("floatright paddingtop3"); addNewOrgUnitBtn.setWidth("20px"); addNewOrgUnitBtn.setIcon(ICON); cssLayout.addComponent(addNewOrgUnitBtn); } vl.addComponent(cssLayout); OrgUnitMetadataTable metadataTable = new OrgUnitMetadataTable(orgUnit.getMetadataRecords(), controller, router); metadataTable.buildTable(); vl.addComponent(metadataTable); vl.setExpandRatio(metadataTable, 9); innerPanel.setContent(vl); return innerPanel; }
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 ww w. j av a 2 s .com*/ 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.maincontent.ResourceAddViewImpl.java
License:Open Source License
@SuppressWarnings("serial") private void addMetaData() { addResourceForm.addComponent(status); addResourceForm.addComponent(upload); addResourceForm.addComponent(progressLayout); // Make uploading start immediately when file is selected upload.setImmediate(true);//from w w w .j a v a2s . com upload.setButtonCaption(ViewConstants.SELECT_FILE); progressLayout.setSpacing(true); progressLayout.setVisible(false); progressLayout.addComponent(progressIndicator); progressLayout.setComponentAlignment(progressIndicator, Alignment.MIDDLE_LEFT); final Button cancelProcessing = new Button("Cancel"); cancelProcessing.addListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { upload.interruptUpload(); } }); cancelProcessing.setStyleName("small"); progressLayout.addComponent(cancelProcessing); /** * =========== Add needed listener for the upload component: start, progress, finish, success, fail =========== */ upload.addListener(new Upload.StartedListener() { @Override public void uploadStarted(final StartedEvent event) { // This method gets called immediately after upload is started upload.setVisible(false); progressLayout.setVisible(true); progressIndicator.setValue(Float.valueOf(0f)); progressIndicator.setPollingInterval(500); status.setValue("Uploading file \"" + event.getFilename() + "\""); } }); upload.addListener(new Upload.ProgressListener() { @Override public void updateProgress(final long readBytes, final long contentLength) { // This method gets called several times during the update progressIndicator.setValue(new Float(readBytes / (float) contentLength)); } }); 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 boolean isWellFormed = XmlUtil.isWellFormed(receiver.getFileContent()); receiver.setWellFormed(isWellFormed); if (isWellFormed) { status.setValue(ViewConstants.XML_IS_WELL_FORMED); setMetaData(receiver.getFileContent()); upload.setEnabled(false); } else { status.setValue(ViewConstants.XML_IS_NOT_WELL_FORMED); } } }); 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"); } }); }
From source file:org.escidoc.browser.ui.navigation.menubar.ItemAddView.java
License:Open Source License
@SuppressWarnings("serial") private void addMetaData() { // Slow down the upload receiver.setSlow(true);/*from w w w. j a va 2 s .com*/ addForm.addComponent(status); addForm.addComponent(upload); addForm.addComponent(progressLayout); // Make uploading start immediately when file is selected upload.setImmediate(true); upload.setButtonCaption("Select file"); progressLayout.setSpacing(true); progressLayout.setVisible(false); progressLayout.addComponent(progressIndicator); progressLayout.setComponentAlignment(progressIndicator, Alignment.MIDDLE_LEFT); final Button cancelProcessing = new Button("Cancel"); cancelProcessing.addListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { upload.interruptUpload(); } }); cancelProcessing.setStyleName("small"); progressLayout.addComponent(cancelProcessing); /** * =========== Add needed listener for the upload component: start, progress, finish, success, fail =========== */ upload.addListener(new Upload.StartedListener() { @Override public void uploadStarted(final StartedEvent event) { // This method gets called immediately after upload is started upload.setVisible(false); progressLayout.setVisible(true); progressIndicator.setValue(Float.valueOf(0f)); progressIndicator.setPollingInterval(500); status.setValue("Uploading file \"" + event.getFilename() + "\""); } }); upload.addListener(new Upload.ProgressListener() { @Override public void updateProgress(final long readBytes, final long contentLength) { // This method gets called several times during the update progressIndicator.setValue(new Float(readBytes / (float) contentLength)); } }); 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 boolean isWellFormed = XmlUtil.isWellFormed(receiver.getFileContent()); receiver.setWellFormed(isWellFormed); if (isWellFormed) { status.setValue(ViewConstants.XML_IS_WELL_FORMED); } else { status.setValue(ViewConstants.XML_IS_NOT_WELL_FORMED); } } }); 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"); } }); }
From source file:org.escidoc.browser.ui.tools.BulkTasksView.java
License:Open Source License
private void addResult() { final HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setWidth("100%"); horizontalLayout.setSpacing(true);/* ww w.java 2s. c o m*/ textField.setWidth("100%"); createResourceOptions(); final Button filterButton = new Button(ViewConstants.FILTER); filterButton.setStyleName(Reindeer.BUTTON_SMALL); filterButton.addListener(new FilterButtonListener(this, router.getMainWindow(), repositories)); horizontalLayout.addComponent(resourceOption); horizontalLayout.addComponent(createHelpView()); horizontalLayout.addComponent(textField); horizontalLayout.addComponent(filterButton); horizontalLayout.setExpandRatio(textField, 1.0f); addComponent(horizontalLayout); }
From source file:org.escidoc.browser.ui.tools.FilterButtonListener.java
License:Open Source License
private void showDeleteView() { buttonLayout.setSpacing(true);//from www. j ava 2s .c om final Button deleteButton = new Button(ViewConstants.DELETE); deleteButton.setStyleName(Reindeer.BUTTON_SMALL); buttonLayout.addComponent(deleteButton); deleteButton.addListener(new BulkDeleteListener(this, repositories, mainWindow, resultDataSource)); }
From source file:org.escidoc.browser.ui.tools.FilterButtonListener.java
License:Open Source License
private void showExportView() { buttonLayout.setSpacing(true);//w w w . ja v a 2 s . c o m final Button exportButton = new Button(ViewConstants.EXPORT); exportButton.setStyleName(Reindeer.BUTTON_SMALL); buttonLayout.addComponent(exportButton); exportButton.addListener(new ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) { final Set<ResourceModel> selectedResources = getSelectedResources(); mainWindow.open(new StreamResource(new StreamSource() { @Override public InputStream getStream() { try { return zip(selectedResources); } catch (final IOException e) { FilterButtonListener.this.bulkTasksView.showErrorMessage(e); } catch (final EscidocClientException e) { FilterButtonListener.this.bulkTasksView.showErrorMessage(e); } return null; } }, EXPORT_FILENAME, FilterButtonListener.this.bulkTasksView.router.getApp()), "_blank"); } }); }