preview for introduce constant

This commit is contained in:
Max Medvedev
2013-10-31 17:58:31 +02:00
parent 8299623232
commit b5a9cef9d4
3 changed files with 32 additions and 45 deletions
@@ -15,12 +15,10 @@
*/
package org.jetbrains.plugins.groovy.refactoring.introduce.constant;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.PsiType;
import com.intellij.psi.*;
import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
import com.intellij.refactoring.introduceField.IntroduceConstantHandler;
import com.intellij.ui.components.JBCheckBox;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
@@ -163,7 +161,27 @@ public class GrInplaceConstantIntroducer extends GrAbstractInplaceIntroducer<GrI
@Nullable
@Override
protected PsiElement checkLocalScope() {
return getVariable().getContainingFile();
return ((PsiField)getVariable()).getContainingClass();
}
/**
* Created by Max Medvedev on 8/29/13
*/
public class GrInplaceIntroduceConstantPanel {
private JBCheckBox myMoveToAnotherClassJBCheckBox;
private JPanel myRootPane;
private JComponent myPreview;
public boolean isMoveToAnotherClass() {
return myMoveToAnotherClassJBCheckBox.isSelected();
}
public JComponent getRootPane() {
return myRootPane;
}
private void createUIComponents() {
myPreview = getPreviewComponent();
}
}
}
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrInplaceIntroduceConstantPanel">
<grid id="27dc6" binding="myRootPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrInplaceConstantIntroducer.GrInplaceIntroduceConstantPanel">
<grid id="27dc6" binding="myRootPane" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
@@ -10,12 +10,12 @@
<children>
<vspacer id="3c553">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="1ff44" class="com.intellij.ui.components.JBCheckBox" binding="myMoveToAnotherClassJBCheckBox" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<focusable value="false"/>
@@ -23,6 +23,11 @@
<text value="&amp;Move to another class"/>
</properties>
</component>
<component id="3e5fd" class="javax.swing.JComponent" binding="myPreview" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</component>
</children>
</grid>
</form>
@@ -1,36 +0,0 @@
/*
* Copyright 2000-2013 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 org.jetbrains.plugins.groovy.refactoring.introduce.constant;
import com.intellij.ui.components.JBCheckBox;
import javax.swing.*;
/**
* Created by Max Medvedev on 8/29/13
*/
public class GrInplaceIntroduceConstantPanel {
private JBCheckBox myMoveToAnotherClassJBCheckBox;
private JPanel myRootPane;
public boolean isMoveToAnotherClass() {
return myMoveToAnotherClassJBCheckBox.isSelected();
}
public JComponent getRootPane() {
return myRootPane;
}
}