private SelectChartExpressionAction(final Class expressionType) { this.expressionType = expressionType; final ExpressionRegistry expressionRegistry = ExpressionRegistry.getInstance(); final ExpressionMetaData metaData = expressionRegistry.getExpressionMetaData(expressionType.getName()); putValue( Action.NAME, metaData.getMetaAttribute("short-name", Locale.getDefault())); // NON-NLS final String defaultIcon = metaData.getMetaAttribute("icon", Locale.getDefault()); // NON-NLS if (defaultIcon != null) { final URL defaultIconUrl = LegacyChartEditorDialog.class.getResource(defaultIcon); if (defaultIconUrl != null) { standardIcon = new ImageIcon(defaultIconUrl); putValue(Action.SMALL_ICON, standardIcon); } } final String selectedIconProperty = metaData.getMetaAttribute("selected-icon", Locale.getDefault()); // NON-NLS if (selectedIconProperty != null) { final URL selectedIconUrl = LegacyChartEditorDialog.class.getResource(selectedIconProperty); if (selectedIconUrl != null) { selectedIcon = new ImageIcon(selectedIconUrl); } } }
public static void writeElementLayoutExpressions( final WriteableDocumentBundle bundle, final BundleWriterState state, final XmlWriter writer) throws IOException, BundleWriterException { if (state == null) { throw new NullPointerException(); } if (writer == null) { throw new NullPointerException(); } if (bundle == null) { throw new NullPointerException(); } final ExpressionCollection exp = state.getReport().getExpressions(); final ExpressionRegistry registry = ExpressionRegistry.getInstance(); for (int i = 0; i < exp.size(); i++) { final Expression expression = exp.getExpression(i); if (registry.isExpressionRegistered(expression.getClass().getName()) == false) { continue; } final ExpressionMetaData emd = registry.getExpressionMetaData(expression.getClass().getName()); if (emd.isElementLayoutProcessor()) { writeExpression( bundle, state, expression, writer, BundleNamespaces.LAYOUT, "expression"); // NON-NLS } } }
private XmlReadHandler createReadHandler(String propertyName) throws ParseException { try { final ExpressionMetaData expressionMetaData = ExpressionRegistry.getInstance().getExpressionMetaData(expressionClass); final ExpressionPropertyMetaData propertyDescription = expressionMetaData.getPropertyDescription(propertyName); if (propertyDescription != null) { final Class<? extends UserDefinedExpressionPropertyReadHandler> propertyReadHandler = propertyDescription.getPropertyReadHandler(); if (propertyReadHandler != null) { final UserDefinedExpressionPropertyReadHandler xmlReadHandler = propertyReadHandler.newInstance(); xmlReadHandler.init( beanUtility, originalExpressionClass, expressionClass, expression.getName()); return xmlReadHandler; } } return new ExpressionPropertyReadHandler( beanUtility, originalExpressionClass, expressionClass, expression.getName()); } catch (MetaDataLookupException e) { return new ExpressionPropertyReadHandler( beanUtility, originalExpressionClass, expressionClass, expression.getName()); } catch (Exception e) { throw new ParseException( "Unable to read metadata for property '" + propertyName + "'.", getLocator()); } }
public void init() { if (initialized) { return; } initialized = true; final DefaultComboBoxModel<ExpressionMetaData> model = new DefaultComboBoxModel<ExpressionMetaData>(); model.addElement(null); final ExpressionMetaData[] datas = ExpressionRegistry.getInstance().getAllExpressionMetaDatas(); for (int i = 0; i < datas.length; i++) { final ExpressionMetaData expressionMetaData = datas[i]; if (expressionMetaData.isHidden()) { continue; } if (WorkspaceSettings.getInstance().isShowExpertItems() == false && expressionMetaData.isExpert()) { continue; } if (WorkspaceSettings.getInstance().isShowDeprecatedItems() == false && expressionMetaData.isDeprecated()) { continue; } if (StructureFunction.class.isAssignableFrom(expressionMetaData.getExpressionType())) { model.addElement(expressionMetaData); } } expressionEditor.setModel(model); }
public static void main(final String[] args) { ClassicEngineBoot.getInstance().start(); final ExpressionMetaData[] datas = ExpressionRegistry.getInstance().getAllExpressionMetaDatas(); Arrays.sort(datas, GroupedMetaDataComparator.ENGLISH); for (int i = 0; i < datas.length; i++) { final ExpressionMetaData data = datas[i]; if (data instanceof AbstractMetaData == false) { continue; } printMetaBundle(data); } }
public static boolean isElementLayoutExpressionActive(final BundleWriterState state) { if (state == null) { throw new NullPointerException(); } final ExpressionCollection exp = state.getReport().getExpressions(); final ExpressionRegistry registry = ExpressionRegistry.getInstance(); for (int i = 0; i < exp.size(); i++) { final Expression expression = exp.getExpression(i); if (registry.isExpressionRegistered(expression.getClass().getName()) == false) { continue; } final ExpressionMetaData emd = registry.getExpressionMetaData(expression.getClass().getName()); if (emd.isElementLayoutProcessor()) { return true; } } return false; }
protected void traverseStyleExpressions(final ReportElement element) { final Map map = element.getStyleExpressions(); final Iterator styleExprIt = map.entrySet().iterator(); while (styleExprIt.hasNext()) { final Map.Entry entry = (Map.Entry) styleExprIt.next(); final StyleKey styleKey = (StyleKey) entry.getKey(); final Expression expression = (Expression) entry.getValue(); if (expression == null) { continue; } final String expressionName = expression.getClass().getName(); if (ExpressionRegistry.getInstance().isExpressionRegistered(expressionName) == false) { inspectStyleExpression(element, styleKey, expression, null); } else { final ExpressionMetaData metaData = ExpressionRegistry.getInstance().getExpressionMetaData(expressionName); inspectStyleExpression(element, styleKey, expression, metaData); } } }
protected void traverseAttributeExpressions(final ReportElement element) { final String[] attrExprNamespaces = element.getAttributeExpressionNamespaces(); for (int i = 0; i < attrExprNamespaces.length; i++) { final String attrExprNamespace = attrExprNamespaces[i]; final String[] names = element.getAttributeExpressionNames(attrExprNamespace); for (int j = 0; j < names.length; j++) { final String name = names[j]; final Expression expression = element.getAttributeExpression(attrExprNamespace, name); if (expression == null) { continue; } final String expressionName = expression.getClass().getName(); if (ExpressionRegistry.getInstance().isExpressionRegistered(expressionName) == false) { inspectAttributeExpression(element, attrExprNamespace, name, expression, null); } else { final ExpressionMetaData metaData = ExpressionRegistry.getInstance().getExpressionMetaData(expressionName); inspectAttributeExpression(element, attrExprNamespace, name, expression, metaData); } } } }
private static ExpressionPropertyWriteHandler createWriteHandler(Expression e, String key) { try { final ExpressionMetaData expressionMetaData = ExpressionRegistry.getInstance().getExpressionMetaData(e.getClass().getName()); final ExpressionPropertyMetaData propertyDescription = expressionMetaData.getPropertyDescription(key); final Class<? extends ExpressionPropertyWriteHandler> writeHandlerRef = propertyDescription.getPropertyWriteHandler(); if (writeHandlerRef != null) { return writeHandlerRef.newInstance(); } } catch (Exception ex) { logger.info("No valid property metadata defined for " + e.getClass() + " on property " + key); } return new DefaultExpressionPropertyWriteHandler(); }
/** @noinspection ThrowableResultOfMethodCallIgnored */ public static void main(final String[] args) { boolean offlineMode = false; boolean offlineModeSecurityManager = false; int parsePos; for (parsePos = 0; parsePos < args.length; parsePos += 1) { final String arg = args[parsePos]; if ("--offline".equals(arg) || "-o".equals(arg)) // NON-NLS { offlineMode = true; continue; } if ("--with-offline-mode-security-manager".equals(arg)) // NON-NLS { offlineModeSecurityManager = true; continue; } break; } final File[] files = new File[args.length - parsePos]; for (int i = 0; i < args.length; i++) { final String arg = args[i]; files[i] = new File(arg); } System.setProperty("sun.awt.exception.handler", ThrowableHandler.class.getName()); // NON-NLS Thread.setDefaultUncaughtExceptionHandler(ThrowableHandler.getInstance()); System.setProperty( "java.util.prefs.PreferencesFactory", BinaryPreferencesFactory.class.getName()); // NON-NLS System.setProperty("sun.swing.enableImprovedDragGesture", "true"); // NON-NLS ProxySelector.setDefault(new FirewallingProxySelector(ProxySelector.getDefault())); if (offlineModeSecurityManager) { try { System.setSecurityManager(new FirewallingSecurityManager()); } catch (SecurityException se) { DebugLog.log( "Unable to set security manager. An other security manager prevented us from gaining control."); // NON-NLS } } if (offlineMode) { WorkspaceSettings.getInstance().setOfflineMode(true); } PropertyEditorManager.registerEditor(Color.class, ColorPropertyEditor.class); try { SwingUtilities.invokeAndWait(new SetLookAndFeelTask()); SwingUtilities.invokeAndWait(new InstallAWTHandlerRunnable()); SwingUtilities.invokeAndWait(new InitializeSplashScreenTask()); // avoid the big cascading boot so that we can update the splashscreen // with some meaning full messages SwingUtilities.invokeAndWait(new UpdateStatusTask("Booting Base Libraries ..")); // NON-NLS LibLoaderBoot.getInstance().start(); if (LibLoaderBoot.getInstance().isBootFailed()) { throw new IllegalStateException( "Booting failed", LibLoaderBoot.getInstance().getBootFailureReason()); } SwingUtilities.invokeAndWait( new UpdateStatusTask("Booting Font Rendering System ..")); // NON-NLS LibFontBoot.getInstance().start(); if (LibFontBoot.getInstance().isBootFailed()) { throw new IllegalStateException( "Booting failed", LibFontBoot.getInstance().getBootFailureReason()); } SwingUtilities.invokeAndWait(new UpdateStatusTask("Booting Reporting-Engine ..")); // NON-NLS ClassicEngineBoot.getInstance().start(); if (ClassicEngineBoot.getInstance().isBootFailed()) { throw new IllegalStateException( "Booting failed", ClassicEngineBoot.getInstance().getBootFailureReason()); } SwingUtilities.invokeAndWait(new UpdateStatusTask("Booting Report-Designer ..")); // NON-NLS ReportDesignerBoot.getInstance().start(); if (ReportDesignerBoot.getInstance().isBootFailed()) { throw new IllegalStateException( "Booting failed", ReportDesignerBoot.getInstance().getBootFailureReason()); } // initialize some of the more expensive model components. SwingUtilities.invokeAndWait(new UpdateStatusTask("Preloading classes ..")); // NON-NLS ExpressionRegistry.getInstance(); ExpressionsTreeModel.getTreeModel(); ExpressionUtil.getInstance(); preloadFonts(); SwingUtilities.invokeAndWait( new UpdateStatusTask("Checking initial configuration ..")); // NON-NLS SettingsUtil.createInitialConfiguration(); SwingUtilities.invokeAndWait(new UpdateStatusTask("Collecting Sample Reports ..")); // NON-NLS SamplesTreeBuilder.getSampleTreeModel(); SwingUtilities.invokeAndWait(new UpdateStatusTask("Starting ..")); // NON-NLS SwingUtilities.invokeAndWait(new CreateReportDesignerFrame(files)); SwingUtilities.invokeAndWait(new VersionCheckerTask()); final ElementMetaData data = ElementTypeRegistry.getInstance().getElementType("page-header"); // NON-NLS final AttributeMetaData[] datas = data.getAttributeDescriptions(); final int x = datas.length; // ensure that there is some metadata. } catch (Throwable t) { if (splashScreen != null) { splashScreen.dispose(); } UncaughtExceptionsModel.getInstance().addException(t); final ExceptionDialog dialog = new ExceptionDialog(); dialog.setModal(true); dialog.showDialog(); System.exit(1); } }
public static void writeExpressionCore( final WriteableDocumentBundle bundle, final BundleWriterState state, final Expression expression, final XmlWriter writer, final String namespaceUri, final String expressionTag, final AttributeList expressionAttrList) throws IOException, BundleWriterException { if (bundle == null) { throw new NullPointerException(); } if (state == null) { throw new NullPointerException(); } if (expression == null) { throw new NullPointerException(); } if (writer == null) { throw new NullPointerException(); } if (namespaceUri == null) { throw new NullPointerException(); } if (expressionTag == null) { throw new NullPointerException(); } if (expressionAttrList == null) { throw new NullPointerException(); } if (expression instanceof FormulaExpression) { final FormulaExpression fe = (FormulaExpression) expression; if (StringUtils.isEmpty(fe.getFormula())) { return; } expressionAttrList.setAttribute(namespaceUri, "formula", fe.getFormula()); // NON-NLS writer.writeTag(namespaceUri, expressionTag, expressionAttrList, XmlWriterSupport.CLOSE); return; } if (expression instanceof FormulaFunction) { final FormulaFunction fe = (FormulaFunction) expression; if (StringUtils.isEmpty(fe.getFormula())) { return; } expressionAttrList.setAttribute(namespaceUri, "formula", fe.getFormula()); // NON-NLS expressionAttrList.setAttribute(namespaceUri, "initial", fe.getInitial()); // NON-NLS writer.writeTag(namespaceUri, expressionTag, expressionAttrList, XmlWriterSupport.CLOSE); return; } try { final String expressionId = expression.getClass().getName(); expressionAttrList.setAttribute(namespaceUri, "class", expressionId); final ExpressionMetaData emd; if (ExpressionRegistry.getInstance().isExpressionRegistered(expressionId)) { emd = ExpressionRegistry.getInstance().getExpressionMetaData(expressionId); } else { emd = null; } if (emd != null) { final BeanUtility bu = new BeanUtility(expression); final ExpressionPropertyMetaData[] expressionProperties = emd.getPropertyDescriptions(); boolean propertiesOpen = false; for (int i = 0; i < expressionProperties.length; i++) { final ExpressionPropertyMetaData metaData = expressionProperties[i]; final String propertyName = metaData.getName(); if (isFilteredProperty(propertyName)) { continue; } if (metaData.isComputed()) { continue; } if (propertiesOpen == false) { writer.writeTag(namespaceUri, expressionTag, expressionAttrList, XmlWriterSupport.OPEN); writer.writeTag(namespaceUri, "properties", XmlWriterSupport.OPEN); // NON-NLS propertiesOpen = true; } copyStaticResources(bundle, state, expression, bu, expressionProperties); writeExpressionParameter( bundle, state, writer, expression, bu, propertyName, namespaceUri); } if (propertiesOpen) { writer.writeCloseTag(); writer.writeCloseTag(); } else { writer.writeTag(namespaceUri, expressionTag, expressionAttrList, XmlWriterSupport.CLOSE); } } else { // the classic way, in case the expression does not provide any meta-data. This is // in the code for legacy reasons, as there are many expression implementations out there // that do not yet provide meta-data descriptions .. final BeanUtility beanUtility = new BeanUtility(expression); final String[] propertyNames = beanUtility.getProperties(); for (int i = 0; i < propertyNames.length; i++) { final String key = propertyNames[i]; // filter some of the standard properties. These are system-properties // and are set elsewhere if (isFilteredProperty(key)) { continue; } writeExpressionParameter( bundle, state, writer, expression, beanUtility, key, namespaceUri); } } } catch (IOException ioe) { throw ioe; } catch (Exception e) { throw new BundleWriterException("Unable to extract or write properties.", e); } }
public void actionPerformed(final ActionEvent e) { final ExpressionMetaData data = ExpressionRegistry.getInstance().getExpressionMetaData(expressionType.getName()); editModel.getChartExpressionsModel().setSelectedItem(data); }
public ChartEditingResult performEdit( final Element element, final ReportDesignerContext reportDesignerContext) throws CloneNotSupportedException { if (element == null) { throw new NullPointerException(); } if (reportDesignerContext == null) { throw new NullPointerException(); } if (LegacyChartsUtil.isLegacyChartElement(element) == false) { return null; } try { chartTable.setReportDesignerContext(reportDesignerContext); primaryDataSourceTable.setReportDesignerContext(reportDesignerContext); secondaryDataSourceTable.setReportDesignerContext(reportDesignerContext); chartPropertiesTableModel.setActiveContext(reportDesignerContext.getActiveContext()); primaryDataSourcePropertiesTableModel.setActiveContext( reportDesignerContext.getActiveContext()); secondaryDataSourcePropertiesTableModel.setActiveContext( reportDesignerContext.getActiveContext()); final Element editableElement = element.derive(); final Expression chartExpression = editableElement.getAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE); final Expression originalPrimaryDataSourceExpression; final Expression originalSecondaryDataSourceExpression; if (chartExpression != null) { originalPrimaryDataSourceExpression = extractPrimaryDatasource(element); originalSecondaryDataSourceExpression = extractSecondaryDatasource(element); editModel.setChartExpression(chartExpression.getInstance()); if (originalPrimaryDataSourceExpression != null) { editModel.setPrimaryDataSource(originalPrimaryDataSourceExpression.getInstance()); } else { editModel.setPrimaryDataSource(null); } if (originalSecondaryDataSourceExpression != null) { editModel.setSecondaryDataSource(originalSecondaryDataSourceExpression.getInstance()); } else { editModel.setSecondaryDataSource(null); } } else { editModel.setChartExpression(null); editModel.setPrimaryDataSource(null); editModel.setSecondaryDataSource(null); originalPrimaryDataSourceExpression = null; originalSecondaryDataSourceExpression = null; } if (editModel.getCurrentChartType() != null) { final ChartType chartType = editModel.getCurrentChartType(); if (editModel.getPrimaryDataSource() == null) { final Class dataSourceImplementation = chartType.getPreferredPrimaryDataSourceImplementation(); final ExpressionMetaData data = ExpressionRegistry.getInstance() .getExpressionMetaData(dataSourceImplementation.getName()); editModel.getPrimaryDataSourcesModel().setSelectedItem(data); } if (editModel.getSecondaryDataSource() == null) { final Class dataSourceImplementation = chartType.getPreferredSecondaryDataSourceImplementation(); if (dataSourceImplementation != null) { final ExpressionMetaData data = ExpressionRegistry.getInstance() .getExpressionMetaData(dataSourceImplementation.getName()); editModel.getSecondaryDataSourcesModel().setSelectedItem(data); } } } if (performEdit() == false) { return null; } secondaryDataSourceTable.stopEditing(); primaryDataSourceTable.stopEditing(); chartTable.stopEditing(); return new ChartEditingResult( chartExpression, originalPrimaryDataSourceExpression, originalSecondaryDataSourceExpression, editModel.getChartExpression(), editModel.getPrimaryDataSource(), editModel.getSecondaryDataSource()); } finally { chartTable.setReportDesignerContext(null); primaryDataSourceTable.setReportDesignerContext(null); secondaryDataSourceTable.setReportDesignerContext(null); chartPropertiesTableModel.setActiveContext(null); primaryDataSourcePropertiesTableModel.setActiveContext(null); secondaryDataSourcePropertiesTableModel.setActiveContext(null); } }