/*
 * Copyright 2000-2011 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.cvsSupport2.cvsoperations.cvsAdd.ui;

import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.cvsoperations.cvsAdd.AddedFileInfo;
import com.intellij.cvsSupport2.keywordSubstitution.KeywordSubstitutionWrapper;
import com.intellij.util.ui.FileLabel;
import org.netbeans.lib.cvsclient.command.KeywordSubstitution;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * author: lesya
 */
public class AddFileConfirmationPanel extends AbstractAddFileConfirmationPanel {

  private JComboBox mySubstitutionComboBox;
  private FileLabel myFileLabel;
  private JPanel myPanel;


  public AddFileConfirmationPanel(AddedFileInfo addedFileInfo) {
    super(addedFileInfo);

    myPanel = new JPanel(new GridBagLayout());

    final JPanel panel1 = new JPanel(new GridBagLayout());
    final GridBagConstraints constraints = new GridBagConstraints();
    final JLabel label1 = new JLabel(CvsBundle.message("label.add.file.confirmation.keyword.substitution.add.file"));
    panel1.add(label1, constraints);
    myFileLabel = new FileLabel();
    constraints.insets.left = 10;
    panel1.add(myFileLabel, constraints);
    final JLabel label2 = new JLabel(CvsBundle.message("label.add.file.confirmation.keyword.substitution.to.cvs.with"));
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 3;
    constraints.insets.left = 0;
    constraints.anchor = GridBagConstraints.LINE_START;
    constraints.insets.bottom = 5;
    myPanel.add(panel1, constraints);

    constraints.gridy = 1;
    constraints.gridx = 0;
    constraints.gridwidth = 1;
    myPanel.add(label2, constraints);
    mySubstitutionComboBox = new JComboBox();
    constraints.gridx = 1;
    myPanel.add(mySubstitutionComboBox, constraints);
    final JLabel label3 = new JLabel(CvsBundle.message("label.add.file.confirmation.keyword.substitution"));
    constraints.gridx = 2;
    myPanel.add(label3, constraints);

    KeywordSubstitution defaultSubstitution = myAddedFileInfo.getKeywordSubstitution();
    KeywordSubstitutionWrapper.fillComboBox(mySubstitutionComboBox, defaultSubstitution);

    mySubstitutionComboBox.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        final KeywordSubstitutionWrapper selectedItem = (KeywordSubstitutionWrapper)mySubstitutionComboBox.getSelectedItem();
        myAddedFileInfo.setKeywordSubstitution(selectedItem.getSubstitution());
      }
    });

    init();
  }

  public Component getPanel() {
    return myPanel;
  }

  protected FileLabel getFileLabel() {
    return myFileLabel;
  }
}

@@ -1261,17 +1261,16 @@
 Panel;%0A%0A
-%0A
   public
@@ -1525,24 +1525,74 @@
 straints();%0A
+    constraints.anchor = GridBagConstraints.WEST;%0A
     final JL
@@ -1765,24 +1765,55 @@
 ileLabel();%0A
+    constraints.weightx = 1.0;%0A
     constrai
@@ -1868,32 +1868,33 @@
 , constraints);%0A
+%0A
     final JLabel
@@ -1994,24 +1994,55 @@
 vs.with%22));%0A
+    constraints.weightx = 0.0;%0A
     constrai
@@ -2155,38 +2155,36 @@
     constraints.
-anchor
+fill
  = GridBagConstr
@@ -2193,18 +2193,18 @@
 nts.
-LINE_START
+HORIZONTAL
 ;%0A  
@@ -2270,25 +2270,24 @@
 nstraints);%0A
-%0A
     constrai
@@ -2660,16 +2660,47 @@
 dx = 2;%0A
+    constraints.weightx = 1.0;%0A
     myPa
@@ -2730,20 +2730,26 @@
 ints);%0A%0A
-
     
+final 
 KeywordS

tweak add file dialog layout a little bit