Exemplo n.º 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;
      }
    }
  }
Exemplo n.º 2
0
  protected void updateSelection() {
    final ReportSelectionModel selectionModel1 = getSelectionModel();
    if (selectionModel1 == null) {
      setEnabled(false);
      editedDataFactory = null;
      return;
    }

    final Object[] selectedObjects = selectionModel1.getSelectedElements();
    for (int i = 0; i < selectedObjects.length; i++) {
      final Object selectedObject = selectedObjects[i];
      if (selectedObject instanceof ReportQueryNode == false) {
        continue;
      }
      final ReportQueryNode queryNode = (ReportQueryNode) selectedObject;
      final DataFactory dataFactory = queryNode.getDataFactory();

      final DataFactoryMetaData metadata = dataFactory.getMetaData();
      if (metadata.isEditable()) {
        setEnabled(true);
        return;
      }
    }

    setEnabled(false);
  }