diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.form b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.form index 891f3371fe28..a69d2e872668 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.form +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.form @@ -1,8 +1,9 @@
- + + - + @@ -11,15 +12,17 @@ - - + - + + + + + - - + @@ -28,8 +31,7 @@ - - + @@ -39,13 +41,14 @@ - - + + + - - + + @@ -54,7 +57,7 @@ - + @@ -63,7 +66,7 @@ - + @@ -71,20 +74,20 @@ - + - + - + @@ -112,8 +115,7 @@ - - + @@ -129,12 +131,17 @@ - + + + + + + diff --git a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java index d875e4f1ca1c..7c986bb8e55a 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java @@ -38,7 +38,9 @@ import com.intellij.refactoring.RefactoringBundle; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.RecentsManager; import com.intellij.ui.TextFieldWithHistoryWithBrowseButton; +import com.intellij.ui.components.JBLabelDecorator; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.ui.FormBuilder; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; @@ -49,7 +51,7 @@ import java.awt.*; import java.io.File; import java.util.List; -class CopyFilesOrDirectoriesDialog extends DialogWrapper{ +class CopyFilesOrDirectoriesDialog extends DialogWrapper { private JLabel myInformationLabel; private TextFieldWithHistoryWithBrowseButton myTargetDirectoryField; private JTextField myNewNameField; @@ -104,7 +106,8 @@ class CopyFilesOrDirectoriesDialog extends DialogWrapper{ } if (myShowDirectoryField) { - myTargetDirectoryField.getChildComponent().setText(defaultTargetDirectory == null ? "" : defaultTargetDirectory.getVirtualFile().getPresentableUrl()); + myTargetDirectoryField.getChildComponent() + .setText(defaultTargetDirectory == null ? "" : defaultTargetDirectory.getVirtualFile().getPresentableUrl()); } validateOKButton(); } @@ -131,8 +134,8 @@ class CopyFilesOrDirectoriesDialog extends DialogWrapper{ } } - protected Action[] createActions(){ - return new Action[]{getOKAction(),getCancelAction(),getHelpAction()}; + protected Action[] createActions() { + return new Action[]{getOKAction(), getCancelAction(), getHelpAction()}; } public JComponent getPreferredFocusedComponent() { @@ -144,63 +147,47 @@ class CopyFilesOrDirectoriesDialog extends DialogWrapper{ } protected JComponent createNorthPanel() { - JPanel panel = new JPanel(new GridBagLayout()); - - myInformationLabel = new JLabel(); - - panel.add(myInformationLabel, new GridBagConstraints(0,0,2,1,1,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,8,4,8),0,0)); - + myInformationLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); + final FormBuilder formBuilder = FormBuilder.createFormBuilder().addComponent(myInformationLabel).addVerticalGap( + UIUtil.LARGE_VGAP - UIUtil.DEFAULT_VGAP); DocumentListener documentListener = new DocumentAdapter() { public void textChanged(DocumentEvent event) { validateOKButton(); } }; + if (myShowNewNameField) { - myNewNameField = new JTextField(); - Dimension size = myNewNameField.getPreferredSize(); - FontMetrics fontMetrics = myNewNameField.getFontMetrics(myNewNameField.getFont()); - size.width = fontMetrics.charWidth('a') * 60; - myNewNameField.setPreferredSize(size); - - panel.add(new JLabel(RefactoringBundle.message("copy.files.new.name.label")), new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,8,4,8),0,0)); - - panel.add(myNewNameField, new GridBagConstraints(1,1,1,1,1,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,0,4,8),0,0)); - + myNewNameField = new JTextField(60); myNewNameField.getDocument().addDocumentListener(documentListener); + formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"), myNewNameField); } if (myShowDirectoryField) { - panel.add(new JLabel(RefactoringBundle.message("copy.files.to.directory.label")), new GridBagConstraints(0,2,1,1,0,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,8,4,8),0,0)); - myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton(); final List recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); - if (recentEntries != null) { myTargetDirectoryField.getChildComponent().setHistory(recentEntries); } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), - RefactoringBundle.message("the.file.will.be.copied.to.this.directory"), - myProject, descriptor, - TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); - + RefactoringBundle.message("the.file.will.be.copied.to.this.directory"), + myProject, descriptor, + TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); myTargetDirectoryField.setTextFieldPreferredWidth(60); - panel.add(myTargetDirectoryField, new GridBagConstraints(1,2,1,1,1,0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(4,0,2,8),0,0)); - myTargetDirectoryField.getChildComponent().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); - String shortcutText = KeymapUtil - .getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); - final JLabel label = new JLabel(RefactoringBundle.message("path.completion.shortcut", shortcutText)); - UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, label); - panel.add(label, new GridBagConstraints(1,3,2,1,1,0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0,6,4,8), 0,0)); + formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.to.directory.label"), myTargetDirectoryField); + + String shortcutText = + KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); + formBuilder.addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)); } - return panel; + return formBuilder.getPanel(); } public PsiDirectory getTargetDirectory() { @@ -211,12 +198,13 @@ class CopyFilesOrDirectoriesDialog extends DialogWrapper{ return myNewNameField != null ? myNewNameField.getText().trim() : null; } - protected void doOKAction(){ + protected void doOKAction() { if (myShowNewNameField) { String newName = getNewName(); if (newName.length() == 0) { - Messages.showMessageDialog(myProject, RefactoringBundle.message("no.new.name.specified"), RefactoringBundle.message("error.title"), Messages.getErrorIcon()); + Messages.showMessageDialog(myProject, RefactoringBundle.message("no.new.name.specified"), RefactoringBundle.message("error.title"), + Messages.getErrorIcon()); return; } } @@ -225,7 +213,8 @@ class CopyFilesOrDirectoriesDialog extends DialogWrapper{ final String targetDirectoryName = myTargetDirectoryField.getChildComponent().getText(); if (targetDirectoryName.length() == 0) { - Messages.showMessageDialog(myProject, RefactoringBundle.message("no.target.directory.specified"), RefactoringBundle.message("error.title"), Messages.getErrorIcon()); + Messages.showMessageDialog(myProject, RefactoringBundle.message("no.target.directory.specified"), + RefactoringBundle.message("error.title"), Messages.getErrorIcon()); return; } @@ -236,7 +225,8 @@ class CopyFilesOrDirectoriesDialog extends DialogWrapper{ ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { try { - myTargetDirectory = DirectoryUtil.mkdirs(PsiManager.getInstance(myProject), targetDirectoryName.replace(File.separatorChar, '/')); + myTargetDirectory = + DirectoryUtil.mkdirs(PsiManager.getInstance(myProject), targetDirectoryName.replace(File.separatorChar, '/')); } catch (IncorrectOperationException e) { } @@ -246,7 +236,9 @@ class CopyFilesOrDirectoriesDialog extends DialogWrapper{ }, RefactoringBundle.message("create.directory"), null); if (myTargetDirectory == null) { - Messages.showMessageDialog(myProject, RefactoringBundle.message("cannot.create.directory"), RefactoringBundle.message("error.title"), Messages.getErrorIcon()); + Messages + .showMessageDialog(myProject, RefactoringBundle.message("cannot.create.directory"), RefactoringBundle.message("error.title"), + Messages.getErrorIcon()); return; } } diff --git a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java index 395f8a5fd4cd..e2a6132e9a86 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java @@ -41,17 +41,18 @@ import com.intellij.ui.DocumentAdapter; import com.intellij.ui.NonFocusableCheckBox; import com.intellij.ui.RecentsManager; import com.intellij.ui.TextFieldWithHistoryWithBrowseButton; +import com.intellij.ui.components.JBLabelDecorator; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.ui.FormBuilder; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import javax.swing.*; import javax.swing.event.DocumentEvent; -import java.awt.*; import java.io.File; import java.util.List; -public class MoveFilesOrDirectoriesDialog extends DialogWrapper{ +public class MoveFilesOrDirectoriesDialog extends DialogWrapper { @NonNls private static final String RECENT_KEYS = "MoveFile.RECENT_KEYS"; public interface Callback { @@ -74,8 +75,8 @@ public class MoveFilesOrDirectoriesDialog extends DialogWrapper{ init(); } - protected Action[] createActions(){ - return new Action[]{getOKAction(),getCancelAction(),getHelpAction()}; + protected Action[] createActions() { + return new Action[]{getOKAction(), getCancelAction(), getHelpAction()}; } public JComponent getPreferredFocusedComponent() { @@ -87,20 +88,8 @@ public class MoveFilesOrDirectoriesDialog extends DialogWrapper{ } protected JComponent createNorthPanel() { - JPanel panel = new JPanel(new GridBagLayout()); - final GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = 0; - c.fill = GridBagConstraints.HORIZONTAL; - c.insets = new Insets(0, 2, 0, 0); + myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); - myNameLabel = new JLabel(); - panel.add(myNameLabel, c); - c.insets.top = 10; - c.gridy++; - panel.add(new JLabel(RefactoringBundle.message("move.files.to.directory.label")), c); - c.insets.top = 0; - myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton(); final List recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); if (recentEntries != null) { @@ -114,33 +103,24 @@ public class MoveFilesOrDirectoriesDialog extends DialogWrapper{ TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); final JTextField textField = myTargetDirectoryField.getChildComponent().getTextEditor(); FileChooserFactory.getInstance().installFileCompletion(textField, descriptor, true, getDisposable()); - myTargetDirectoryField.setTextFieldPreferredWidth(60); - c.insets.left = 0; - c.gridy++; - panel.add(myTargetDirectoryField, c); - String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); - final JLabel label = new JLabel(RefactoringBundle.message("path.completion.shortcut", shortcutText)); - UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, label); - c.insets.left = 6; - c.gridy++; - panel.add(label, c); - - myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); - myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE); - c.insets.top = 10; - c.insets.left = 0; - c.gridy++; - panel.add(myCbSearchForReferences, c); - textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); + myTargetDirectoryField.setTextFieldPreferredWidth(60); Disposer.register(getDisposable(), myTargetDirectoryField); - return panel; + String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); + + myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); + myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE); + + return FormBuilder.createFormBuilder().addComponent(myNameLabel) + .addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"), myTargetDirectoryField, UIUtil.LARGE_VGAP) + .addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)) + .addComponentToRightColumn(myCbSearchForReferences, UIUtil.LARGE_VGAP).getPanel(); } public void setData(PsiElement[] psiElements, PsiDirectory initialTargetDirectory, @NonNls String helpID) { @@ -170,7 +150,8 @@ public class MoveFilesOrDirectoriesDialog extends DialogWrapper{ RefactoringBundle.message("move.specified.elements")); } - myTargetDirectoryField.getChildComponent().setText(initialTargetDirectory == null ? "" : initialTargetDirectory.getVirtualFile().getPresentableUrl()); + myTargetDirectoryField.getChildComponent() + .setText(initialTargetDirectory == null ? "" : initialTargetDirectory.getVirtualFile().getPresentableUrl()); validateOKButton(); myHelpID = helpID; diff --git a/platform/util/src/com/intellij/util/ui/FormBuilder.java b/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java similarity index 90% rename from platform/util/src/com/intellij/util/ui/FormBuilder.java rename to platform/platform-api/src/com/intellij/util/ui/FormBuilder.java index 5b1088debd19..fe74bc1009ac 100644 --- a/platform/util/src/com/intellij/util/ui/FormBuilder.java +++ b/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java @@ -19,10 +19,12 @@ */ package com.intellij.util.ui; +import com.intellij.ui.components.JBLabel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.border.EmptyBorder; import java.awt.*; import static com.intellij.util.ui.UIUtil.DEFAULT_HGAP; @@ -109,6 +111,20 @@ public class FormBuilder { new Box.Filler(new Dimension(0, height), new Dimension(0, height), new Dimension(Short.MAX_VALUE, height))); } + public FormBuilder addTooltip(final String text) { + final JBLabel label = new JBLabel(text, UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER); + label.setBorder(new EmptyBorder(0, 10, 0, 0)); + return addComponentToRightColumn(label, 1); + } + + public FormBuilder addComponentToRightColumn(@NotNull final JComponent component) { + return addComponentToRightColumn(component, myVerticalGap); + } + + public FormBuilder addComponentToRightColumn(@NotNull final JComponent component, final int topInset) { + return addLabeledComponent(new JLabel(), component, topInset); + } + public FormBuilder addLabeledComponent(@Nullable JComponent label, @NotNull JComponent component, int topInset, boolean labelOnTop) { GridBagConstraints c = new GridBagConstraints(); topInset = myLineCount > 0 ? topInset : 0; diff --git a/plugins/github/src/org/jetbrains/plugins/github/tasks/GitHubRepositoryEditor.java b/plugins/github/src/org/jetbrains/plugins/github/tasks/GitHubRepositoryEditor.java index 018956a09f2e..b07f32d06794 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/tasks/GitHubRepositoryEditor.java +++ b/plugins/github/src/org/jetbrains/plugins/github/tasks/GitHubRepositoryEditor.java @@ -7,9 +7,6 @@ import com.intellij.ui.components.JBLabel; import com.intellij.util.Consumer; import com.intellij.util.ui.FormBuilder; import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.github.tasks.GitHubRepository; -import com.intellij.util.ui.FormBuilder; -import org.jetbrains.annotations.Nullable; import javax.swing.*; diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/connector/WebRepositoryEditor.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/connector/WebRepositoryEditor.java index 3dabbcc8e26f..e489c7cf6111 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/connector/WebRepositoryEditor.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/connector/WebRepositoryEditor.java @@ -5,7 +5,6 @@ import com.intellij.tasks.config.BaseRepositoryEditor; import com.intellij.ui.components.JBLabel; import com.intellij.util.Consumer; import com.intellij.util.ui.FormBuilder; -import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -54,15 +53,12 @@ public class WebRepositoryEditor extends BaseRepositoryEditor { return FormBuilder.createFormBuilder().setAlignLabelOnRight(true) .addVerticalGap(8) .addLabeledComponent(myTasksListURLLabel, myTasksListURLText) - .addLabeledComponent(new JLabel(), new JBLabel("Available placeholders: " + WebRepository.SERVER_URL_PLACEHOLDER, UIUtil.ComponentStyle.SMALL, - UIUtil.FontColor.BRIGHTER), 1) + .addTooltip("Available placeholders: " + WebRepository.SERVER_URL_PLACEHOLDER) .addLabeledComponent(myTaskPatternLabel, myTaskPatternText, 8) - .addLabeledComponent(new JLabel(), new JBLabel("Task pattern should be a regexp with two matching group: ({id}.+?) and ({summary}.+?)", - UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER), 1) + .addTooltip("Task pattern should be a regexp with two matching group: ({id}.+?) and ({summary}.+?)") .addLabeledComponent(myLoginURLLabel, myLoginURLText, 8) - .addLabeledComponent(new JLabel(), new JBLabel("Available placeholders: " + WebRepository.SERVER_URL_PLACEHOLDER + ", " + - WebRepository.USERNAME_PLACEHOLDER + ", " + WebRepository.PASSWORD_PLACEHOLDER, UIUtil.ComponentStyle.SMALL, - UIUtil.FontColor.BRIGHTER), 1) + .addTooltip("Available placeholders: " + WebRepository.SERVER_URL_PLACEHOLDER + ", " + + WebRepository.USERNAME_PLACEHOLDER + ", " + WebRepository.PASSWORD_PLACEHOLDER) .addVerticalGap(8) .getPanel(); }