/*
 * This program is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
 * Foundation.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
 * or from the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * Copyright (c) 2009 Pentaho Corporation.  All rights reserved.
 */

package org.pentaho.reporting.designer.core.editor;

import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashSet;

import org.pentaho.reporting.designer.core.Messages;
import org.pentaho.reporting.designer.core.util.exceptions.UncaughtExceptionsModel;
import org.pentaho.reporting.engine.classic.core.ClassicEngineBoot;
import org.pentaho.reporting.libraries.base.config.HierarchicalConfiguration;
import org.pentaho.reporting.libraries.base.config.ModifiableConfiguration;
import org.pentaho.reporting.libraries.designtime.swing.CommonDialog;
import org.pentaho.reporting.tools.configeditor.ConfigEditorPane;

public class ConfigurationEditorDialog extends CommonDialog
{
  private ConfigEditorPane editorPane;

  public ConfigurationEditorDialog()
  {
    init();
  }

  public ConfigurationEditorDialog(final Frame owner)
  {
    super(owner);
    init();
  }

  public ConfigurationEditorDialog(final Dialog owner)
  {
    super(owner);
    init();
  }

  protected Component createContentPane()
  {
    setTitle(Messages.getString("ConfigurationEditorDialog.Title"));

    editorPane = new ConfigEditorPane(ClassicEngineBoot.getInstance(), false);
    try
    {
      editorPane.load(false);
    }
    catch (final IOException ioe)
    {
      UncaughtExceptionsModel.getInstance().addException(ioe);
    }
    return editorPane;
  }

  protected String getDialogId()
  {
    return "ReportDesigner.Core.Configuration";
  }

  public boolean performEdit(final ModifiableConfiguration config)
  {
    final HashSet<String> existingKeys = new HashSet<String>();
    final HierarchicalConfiguration hconf = new HierarchicalConfiguration(config);
    if (config instanceof HierarchicalConfiguration)
    {
      final HierarchicalConfiguration oconf = (HierarchicalConfiguration) config;
      final Enumeration configProperties = oconf.getConfigProperties();
      while (configProperties.hasMoreElements())
      {
        // mark all manually set properties as defined ..
        final String key = (String) configProperties.nextElement();
        hconf.setConfigProperty(key, oconf.getConfigProperty(key));
        existingKeys.add(key);
      }
    }
    editorPane.updateConfiguration(hconf);

    if (performEdit() == false)
    {
      return false;
    }
    
    editorPane.commit();

    final Enumeration configProperties = hconf.getConfigProperties();
    while (configProperties.hasMoreElements())
    {
      final String key = (String) configProperties.nextElement();
      config.setConfigProperty(key, hconf.getConfigProperty(key));
      existingKeys.remove(key);
    }

    final String[] keys = existingKeys.toArray(new String[existingKeys.size()]);
    for (int i = 0; i < keys.length; i++)
    {
      final String key = keys[i];
      config.setConfigProperty(key, null);
    }
    return true;
  }

  public static void main(final String[] args)
  {
    ClassicEngineBoot.getInstance().start();
    final ConfigurationEditorDialog dialog = new ConfigurationEditorDialog();
    dialog.performEdit(ClassicEngineBoot.getInstance().getEditableConfig());
  }


}

@@ -1631,16 +1631,47 @@
 torPane;
+%0A  private boolean defaultSize;
 %0A%0A  publ
@@ -3148,24 +3148,115 @@
 on(hconf);%0A%0A
+    if (defaultSize)%0A    %7B%0A      performInitialResize();%0A      defaultSize = false;%0A    %7D%0A%0A
     if (perf
@@ -3863,24 +3863,130 @@
  true;%0A  %7D%0A%0A
+  protected void performInitialResize()%0A  %7B%0A    super.performInitialResize();%0A    defaultSize = true;%0A  %7D%0A
   public sta

Change calculation for open dialog to correct size