private void rebuildUi() {
    removeAll();
    if (isSingleTabMode()) {
      final JPanel buttonPanel = new JPanel();
      buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
      if (isShowRefreshButton()) {
        buttonPanel.add(new BorderlessButton(refreshParameterAction));
        if (isAllowCustomParameter()) {
          buttonPanel.add(Box.createHorizontalStrut(10));
        }
      }

      if (isAllowCustomParameter()) {
        buttonPanel.add(new BorderlessButton(addParameterAction));
        buttonPanel.add(new BorderlessButton(allInOneRemoveAction));
      }

      final JPanel tablePanel = new JPanel(new BorderLayout());
      tablePanel.add(new JScrollPane(allInOneTable), BorderLayout.CENTER);
      if (isShowHideParameterUiCheckbox()) {
        tablePanel.add(hideParameterUiCheckbox, BorderLayout.NORTH);
      }

      final JPanel headerPanel = new JPanel();
      headerPanel.setLayout(new BorderLayout());
      headerPanel.add(title, BorderLayout.WEST);
      headerPanel.add(buttonPanel, BorderLayout.EAST);

      final JPanel centralPanel = new JPanel();
      centralPanel.setLayout(new BorderLayout());
      // centralPanel.setBorder( new EmptyBorder( 5, 5, 5, 5 ) ); // Better layout --Kaa
      centralPanel.add(headerPanel, BorderLayout.NORTH);
      centralPanel.add(tablePanel, BorderLayout.CENTER);
      add(centralPanel, BorderLayout.CENTER);

    } else {
      final JPanel systemTablePanel = new JPanel(new BorderLayout());
      systemTablePanel.add(new JScrollPane(systemParameterTable), BorderLayout.CENTER);
      systemTablePanel.add(
          createButtonPanel(null, isShowHideParameterUiCheckbox()), BorderLayout.NORTH);
      systemTablePanel.add(createAdvancedParameterPanel(), BorderLayout.SOUTH);

      final JPanel predefinedTablePanel = new JPanel(new BorderLayout());
      predefinedTablePanel.add(new JScrollPane(predefinedParameterTable), BorderLayout.CENTER);
      predefinedTablePanel.add(createButtonPanel(null, false), BorderLayout.NORTH);

      final JPanel manualTablePanel = new JPanel(new BorderLayout());
      manualTablePanel.add(new JScrollPane(manualParameterTable), BorderLayout.CENTER);
      manualTablePanel.add(
          createButtonPanel(manualParameterRemoveAction, false), BorderLayout.NORTH);

      final JTabbedPane tabbedPane = new JTabbedPane();
      tabbedPane.addTab(
          Messages.getString("DrillDownParameterTable.Tab.Report"), predefinedTablePanel);
      tabbedPane.addTab(Messages.getString("DrillDownParameterTable.Tab.System"), systemTablePanel);
      tabbedPane.addTab(Messages.getString("DrillDownParameterTable.Tab.Manual"), manualTablePanel);

      add(tabbedPane, BorderLayout.CENTER);
    }
  }
 public String getColumnName(final int column) {
   switch (column) {
     case 0:
       return Messages.getString("CrosstabDetailTableModel.Field");
     case 1:
       return Messages.getString("CrosstabDetailTableModel.Aggregation");
     default:
       throw new IllegalStateException();
   }
 }
  public DrillDownParameterTable() {
    setLayout(new BorderLayout());

    listeners = new ArrayList<DrillDownParameterRefreshListener>();
    refreshParameterAction = new RefreshParameterAction();
    addParameterAction = new AddParameterAction();
    advancedEditorAction = new ShowAdvancedEditorAction();

    parameterTableModel = new DrillDownParameterTableModel();
    parameterTableModel.addTableModelListener(new DrillDownParameterChangeHandler());

    allInOneTable = new ElementMetaDataTable();
    allInOneTable.setFormulaFragment(true);
    allInOneTable.setDefaultEditor(GroupedName.class, new GroupedNameCellEditor());
    allInOneTable.setDefaultRenderer(String.class, new FormulaFragmentCellRenderer());
    allInOneTable.setModel(new GroupedMetaTableModel(parameterTableModel));

    allInOneRemoveAction = new RemoveParameterAction(allInOneTable);

    systemParameterTable = new ElementMetaDataTable();
    systemParameterTable.setFormulaFragment(true);
    systemParameterTable.setDefaultEditor(GroupedName.class, new GroupedNameCellEditor());
    systemParameterTable.setDefaultRenderer(String.class, new FormulaFragmentCellRenderer());
    systemParameterTable.setModel(
        new FilteringParameterTableModel(
            DrillDownParameter.Type.SYSTEM, parameterTableModel, true));

    manualParameterTable = new ElementMetaDataTable();
    manualParameterTable.setFormulaFragment(true);
    manualParameterTable.setDefaultEditor(GroupedName.class, new GroupedNameCellEditor());
    manualParameterTable.setDefaultRenderer(String.class, new FormulaFragmentCellRenderer());
    manualParameterTable.setModel(
        new FilteringParameterTableModel(DrillDownParameter.Type.MANUAL, parameterTableModel));
    manualParameterRemoveAction = new RemoveParameterAction(manualParameterTable);

    predefinedParameterTable = new ElementMetaDataTable();
    predefinedParameterTable.setFormulaFragment(true);
    predefinedParameterTable.setDefaultEditor(GroupedName.class, new GroupedNameCellEditor());
    predefinedParameterTable.setDefaultRenderer(String.class, new FormulaFragmentCellRenderer());
    predefinedParameterTable.setModel(
        new FilteringParameterTableModel(DrillDownParameter.Type.PREDEFINED, parameterTableModel));

    hideParameterUiCheckbox =
        new JCheckBox(Messages.getString("DrillDownParameterTable.HideParameterUI"));
    hideParameterUiCheckbox.addItemListener(new HideParamUiSelectionListener());

    title = new JLabel(Messages.getString("DrillDownParameterTable.Title"));

    rebuildUi();
  }
 private KeyedComboBoxModel createWhitspaceModel() {
   final KeyedComboBoxModel model = new KeyedComboBoxModel();
   model.add(
       WhitespaceCollapse.COLLAPSE,
       Messages.getString("ParagraphPropertiesPane.CollapseWhitespaces"));
   model.add(
       WhitespaceCollapse.DISCARD,
       Messages.getString("ParagraphPropertiesPane.DiscardAllWhitespaces"));
   model.add(
       WhitespaceCollapse.PRESERVE,
       Messages.getString("ParagraphPropertiesPane.PreserveAllWhitespaces"));
   model.add(
       WhitespaceCollapse.PRESERVE_BREAKS,
       Messages.getString("ParagraphPropertiesPane.PreserveBreaks"));
   return model;
 }
 private KeyedComboBoxModel createTextAlignmentModel() {
   final KeyedComboBoxModel model = new KeyedComboBoxModel();
   model.add(VerticalTextAlign.TOP, Messages.getString("ParagraphPropertiesPane.Top"));
   model.add(VerticalTextAlign.CENTRAL, Messages.getString("ParagraphPropertiesPane.Central"));
   model.add(VerticalTextAlign.MIDDLE, Messages.getString("ParagraphPropertiesPane.Middle"));
   model.add(VerticalTextAlign.BASELINE, Messages.getString("ParagraphPropertiesPane.Baseline"));
   model.add(
       VerticalTextAlign.USE_SCRIPT, Messages.getString("ParagraphPropertiesPane.UseScript"));
   model.add(VerticalTextAlign.TEXT_TOP, Messages.getString("ParagraphPropertiesPane.TextTop"));
   model.add(
       VerticalTextAlign.TEXT_BOTTOM, Messages.getString("ParagraphPropertiesPane.TextBottom"));
   model.add(VerticalTextAlign.SUB, Messages.getString("ParagraphPropertiesPane.Subscript"));
   model.add(VerticalTextAlign.SUPER, Messages.getString("ParagraphPropertiesPane.Superscript"));
   model.add(VerticalTextAlign.BOTTOM, Messages.getString("ParagraphPropertiesPane.Bottom"));
   return model;
 }
    /**
     * Defines an <code>Action</code> object with a default description string and default icon.
     *
     * @param table the table.
     */
    private RemoveParameterAction(final JTable table) {
      this.model = (GroupedTableModel) table.getModel();
      this.table = table;
      putValue(Action.SMALL_ICON, IconLoader.getInstance().getRemoveIcon());
      putValue(
          Action.SHORT_DESCRIPTION, Messages.getString("DrillDownParameterTable.RemoveParameter"));
      setEnabled(false);

      table.getSelectionModel().addListSelectionListener(this);
    }
    /** Invoked when an action occurs. */
    public void actionPerformed(final ActionEvent e) {
      final DrillDownParameter[] data = parameterTableModel.getData();
      final DrillDownParameter[] data2 = new DrillDownParameter[data.length + 1];
      System.arraycopy(data, 0, data2, 0, data.length);

      data2[data.length] =
          new DrillDownParameter(
              Messages.getString("DrillDownParameterTable.Parameter.DefaultName"));
      data2[data.length].setPosition(data.length);
      parameterTableModel.setData(data2);
    }
  protected void init() {
    setTitle(Messages.getString("ElementFormatDialog.FormatElement"));

    fontPropertiesPane = new FontPropertiesPane();
    advancedFontPropertiesPane = new AdvancedFontPropertiesPane();
    paragraphPropertiesPane = new ParagraphPropertiesPane();
    colorPropertiesPane = new ColorPropertiesPane();
    borderPropertiesPane = new BorderPropertiesPane();

    tabbedPane = new JTabbedPane();
    tabbedPane.add(Messages.getString("ElementFormatDialog.Font"), fontPropertiesPane);
    tabbedPane.add(
        Messages.getString("ElementFormatDialog.AdvancedFontSettings"), advancedFontPropertiesPane);
    tabbedPane.add(Messages.getString("ElementFormatDialog.Paragraph"), paragraphPropertiesPane);
    tabbedPane.add(Messages.getString("ElementFormatDialog.SizeAndBorders"), borderPropertiesPane);
    tabbedPane.add(
        Messages.getString("ElementFormatDialog.ColorAndBackground"), colorPropertiesPane);

    super.init();
  }
  public ParagraphPropertiesPane() {
    setLayout(new VerticalLayout());

    leftAlignButton = new JRadioButton(Messages.getString("ParagraphPropertiesPane.Left"));
    centerAlignButton = new JRadioButton(Messages.getString("ParagraphPropertiesPane.Center"));
    rightAlignButton = new JRadioButton(Messages.getString("ParagraphPropertiesPane.Right"));
    final ButtonGroup halignGroup = new ButtonGroup();
    halignGroup.add(leftAlignButton);
    halignGroup.add(centerAlignButton);
    halignGroup.add(rightAlignButton);

    topAlignButton = new JRadioButton(Messages.getString("ParagraphPropertiesPane.Top"));
    middleAlignButton = new JRadioButton(Messages.getString("ParagraphPropertiesPane.Middle"));
    bottomAlignButton = new JRadioButton(Messages.getString("ParagraphPropertiesPane.Bottom"));
    final ButtonGroup valignGroup = new ButtonGroup();
    valignGroup.add(topAlignButton);
    valignGroup.add(middleAlignButton);
    valignGroup.add(bottomAlignButton);

    textAlignModel = createTextAlignmentModel();
    whitespaceModel = createWhitspaceModel();

    final JComboBox textAlignmentComboBox = new JComboBox(textAlignModel);
    wrapTextCheckbox =
        new JCheckBox(Messages.getString("ParagraphPropertiesPane.AllowTextWrapping"));
    lineHeightField = new JTextField();
    lineHeightField.setColumns(10);
    final JComboBox whitespaceComboBox = new JComboBox(whitespaceModel);

    final JPanel halignPanel = new JPanel();
    halignPanel.setLayout(new VerticalLayout());
    halignPanel.setBorder(
        BorderFactory.createTitledBorder(
            Messages.getString("ParagraphPropertiesPane.HorizontalAlignment")));
    halignPanel.add(leftAlignButton);
    halignPanel.add(centerAlignButton);
    halignPanel.add(rightAlignButton);

    final JPanel valignPanel = new JPanel();
    valignPanel.setLayout(new VerticalLayout());
    valignPanel.setBorder(
        BorderFactory.createTitledBorder(
            Messages.getString("ParagraphPropertiesPane.VerticalAlignment")));
    valignPanel.add(topAlignButton);
    valignPanel.add(middleAlignButton);
    valignPanel.add(bottomAlignButton);

    final JPanel textToTextPanel = new JPanel();
    textToTextPanel.setLayout(new GridBagLayout());
    textToTextPanel.setBorder(
        BorderFactory.createTitledBorder(
            Messages.getString("ParagraphPropertiesPane.TextToTextAlignment")));

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.WEST;
    textToTextPanel.add(new JLabel(Messages.getString("ParagraphPropertiesPane.Alignment")), gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    textToTextPanel.add(textAlignmentComboBox, gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.anchor = GridBagConstraints.WEST;
    textToTextPanel.add(new JLabel(Messages.getString("ParagraphPropertiesPane.LineHeight")), gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    textToTextPanel.add(lineHeightField, gbc);

    final JPanel whitespacePanel = new JPanel();
    whitespacePanel.setLayout(new GridBagLayout());
    whitespacePanel.setBorder(
        BorderFactory.createTitledBorder(
            Messages.getString("ParagraphPropertiesPane.WhitespaceProcessing")));

    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    whitespacePanel.add(wrapTextCheckbox, gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.anchor = GridBagConstraints.WEST;
    whitespacePanel.add(
        new JLabel(Messages.getString("ParagraphPropertiesPane.WhitespaceProcessing")), gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    whitespacePanel.add(whitespaceComboBox, gbc);

    add(halignPanel);
    add(valignPanel);
    add(textToTextPanel);
    add(whitespacePanel);
  }
 private void registerChanges() {
   final MassElementStyleUndoEntry massElementStyleUndoEntry = builder.finish();
   context
       .getUndo()
       .addChange(Messages.getString("AlignmentUtilities.Undo"), massElementStyleUndoEntry);
 }
 /** Defines an <code>Action</code> object with a default description string and default icon. */
 private AddParameterAction() {
   putValue(Action.SMALL_ICON, IconLoader.getInstance().getAddIcon());
   putValue(
       Action.SHORT_DESCRIPTION, Messages.getString("DrillDownParameterTable.AddParameter"));
 }
 /** Defines an <code>Action</code> object with a default description string and default icon. */
 private ShowAdvancedEditorAction() {
   putValue(Action.NAME, Messages.getString("DrillDownParameterTable.Advanced"));
 }
 /** Defines an <code>Action</code> object with a default description string and default icon. */
 private RefreshParameterAction() {
   putValue(Action.SMALL_ICON, IconLoader.getInstance().getRefreshIcon());
   putValue(
       Action.SHORT_DESCRIPTION, Messages.getString("DrillDownParameterTable.RefreshParameter"));
   setEnabled(false);
 }
  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)));
    }
  }
    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});
    }