mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inplace introduce: update size on typing
This commit is contained in:
-2
@@ -65,7 +65,6 @@ public class InplaceIntroduceConstantPopup extends AbstractJavaInplaceIntroducer
|
||||
|
||||
private JCheckBox myMoveToAnotherClassCb;
|
||||
|
||||
private JPanel myWholePanel;
|
||||
private final PsiClass myParentClass;
|
||||
|
||||
public InplaceIntroduceConstantPopup(Project project,
|
||||
@@ -97,7 +96,6 @@ public class InplaceIntroduceConstantPopup extends AbstractJavaInplaceIntroducer
|
||||
myInitializerText = getExprText(expr, localVariable);
|
||||
|
||||
|
||||
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);
|
||||
myWholePanel.add(myLabel, gc);
|
||||
|
||||
-4
@@ -55,8 +55,6 @@ public class InplaceIntroduceFieldPopup extends AbstractJavaInplaceIntroducer {
|
||||
|
||||
private final IntroduceFieldCentralPanel myIntroduceFieldPanel;
|
||||
|
||||
private JPanel myWholePanel;
|
||||
|
||||
static BaseExpressionToFieldHandler.InitializationPlace ourLastInitializerPlace;
|
||||
|
||||
public InplaceIntroduceFieldPopup(PsiLocalVariable localVariable,
|
||||
@@ -94,8 +92,6 @@ public class InplaceIntroduceFieldPopup extends AbstractJavaInplaceIntroducer {
|
||||
new IntroduceFieldPopupPanel(parentClass, initializerExpression, localVariable, currentMethodConstructor, localVariable != null, aStatic,
|
||||
myOccurrences, allowInitInMethod, allowInitInMethodIfAll, typeSelectorManager);
|
||||
|
||||
myWholePanel = new JPanel(new BorderLayout());
|
||||
myWholePanel.setBorder(null);
|
||||
myWholePanel.add(myLabel, BorderLayout.NORTH);
|
||||
|
||||
final JComponent centerPanel = myIntroduceFieldPanel.createCenterPanel();
|
||||
|
||||
+6
-4
@@ -20,13 +20,16 @@ import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.ui.BalloonImpl;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.ui.PositionTracker;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import gnu.trove.TIntProcedure;
|
||||
@@ -47,7 +50,6 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
private final PsiMethod myMethodToSearchFor;
|
||||
private final boolean myMustBeFinal;
|
||||
|
||||
private final JPanel myWholePanel;
|
||||
private int myParameterIndex = -1;
|
||||
private InplaceIntroduceParameterUI myPanel;
|
||||
|
||||
@@ -69,8 +71,6 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
myMethodToSearchFor = methodToSearchFor;
|
||||
myMustBeFinal = mustBeFinal;
|
||||
|
||||
myWholePanel = new JPanel(new GridBagLayout());
|
||||
myWholePanel.setBorder(null);
|
||||
myWholePanel.add(myLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
|
||||
new Insets(0,5,0,5), 0,0));
|
||||
myPanel = new InplaceIntroduceParameterUI(project, localVar, expr, method, parametersToRemove, typeSelectorManager,
|
||||
@@ -206,7 +206,7 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
|
||||
@Override
|
||||
protected void updateTitle(PsiVariable variable, String value) {
|
||||
final PsiElement declarationScope = ((PsiParameter)variable).getDeclarationScope();
|
||||
final PsiElement declarationScope = variable != null ? ((PsiParameter)variable).getDeclarationScope() : null;
|
||||
if (declarationScope instanceof PsiMethod) {
|
||||
final PsiMethod psiMethod = (PsiMethod)declarationScope;
|
||||
myLabel.clear();
|
||||
@@ -227,6 +227,8 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
}
|
||||
myLabel.append(")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
myWholePanel.revalidate();
|
||||
((BalloonImpl)myBalloon).revalidate(new PositionTracker.Static<Balloon>(myTarget));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-1
@@ -37,6 +37,7 @@ import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -45,7 +46,9 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
|
||||
import com.intellij.ui.BalloonImpl;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.util.ui.PositionTracker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -70,6 +73,7 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
|
||||
protected SimpleColoredComponent myLabel = new SimpleColoredComponent();
|
||||
private DocumentAdapter myDocumentAdapter;
|
||||
protected final JPanel myWholePanel;
|
||||
|
||||
public AbstractInplaceIntroducer(Project project,
|
||||
Editor editor,
|
||||
@@ -94,6 +98,8 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
myLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0));
|
||||
myLabel.append("#########################");
|
||||
|
||||
myWholePanel = new JPanel(new GridBagLayout());
|
||||
myWholePanel.setBorder(null);
|
||||
|
||||
final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
|
||||
final Shortcut[] shortcuts = keymap.getShortcuts(getActionName());
|
||||
@@ -157,7 +163,7 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
if (templateState != null) {
|
||||
final String variableValue =
|
||||
templateState.getVariableValue(VariableInplaceRenamer.PRIMARY_VARIABLE_NAME).getText();
|
||||
updateTitle(variable, variableValue);
|
||||
updateTitle(getVariable(), variableValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -185,11 +191,15 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
protected void updateTitle(V variable, String value) {
|
||||
myLabel.clear();
|
||||
myLabel.append(variable.getText().replace(variable.getName(), value));
|
||||
myWholePanel.revalidate();
|
||||
((BalloonImpl)myBalloon).revalidate(new PositionTracker.Static<Balloon>(myTarget));
|
||||
}
|
||||
|
||||
protected void updateTitle(V variable) {
|
||||
myLabel.clear();
|
||||
myLabel.append(variable.getText());
|
||||
myWholePanel.revalidate();
|
||||
((BalloonImpl)myBalloon).revalidate(new PositionTracker.Static<Balloon>(myTarget));
|
||||
}
|
||||
|
||||
public void restartInplaceIntroduceTemplate() {
|
||||
|
||||
+3
-1
@@ -60,6 +60,7 @@ public abstract class AbstractInplaceVariableIntroducer<E extends PsiElement> ex
|
||||
|
||||
protected Balloon myBalloon;
|
||||
protected String myTitle;
|
||||
protected RelativePoint myTarget;
|
||||
|
||||
public AbstractInplaceVariableIntroducer(PsiNamedElement elementToRename,
|
||||
Editor editor,
|
||||
@@ -142,7 +143,8 @@ public abstract class AbstractInplaceVariableIntroducer<E extends PsiElement> ex
|
||||
if (target.getPoint().getY() > myEditor.getLineHeight() + myBalloon.getPreferredSize().getHeight()) {
|
||||
y -= myEditor.getLineHeight();
|
||||
}
|
||||
myBalloon.show(new RelativePoint(new Point(screenPoint.x, y)), Balloon.Position.above);
|
||||
myTarget = new RelativePoint(new Point(screenPoint.x, y));
|
||||
myBalloon.show(myTarget, Balloon.Position.above);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user