List of usage examples for com.vaadin.server Page getCurrent
public static Page getCurrent()
From source file:org.apache.openaz.xacml.admin.view.components.LDAPPIPConfigurationComponent.java
License:Apache License
protected void testLDAPConnection() { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, this.textFieldFactory.getValue()); env.put(Context.PROVIDER_URL, this.textFieldProviderURL.getValue()); env.put(Context.SECURITY_PRINCIPAL, this.textFieldPrincipal.getValue()); env.put(Context.SECURITY_CREDENTIALS, this.textFieldCredentials.getValue()); String auth = this.comboBoxAuthentication.getValue().toString(); env.put(Context.SECURITY_AUTHENTICATION, auth); ///*from ww w .ja va 2s. c o m*/ // Do we need to do anything? // /* if (auth.equals(LDAP_AUTH_ANONYMOUS)) { } else if (auth.equals(LDAP_AUTH_SIMPLE)) { } else if (auth.equals(LDAP_AUTH_SASL)) { } */ DirContext ctx = null; try { ctx = new InitialDirContext(env); new Notification("Success!", "Connection Established!", Type.HUMANIZED_MESSAGE, true) .show(Page.getCurrent()); } catch (NamingException e) { logger.error(e); new Notification("Connection Failed", "<br/>" + e.getLocalizedMessage(), Type.ERROR_MESSAGE, true) .show(Page.getCurrent()); } finally { try { if (ctx != null) { ctx.close(); } } catch (NamingException idontcare) { //NOPMD } } }
From source file:org.apache.openaz.xacml.admin.view.components.SQLPIPConfigurationComponent.java
License:Apache License
protected void testJNDIConnection() { try {//ww w . j a va 2 s . c om Context initialContext = new InitialContext(); DataSource dataSource = (DataSource) initialContext.lookup(this.textFieldDataSource.getValue()); try (Connection connection = dataSource.getConnection()) { new Notification("Success!", "Connection Established!", Type.HUMANIZED_MESSAGE, true) .show(Page.getCurrent()); } } catch (NamingException e) { logger.error(e); new Notification("JNDI Naming Exception", "<br/>" + e.getLocalizedMessage() + "<br/>Is the context defined in this J2EE Container instance?", Type.ERROR_MESSAGE, true).show(Page.getCurrent()); } catch (SQLException e) { logger.error(e); new Notification("SQL Exception", "<br/>" + e.getLocalizedMessage() + "<br/>Are the configuration parameters correct?", Type.ERROR_MESSAGE, true).show(Page.getCurrent()); } }
From source file:org.apache.openaz.xacml.admin.view.components.SQLPIPConfigurationComponent.java
License:Apache License
protected void testJDBCConnection() { try {/* w w w . ja va 2s . c o m*/ if (this.comboBoxSQLDriver.getValue() != null) { Class.forName(this.comboBoxSQLDriver.getValue().toString()); } else { throw new ClassNotFoundException("Please select a JDBC driver to load."); } } catch (ClassNotFoundException e) { logger.error(e); new Notification("Driver Exception", "<br/>" + e.getLocalizedMessage() + "<br/>Is the JDBC driver's jar in the J2EE container path?", Type.ERROR_MESSAGE, true).show(Page.getCurrent()); return; } Connection connection = null; try { connection = DriverManager.getConnection(this.textFieldConnectionURL.getValue(), this.textFieldUser.getValue(), this.textFieldPassword.getValue()); new Notification("Success!", "Connection Established!", Type.HUMANIZED_MESSAGE, true) .show(Page.getCurrent()); } catch (SQLException e) { logger.error(e); new Notification("SQL Exception", "<br/>" + e.getLocalizedMessage() + "<br/>Are the configuration parameters correct?", Type.ERROR_MESSAGE, true).show(Page.getCurrent()); } finally { if (connection != null) { try { connection.close(); } catch (SQLException idontcare) { //NOPMD } } } }
From source file:org.apache.tamaya.ui.components.PageTitleUpdater.java
License:Apache License
@Override public void afterViewChange(ViewChangeEvent event) { View view = event.getNewView(); String displayName = ServiceContextManager.getServiceContext().getService(MessageProvider.class) .getMessage("view." + view.getClass().getSimpleName() + ".name"); if (displayName != null) { Page.getCurrent().setTitle(displayName); }//from w w w . j a va2 s . c o m }
From source file:org.apache.tamaya.ui.TamayaUI.java
License:Apache License
@Subscribe public void logout(LogoutEvent logoutEvent) { // Don't invalidate the underlying HTTP session if you are using it for something else VaadinSession.getCurrent().getSession().invalidate(); VaadinSession.getCurrent().close();//from w ww . jav a 2s . co m Page.getCurrent().reload(); }
From source file:org.azrul.langkuik.framework.customtype.attachment.AttachmentCustomTypeUICreator.java
@Override public Component createUIForForm(final C currentBean, final Class<? extends CustomType> attachmentClass, final String pojoFieldName, final BeanView beanView, final DataAccessObject<C> conatainerClassDao, final DataAccessObject<? extends CustomType> customTypeDao, final RelationManagerFactory relationManagerFactory, final Configuration config, final ComponentState componentState, final Window window) { final FormLayout form = new FormLayout(); final DataAccessObject<AttachmentCustomType> attachmentDao = ((DataAccessObject<AttachmentCustomType>) customTypeDao); final Collection<AttachmentCustomType> attachments = attachmentDao.find(currentBean, pojoFieldName, null, true, 0, Integer.parseInt(config.get("uploadCountLimit"))); final WebEntityItemContainer attachmentIC = new WebEntityItemContainer(attachmentClass); if (!attachments.isEmpty()) { attachmentIC.addAll(attachments); }//from www.j a va 2 s .c o m final ListSelect attachmentList = new ListSelect("", attachmentIC); createAtachmentList(attachmentList, attachments, config, beanView, form); final String relativePath = currentBean.getClass().getCanonicalName() + File.separator + conatainerClassDao.getIdentifierValue(currentBean); final String fullPath = config.get("attachmentRepository") + File.separator + relativePath; MyUploadHandler<C> uploadFinishHandler = new MyUploadHandler<>(currentBean, Integer.parseInt(config.get("uploadCountLimit").trim()), pojoFieldName, fullPath, relativePath, attachmentList, attachmentIC, customTypeDao, attachmentClass, relationManagerFactory); //File upload/download/delete buttons HorizontalLayout attachmentButtons = new HorizontalLayout(); attachmentButtons.setSpacing(true); UploadStateWindow uploadStateWindow = new UploadStateWindow(); MultiFileUpload fileUpload = new MultiFileUpload(uploadFinishHandler, uploadStateWindow); uploadFinishHandler.setFileUpload(fileUpload); fileUpload.getSmartUpload().setEnabled(true); fileUpload.getSmartUpload().setMaxFileSize(Integer.parseInt(config.get("uploadSizeLimit").trim())); fileUpload.getSmartUpload().setUploadButtonCaptions("Upload files", "Upload files"); fileUpload.getSmartUpload().setId("Upload files"); fileUpload.setId("Upload files2"); Button deleteAttachmentBtn = new Button("Delete file", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList .getValue(); if (!attachments.isEmpty()) { customTypeDao.unlinkAndDelete(attachments, currentBean, pojoFieldName, relationManagerFactory.create(currentBean.getClass(), attachmentClass)); Collection<AttachmentCustomType> a = attachmentDao.find(currentBean, pojoFieldName, null, true, 0, Integer.parseInt(config.get("uploadCountLimit"))); attachmentIC.removeAllItems(); attachmentIC.addAll(a); attachmentIC.refreshItems(); } } }); deleteAttachmentBtn.setId(deleteAttachmentBtn.getCaption()); Button downloadAttachmentBtn = new Button("Download file", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList .getValue(); if (!attachments.isEmpty()) { AttachmentCustomType attachment = attachments.iterator().next(); final String fullPath = config.get("attachmentRepository") + File.separator + attachment.getRelativeLocation() + File.separator + attachment.getFileName(); FileResource res = new FileResource(new File(fullPath)); beanView.setViewResource("DOWNLOAD", res); ResourceReference rr = ResourceReference.create(res, beanView, "DOWNLOAD"); Page.getCurrent().open(rr.getURL(), null); } } }); downloadAttachmentBtn.setId(downloadAttachmentBtn.getCaption()); Button closeWindowBtn = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { window.close(); } }); closeWindowBtn.setId(closeWindowBtn.getCaption()); if (componentState.equals(ComponentState.EDITABLE)) { attachmentButtons.addComponent(fileUpload); attachmentButtons.addComponent(deleteAttachmentBtn); } if (componentState.equals(ComponentState.EDITABLE) || componentState.equals(ComponentState.READ_ONLY)) { attachmentButtons.addComponent(downloadAttachmentBtn); } attachmentButtons.addComponent(closeWindowBtn); form.addComponent(attachmentButtons); form.setMargin(true); //beanView.addComponent(form); return form; }
From source file:org.azrul.langkuik.framework.customtype.attachment.AttachmentCustomTypeUICreator.java
private void createAtachmentList(final ListSelect attachmentList, final Collection<? extends CustomType> attachments, final Configuration config, final BeanView view, final FormLayout form) { attachmentList.setHeight(attachments.size() + 2, Sizeable.Unit.EM); attachmentList.setMultiSelect(true); VerticalLayout attachmentListCont = new VerticalLayout(); attachmentListCont.setCaption("Attachments"); attachmentListCont.addComponent(attachmentList); attachmentListCont.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override/*from w w w. j av a 2 s . c o m*/ public void layoutClick(LayoutEvents.LayoutClickEvent event) { if (event.getClickedComponent() == null) { return; } if (event.getClickedComponent().equals(attachmentList)) { Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList .getValue(); if (!attachments.isEmpty()) { AttachmentCustomType attachment = attachments.iterator().next(); final String fullPath = config.get("attachmentRepository") + File.separator + attachment.getRelativeLocation() + File.separator + attachment.getFileName(); FileResource res = new FileResource(new File(fullPath)); view.setViewResource("DOWNLOAD", res); ResourceReference rr = ResourceReference.create(res, view, "DOWNLOAD"); Page.getCurrent().open(rr.getURL(), null); } } } }); form.addComponent(attachmentListCont); }
From source file:org.bubblecloud.ilves.site.view.valo.DefaultValoView.java
License:Apache License
/** * {@inheritDoc}//from www. j ava 2s . com */ @Override protected void initializeComponents() { final AbstractComponent contentComponent = getComponent("content"); final AbstractComponent footerComponent = getComponent("footer"); if (Page.getCurrent().getWebBrowser().isIE() && Page.getCurrent().getWebBrowser().getBrowserMajorVersion() == 9) { menu.setWidth("320px"); } Responsive.makeResponsive(UI.getCurrent()); setWidth("100%"); addMenu(buildMenu()); getContentContainer().addComponent(contentComponent); if (footerComponent != null) { getContentContainer().addComponent(footerComponent); } }
From source file:org.dussan.vaadin.dcharts.test.DChartsTestUI.java
License:Apache License
private void showEventNotification(String event, Object chartObject) { String caption = "<span style='color:#ff6600'>Event: " + event + "</span>"; StringBuilder description = new StringBuilder(); if (chartObject instanceof ChartData) { ChartData chartData = (ChartData) chartObject; description.append("<b>Chart id:</b> " + chartData.getChartId()); if (chartData.getSeriesIndex() != null) { description.append("<br /><b>Series index:</b> " + chartData.getSeriesIndex()); }//from w ww. j a v a 2s . c o m if (chartData.getPointIndex() != null) { description.append("<br /><b>Point index:</b> " + chartData.getPointIndex()); } if (chartData.getData() != null) { description.append("<br /><b>Chart data:</b> " + Arrays.toString(chartData.getData())); } if (chartData.getOriginData() != null) { if (chartData.getOriginData() instanceof Object[]) { description.append( "<br /><b>Origin data:</b> " + Arrays.toString((Object[]) chartData.getOriginData())); } else { description.append("<br /><b>Origin data:</b> " + chartData.getOriginData().toString()); } } } else if (chartObject instanceof BufferedImage) { BufferedImage chartImage = (BufferedImage) chartObject; description.append("<b>Chart image width:</b> " + chartImage.getWidth() + "px"); description.append("<br /><b>Chart image height:</b> " + chartImage.getHeight() + "px"); } Notification notification = new Notification(caption, description.toString(), Type.TRAY_NOTIFICATION); notification.setDelayMsec(3000); notification.setHtmlContentAllowed(true); notification.show(Page.getCurrent()); }
From source file:org.dussan.vaadin.dcharts.test.DChartsTestUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); layout.setSizeFull();//from w w w.j a v a 2s . c om setContent(layout); Page.getCurrent().setTitle("dCharts Application"); DCharts charts1 = chartsDemo1(); DCharts charts2 = chartsDemo2(); DCharts charts3_1 = chartsDemo3_1(); DCharts charts3_2 = chartsDemo3_2(); DCharts charts4 = chartsDemo4(); DCharts charts5 = chartsDemo5(); DCharts charts6 = chartsDemo6(); DCharts charts7 = chartsDemo7(); DCharts charts8 = chartsDemo8(); HorizontalLayout layout3 = new HorizontalLayout(); layout3.addComponent(charts3_1); layout3.addComponent(charts3_2); TabSheet demoTabSheet = new TabSheet(); layout.addComponent(demoTabSheet); demoTabSheet.addTab(charts1, "Demo 1"); demoTabSheet.addTab(charts2, "Demo 2"); demoTabSheet.addTab(layout3, "Demo 3"); demoTabSheet.addTab(charts4, "Demo 4"); demoTabSheet.addTab(charts5, "Demo 5"); demoTabSheet.addTab(charts6, "Demo 6"); demoTabSheet.addTab(charts7, "Demo 7"); demoTabSheet.addTab(charts8, "Demo 8"); }