inplace refactoring balloons with titles

This commit is contained in:
Kirill Kalishev
2011-05-11 14:36:55 +04:00
parent ff9f3e7ba5
commit 175d9158af
6 changed files with 18 additions and 33 deletions
@@ -132,12 +132,6 @@ public class InplaceIntroduceConstantPopup {
myWholePanel = new JPanel(new GridBagLayout());
GridBagConstraints gc = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0 , 0, 0), 0, 0);
final TitlePanel titlePanel = new TitlePanel();
titlePanel.setBorder(null);
titlePanel.setText(IntroduceConstantHandler.REFACTORING_NAME);
gc.gridwidth = 2;
myWholePanel.add(titlePanel, gc);
gc.gridwidth = 1;
gc.gridy = 1;
myWholePanel.add(createLeftPanel(), gc);
@@ -388,7 +382,7 @@ public class InplaceIntroduceConstantPopup {
myEditor, field, false,
myTypeSelectorManager.getTypesForAll().length > 1,
myExpr != null && myExpr.isPhysical() ? myEditor.getDocument().createRangeMarker(myExpr.getTextRange()) : null, InplaceIntroduceConstantPopup.this.getOccurrenceMarkers(),
IntroduceConstantHandler.REFACTORING_NAME);
IntroduceConstantHandler.REFACTORING_NAME, IntroduceConstantHandler.REFACTORING_NAME);
myDefaultParameterTypePointer =
SmartTypePointerManager.getInstance(myProject).createSmartTypePointer(myTypeSelectorManager.getDefaultType());
@@ -36,7 +36,6 @@ import com.intellij.refactoring.introduceParameter.AbstractInplaceIntroducer;
import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import com.intellij.refactoring.util.occurences.OccurenceManager;
import com.intellij.ui.TitlePanel;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.Nullable;
@@ -125,15 +124,10 @@ public class InplaceIntroduceFieldPopup {
myWholePanel = new JPanel(new GridBagLayout());
myWholePanel.setBorder(null);
final TitlePanel titlePanel = new TitlePanel();
titlePanel.setBorder(null);
titlePanel.setText(IntroduceFieldHandler.REFACTORING_NAME);
GridBagConstraints gc =
new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(0,0,0,0), 0, 0);
myWholePanel.add(titlePanel, gc);
gc.gridy++;
gc.insets.top = 5;
@@ -253,7 +247,7 @@ public class InplaceIntroduceFieldPopup {
myEditor, psiVariable, false,
myTypeSelectorManager.getTypesForAll().length > 1,
myInitializerExpression != null && myInitializerExpression.isPhysical() ? myEditor.getDocument().createRangeMarker(myInitializerExpression.getTextRange()) : null, InplaceIntroduceFieldPopup.this.getOccurrenceMarkers(),
IntroduceFieldHandler.REFACTORING_NAME);
IntroduceFieldHandler.REFACTORING_NAME, IntroduceFieldHandler.REFACTORING_NAME);
myDefaultParameterTypePointer =
SmartTypePointerManager.getInstance(myProject).createSmartTypePointer(myTypeSelectorManager.getDefaultType());
myFieldRangeStart = myEditor.getDocument().createRangeMarker(psiVariable.getTextRange());
@@ -57,8 +57,8 @@ public abstract class AbstractInplaceIntroducer extends VariableInplaceIntroduce
boolean cantChangeFinalModifier,
boolean hasTypeSuggestion,
RangeMarker exprMarker,
List<RangeMarker> occurrenceMarkers, String commandName) {
super(project, expression, editor, elementToRename, cantChangeFinalModifier, hasTypeSuggestion, exprMarker, occurrenceMarkers, commandName);
List<RangeMarker> occurrenceMarkers, String commandName, String title) {
super(project, expression, editor, elementToRename, cantChangeFinalModifier, hasTypeSuggestion, exprMarker, occurrenceMarkers, commandName, title);
}
protected abstract boolean isReplaceAllOccurrences();
@@ -111,12 +111,6 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI {
final GridBagConstraints gc =
new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
final TitlePanel titlePanel = new TitlePanel();
titlePanel.setBorder(null);
titlePanel.setText(IntroduceParameterHandler.REFACTORING_NAME);
gc.gridwidth = 2;
myWholePanel.add(titlePanel, gc);
gc.insets = new Insets(0, 5, 0, 0);
gc.gridwidth = 1;
gc.fill = GridBagConstraints.NONE;
@@ -255,7 +249,7 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI {
super(myProject, new TypeExpression(myProject, myTypeSelectorManager.getTypesForAll()),
myEditor, parameter, myMustBeFinal,
myTypeSelectorManager.getTypesForAll().length > 1, myExprMarker, InplaceIntroduceParameterPopup.this.getOccurrenceMarkers(),
IntroduceParameterHandler.REFACTORING_NAME);
IntroduceParameterHandler.REFACTORING_NAME, IntroduceParameterHandler.REFACTORING_NAME);
myDefaultParameterTypePointer = SmartTypePointerManager.getInstance(myProject).createSmartTypePointer(parameter.getType());
}
@@ -479,7 +479,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
final boolean cantChangeFinalModifier = (hasWriteAccess || inFinalContext) && choice == OccurrencesChooser.ReplaceChoice.ALL;
final VariableInplaceRenamer renamer =
new VariableInplaceIntroducer(project, expression, editor, elementToRename, cantChangeFinalModifier,
typeSelectorManager.getTypesForAll().length > 1, exprMarker, occurrenceMarkers, IntroduceVariableBase.REFACTORING_NAME);
typeSelectorManager.getTypesForAll().length > 1, exprMarker, occurrenceMarkers, IntroduceVariableBase.REFACTORING_NAME, IntroduceVariableBase.REFACTORING_NAME);
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
renamer.performInplaceRename(false, new LinkedHashSet<String>(Arrays.asList(suggestedName.names)));
}
@@ -76,6 +76,7 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
protected JCheckBox myCanBeFinalCb;
private Balloon myBalloon;
private String myTitle;
public VariableInplaceIntroducer(final Project project,
final TypeExpression expression,
@@ -85,12 +86,14 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
final boolean hasTypeSuggestion,
final RangeMarker exprMarker,
final List<RangeMarker> occurrenceMarkers,
final String commandName) {
final String commandName,
final String title) {
super(elementToRename, editor);
myProject = project;
myEditor = editor;
myElementToRename = elementToRename;
myExpression = expression;
myTitle = title;
myExprMarker = exprMarker;
myOccurrenceMarkers = occurrenceMarkers;
@@ -240,11 +243,6 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
final JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(null);
final TitlePanel titlePanel = new TitlePanel();
titlePanel.setBorder(null);
titlePanel.setText(IntroduceVariableBase.REFACTORING_NAME);
panel.add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
if (myCanBeFinalCb != null) {
panel.add(myCanBeFinalCb, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
}
@@ -360,18 +358,23 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
}
protected String getTitle() {
return myTitle;
}
private void showBalloon() {
final JComponent component = getComponent();
if (component == null) return;
if (ApplicationManager.getApplication().isHeadlessEnvironment()) return;
final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(component);
balloonBuilder.setFadeoutTime(0)
.setFillColor(IdeTooltipManager.GRAPHITE_COLOR.brighter().brighter())
.setAnimationCycle(0)
.setFillColor(UIManager.getColor("Panel.background"))
.setAnimationCycle(100)
.setHideOnClickOutside(false)
.setHideOnKeyOutside(false)
.setHideOnAction(false)
.setCloseButtonEnabled(true);
.setCloseButtonEnabled(true)
.setTitle(getTitle());
final RelativePoint target = JBPopupFactory.getInstance().guessBestPopupLocation(myEditor);
final Point screenPoint = target.getScreenPoint();