/** * Starts parsing. * * @param attrs the attributes. * @throws org.xml.sax.SAXException if there is a parsing error. */ protected void startParsing(final Attributes attrs) throws SAXException { name = attrs.getValue(getUri(), "name"); if (StringUtils.isEmpty(name)) { throw new ParseException("Required attribute 'name' is missing.", getLocator()); } value = attrs.getValue(getUri(), "formula"); if (StringUtils.isEmpty(value)) { throw new ParseException("Required attribute 'formula' is missing.", getLocator()); } }
public ReportEnvironmentDataRow( final ReportEnvironment environment, final ReportEnvironmentMapping reportEnvironmentMapping) { final Map<String, String> envMapping = reportEnvironmentMapping.createEnvironmentMapping(); this.columnMap = new LinkedHashMap<String, String>(); for (final Map.Entry<String, String> entry : envMapping.entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); if (StringUtils.isEmpty(key) == false && StringUtils.isEmpty(value) == false) { this.columnMap.put(value, key); } } this.columnNames = columnMap.keySet().toArray(new String[columnMap.size()]); this.environment = environment; }
private boolean isSupportedFormat(final URL sourceURL) { final String file = sourceURL.getFile(); if (StringUtils.endsWithIgnoreCase(file, ".png")) { return true; } if (StringUtils.endsWithIgnoreCase(file, ".jpg") || StringUtils.endsWithIgnoreCase(file, ".jpeg")) { return true; } if (StringUtils.endsWithIgnoreCase(file, ".bmp") || StringUtils.endsWithIgnoreCase(file, ".ico")) { return true; } return false; }
protected void drawImageMap(final RenderableReplacedContentBox content) { if (version < '6') { return; } final ImageMap imageMap = RenderUtility.extractImageMap(content); // only generate a image map, if the user does not specify their own onw via the override. // Of course, they would have to provide the map by other means as well. if (imageMap == null) { return; } final ImageMapEntry[] imageMapEntries = imageMap.getMapEntries(); for (int i = 0; i < imageMapEntries.length; i++) { final ImageMapEntry imageMapEntry = imageMapEntries[i]; final String link = imageMapEntry.getAttribute(LibXmlInfo.XHTML_NAMESPACE, "href"); final String tooltip = imageMapEntry.getAttribute(LibXmlInfo.XHTML_NAMESPACE, "title"); if (StringUtils.isEmpty(tooltip)) { continue; } final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final int x = (int) (translateX + StrictGeomUtility.toExternalValue(content.getX())); final int y = (int) StrictGeomUtility.toExternalValue(content.getY()); final float[] translatedCoords = translateCoordinates(imageMapEntry.getAreaCoordinates(), x, y); final PolygonAnnotation polygonAnnotation = new PolygonAnnotation(writer, translatedCoords); polygonAnnotation.put(PdfName.CONTENTS, new PdfString(tooltip, PdfObject.TEXT_UNICODE)); writer.addAnnotation(polygonAnnotation); } }
protected void drawHyperlink( final RenderNode box, final String target, final String window, final String title) { if (box.isNodeVisible(getDrawArea()) == false) { return; } final PdfAction action = createActionForLink(target); final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final float leftX = translateX + (float) (StrictGeomUtility.toExternalValue(box.getX())); final float rightX = translateX + (float) (StrictGeomUtility.toExternalValue(box.getX() + box.getWidth())); final float lowerY = (float) (globalHeight - StrictGeomUtility.toExternalValue(box.getY() + box.getHeight())); final float upperY = (float) (globalHeight - StrictGeomUtility.toExternalValue(box.getY())); if (action != null) { final PdfAnnotation annotation = new PdfAnnotation(writer, leftX, lowerY, rightX, upperY, action); writer.addAnnotation(annotation); } else if (StringUtils.isEmpty(title) == false) { final Rectangle rect = new Rectangle(leftX, lowerY, rightX, upperY); final PdfAnnotation commentAnnotation = PdfAnnotation.createText(writer, rect, "Tooltip", title, false, null); commentAnnotation.setAppearance( PdfAnnotation.APPEARANCE_NORMAL, writer.getDirectContent().createAppearance(rect.getWidth(), rect.getHeight())); writer.addAnnotation(commentAnnotation); } }
/** * This method gets called when a bound property is changed. * * @param evt A PropertyChangeEvent object describing the event source and the property that has * changed. */ public void propertyChange(final PropertyChangeEvent evt) { if (StringUtils.isEmpty(getWrapper().getDrillDownPath())) { paramTableElement.setDisabled(true); } else { paramTableElement.setDisabled(false); } }
public void summaryRowSelection(final ReportEvent event) { if (rowbandingOnGroup == false) { return; } if (StringUtils.isEmpty(group)) { final Group group = event.getReport().getGroup(event.getState().getCurrentGroupIndex()); if (group instanceof CrosstabRowGroup) { final GroupBody body = group.getBody(); if (body instanceof CrosstabColumnGroupBody) { if (Boolean.TRUE.equals( group.getAttribute( AttributeNames.Crosstab.NAMESPACE, AttributeNames.Crosstab.PRINT_SUMMARY))) { triggerVisibleStateCrosstab(event); } } } } else { if (FunctionUtilities.isDefinedGroup(group, event)) { final Group group = event.getReport().getGroup(event.getState().getCurrentGroupIndex()); if (Boolean.TRUE.equals( group.getAttribute( AttributeNames.Crosstab.NAMESPACE, AttributeNames.Crosstab.PRINT_SUMMARY))) { triggerVisibleStateCrosstab(event); } } } }
public boolean isValid(final Locale locale, final boolean deepCheck) { final String[] textProperties = {"display-name", "grouping"}; for (int i = 0; i < textProperties.length; i++) { final String property = textProperties[i]; if (StringUtils.isEmpty(getMetaAttribute(property, locale))) { return false; } } final String[] optionalTextProperties = {"description", "deprecated"}; for (int i = 0; i < optionalTextProperties.length; i++) { final String property = optionalTextProperties[i]; if (getMetaAttribute(property, locale) == null) { return false; } } final String[] integerProperties = {"grouping.ordinal", "ordinal"}; for (int i = 0; i < integerProperties.length; i++) { final String property = integerProperties[i]; if (ParserUtil.parseInt(getMetaAttribute(property, locale), Integer.MAX_VALUE) == Integer.MAX_VALUE) { return false; } } return true; }
/** Invoked when an action occurs. */ public void actionPerformed(final ActionEvent e) { final CreateNewRepositoryFolderDialog newFolderDialog = new CreateNewRepositoryFolderDialog(RepositoryPublishDialog.this); if (!newFolderDialog.performEdit()) { return; } final FileObject treeNode = getSelectedView(); if (treeNode == null) { return; } if (!StringUtils.isEmpty(newFolderDialog.getName())) { final Component glassPane = SwingUtilities.getRootPane(RepositoryPublishDialog.this).getGlassPane(); try { glassPane.setVisible(true); glassPane.setCursor(new Cursor(Cursor.WAIT_CURSOR)); final FileObject child = treeNode.resolveFile(newFolderDialog.getFolderName()); child.createFolder(); if (child instanceof WebSolutionFileObject) { final WebSolutionFileObject webSolutionFileObject = (WebSolutionFileObject) child; webSolutionFileObject.setDescription(newFolderDialog.getDescription()); } getTable().refresh(); } catch (Exception e1) { UncaughtExceptionsModel.getInstance().addException(e1); } finally { glassPane.setVisible(false); glassPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } }
/** Selects a file to use as target for the report processing. */ protected void performSelectFile() { if (fileChooser == null) { fileChooser = new JFileChooser(); final FilesystemFilter filter = new FilesystemFilter( CSVDataExportDialog.CSV_FILE_EXTENSION, getResources().getString("csvexportdialog.csv-file-description")); // $NON-NLS-1$ fileChooser.addChoosableFileFilter(filter); fileChooser.setMultiSelectionEnabled(false); } fileChooser.setSelectedFile(new File(getFilename())); final int option = fileChooser.showSaveDialog(this); if (option == JFileChooser.APPROVE_OPTION) { final File selFile = fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); // Test if ends on csv if (StringUtils.endsWithIgnoreCase(selFileName, CSVDataExportDialog.CSV_FILE_EXTENSION) == false) { selFileName = selFileName + CSVDataExportDialog.CSV_FILE_EXTENSION; } setFilename(selFileName); } }
private String computeGreetingName() { if (StringUtils.isEmpty(getField())) { return null; } Object raw = getDataRow().get(getField()); if (raw == null) { return null; } String text = String.valueOf(raw); if (StringUtils.isEmpty(text)) { return null; } return text; }
/** * Receives notification that report generation initializes the current run. * * <p>The event carries a ReportState.Started state. Use this to initialize the report. * * @param event The event. */ public void reportInitialized(final ReportEvent event) { if (ignoreCrosstabMode) { // If the user forces us into relational-mode, then we obey .. rowbandingOnGroup = StringUtils.isEmpty(group) == false; } else { // check whether there is a crosstab if (FunctionUtilities.isCrosstabDefined(event)) { // when we have one, we always rowband on a group instead of an item-count rowbandingOnGroup = true; } else { // we only row-band on an item-count if the group is not empty. rowbandingOnGroup = StringUtils.isEmpty(group) == false; } } trigger = !getInitialState(); count = 0; }
/** * Set the property value by parsing a given String. May raise java.lang.IllegalArgumentException * if either the String is badly formatted or if this kind of property can't be expressed as text. * * @param text The string to be parsed. */ public void setAsText(final String text) throws IllegalArgumentException { if (StringUtils.isEmpty(text)) { setValue(null); return; } try { setValue(valueConverter.toPropertyValue(text)); } catch (BeanException e) { throw new IllegalArgumentException("This is not a valid property-value"); } }
/** * This method gets called when a bound property is changed. * * @param evt A PropertyChangeEvent object describing the event source and the property that has * changed. */ public void propertyChange(final PropertyChangeEvent evt) { final String path = getModel().getDrillDownPath(); if (StringUtils.isEmpty(path)) { return; } if (path.matches("\\w+\\://.*")) // NON-NLS { getModel().setDrillDownConfig("generic-url"); // NON-NLS } else { getModel().setDrillDownConfig("local-url"); // NON-NLS } }
private Object computeDataValue(final ReportEvent event) { final DataRow dataRow = extractDataRow(event); if (StringUtils.isEmpty(dataField) == false) { return dataRow.get(dataField); } try { this.dataFormula.setRuntime(new WrapperExpressionRuntime(dataRow, getRuntime())); return dataFormula.getValue(); } finally { this.dataFormula.setRuntime(null); } }
private ScriptableDataFactory produceFactory() { final ScriptableDataFactory returnDataFactory = new ScriptableDataFactory(); returnDataFactory.setLanguage((String) languageField.getSelectedValue()); if (StringUtils.isEmpty(initScriptTextArea.getText())) { returnDataFactory.setScript(null); } else { returnDataFactory.setScript(initScriptTextArea.getText()); } if (StringUtils.isEmpty(shutdownScriptTextArea.getText())) { returnDataFactory.setShutdownScript(null); } else { returnDataFactory.setShutdownScript(shutdownScriptTextArea.getText()); } final DataSetQuery[] queries = this.queries.values().toArray(new DataSetQuery[this.queries.size()]); for (int i = 0; i < queries.length; i++) { final DataSetQuery query = queries[i]; returnDataFactory.setQuery(query.getQueryName(), query.getQuery()); } return returnDataFactory; }
@SuppressWarnings("rawtypes") private static Element createParameterElement( final Element parametersElement, final String paramName, final Class type, final String label, final String role, final String group, final String[] values) { final Element parameterElement = parametersElement.addElement("parameter"); parameterElement.addAttribute("name", paramName); parameterElement.addAttribute("type", type.getName()); if (StringUtils.isEmpty(label) == false) { final Element labelAttr = parameterElement.addElement("attribute"); labelAttr.addAttribute( "namespace", "http://reporting.pentaho.org/namespaces/engine/parameter-attributes/core"); labelAttr.addAttribute("name", "label"); labelAttr.addAttribute("value", label); } final Element roleAttr = parameterElement.addElement("attribute"); roleAttr.addAttribute( "namespace", "http://reporting.pentaho.org/namespaces/engine/parameter-attributes/core"); roleAttr.addAttribute("name", "role"); roleAttr.addAttribute("value", role); final Element paramGroupAttr = parameterElement.addElement("attribute"); paramGroupAttr.addAttribute( "namespace", "http://reporting.pentaho.org/namespaces/engine/parameter-attributes/core"); paramGroupAttr.addAttribute("name", "parameter-group"); paramGroupAttr.addAttribute("value", group); final Element paramGroupLabelAttr = parameterElement.addElement("attribute"); paramGroupLabelAttr.addAttribute( "namespace", "http://reporting.pentaho.org/namespaces/engine/parameter-attributes/core"); paramGroupLabelAttr.addAttribute("name", "parameter-group-label"); paramGroupLabelAttr.addAttribute("value", lookupParameterGroupLabel(group)); if (values.length > 0) { final Element valuesElement = parameterElement.addElement("values"); for (final String value : values) { final Element valueAttr = valuesElement.addElement("value"); valueAttr.addAttribute("type", String.class.getName()); valueAttr.addAttribute("value", value); valueAttr.addAttribute("selected", String.valueOf(values.length == 1)); } } return parameterElement; }
private static String calculatePrefix(final MetaData type) { final String prefix; if (type instanceof AbstractMetaData) { final AbstractMetaData metaData = (AbstractMetaData) type; final String prefixMetadata = metaData.getKeyPrefix(); if (StringUtils.isEmpty(prefixMetadata)) { prefix = ""; } else { prefix = prefixMetadata + type.getName() + "."; } } else { prefix = ""; } return prefix; }
private PdfAction createActionForLink(final String target) { if (StringUtils.isEmpty(target)) { return null; } final PdfAction action = new PdfAction(); if (target.startsWith("#")) { // its a local link .. action.put(PdfName.S, PdfName.GOTO); action.put(PdfName.D, new PdfString(target.substring(1))); } else { action.put(PdfName.S, PdfName.URI); action.put(PdfName.URI, new PdfString(target)); } return action; }
public JdbcConnectionInfo(final Element connection) { final String driver = (String) connection.selectObject("string(./Driver)"); final String url = (String) connection.selectObject("string(./Url)"); final String userName = (String) connection.selectObject("string(./User)"); final String password = (String) connection.selectObject("string(./Pass)"); final String role = (String) connection.selectObject("string(./Role)"); final String roleFormula = (String) connection.selectObject("string(./RoleField)"); final String userFormula = (String) connection.selectObject("string(./UserField)"); final String passFormula = (String) connection.selectObject("string(./PassField)"); if (StringUtils.isEmpty(driver)) { throw new IllegalStateException("A driver is mandatory"); } if (StringUtils.isEmpty(url)) { throw new IllegalStateException("A url is mandatory"); } setDriver(driver); setUrl(url); if (userName != null) { setUser(userName); } if (password != null) { setPass(password); } if (StringUtils.isEmpty(role) == false) { setMondrianRole(role); } if (StringUtils.isEmpty(userFormula) == false) { setUserField(userFormula); } if (StringUtils.isEmpty(passFormula) == false) { setPasswordField(passFormula); } if (StringUtils.isEmpty(roleFormula) == false) { setRoleField(roleFormula); } properties = new Properties(); final List list = connection.elements("Property"); for (int i = 0; i < list.size(); i++) { final Element childElement = (Element) list.get(i); final String name = childElement.attributeValue("name"); final String text = childElement.getText(); properties.put(name, text); } setCatalog((String) connection.selectObject("string(./Catalog)")); setCube((String) connection.selectObject("string(./Cube)")); }
public Component getListCellRendererComponent( final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { final JLabel listCellRendererComponent = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { final String queryName = ((DataSetQuery) value).getQueryName(); if (StringUtils.isEmpty(queryName) == false) { listCellRendererComponent.setText(queryName); } else { listCellRendererComponent.setText(" "); } } return listCellRendererComponent; }
public void actionPerformed(final ActionEvent e) { final FileFilter[] fileFilters = new FileFilter[] { new FilesystemFilter( new String[] {".ktr"}, Messages.getString("KettleDataSourceDialog.KtrFileDescription") + " (*.ktr)", true) }; final File reportContextFile = DesignTimeUtil.getContextAsFile(designTimeContext.getReport()); final CommonFileChooser fileChooser = FileChooserService.getInstance().getFileChooser("kettle"); final String fileText = fileTextField.getText(); if (StringUtils.isEmpty(fileText) == false) { if (reportContextFile != null) { fileChooser.setSelectedFile( new File(reportContextFile.getParentFile(), fileTextField.getText())); } else { fileChooser.setSelectedFile(new File(fileTextField.getText())); } } fileChooser.setFilters(fileFilters); if (fileChooser.showDialog(KettleDataSourceDialog.this, JFileChooser.OPEN_DIALOG) == false) { return; } final File file = fileChooser.getSelectedFile(); if (file == null) { return; } final String path; if (reportContextFile != null) { path = IOUtils.getInstance() .createRelativePath(file.getPath(), reportContextFile.getAbsolutePath()); } else { path = file.getPath(); } final KettleQueryEntry queryEntry = (KettleQueryEntry) queryNameList.getSelectedValue(); queryEntry.setFile(path); fileTextField.setText(path); }
public void groupStarted(final ReportEvent event) { if (rowbandingOnGroup == false) { return; } if (StringUtils.isEmpty(group)) { final Group group = event.getReport().getGroup(event.getState().getCurrentGroupIndex()); if (group instanceof CrosstabRowGroup) { final GroupBody body = group.getBody(); if (body instanceof CrosstabColumnGroupBody) { triggerVisibleStateCrosstab(event); } } } else { if (FunctionUtilities.isDefinedGroup(group, event)) { triggerVisibleStateCrosstab(event); } } }
protected boolean validateInputs(final boolean onConfirm) { if (super.validateInputs(onConfirm) == false) { return false; } if (onConfirm == false) { return true; } final String reportName = getFileNameTextField().getText(); if (StringUtils.isEmpty(reportName) == false && reportName.endsWith(REPORT_BUNDLE_EXTENSION) == false) { final String safeReportName = reportName + REPORT_BUNDLE_EXTENSION; getFileNameTextField().setText(safeReportName); } try { final FileObject selectedView = getSelectedView(); final String validateName = getSelectedFile(); if (validateName == null || selectedView == null) { return false; } final FileObject targetFile = selectedView.resolveFile(getFileNameTextField().getText()); final FileObject fileObject = selectedView.getFileSystem().resolveFile(targetFile.getName()); if (fileObject.getType() == FileType.IMAGINARY) { return true; } final int result = JOptionPane.showConfirmDialog( this, Messages.getInstance() .formatMessage("PublishToServerAction.FileExistsOverride", validateName), Messages.getInstance().getString("PublishToServerAction.Information.Title"), JOptionPane.YES_NO_OPTION); return result == JOptionPane.YES_OPTION; } catch (FileSystemException fse) { UncaughtExceptionsModel.getInstance().addException(fse); return false; } }
public String decrypt(final RootXmlReadHandler root, final String encryptedPassword) { if (StringUtils.isEmpty(encryptedPassword)) { // empty string vs. null may have significance. return encryptedPassword; } final Object helperObject = root.getHelperObject(ContentRootElementHandler.PRPT_SPEC_VERSION); final boolean legacyFix; if (helperObject instanceof Integer) { final Integer version = (Integer) helperObject; if (version == -1) { logger.warn("Decrypting password skipped, as we are dealing with an older version. "); return encryptedPassword; } legacyFix = (version.intValue() < ClassicEngineBoot.computeVersionId(5, 0, 0)); } else { legacyFix = false; } final int separatorPos = encryptedPassword.indexOf(':'); if (separatorPos == -1) { // assume legacy mode logger.warn("Decrypting password skipped, as the password-text has no service indicator. "); return encryptedPassword; } final String serviceName = encryptedPassword.substring(0, separatorPos); final String payload = encryptedPassword.substring(separatorPos + 1); final PasswordEncryptionServiceProvider provider = services.get(serviceName); if (legacyFix && ObscurificatePasswordEncryptionServiceProvider.SERVICE_TAG.equals(serviceName)) { return new Obscurificate48PasswordEncryptionServiceProvider().decrypt(payload); } if (provider != null) { return provider.decrypt(payload); } logger.debug("Decrypting password skipped, as the service indicator is not recognized. "); return encryptedPassword; }
/** * Returns the object for this element or null, if this element does not create an object. * * @return the object. * @throws SAXException if an parser error occured. */ public Expression getFormula() throws SAXException { if (propertyReadHandler == null) { return null; } String s = propertyReadHandler.getResult(); if (StringUtils.isEmpty(s, true) == false) { final FormulaExpression formulaExpression = new FormulaExpression(); if (s.startsWith("report:")) { s = "=" + s.substring("report:".length()).trim(); } else { s = s.trim(); } if (s.endsWith(";")) { s = s.substring(0, s.length() - 1); } formulaExpression.setFormula(s); return formulaExpression; } return null; }
private static void setLookAndFeel() { try { final String lnfName = WorkspaceSettings.getInstance().getLNF(); if (!StringUtils.isEmpty(lnfName)) { final LookAndFeelInfo[] lnfs = UIManager.getInstalledLookAndFeels(); for (final LookAndFeelInfo lnf : lnfs) { if (lnf.getName().equals(lnfName)) { UIManager.setLookAndFeel(lnf.getClassName()); return; } } } UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Throwable t) { UncaughtExceptionsModel.getInstance().addException(t); } final UIDefaults uiDefaults = UIManager.getDefaults(); uiDefaults.put("Table.gridColor", uiDefaults.get("Panel.background")); // NON-NLS uiDefaults.put("Tree.leftChildIndent", 0); // PRD-4419 }
/** * Returns a string representation of this module. * * @return the string representation of this module for debugging purposes. * @see Object#toString() */ public String toString() { final String lineSeparator = StringUtils.getLineSeparator(); final StringBuilder buffer = new StringBuilder(120); buffer.append("Module : "); buffer.append(getName()); buffer.append(lineSeparator); buffer.append("ModuleClass : "); buffer.append(getModuleClass()); buffer.append(lineSeparator); buffer.append("Version: "); buffer.append(getMajorVersion()); buffer.append('.'); buffer.append(getMinorVersion()); buffer.append('.'); buffer.append(getPatchLevel()); buffer.append(lineSeparator); buffer.append("Producer: "); buffer.append(getProducer()); buffer.append(lineSeparator); buffer.append("Description: "); buffer.append(getDescription()); buffer.append(lineSeparator); return buffer.toString(); }
public String getDescription() { if (StringUtils.isEmpty(desciptionTextField.getText())) { return null; } return desciptionTextField.getText(); }
public String getReportTitle() { if (StringUtils.isEmpty(titleTextField.getText())) { return null; } return titleTextField.getText(); }