예제 #1
0
  /** Invoked when an action occurs. */
  public void actionPerformed(final ActionEvent e) {
    final ReportRenderContext activeContext = getActiveContext();
    if (activeContext == null) {
      return;
    }

    final Object[] selectedElements = getSelectionModel().getSelectedElements();
    for (int i = 0; i < selectedElements.length; i++) {
      final Object element = selectedElements[i];
      if (element instanceof ReportQueryNode) {
        final ReportQueryNode queryNode = (ReportQueryNode) element;
        try {
          performEdit(queryNode.getDataFactory(), queryNode.getQueryName());
        } catch (ReportDataFactoryException e1) {
          UncaughtExceptionsModel.getInstance().addException(e1);
        }
        break;
      } else if (element instanceof DataFactory) {
        try {
          final AbstractReportDefinition report = activeContext.getReportDefinition();
          final DataFactory dataFactory = ((DataFactory) element);
          performEdit(dataFactory, report.getQuery());
        } catch (ReportDataFactoryException e1) {
          UncaughtExceptionsModel.getInstance().addException(e1);
        }
        break;
      }
    }
  }
    /** 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));
        }
      }
    }
    /** Invoked when an action occurs. */
    public void actionPerformed(final ActionEvent e) {
      final Window window = LibSwingUtil.getWindowAncestor(carrierPanel);
      final Object selectedItem = expressionEditor.getSelectedItem();
      if (selectedItem instanceof StructureFunction) {
        final ExpressionPropertiesDialog optionPane;
        if (window instanceof JFrame) {
          optionPane = new ExpressionPropertiesDialog((JFrame) window);
        } else if (window instanceof JDialog) {
          optionPane = new ExpressionPropertiesDialog((JDialog) window);
        } else {
          optionPane = new ExpressionPropertiesDialog();
        }
        final StructureFunction structureFunction = (StructureFunction) selectedItem;
        final StructureFunction expression =
            (StructureFunction) optionPane.editExpression(structureFunction, designerContext);
        if (expression != selectedItem) {
          expressionEditor.setSelectedItem(expression);
        }
        fireEditingStopped();
      } else if (selectedItem instanceof ExpressionMetaData) {
        try {
          final ExpressionMetaData emd = (ExpressionMetaData) selectedItem;
          final Expression expression = (Expression) emd.getExpressionType().newInstance();

          final ExpressionPropertiesDialog optionPane;
          if (window instanceof JFrame) {
            optionPane = new ExpressionPropertiesDialog((JFrame) window);
          } else if (window instanceof JDialog) {
            optionPane = new ExpressionPropertiesDialog((JDialog) window);
          } else {
            optionPane = new ExpressionPropertiesDialog();
          }

          final Expression resultexpression =
              optionPane.editExpression(expression, designerContext);
          if (resultexpression != expression) {
            expressionEditor.setSelectedItem(resultexpression);
          }
          fireEditingStopped();
        } catch (Throwable e1) {
          UncaughtExceptionsModel.getInstance().addException(e1);
        }
      }
    }
  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;
    }
  }
 protected boolean move(
     final Object element,
     final AbstractReportDefinition report,
     final ArrayList<UndoEntry> undos) {
   try {
     if (element instanceof Expression) {
       final UndoEntry undoEntry = moveExpressions(report, element);
       if (undoEntry == null) {
         return false;
       }
       undos.add(undoEntry);
     } else if (element instanceof ParameterDefinitionEntry) {
       final UndoEntry undoEntry = moveParameters(report, element);
       if (undoEntry == null) {
         return false;
       }
       undos.add(undoEntry);
     } else if (element instanceof DataFactory) {
       final UndoEntry undoEntry = moveDataFactories(report, element);
       if (undoEntry == null) {
         return false;
       }
       undos.add(undoEntry);
     } else if (element instanceof RelationalGroup) {
       final UndoEntry undoEntry = moveGroup((RelationalGroup) element);
       if (undoEntry == null) {
         return false;
       }
       undos.add(undoEntry);
     } else if (element instanceof Element) {
       final UndoEntry undoEntry = moveVisualElement(report, (Element) element);
       if (undoEntry == null) {
         return false;
       }
       undos.add(undoEntry);
     }
   } catch (Exception ex) {
     UncaughtExceptionsModel.getInstance().addException(ex);
     return false;
   }
   return true;
 }
 /**
  * Returns the value contained in the editor.
  *
  * @return the value contained in the editor
  */
 public Object getCellEditorValue() {
   final Object o = this.expressionEditor.getSelectedItem();
   if (o instanceof ExpressionMetaData) {
     try {
       final ExpressionMetaData emd = (ExpressionMetaData) o;
       if (StructureFunction.class.isAssignableFrom(emd.getExpressionType())) {
         return emd.getExpressionType().newInstance();
       } else {
         return null;
       }
     } catch (Throwable t) {
       UncaughtExceptionsModel.getInstance().addException(t);
       return null;
     }
   } else if (o instanceof StructureFunction) {
     return o;
   } else {
     return null;
   }
 }
  /** Invoked when an action occurs. */
  public void actionPerformed(final ActionEvent e) {
    final ReportDocumentContext activeContext = getActiveContext();
    if (activeContext == null) {
      return;
    }
    final ReportDesignerContext context = getReportDesignerContext();
    final Component parent = context.getView().getParent();
    final Window window = LibSwingUtil.getWindowAncestor(parent);
    final DocumentMetaDataDialog dialog;
    if (window instanceof JDialog) {
      dialog = new DocumentMetaDataDialog((JDialog) window);
    } else if (window instanceof JFrame) {
      dialog = new DocumentMetaDataDialog((JFrame) window);
    } else {
      dialog = new DocumentMetaDataDialog();
    }

    try {
      final MasterReport report = activeContext.getContextRoot();
      final DocumentBundle bundle = report.getBundle();
      final DocumentMetaData oldMetaData = (DocumentMetaData) bundle.getMetaData().clone();
      final DocumentMetaData result =
          dialog.performEdit(
              oldMetaData, report.getResourceManager(), report.getDefinitionSource());

      if (result == null) {
        return;
      }

      final MetaDataEditUndoEntry undoEntry = new MetaDataEditUndoEntry(oldMetaData, result);
      undoEntry.redo(activeContext);
      activeContext
          .getUndo()
          .addChange(ActionMessages.getString("EditReportPropertiesAction.Text"), undoEntry);
    } catch (CloneNotSupportedException cne) {
      // should not happen
      UncaughtExceptionsModel.getInstance().addException(cne);
    }
  }
  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
  }
예제 #9
0
    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);
      }
    }
예제 #10
0
  /** @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 void run() {
      final ReportDocumentContext context = dragContext.getRenderContext();
      if (rootband) {
        final int result =
            JOptionPane.showOptionDialog(
                dragContext.getRepresentationContainer(),
                Messages.getString(
                    "CrosstabReportElementDragHandler.BandedOrInlineSubreportQuestion"),
                Messages.getString("CrosstabReportElementDragHandler.InsertSubreport"),
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE,
                null,
                new String[] {
                  Messages.getString("CrosstabReportElementDragHandler.Inline"),
                  Messages.getString("CrosstabReportElementDragHandler.Banded"),
                  Messages.getString("CrosstabReportElementDragHandler.Cancel")
                },
                Messages.getString("CrosstabReportElementDragHandler.Inline"));
        if (result == JOptionPane.CLOSED_OPTION || result == 2) {
          return;
        }

        if (result == 0) {
          final UndoManager undo = context.getUndo();
          undo.addChange(
              Messages.getString("CrosstabReportElementDragHandler.UndoEntry"),
              new ElementEditUndoEntry(
                  parent.getObjectID(), parent.getElementCount(), null, subReport));
          parent.addElement(subReport);
        } else {
          final AbstractRootLevelBand arb = (AbstractRootLevelBand) parent;
          final UndoManager undo = context.getUndo();
          undo.addChange(
              Messages.getString("CrosstabReportElementDragHandler.UndoEntry"),
              new BandedSubreportEditUndoEntry(
                  parent.getObjectID(), arb.getSubReportCount(), null, subReport));
          arb.addSubReport(subReport);
        }
      } else {
        final UndoManager undo = context.getUndo();
        undo.addChange(
            Messages.getString("CrosstabReportElementDragHandler.UndoEntry"),
            new ElementEditUndoEntry(
                parent.getObjectID(), parent.getElementCount(), null, subReport));
        parent.addElement(subReport);
      }

      final ReportDesignerContext designerContext = dragContext.getDesignerContext();
      final Window window = LibSwingUtil.getWindowAncestor(designerContext.getView().getParent());
      final AbstractReportDefinition reportDefinition =
          designerContext.getActiveContext().getReportDefinition();

      try {
        // Create the new subreport tab - this is where the contents of the Crosstab
        // dialog will go.  Zoom the crosstab canvas to 150% as crosstab has a lot of elements to
        // display
        subReport.setDataFactory(reportDefinition.getDataFactory());
        subReport
            .getReportDefinition()
            .setAttribute(ReportDesignerBoot.DESIGNER_NAMESPACE, ReportDesignerBoot.ZOOM, 1.5f);

        final ResourceBundleFactory rbf = subReport.getResourceBundleFactory();
        subReport.setResourceBundleFactory(rbf);

        final int idx = designerContext.addSubReport(designerContext.getActiveContext(), subReport);
        designerContext.setActiveDocument(designerContext.getReportRenderContext(idx));
      } catch (ReportDataFactoryException e) {
        UncaughtExceptionsModel.getInstance().addException(e);
      }

      // Prompt user to either create or use an existing data-source.
      final SubReportDataSourceDialog crosstabDataSourceDialog;
      if (window instanceof Dialog) {
        crosstabDataSourceDialog = new SubReportDataSourceDialog((Dialog) window);
      } else if (window instanceof Frame) {
        crosstabDataSourceDialog = new SubReportDataSourceDialog((Frame) window);
      } else {
        crosstabDataSourceDialog = new SubReportDataSourceDialog();
      }

      // User has prompted to select a data-source.  Get the selected query
      final String queryName = crosstabDataSourceDialog.performSelection(designerContext);
      if (queryName != null) {
        subReport.setQuery(queryName);

        // Invoke Crosstab dialog
        final InsertCrosstabGroupAction crosstabAction = new InsertCrosstabGroupAction();
        crosstabAction.setReportDesignerContext(designerContext);
        crosstabAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, ""));
      }

      dragContext
          .getRenderContext()
          .getSelectionModel()
          .setSelectedElements(new Object[] {subReport});
    }