public static void main(final String[] args) { final HashMap styles = new HashMap(); ClassicEngineBoot.getInstance().start(); final ElementMetaData[] elementMetaDatas = ElementTypeRegistry.getInstance().getAllElementTypes(); for (int i = 0; i < elementMetaDatas.length; i++) { final ElementMetaData elementMetaData = elementMetaDatas[i]; final StyleMetaData[] styleMetaDatas = elementMetaData.getStyleDescriptions(); for (int j = 0; j < styleMetaDatas.length; j++) { final StyleMetaData styleMetaData = styleMetaDatas[j]; styles.put(styleMetaData.getName(), styleMetaData); } } final StyleMetaData[] stylesArray = (StyleMetaData[]) styles.values().toArray(new StyleMetaData[styles.size()]); Arrays.sort(stylesArray, new PlainMetaDataComparator()); for (int i = 0; i < stylesArray.length; i++) { StyleMetaData metaData = stylesArray[i]; final String name = metaData.getName(); System.out.println("style." + name + ".display-name=" + name); System.out.println( "style." + name + ".grouping=" + filter(metaData.getGrouping(Locale.ENGLISH), "Group")); System.out.println( "style." + name + ".description=" + filter(metaData.getDescription(Locale.ENGLISH), "")); System.out.println( "style." + name + ".deprecated=" + filter(metaData.getDeprecationMessage(Locale.ENGLISH), "")); } }
public static boolean validateElementMetaData(ElementType elementType) { ElementMetaData metaData = elementType.getMetaData(); if (metaData == null) { logger.warn("No Metadata defined"); return false; } if (validateCanInstantiate(metaData)) { return false; } final String typeName = metaData.getName(); logger.debug("Processing " + typeName); ArrayList<String> missingProperties = new ArrayList<String>(); validateCoreMetaData(metaData, missingProperties); validateStyleMetaData(metaData, missingProperties); validateAttributeMetaData(metaData, missingProperties); flushSystemErr(); for (String property : missingProperties) { System.out.println(property); } return missingProperties.isEmpty(); }
private static boolean validateCanInstantiate(final ElementMetaData metaData) { try { //noinspection UnusedDeclaration final Object type = metaData.create(); } catch (InstantiationException e) { logger.warn("Failed to instantiate ElementType"); return true; } return false; }
private static void validateStyleMetaData( final ElementMetaData metaData, final ArrayList<String> missingProperties) { final Locale locale = Locale.getDefault(); final String typeName = metaData.getName(); final StyleMetaData[] styleMetaDatas = metaData.getStyleDescriptions(); for (int j = 0; j < styleMetaDatas.length; j++) { final StyleMetaData propertyMetaData = styleMetaDatas[j]; final String propertyDisplayName = propertyMetaData.getDisplayName(locale); if (isValid(propertyDisplayName, propertyMetaData.getName(), missingProperties) == false) { logger.warn( "ElementType '" + typeName + ": Style " + propertyMetaData.getName() + ": No DisplayName"); } final String propertyGrouping = propertyMetaData.getGrouping(locale); if (isValid(propertyGrouping, "common", missingProperties) == false) { logger.warn( "ElementType '" + typeName + ": Style " + propertyMetaData.getName() + ": Grouping is not valid"); } if (propertyMetaData.isDeprecated()) { final String deprecateMessage = propertyMetaData.getDeprecationMessage(locale); if (isValid(deprecateMessage, "Deprecated", missingProperties) == false) { logger.warn( "ElementType '" + typeName + ": Style " + propertyMetaData.getName() + ": No valid deprecate message"); } } } }
protected Element createElement( final ElementMetaData elementMetaData, final String fieldName, final ReportDocumentContext context) throws InstantiationException { final ElementType type = elementMetaData.create(); final IndexElement visualElement = new IndexElement(); visualElement.setAutoSort(Boolean.TRUE); visualElement .getRelationalGroup(0) .getHeader() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); visualElement .getRelationalGroup(0) .getFooter() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); visualElement .getDetailsFooter() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); visualElement .getDetailsHeader() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); visualElement .getNoDataBand() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); visualElement .getWatermark() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); type.configureDesignTimeDefaults(visualElement, Locale.getDefault()); final ElementStyleSheet styleSheet = visualElement.getStyle(); styleSheet.setStyleProperty(ElementStyleKeys.MIN_WIDTH, DEFAULT_WIDTH); styleSheet.setStyleProperty(ElementStyleKeys.MIN_HEIGHT, DEFAULT_HEIGHT); return visualElement; }
protected Element createElement( final ElementMetaData elementMetaData, final String fieldName, final ReportDocumentContext context) throws InstantiationException { // Create a crosstab element final ElementType type = elementMetaData.create(); final CrosstabElement visualElement = new CrosstabElement(); visualElement.setElementType(type); visualElement.setRootGroup(new CrosstabGroup()); // Hide all bands except for Details visualElement .getPageHeader() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); visualElement .getReportHeader() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); visualElement .getReportFooter() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); visualElement .getPageFooter() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); visualElement .getWatermark() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE); type.configureDesignTimeDefaults(visualElement, Locale.getDefault()); final ElementStyleSheet styleSheet = visualElement.getStyle(); styleSheet.setStyleProperty(ElementStyleKeys.MIN_WIDTH, DEFAULT_WIDTH); styleSheet.setStyleProperty(ElementStyleKeys.MIN_HEIGHT, DEFAULT_HEIGHT); return visualElement; }
private ReportElementDragHandler createDragHandler(final ElementMetaData metaData) { if (metaData == null) { return null; } ReportElementEditor elementEditor = ReportElementEditorRegistry.getInstance().getPlugin(metaData.getName()); if (elementEditor == null) { elementEditor = ReportElementEditorRegistry.getInstance().getPlugin(null); if (elementEditor == null) { return null; } } return elementEditor.createDragHandler(); }
private static void printMetaBundle(final ElementMetaData data, Map globalAttributes) { System.out.println("-----------------------------------------------------"); final AbstractMetaData amd = (AbstractMetaData) data; final String keyPrefix = amd.getKeyPrefix(); final String ename = amd.getName(); final String ebundle = amd.getBundleLocation(); System.out.println(keyPrefix + ename + ".display-name=" + ename); System.out.println( keyPrefix + ename + ".grouping=" + filter(amd.getGrouping(Locale.ENGLISH), "Group")); System.out.println( keyPrefix + ename + ".description=" + filter(amd.getDescription(Locale.ENGLISH), "")); System.out.println( keyPrefix + ename + ".deprecated=" + filter(amd.getDeprecationMessage(Locale.ENGLISH), "")); final AttributeMetaData[] attributes = data.getAttributeDescriptions(); for (int j = 0; j < attributes.length; j++) { final AttributeMetaData attribute = attributes[j]; final AbstractMetaData aamd = (AbstractMetaData) attribute; final String akeyPrefix = aamd.getKeyPrefix(); final String abundle = aamd.getBundleLocation(); final String aname = attribute.getName(); if (abundle.equals(GLOBAL_BUNDLE) && akeyPrefix.startsWith("attribute.")) { globalAttributes.put(aname, attribute); continue; } System.out.println(akeyPrefix + aname + ".display-name=" + aname); System.out.println( akeyPrefix + aname + ".grouping=" + filter(aamd.getGrouping(Locale.ENGLISH), "Group")); System.out.println( akeyPrefix + aname + ".description=" + filter(aamd.getDescription(Locale.ENGLISH), "")); System.out.println( akeyPrefix + aname + ".deprecated=" + filter(aamd.getDeprecationMessage(Locale.ENGLISH), "")); } System.out.println("-----------------------------------------------------"); }
private static void validateCoreMetaData( final ElementMetaData metaData, final ArrayList<String> missingProperties) { final Locale locale = Locale.getDefault(); final String typeName = metaData.getName(); final String displayName = metaData.getDisplayName(locale); if (isValid(displayName, metaData.getName(), missingProperties) == false) { logger.warn("ElementType '" + typeName + ": No valid display name"); } if (metaData.isDeprecated()) { final String deprecateMessage = metaData.getDeprecationMessage(locale); if (isValid(deprecateMessage, "Deprecated", missingProperties) == false) { logger.warn("ElementType '" + typeName + ": No valid deprecate message"); } } final String grouping = metaData.getGrouping(locale); if (isValid(grouping, "common", missingProperties) == false) { logger.warn("ElementType '" + typeName + ": No valid grouping message"); } }
/** @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); } }
/** * Creates a deep copy of this element and regenerates all instance-ids. * * @param preserveElementInstanceIds defines whether this call generates new instance-ids for the * derived elements. Instance-IDs are used by the report processor to recognize reoccurring * elements and must not changed within the report run. Outside of the report processors new * instance ids should be generated at all times to separate instances and to make them * uniquely identifiable. * @return the copy of the element. */ public Element derive(final boolean preserveElementInstanceIds) { try { final Element e = (Element) super.clone(); e.elementContext = null; if (preserveElementInstanceIds == false) { e.treeLock = new InstanceID(); } e.style = (InternalElementStyleSheet) style.derive(preserveElementInstanceIds); e.datasource = datasource.clone(); e.parent = null; e.style.updateElementReference(e); e.attributes = attributes.clone(); e.copyOnWrite = false; final ElementMetaData metaData = e.getMetaData(); final String[] namespaces = e.attributes.getNameSpaces(); for (int i = 0; i < namespaces.length; i++) { final String namespace = namespaces[i]; final Map attrsNs = attributes.getAttributes(namespace); final Iterator it = attrsNs.entrySet().iterator(); while (it.hasNext()) { final Map.Entry entry = (Map.Entry) it.next(); final Object value = entry.getValue(); final String name = (String) entry.getKey(); final AttributeMetaData data = metaData.getAttributeDescription(namespace, name); if (data == null) { if (logger.isDebugEnabled()) { logger.debug( getElementTypeName() + ": Attribute " + namespace + "|" + name + " is not listed in the metadata."); } } if (value instanceof Cloneable) { e.attributes.setAttribute(namespace, name, ObjectUtilities.clone(value)); } else if (data == null || data.isComputed() == false || data.isDesignTimeValue()) { e.attributes.setAttribute(namespace, name, value); } else { e.attributes.setAttribute(namespace, name, null); } } } if (e.cachedAttributes != null && e.attributes.getChangeTracker() != e.cachedAttributes.getChangeTracker()) { e.cachedAttributes = null; } if (attributeExpressions != null) { e.attributeExpressions = attributeExpressions.clone(); final String[] attrExprNamespaces = e.attributeExpressions.getNameSpaces(); for (int i = 0; i < attrExprNamespaces.length; i++) { final String namespace = attrExprNamespaces[i]; final Map attrsNs = attributeExpressions.getAttributes(namespace); final Iterator it = attrsNs.entrySet().iterator(); while (it.hasNext()) { final Map.Entry entry = (Map.Entry) it.next(); final Expression exp = (Expression) entry.getValue(); e.attributeExpressions.setAttribute( namespace, (String) entry.getKey(), exp.getInstance()); } } } if (styleExpressions != null) { //noinspection unchecked e.styleExpressions = (HashMap<StyleKey, Expression>) styleExpressions.clone(); final Iterator<Map.Entry<StyleKey, Expression>> styleExpressionsIt = e.styleExpressions.entrySet().iterator(); while (styleExpressionsIt.hasNext()) { final Map.Entry<StyleKey, Expression> entry = styleExpressionsIt.next(); final Expression exp = entry.getValue(); entry.setValue(exp.getInstance()); } } return e; } catch (CloneNotSupportedException cne) { throw new IllegalStateException(cne); } }
public void copyInto(final Element target) { final ElementMetaData metaData = getMetaData(); final String[] attributeNamespaces = getAttributeNamespaces(); for (int i = 0; i < attributeNamespaces.length; i++) { final String namespace = attributeNamespaces[i]; final String[] attributeNames = getAttributeNames(namespace); for (int j = 0; j < attributeNames.length; j++) { final String name = attributeNames[j]; final AttributeMetaData attributeDescription = metaData.getAttributeDescription(namespace, name); if (attributeDescription == null) { continue; } if (attributeDescription.isTransient()) { continue; } if (attributeDescription.isComputed()) { continue; } if (AttributeNames.Core.ELEMENT_TYPE.equals(name) && AttributeNames.Core.NAMESPACE.equals(namespace)) { continue; } target.setAttribute(namespace, name, getAttribute(namespace, name), false); } } final String[] attrExprNamespaces = getAttributeExpressionNamespaces(); for (int i = 0; i < attrExprNamespaces.length; i++) { final String namespace = attrExprNamespaces[i]; final String[] attributeNames = getAttributeExpressionNames(namespace); for (int j = 0; j < attributeNames.length; j++) { final String name = attributeNames[j]; final AttributeMetaData attributeDescription = metaData.getAttributeDescription(namespace, name); if (attributeDescription == null) { continue; } if (attributeDescription.isTransient()) { continue; } target.setAttributeExpression(namespace, name, getAttributeExpression(namespace, name)); } } final ElementStyleSheet styleSheet = getStyle(); final StyleKey[] styleKeys = styleSheet.getDefinedPropertyNamesArray(); for (int i = 0; i < styleKeys.length; i++) { final StyleKey styleKey = styleKeys[i]; if (styleKey != null) { target.getStyle().setStyleProperty(styleKey, styleSheet.getStyleProperty(styleKey)); } } final Set<Map.Entry<StyleKey, Expression>> styleExpressionEntries = getStyleExpressions().entrySet(); for (final Map.Entry<StyleKey, Expression> entry : styleExpressionEntries) { target.setStyleExpression(entry.getKey(), entry.getValue()); } }
public void registerReader( final ElementType elementType, final Class<? extends ElementReadHandler> readHandler) { ElementMetaData metaData = elementType.getMetaData(); register(metaData.getNamespace(), metaData.getName(), readHandler); }
public void registerGenericReader(final ElementType elementType) { ElementMetaData metaData = elementType.getMetaData(); register(metaData.getNamespace(), metaData.getName(), GenericElementReadHandler.class); }
public void register( final ElementType elementType, final Class<? extends BundleElementWriteHandler> writeHandler) { ElementMetaData metaData = elementType.getMetaData(); register(metaData.getName(), writeHandler); }