List of usage examples for com.vaadin.server Page getCurrent
public static Page getCurrent()
From source file:facs.components.Booking.java
License:Open Source License
private void showNotification(String title, String description) { Notification notify = new Notification(title, description); notify.setDelayMsec(8000);//from w w w . java 2s. co m notify.setPosition(Position.TOP_CENTER); notify.setIcon(FontAwesome.MEH_O); notify.setStyleName(ValoTheme.NOTIFICATION_TRAY + " " + ValoTheme.NOTIFICATION_CLOSABLE); notify.show(Page.getCurrent()); }
From source file:facs.components.Booking.java
License:Open Source License
private void showSuccessfulNotification(String title, String description) { Notification notify = new Notification(title, description); notify.setDelayMsec(8000);/*from w w w. j a v a 2 s . c om*/ notify.setPosition(Position.TOP_CENTER); notify.setIcon(FontAwesome.SMILE_O); notify.setStyleName(ValoTheme.NOTIFICATION_SUCCESS + " " + ValoTheme.NOTIFICATION_CLOSABLE); notify.show(Page.getCurrent()); }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatFileHandler.java
License:Open Source License
public OutputStream receiveUpload(String filename, String mimeType) { file = null;//from w w w . j av a 2s. c o m if ((filename == null) || filename.length() == 0) { Notification n = new Notification("A file has to be selected", " ", Notification.Type.ERROR_MESSAGE); n.setDelayMsec(5000); n.show(Page.getCurrent()); return null; } if (!filename.toLowerCase().endsWith(".ifc")) { Notification n = new Notification("The file extension has to be .ifc", " ", Notification.Type.ERROR_MESSAGE); n.setDelayMsec(5000); n.show(Page.getCurrent()); return null; } // Create upload stream FileOutputStream fos = null; // Stream to write to try { // Open the file for writing. file = new File(uploads + filename); fos = new FileOutputStream(file); } catch (final java.io.FileNotFoundException e) { Notification n = new Notification("Could not open file ", e.getMessage(), Notification.Type.ERROR_MESSAGE); n.setDelayMsec(5000); n.show(Page.getCurrent()); return null; } return fos; // Return the output stream to write to }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatFileHandler.java
License:Open Source License
public void receiveFileFromURL(String url_string) { if (url_string == null || url_string.length() == 0) { return;// w w w.j a v a 2s. c om } if (!url_string.toLowerCase().endsWith(".ifc")) { Notification n = new Notification("The file extension has to be .ifc", " ", Notification.Type.ERROR_MESSAGE); n.setDelayMsec(5000); n.show(Page.getCurrent()); return; } CloseableHttpClient httpClient = HttpClientBuilder.create().build(); HttpGet httpget = new HttpGet(url_string); HttpResponse response; String urlfile = null; if (url_string != null) { urlfile = url_string.substring(url_string.lastIndexOf('/') + 1, url_string.length()); } if (urlfile == null) { return; } try { response = httpClient.execute(httpget); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream inputStream = entity.getContent(); File targetFile = new File(uploads + urlfile); OutputStream outputStream = new FileOutputStream(targetFile); IOUtils.copy(inputStream, outputStream); outputStream.close(); } } catch (Exception e) { e.printStackTrace(); Notification n = new Notification("Could not read the URL: ", e.getMessage(), Notification.Type.ERROR_MESSAGE); n.setDelayMsec(5000); n.show(Page.getCurrent()); return; } finally { try { httpClient.close(); } catch (IOException e) { e.printStackTrace(); } } File readyFile = new File(uploads + urlfile); if (readyFile.exists()) handleNewFile(readyFile); }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatFileHandler.java
License:Open Source License
private void handleNewFile(File file) { Properties prop = new Properties(); OutputStream output = null;//from w w w .j a va2 s.c o m if (file == null) return; String realEstate = parent.getSite(); // set the properties value String[] fname_array = file.getName().split("\\."); try { output = new FileOutputStream(DrumbeatConstants.marmotta_import_config_file); prop.setProperty("context", DrumbeatConstants.marmotta_contexts_baseurl + realEstate + "." + fname_array[0]); prop.setProperty("label", realEstate + "." + fname_array[0]); parent.createDataset(fname_array[0]); // save properties to project root folder prop.store(output, null); } catch (Exception e) { e.printStackTrace(); Notification n = new Notification("File name error", file.getName() + " ; " + e.getMessage(), Notification.Type.ERROR_MESSAGE); n.setDelayMsec(5000); n.show(Page.getCurrent()); return; } finally { if (output != null) { try { output.close(); } catch (IOException e) { e.printStackTrace(); } } } if (!convertIFC2RDFDefault(file, realEstate + "." + fname_array[0])) return; // Stop if the conversion fails try { BIMFileLoader bfl = new BIMFileLoader(); bfl.load(file); } catch (Exception e) { Notification n = new Notification("BIMFileLoader error ", e.getMessage(), Notification.Type.ERROR_MESSAGE); n.setDelayMsec(50000); n.show(Page.getCurrent()); return; } Notification.show("File was uploaded"); parent.updateData(); }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatFileHandler.java
License:Open Source License
private boolean convertIFC2RDFDefault(File file, String name) { try {/* www.java 2 s . com*/ IfcModel model = IfcParserUtil.parseModel(file.getAbsolutePath()); ComplexProcessorConfiguration groundingConfiguration = IfcModelAnalyser.getDefaultGroundingRuleSets(); IfcModelAnalyser modelAnalyser = new IfcModelAnalyser(model); modelAnalyser.groundNodes(groundingConfiguration); OntModel modelExport = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_TRANS_INF); Ifc2RdfExportUtil.exportModelToJenaModel(modelExport, model); RdfUtils.exportJenaModelToRdfFile(modelExport, DrumbeatConstants.marmotta_import_directory + file.getName(), RDFFormat.TURTLE, false); JenaModelFactoryBase jenaModelFactory = new MemoryJenaModelFactory(); try { Model metaModelGraph = jenaModelFactory.createModel(); try { metaModelGraph.read(DrumbeatConstants.metadata_location, "TURTLE"); } catch (Exception e) { e.printStackTrace(); } Ifc2RdfExportUtil.exportMetaModelToJenaModel(DrumbeatConstants.metadata_base + name, metaModelGraph, model); FileOutputStream fout = new FileOutputStream(new File(DrumbeatConstants.metadata_location)); RDFDataMgr.write(fout, metaModelGraph, RDFFormat.TURTLE_PRETTY); fout.close(); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); Notification n = new Notification("Default IFC2RDF export error ", e.getMessage(), Notification.Type.ERROR_MESSAGE); n.setDelayMsec(5000); n.show(Page.getCurrent()); return false; } return true; }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatFileHandler.java
License:Open Source License
@Override public void uploadFailed(FailedEvent event) { Notification n = new Notification("Uploading the file failed.", Notification.Type.ERROR_MESSAGE); n.setDelayMsec(1000);/* w w w.ja v a2s. co m*/ n.show(Page.getCurrent()); }
From source file:fi.jasoft.dragdroplayouts.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout content = new VerticalLayout(); content.setSizeFull();/*from w w w .j ava2 s . c o m*/ setContent(content); Label header = new Label("DragDropLayouts for Vaadin 8"); header.setStyleName(ValoTheme.LABEL_H1); content.addComponent(header); HorizontalLayout hl = new HorizontalLayout(); hl.setSizeFull(); content.addComponent(hl); content.setExpandRatio(hl, 1); VerticalSplitPanel split = new VerticalSplitPanel(); hl.addComponent(split); hl.setExpandRatio(split, 1); CssLayout placeHolder = new CssLayout(new Label("No view selected.")); placeHolder.setSizeFull(); split.setFirstComponent(placeHolder); Panel codePanel = new Panel(codeLabel); codePanel.setSizeFull(); split.setSecondComponent(codePanel); navigator = new Navigator(this, placeHolder); navigator.addViewChangeListener(new ViewChangeListener() { @Override public boolean beforeViewChange(ViewChangeEvent event) { DemoView view = (DemoView) event.getNewView(); selection.getSelectionModel().select(view); codeLabel.setValue(getFormattedSourceCode(view.getSource())); return true; } @Override public void afterViewChange(ViewChangeEvent event) { // TODO Auto-generated method stub } }); try { addView(new DragdropAbsoluteLayoutDemo(navigator)); addView(new DragdropVerticalLayoutDemo(navigator)); addView(new DragdropHorizontalLayoutDemo(navigator)); addView(new DragdropGridLayoutDemo(navigator)); addView(new DragdropCssLayoutDemo(navigator)); addView(new DragdropFormLayoutDemo(navigator)); addView(new DragdropPanelDemo(navigator)); addView(new DragdropLayoutDraggingDemo(navigator)); addView(new DragdropHorizontalSplitPanelDemo(navigator)); addView(new DragdropVerticalSplitPanelDemo(navigator)); addView(new DragdropTabsheetDemo(navigator)); addView(new DragdropAccordionDemo(navigator)); addView(new DragdropDragFilterDemo(navigator)); addView(new DragdropCaptionModeDemo(navigator)); addView(new DragdropV7VerticalLayoutDemo(navigator)); addView(new DragdropV7HorizontalLayoutDemo(navigator)); // addView(new DragdropIframeDragging(navigator)); } catch (Exception e) { e.printStackTrace(); return; } hl.addComponent(selection = createViewSelection(), 0); String fragment = Page.getCurrent().getUriFragment(); if (fragment == null || fragment.equals("")) { navigator.navigateTo(DragdropAbsoluteLayoutDemo.NAME); } }
From source file:fi.racetrace.adminpanel.ui.CustomerDetails.java
License:Open Source License
private void setTitle() { Page.getCurrent().setTitle(customer.getItemProperty("name").getValue() + " - Customers - RaceTrace"); }
From source file:fi.racetrace.adminpanel.ui.CustomerList.java
License:Open Source License
private void setTitle() { Page.getCurrent().setTitle("Customers - RaceTrace"); }