diff --git a/platform/platform-api/src/com/intellij/ui/SeparatorFactory.java b/platform/platform-api/src/com/intellij/ui/SeparatorFactory.java index 7a5bdc9fa54b..1541d771411d 100644 --- a/platform/platform-api/src/com/intellij/ui/SeparatorFactory.java +++ b/platform/platform-api/src/com/intellij/ui/SeparatorFactory.java @@ -29,11 +29,11 @@ public class SeparatorFactory { } @Deprecated - public static JComponent createSeparator(String textWithMnemonic, @Nullable JComponent labelFor, boolean boldFont, boolean smallFont) { + public static TitledSeparatorWithMnemonic createSeparator(String textWithMnemonic, @Nullable JComponent labelFor, boolean boldFont, boolean smallFont) { return new TitledSeparatorWithMnemonic(textWithMnemonic, labelFor); } - public static JComponent createSeparator(String textWithMnemonic, @Nullable JComponent labelFor) { + public static TitledSeparatorWithMnemonic createSeparator(String textWithMnemonic, @Nullable JComponent labelFor) { return new TitledSeparatorWithMnemonic(textWithMnemonic, labelFor); } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractDataProviderPanel.java b/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractDataProviderPanel.java new file mode 100644 index 000000000000..fc8caf1e75f2 --- /dev/null +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractDataProviderPanel.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2012 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.openapi.vcs; + +import com.intellij.openapi.actionSystem.TypeSafeDataProvider; + +import javax.swing.*; +import java.awt.*; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 9/14/12 + * Time: 11:46 AM + */ +public abstract class AbstractDataProviderPanel extends JPanel implements TypeSafeDataProvider { + public AbstractDataProviderPanel(GridBagLayout layout) { + super(layout); + } + + protected AbstractDataProviderPanel(LayoutManager layout, boolean isDoubleBuffered) { + super(layout, isDoubleBuffered); + } + + protected AbstractDataProviderPanel(LayoutManager layout) { + super(layout); + } + + protected AbstractDataProviderPanel(boolean isDoubleBuffered) { + super(isDoubleBuffered); + } + + protected AbstractDataProviderPanel() { + } +} diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/CheckinProjectPanel.java b/platform/vcs-api/src/com/intellij/openapi/vcs/CheckinProjectPanel.java index 96edd11c7e22..9254e8025b62 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/CheckinProjectPanel.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/CheckinProjectPanel.java @@ -29,9 +29,9 @@ import java.util.Collection; * included in the checkin operation, getting/setting the commit message and so on). * The active check-in dialog can be retrieved from the using {@link Refreshable#PANEL_KEY} * - * @see com.intellij.openapi.vcs.checkin.BaseCheckinHandlerFactory#createHandler(CheckinProjectPanel, CommitContext) + * @see com.intellij.openapi.vcs.checkin.BaseCheckinHandlerFactory#createHandler(CommitMessageI, CommitContext) */ -public interface CheckinProjectPanel extends Refreshable { +public interface CheckinProjectPanel extends Refreshable, CommitMessageI { JComponent getComponent(); JComponent getPreferredFocusedComponent(); @@ -83,13 +83,6 @@ public interface CheckinProjectPanel extends Refreshable { */ Collection getRoots(); - /** - * Sets the description for the check-in. - * - * @param currentDescription the description text. - */ - void setCommitMessage(final String currentDescription); - void setWarning(final String s); /** @@ -101,16 +94,4 @@ public interface CheckinProjectPanel extends Refreshable { String getCommitMessage(); String getCommitActionName(); - - /** - * @return true if commit message is checked for spelling errors; false otherwise - */ - boolean isCheckCommitMessageSpelling(); - - /** - * Allows to define whether commit message should be checked for spelling errors. - * - * @param checkSpelling true if commit message should be checked for spelling errors; false otherwise - */ - void setCheckCommitMessageSpelling(boolean checkSpelling); } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/CommitMessageI.java b/platform/vcs-api/src/com/intellij/openapi/vcs/CommitMessageI.java new file mode 100644 index 000000000000..009c71489f05 --- /dev/null +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/CommitMessageI.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2012 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.openapi.vcs; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 9/14/12 + * Time: 11:25 AM + */ +public interface CommitMessageI { + /** + * @return true if commit message is checked for spelling errors; false otherwise + */ + boolean isCheckSpelling(); + + /** + * Allows to define whether commit message should be checked for spelling errors. + * + * @param checkSpelling true if commit message should be checked for spelling errors; false otherwise + */ + void setCheckSpelling(boolean checkSpelling); + + /** + * Sets the description for the check-in. + * + * @param currentDescription the description text. + */ + void setCommitMessage(String currentDescription); +} diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsDataKeys.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsDataKeys.java index f71173dff76e..d1dc12cf02c2 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsDataKeys.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsDataKeys.java @@ -59,4 +59,5 @@ public interface VcsDataKeys { DataKey LABEL_BEFORE = DataKey.create("LABEL_BEFORE"); DataKey LABEL_AFTER = DataKey.create("LABEL_AFTER"); DataKey PRESET_COMMIT_MESSAGE = DataKey.create("PRESET_COMMIT_MESSAGE"); + DataKey COMMIT_MESSAGE_CONTROL = DataKey.create("COMMIT_MESSAGE_CONTROL"); } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/actions/CheckCommitMessageSpellingAction.java b/platform/vcs-api/src/com/intellij/openapi/vcs/actions/CheckCommitMessageSpellingAction.java index a7192e7c8b8e..02a69f66eb4e 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/actions/CheckCommitMessageSpellingAction.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/actions/CheckCommitMessageSpellingAction.java @@ -3,7 +3,8 @@ package com.intellij.openapi.vcs.actions; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.vcs.CheckinProjectPanel; +import com.intellij.openapi.vcs.CommitMessageI; +import com.intellij.openapi.vcs.VcsDataKeys; import com.intellij.openapi.vcs.ui.Refreshable; import org.jetbrains.annotations.Nullable; @@ -21,26 +22,30 @@ public class CheckCommitMessageSpellingAction extends ToggleAction implements Du @Override public boolean isSelected(AnActionEvent e) { - CheckinProjectPanel checkinPanel = getCheckinPanel(e); - return checkinPanel == null || checkinPanel.isCheckCommitMessageSpelling(); + CommitMessageI checkinPanel = getCheckinPanel(e); + return checkinPanel != null && checkinPanel.isCheckSpelling(); } @Override public void setSelected(AnActionEvent e, boolean state) { - CheckinProjectPanel checkinPanel = getCheckinPanel(e); + CommitMessageI checkinPanel = getCheckinPanel(e); if (checkinPanel != null) { - checkinPanel.setCheckCommitMessageSpelling(state); + checkinPanel.setCheckSpelling(state); } } @Nullable - private static CheckinProjectPanel getCheckinPanel(@Nullable AnActionEvent e) { + private static CommitMessageI getCheckinPanel(@Nullable AnActionEvent e) { if (e == null) { return null; } Refreshable data = Refreshable.PANEL_KEY.getData(e.getDataContext()); - if (data instanceof CheckinProjectPanel) { - return (CheckinProjectPanel)data; + if (data instanceof CommitMessageI) { + return (CommitMessageI)data; + } + CommitMessageI commitMessageI = VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(e.getDataContext()); + if (commitMessageI != null) { + return commitMessageI; } return null; } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowMessageHistoryAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowMessageHistoryAction.java index 5abec500824f..a7079731d343 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowMessageHistoryAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowMessageHistoryAction.java @@ -17,12 +17,13 @@ package com.intellij.openapi.vcs.actions; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.editor.actions.ContentChooser; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; -import com.intellij.openapi.vcs.CheckinProjectPanel; -import com.intellij.openapi.vcs.VcsBundle; -import com.intellij.openapi.vcs.VcsConfiguration; +import com.intellij.openapi.vcs.*; +import com.intellij.openapi.vcs.ui.Refreshable; import java.util.ArrayList; import java.util.Collections; @@ -44,24 +45,32 @@ public class ShowMessageHistoryAction extends AnAction implements DumbAware { public void update(AnActionEvent e) { super.update(e); - final CheckinProjectPanel panel = (CheckinProjectPanel)CheckinProjectPanel.PANEL_KEY.getData(e.getDataContext()); + final DataContext dc = e.getDataContext(); + final Project project = PlatformDataKeys.PROJECT.getData(dc); + Object panel = CheckinProjectPanel.PANEL_KEY.getData(dc); + if (! (panel instanceof CommitMessageI)) { + panel = VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(dc); + } - if (panel == null) { + if (project == null || panel == null) { e.getPresentation().setVisible(false); e.getPresentation().setEnabled(false); } else { e.getPresentation().setVisible(true); - final ArrayList recentMessages = VcsConfiguration.getInstance(panel.getProject()).getRecentMessages(); + final ArrayList recentMessages = VcsConfiguration.getInstance(project).getRecentMessages(); e.getPresentation().setEnabled(!recentMessages.isEmpty()); } } public void actionPerformed(AnActionEvent e) { - final CheckinProjectPanel panel = (CheckinProjectPanel)CheckinProjectPanel.PANEL_KEY.getData(e.getDataContext()); + CommitMessageI commitMessageI; + final DataContext dc = e.getDataContext(); + final Project project = PlatformDataKeys.PROJECT.getData(dc); + final Refreshable panel = CheckinProjectPanel.PANEL_KEY.getData(dc); + commitMessageI = (panel instanceof CommitMessageI) ? (CommitMessageI)panel : VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(dc); - if (panel != null) { - final Project project = panel.getProject(); + if (commitMessageI != null && project != null) { final VcsConfiguration configuration = VcsConfiguration.getInstance(project); @@ -90,7 +99,7 @@ public class ShowMessageHistoryAction extends AnAction implements DumbAware { final int selectedIndex = contentChooser.getSelectedIndex(); if (selectedIndex >= 0) { - panel.setCommitMessage(contentChooser.getAllContents().get(selectedIndex)); + commitMessageI.setCommitMessage(contentChooser.getAllContents().get(selectedIndex)); } } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index a4af005dbc8c..d4c26064d8ca 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -780,13 +780,13 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj } @Override - public boolean isCheckCommitMessageSpelling() { + public boolean isCheckSpelling() { VcsConfiguration configuration = VcsConfiguration.getInstance(myProject); return configuration == null || configuration.CHECK_COMMIT_MESSAGE_SPELLING; } @Override - public void setCheckCommitMessageSpelling(boolean checkSpelling) { + public void setCheckSpelling(boolean checkSpelling) { VcsConfiguration configuration = VcsConfiguration.getInstance(myProject); if (configuration != null) { configuration.CHECK_COMMIT_MESSAGE_SPELLING = checkSpelling; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java index 561a01b82ade..b75c6a6854e4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java @@ -25,12 +25,8 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; -import com.intellij.openapi.vcs.VcsBundle; -import com.intellij.openapi.vcs.VcsConfiguration; -import com.intellij.ui.EditorCustomization; -import com.intellij.ui.EditorTextField; -import com.intellij.ui.EditorTextFieldProvider; -import com.intellij.ui.SeparatorFactory; +import com.intellij.openapi.vcs.*; +import com.intellij.ui.*; import com.intellij.util.Consumer; import org.jetbrains.annotations.Nullable; @@ -39,12 +35,14 @@ import java.awt.*; import java.util.EnumSet; import java.util.Set; -public class CommitMessage extends JPanel implements Disposable { +public class CommitMessage extends AbstractDataProviderPanel implements Disposable, CommitMessageI { public static final Key DATA_CONTEXT_KEY = Key.create("commit message data context"); private final EditorTextField myEditorField; private final Project myProject; private Consumer myMessageConsumer; + private final TitledSeparatorWithMnemonic mySeparator; + private boolean myCheckSpelling; public CommitMessage(Project project) { super(new BorderLayout()); @@ -64,9 +62,9 @@ public class CommitMessage extends JPanel implements Disposable { JPanel labelPanel = new JPanel(new BorderLayout()); labelPanel.setBorder(BorderFactory.createEmptyBorder()); - JComponent separator = SeparatorFactory.createSeparator(VcsBundle.message("label.commit.comment"), myEditorField.getComponent(), true, true); + mySeparator = SeparatorFactory.createSeparator(VcsBundle.message("label.commit.comment"), myEditorField.getComponent(), true, true); JPanel separatorPanel = new JPanel(new BorderLayout()); - separatorPanel.add(separator, BorderLayout.SOUTH); + separatorPanel.add(mySeparator, BorderLayout.SOUTH); separatorPanel.add(Box.createVerticalGlue(), BorderLayout.NORTH); labelPanel.add(separatorPanel, BorderLayout.CENTER); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, getToolbarActions(), true); @@ -79,6 +77,22 @@ public class CommitMessage extends JPanel implements Disposable { setBorder(BorderFactory.createEmptyBorder()); } + @Override + public void calcData(DataKey key, DataSink sink) { + if (key.is(VcsDataKeys.COMMIT_MESSAGE_CONTROL.getName())) { + sink.put(VcsDataKeys.COMMIT_MESSAGE_CONTROL, this); + } + } + + public void setSeparatorText(final String text) { + mySeparator.setText(text); + } + + @Override + public void setCommitMessage(String currentDescription) { + setText(currentDescription); + } + private static EditorTextField createEditorField(final Project project, final boolean checkSpelling) { EditorTextField editorField = createCommitTextEditor(project, checkSpelling); editorField.getDocument().putUserData(DATA_CONTEXT_KEY, DataManager.getInstance().getDataContext(editorField.getComponent())); @@ -130,7 +144,13 @@ public class CommitMessage extends JPanel implements Disposable { myEditorField.selectAll(); } + @Override + public boolean isCheckSpelling() { + return myCheckSpelling; + } + public void setCheckSpelling(boolean check) { + myCheckSpelling = check; Editor editor = myEditorField.getEditor(); if (!(editor instanceof EditorEx)) { return; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties index 9eb333e944de..9db0ae7d40f8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties @@ -484,7 +484,7 @@ copy.dialog.title=Branch or Tag move.dialog.title=Move or Rename select.location.invalid.url.message=Invalid Subversion repository URL: ''{0}'' share.directory.action=Share Directory... -share.directory.commit.message=Directory ''{0}'' created by {1} +share.directory.commit.message={2}\nDirectory ''{0}'' created by {1} share.directory.title=Share Directory share.directory.info.message=To complete share operation commit ''{0}''. share.directory.create.dir.progress.text=Creating remote folder {0} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java index e5b95c25ca6e..fa0305fa5e09 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java @@ -136,23 +136,23 @@ public class ShareProjectAction extends BasicAction { final SVNURL parenUrl = SVNURL.parseURIEncoded(parent); final SVNURL checkoutUrl; final SVNRevision revision; - + final String commitText = shareDialog.getCommitText(); if (ShareDialog.ShareTarget.useSelected.equals(shareTarget)) { checkoutUrl = parenUrl; revision = SVNRevision.HEAD; } else if (ShareDialog.ShareTarget.useProjectName.equals(shareTarget)) { - final Pair pair = createRemoteFolder(activeVcs, parenUrl, file.getName()); + final Pair pair = createRemoteFolder(activeVcs, parenUrl, file.getName(), commitText); revision = pair.getFirst(); checkoutUrl = pair.getSecond(); } else { - final Pair pair = createRemoteFolder(activeVcs, parenUrl, file.getName()); - final Pair trunkPair = createRemoteFolder(activeVcs, pair.getSecond(), "trunk"); + final Pair pair = createRemoteFolder(activeVcs, parenUrl, file.getName(), commitText); + final Pair trunkPair = createRemoteFolder(activeVcs, pair.getSecond(), "trunk", commitText); checkoutUrl = trunkPair.getSecond(); revision = trunkPair.getFirst(); if (shareDialog.createStandardStructure()) { - createRemoteFolder(activeVcs, pair.getSecond(), "branches"); - createRemoteFolder(activeVcs, pair.getSecond(), "tags"); + createRemoteFolder(activeVcs, pair.getSecond(), "branches", commitText); + createRemoteFolder(activeVcs, pair.getSecond(), "tags", commitText); } } @@ -215,7 +215,10 @@ public class ShareProjectAction extends BasicAction { return folderEmpty[0]; } - private static Pair createRemoteFolder(final SvnVcs vcs, final SVNURL parent, final String folderName) throws SVNException { + private static Pair createRemoteFolder(final SvnVcs vcs, + final SVNURL parent, + final String folderName, + String commitText) throws SVNException { SVNURL url = parent.appendPath(folderName, false); final String urlText = url.toString(); final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); @@ -225,7 +228,7 @@ public class ShareProjectAction extends BasicAction { } final SVNCommitInfo info = vcs.createCommitClient().doMkDir(new SVNURL[]{url}, SvnBundle.message("share.directory.commit.message", folderName, - ApplicationNamesInfo.getInstance().getFullProductName())); + ApplicationNamesInfo.getInstance().getFullProductName(), commitText)); return new Pair(SVNRevision.create(info.getNewRevision()), url); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java index 76ddc53347b0..02b124f5f520 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java @@ -85,7 +85,7 @@ import java.util.Map; public class RepositoryBrowserDialog extends DialogWrapper { private final Project myProject; - private final SvnVcs myVCS; + protected final SvnVcs myVCS; private RepositoryBrowserComponent myRepositoryBrowser; @NonNls public static final String COPY_OF_PREFIX = "CopyOf"; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ShareDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ShareDialog.java index 2bb8446f3291..b2be62d7ee9d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ShareDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ShareDialog.java @@ -18,7 +18,13 @@ package org.jetbrains.idea.svn.dialogs; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.ActionPopupMenu; import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vcs.changes.ChangeListManager; +import com.intellij.openapi.vcs.changes.LocalChangeList; +import com.intellij.openapi.vcs.changes.ui.EditChangelistSupport; +import com.intellij.openapi.vcs.ui.CommitMessage; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -26,6 +32,8 @@ import javax.swing.event.ChangeListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.text.MessageFormat; public class ShareDialog extends RepositoryBrowserDialog { @@ -40,6 +48,8 @@ public class ShareDialog extends RepositoryBrowserDialog { private JRadioButton mySameNameAsLocal; private JRadioButton myTrunk; private JCheckBox myCreateStandard; + private CommitMessage myCommitMessage; + private JComponent myPrefferedFocused; public ShareDialog(Project project, final String name) { super(project, false, "Point to repository location"); @@ -50,6 +60,7 @@ public class ShareDialog extends RepositoryBrowserDialog { myTrunk.setToolTipText(MessageFormat.format(ourStandart, myName)); myRepositoriesLabel.setFont(myRepositoriesLabel.getFont().deriveFont(Font.BOLD)); + myPrefferedFocused = (JComponent) getRepositoryBrowser().getPreferredFocusedComponent(); } public void init() { @@ -67,6 +78,12 @@ public class ShareDialog extends RepositoryBrowserDialog { }); getOKAction().setEnabled(getRepositoryBrowser().getSelectedURL() != null); ((RepositoryTreeModel) getRepositoryBrowser().getRepositoryTree().getModel()).setShowFiles(false); + getRepositoryBrowser().getPreferredFocusedComponent().addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + myPrefferedFocused = (JComponent)getRepositoryBrowser().getPreferredFocusedComponent(); + } + }); } private void updateOptionsTexts(String selectedURL) { @@ -88,6 +105,11 @@ public class ShareDialog extends RepositoryBrowserDialog { myCreateStandard.setEnabled(enabled && myTrunk.isSelected()); } + @Override + public JComponent getPreferredFocusedComponent() { + return myPrefferedFocused; + } + protected Action[] createActions() { return new Action[] {getOKAction(), getCancelAction(), getHelpAction()}; } @@ -130,8 +152,9 @@ public class ShareDialog extends RepositoryBrowserDialog { wrapper.add(repositoryPanel, gb); ++ gb.gridy; gb.fill = GridBagConstraints.NONE; - gb.weightx = 0; + gb.weightx = 1; gb.weighty = 0; + gb.fill = GridBagConstraints.HORIZONTAL; wrapper.add(createFolderPanel(), gb); return wrapper; } @@ -150,7 +173,30 @@ public class ShareDialog extends RepositoryBrowserDialog { return myCreateStandard.isSelected(); } + public String getCommitText() { + return myCommitMessage.getComment(); + } + private JComponent createFolderPanel() { + final Project project = myVCS.getProject(); + myCommitMessage = new CommitMessage(project) { + @Override + public Dimension getPreferredSize() { + final Dimension superValue = super.getPreferredSize(); + return new Dimension(superValue.width, superValue.height > 90 ? superValue.height : 90); + } + + @Override + public void addNotify() { + super.addNotify(); + myCommitMessage.getEditorField().getFocusTarget().addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + myPrefferedFocused = myCommitMessage.getEditorField(); + } + }); + } + }; final JPanel panel = new JPanel(new GridBagLayout()); final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0); @@ -190,6 +236,23 @@ public class ShareDialog extends RepositoryBrowserDialog { gb.insets.left = 10; panel.add(myCreateStandard, gb); + ++ gb.gridy; + gb.gridx = 0; + gb.insets.top = 1; + gb.insets.left = 1; + gb.weightx = 1; + gb.fill = GridBagConstraints.HORIZONTAL; + + final LocalChangeList list = ChangeListManager.getInstance(project).getDefaultChangeList(); + String text = list.getComment(); + text = StringUtil.isEmptyOrSpaces(text) ? (list.hasDefaultName() ? "" : list.getName()) : text; + myCommitMessage.setText(text); + panel.add(myCommitMessage, gb); + myCommitMessage.setSeparatorText("Commit Comment Prefix"); + for (EditChangelistSupport support : Extensions.getExtensions(EditChangelistSupport.EP_NAME, project)) { + support.installSearch(myCommitMessage.getEditorField(), myCommitMessage.getEditorField()); + } + myTrunk.setSelected(true); return panel;