List of usage examples for com.vaadin.server ClassResource ClassResource
public ClassResource(String resourceName)
From source file:com.foc.desc.parsers.xml.FocDescDeclaration_XMLBased.java
License:Apache License
private XMLFocDesc parse() { XMLFocDesc xmlFocDesc = null;//from ww w . j a v a2 s. c o m try { ClassResource resource = null; InputStream inputStream = null; resource = new ClassResource(xmlFileName); inputStream = resource.getStream().getStream(); SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); XMLFocDescParser focDescParser = new XMLFocDescParser(this); saxParser.parse(inputStream, focDescParser); xmlFocDesc = focDescParser.getXmlFocDesc(); } catch (Exception e) { Globals.logString("Could not load file : " + xmlFileName); Globals.logException(e); } return xmlFocDesc; }
From source file:com.foc.focDataSourceDB.FocDataSource_DB.java
License:Apache License
@Override public boolean command_executeRequestForModulesSP(String spFileName) { try {// w w w. ja v a2 s.c o m Globals.logString("SP Re-Generation : " + spFileName); ClassResource resource = new ClassResource(spFileName); InputStream inputStream = resource.getStream().getStream(); InputStreamReader isReader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(isReader); Connection connection = getDBManagerServer() != null ? getDBManagerServer().getConnection() : null; if (connection != null) { Statement sqlStatement = connection.createStatement(); if (sqlStatement != null) { String line = null; StringBuilder stringBuilder = null; while ((line = bufferedReader.readLine()) != null) { line = line.trim(); if (!Utils.isStringEmpty(line)) { if (stringBuilder != null && (line.contains(SP_DELIMITER) || line.contains(SP_DELIMITER.toLowerCase()))) { String query = stringBuilder.toString().replaceAll("//", ""); sqlStatement.addBatch(query); stringBuilder = null; } else { if (stringBuilder == null) { stringBuilder = new StringBuilder(); } if (stringBuilder.length() != 0) stringBuilder.append("\n"); stringBuilder.append(line); } } } sqlStatement.executeBatch(); } } inputStream.close(); inputStream = null; isReader.close(); isReader = null; bufferedReader.close(); bufferedReader = null; Globals.logString("SP Re-Generation : Successful"); } catch (Exception ex) { Globals.logString("SP Re-Generation : Failed"); Globals.logException(ex); } return false; }
From source file:com.foc.helpBook.FocHelpPage.java
License:Apache License
private InputStream getXMLStream() { InputStream inputStream = null; ClassResource resource = null;/*from ww w. j a v a2 s . c o m*/ try { if (fileName != null && !fileName.isEmpty()) { resource = new ClassResource(fileName); inputStream = resource.getStream().getStream(); } } catch (Exception e) { Globals.logString("Could not load file : " + fileName); Globals.logException(e); } if (inputStream == null) { Globals.showNotification("Could not load help page " + fileName, " for page code" + pageCode, IFocEnvironment.TYPE_ERROR_MESSAGE); } return inputStream; }
From source file:com.foc.msword.WordTemplateFillerResource.java
License:Apache License
@Override public DownloadStream getStream() { DownloadStream downloadStream = null; try {// w w w.ja v a 2 s .c o m ClassResource resource = null; InputStream inputStream = null; resource = new ClassResource(tempateFileName); inputStream = resource.getStream().getStream(); ExtendedWordDocument xWord = new ExtendedWordDocument(inputStream); if (xWord != null) { fill(xWord); ByteArrayOutputStream baos = new ByteArrayOutputStream(); xWord.write(baos); bais = new ByteArrayInputStream(baos.toByteArray()); } xWord.dispose(); } catch (Exception e) { Globals.logException(e); } if (bais != null) { String fileName2 = downloadFileName; if (!fileName2.endsWith(".doc") && !fileName2.endsWith(".docx")) { fileName2 += ".docx"; } downloadStream = new DownloadStream(bais, "application/x-unknown", fileName2); downloadStream.setParameter("Content-Disposition", "attachment; filename=" + fileName2); downloadStream.setCacheTime(0); } return downloadStream; }
From source file:com.foc.web.server.xmlViewDictionary.XMLView.java
License:Apache License
private InputStream getXMLStream(boolean help) { InputStream inputStream = null; if (getXmlviewDefinition() != null) { if (!help) { XMLViewDefinition xmlViewDef = getXmlviewDefinition(); String xml = xmlViewDef.getXML(); try { Globals.logString("XML before new ByteArray=" + xml); inputStream = new ByteArrayInputStream(xml.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { Globals.logException(e); }/*from w w w . j av a2s.co m*/ if (inputStream == null) { Globals.showNotification("Could not load XML from table", "View key : " + getXmlViewKey().getStringKey(), FocWebEnvironment.TYPE_ERROR_MESSAGE); } } } else { ClassResource resource = null; try { String fileName = help ? getXmlFileName_ForHelp() : getXmlFileName(); if (fileName != null && !fileName.isEmpty()) { resource = new ClassResource(fileName); inputStream = resource.getStream().getStream(); } } catch (Exception e) { Globals.logString("Could not load file : " + getXmlFileName()); Globals.logException(e); if (ConfigInfo.isForDevelopment()) { Globals.logString("Developer? Will Attempt creating the file : " + getXmlFileName()); String fullFileName = getFullFileName(); File file = new File(fullFileName); if (!file.exists()) { try { file.createNewFile(); resource = new ClassResource(getXmlFileName()); inputStream = resource.getStream().getStream(); } catch (IOException eForFileCreation) { Globals.logException(eForFileCreation); } } } } if (inputStream == null) { Globals.showNotification("Could not load XML from file", "View key : " + getXmlViewKey().getStringKey() + "\nFile : " + getXmlFileName(), IFocEnvironment.TYPE_ERROR_MESSAGE); Globals.logString("!!!! ERROR : Could Not Load file : " + getXmlFileName()); } } return inputStream; }
From source file:com.foc.web.unitTesting.FocUnitTestingSuite.java
License:Apache License
private void parseXML_IfNeeded() throws Exception { try {/* w w w .j a va 2s . c o m*/ if (!isParsingDone()) { setParsingDone(true); String fileName = getFileName(); ClassResource resource = null; InputStream inputStream = null; try { resource = new ClassResource(fileName); inputStream = resource.getStream().getStream(); } catch (Exception e) { FocLogger.getInstance().addError("Could not load file : " + fileName); FocLogger.getInstance().addError(e.getMessage()); Globals.logString("Could not load file : " + fileName); Globals.logException(e); } if (inputStream == null) { FocLogger.getInstance() .addError("Input stream is null. Could not load file: " + fileName + "."); } SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); saxParser.parse(inputStream, new FocXMLUnitHandler()); } } catch (Exception e) { Globals.logException(e); FocLogger.getInstance().addError(e.getMessage()); } }
From source file:com.haulmont.cuba.web.gui.components.WebComponentsHelper.java
License:Apache License
public static Resource getResource(String resURL) { if (StringUtils.isEmpty(resURL)) return null; if (resURL.startsWith("file:")) { return new FileResource(new File(resURL.substring("file:".length()))); } else if (resURL.startsWith("jar:")) { return new ClassResource(resURL.substring("jar:".length())); } else if (resURL.startsWith("theme:")) { String resourceId = resURL.substring("theme:".length()); Configuration configuration = AppBeans.get(Configuration.NAME); WebConfig webConfig = configuration.getConfig(WebConfig.class); if (webConfig.getUseFontIcons()) { String fontIcon;/* w ww . j a va 2s . co m*/ ThemeConstants themeConstants = App.getInstance().getThemeConstants(); String iconKey = "cuba.web." + StringUtils.replace(resourceId, "/", "."); fontIcon = themeConstants.get(iconKey); try { Resource resource = getFontIconResource(fontIcon); if (resource != null) { return resource; } } catch (NoSuchFieldException | IllegalAccessException e) { LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon " + fontIcon); } } return new VersionedThemeResource(resourceId); } else if (resURL.contains("icon:")) { try { return getFontIconResource(resURL); } catch (NoSuchFieldException | IllegalAccessException e) { LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon " + resURL); } return null; } else { return new VersionedThemeResource(resURL); } }
From source file:com.haulmont.cuba.web.gui.icons.ClassPathIconProvider.java
License:Apache License
@Override public Resource getIconResource(String iconPath) { Preconditions.checkNotEmptyString(iconPath, "Icon path should not be empty"); String icon = iconPath.substring(CLASSPATH_PREFIX.length()); return new ClassResource(icon); }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaMultiUpload.java
License:Apache License
public CubaMultiUpload() { registerRpc(rpc);// www. j a v a2s .c o m WebJarAssetLocator webJarAssetLocator = new WebJarAssetLocator(); String swfuploadJs = webJarAssetLocator.getFullPath("swfupload", "swfupload.min.js"); setResource(CubaMultiUploadState.SWFUPLOAD_BOOTSTRAP_JS_KEY, new ClassResource(swfuploadJs)); String swfuploadSwf = webJarAssetLocator.getFullPath("swfupload", "swfupload.swf"); setResource(CubaMultiUploadState.SWFUPLOAD_FLASH_KEY, new ClassResource(swfuploadSwf)); }
From source file:de.catma.ui.tagger.PropertyEditDialog.java
License:Open Source License
@SuppressWarnings("unchecked") private void initData() { for (Property p : tagInstance.getUserDefinedProperties()) { PropertyDefinition propertyDefinition = p.getPropertyDefinition(); ClassResource pIcon = new ClassResource("tagmanager/resources/ylwdiamd.gif"); propertyTree.addItem(new Object[] { propertyDefinition.getName(), null, null }, p); propertyTree.getContainerProperty(p, TreePropertyName.icon).setValue(pIcon); propertyTree.setChildrenAllowed(p, true); Set<String> values = new HashSet<String>(); values.addAll(propertyDefinition.getPossibleValueList().getPropertyValueList().getValues()); values.addAll(p.getPropertyValueList().getValues()); for (String pValue : values) { String pValueItemId = propertyDefinition.getUuid() + "_" + pValue; CheckBox cb = createCheckBox(p, pValue); propertyTree.addItem(new Object[] { null, pValue, cb }, pValueItemId); propertyTree.setParent(pValueItemId, p); propertyTree.setChildrenAllowed(pValueItemId, false); }/*www . j a v a 2s. c om*/ propertyTree.setCollapsed(p, false); } if (tagInstance.getUserDefinedProperties().size() == 1) { propertyTree.setValue(tagInstance.getUserDefinedProperties().iterator().next()); } for (String value : propertyValuesBuffer.getValues()) { newValueInput.addItem(value); } }