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 void run() {
      final SplashScreen splashScreen = new SplashScreen();
      ReportDesigner.splashScreen = splashScreen;

      if (WorkspaceSettings.getInstance().isSplashScreenVisible()) {
        splashScreen.setVisible(true);
      }
    }
 public ResizeRightDragOperation(
     final List<Element> selectedVisualElements,
     final Point2D originPoint,
     final SnapPositionsModel horizontalSnapModel,
     final SnapPositionsModel verticalSnapModel) {
   super(selectedVisualElements, originPoint, horizontalSnapModel, verticalSnapModel);
   snapThreshold = WorkspaceSettings.getInstance().getSnapThreshold();
 }
    public void processResults(final String result) {
      try {
        final SAXReader reader = new SAXReader();
        final Document templateDoc = reader.read(new ByteArrayInputStream(result.getBytes()));
        final List<UpdateInfo> updates = new ArrayList<UpdateInfo>();
        final List updateElements =
            templateDoc.getRootElement().selectNodes("/vercheck/product/update"); // NON-NLS
        for (int i = 0; i < updateElements.size(); i++) {
          final Element updateElement = (Element) updateElements.get(i);
          final String version = updateElement.attributeValue("version"); // NON-NLS
          final String type = updateElement.attributeValue("type"); // NON-NLS
          // final String os = updateElement.attributeValue("os");
          final String downloadUrl =
              updateElement.selectSingleNode("downloadurl").getText(); // NON-NLS
          final UpdateInfo info = new UpdateInfo(version, type, downloadUrl);
          updates.add(info);
        }

        if (updates.isEmpty()) {
          if (forcePrompt) {
            JOptionPane.showMessageDialog(
                parent,
                "No update is available at this time.",
                "Version Update Info",
                JOptionPane.INFORMATION_MESSAGE);
          }
          return;
        }

        if ((forcePrompt
            || !updates
                .get(updates.size() - 1)
                .getVersion()
                .equals(WorkspaceSettings.getInstance().getLastPromptedVersionUpdate()))) {
          final UpdateInfo[] updateInfos = updates.toArray(new UpdateInfo[updates.size()]);
          VersionConfirmationDialog.performUpdateAvailable(parent, updateInfos, exitOnLaunch);
        }
      } catch (Exception e) {
        // we cannot give errors
        logger.error("The version checker encountered an error", e);
        JOptionPane.showMessageDialog(
            parent,
            "No update is available at this time.",
            "Version Update Info",
            JOptionPane.INFORMATION_MESSAGE);
      }
    }
  public static void checkVersion(
      final Component parent, final boolean forcePrompt, final boolean exitOnLaunch) {
    final BasicVersionCheckerProvider dataProvider =
        new BasicVersionCheckerProvider(VersionCheckerUtility.class);
    final boolean gaOnly = !WorkspaceSettings.getInstance().isNotifyForAllBuilds();
    if (gaOnly) {
      dataProvider.setVersionRequestFlags(BasicVersionCheckerProvider.DEPTH_GA_MASK);
    } else {
      dataProvider.setVersionRequestFlags(BasicVersionCheckerProvider.DEPTH_ALL_MASK);
    }
    final VersionChecker vc = new VersionChecker();
    vc.setDataProvider(dataProvider);
    vc.addResultHandler(new InternalResultHandler(parent, forcePrompt, exitOnLaunch));
    vc.addErrorHandler(new NoPromptErrorHandler());

    // start new thread; do not run in event thread
    final Thread vcThread = new Thread(new VersionCheckerRunnable(vc));
    vcThread.setDaemon(true);
    vcThread.start();
  }
  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
  }
    public void run() {
      try {
        final ReportDesignerFrame frame = new ReportDesignerFrame();
        ReportDesigner.reportDesignerFrame = frame;
        frame.pack();

        final Rectangle bounds = WorkspaceSettings.getInstance().getBounds();
        if (bounds == null || LibSwingUtil.safeRestoreWindow(frame, bounds) == false) {
          LibSwingUtil.centerFrameOnScreen(frame);
          frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        }
        frame.initWindowLocations(files);
        frame.setVisible(true);
      } catch (Exception t) {
        if (splashScreen != null) {
          splashScreen.dispose();
        }
        UncaughtExceptionsModel.getInstance().addException(t);
        final ExceptionDialog dialog = new ExceptionDialog();
        dialog.setModal(true);
        dialog.showDialog();
        System.exit(-1);
      }
    }
 private static boolean getCheckVersion() {
   return WorkspaceSettings.getInstance().isUseVersionChecker();
 }
 private static boolean isInitialCheck() {
   return WorkspaceSettings.getInstance().isInitialVersionCheck();
 }
 private static void setCheckVersion(final boolean checkVersion) {
   WorkspaceSettings.getInstance().setUseVersionChecker(checkVersion);
 }
  /** @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);
    }
  }
  protected void inspectExpression(
      final ReportDesignerContext designerContext,
      final ReportRenderContext reportRenderContext,
      final InspectionResultListener resultHandler,
      final String[] columnNames,
      final Expression expression,
      final ExpressionMetaData expressionMetaData) {
    if (expressionMetaData == null) {
      return;
    }

    try {
      final BeanUtility utility = new BeanUtility(expression);
      final ExpressionPropertyMetaData[] datas = expressionMetaData.getPropertyDescriptions();
      for (int i = 0; i < datas.length; i++) {
        final ExpressionPropertyMetaData metaData = datas[i];
        if (metaData.isHidden()) {
          continue;
        }
        if (WorkspaceSettings.getInstance().isShowExpertItems() == false && metaData.isExpert()) {
          continue;
        }
        if (WorkspaceSettings.getInstance().isShowDeprecatedItems() == false
            && metaData.isDeprecated()) {
          continue;
        }

        if (!"ElementName".equals(metaData.getPropertyRole())) // NON-NLS
        {
          continue;
        }

        final Object o = utility.getProperty(metaData.getName());
        final String[] elements = metaData.getReferencedElements(expression, o);
        for (int j = 0; j < elements.length; j++) {
          final String element = elements[j];
          final AbstractReportDefinition reportDefinition =
              reportRenderContext.getReportDefinition();
          final ReportElement e =
              FunctionUtilities.findElementByAttribute(
                  reportDefinition,
                  AttributeNames.Core.NAMESPACE,
                  AttributeNames.Core.NAME,
                  element);
          if (e == null) {
            resultHandler.notifyInspectionResult(
                new InspectionResult(
                    this,
                    InspectionResult.Severity.WARNING,
                    Messages.getString(
                        "InvalidElementReferenceInspection.ExpressionReferencesInvalidName",
                        expression.getName(),
                        metaData.getDisplayName(Locale.getDefault())),
                    new PropertyLocationInfo(expression, metaData.getName())));
          }
        }
      }
    } catch (Exception e) {
      resultHandler.notifyInspectionResult(
          new InspectionResult(
              this,
              InspectionResult.Severity.WARNING,
              e.getMessage(),
              new LocationInfo(expression)));
    }
  }