/*
 * Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
 */

package com.intellij.openapi.vcs.changes.ui;

import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.CommitSession;
import com.intellij.util.Alarm;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.util.List;

public class SessionDialog extends DialogWrapper {
  private final CommitSession mySession;
  private final List<Change> myChanges;

  private final Alarm myOKButtonUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
  private final String myCommitMessage;

  public SessionDialog(String title, Project project,
                       CommitSession session, List<Change> changes,
                       String commitMessage) {
    super(project, true);
    mySession = session;
    myChanges = changes;
    myCommitMessage = commitMessage;
    setTitle(title);
    updateButtons();
    init();
  }


  @Nullable
  protected JComponent createCenterPanel() {
    return mySession.getAdditionalConfigurationUI();
  }

  private void updateButtons() {
    setOKActionEnabled(mySession.canExecute(myChanges, myCommitMessage));
    myOKButtonUpdateAlarm.cancelAllRequests();
    myOKButtonUpdateAlarm.addRequest(new Runnable() {
      public void run() {
        updateButtons();
      }
    }, 300, ModalityState.stateForComponent(getOwner()));
  }

  protected void dispose() {
    super.dispose();
    myOKButtonUpdateAlarm.cancelAllRequests();
  }
}

@@ -459,16 +459,35 @@
 wing.*;%0A
+import java.awt.*;%0A
 import j
@@ -501,16 +501,16 @@
 l.List;%0A
-
 %0Apublic 
@@ -765,16 +765,88 @@
 ssage;%0A%0A
+  private final JPanel myCenterPanel = new JPanel(new BorderLayout());%0A%0A
   public
@@ -1244,15 +1244,26 @@
     
-return 
+myCenterPanel.add(
 mySe
@@ -1298,16 +1298,64 @@
 tionUI()
+, BorderLayout.CENTER);%0A    return myCenterPanel
 ;%0A  %7D%0A%0A 
@@ -1668,18 +1668,21 @@
 ent(
-getOwner()
+myCenterPanel
 ));%0A

update OK button