Search in sources :

Example 1 with GuiEditor

use of com.intellij.uiDesigner.designSurface.GuiEditor in project intellij-community by JetBrains.

the class BindingProperty method updateBoundFieldName.

public static void updateBoundFieldName(final RadRootContainer root, final String oldName, final String newName, final String fieldClassName) {
    final String classToBind = root.getClassToBind();
    if (classToBind == null)
        return;
    final Project project = root.getProject();
    if (newName.length() == 0) {
        checkRemoveUnusedField(root, oldName, FormEditingUtil.getNextSaveUndoGroupId(project));
        return;
    }
    final PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(classToBind, GlobalSearchScope.allScope(project));
    if (aClass == null) {
        return;
    }
    if (oldName == null) {
        if (aClass.findFieldByName(newName, true) == null) {
            CreateFieldFix.runImpl(project, root, aClass, fieldClassName, newName, false, FormEditingUtil.getNextSaveUndoGroupId(project));
        }
        return;
    }
    final PsiField oldField = aClass.findFieldByName(oldName, true);
    if (oldField == null) {
        return;
    }
    if (aClass.findFieldByName(newName, true) != null) {
        checkRemoveUnusedField(root, oldName, FormEditingUtil.getNextSaveUndoGroupId(project));
        return;
    }
    if (!isFieldUnreferenced(oldField)) {
        final int option = Messages.showYesNoDialog(project, MessageFormat.format(UIDesignerBundle.message("message.rename.field"), oldName, newName), UIDesignerBundle.message("title.rename"), Messages.getQuestionIcon());
        if (option != Messages.YES) /*Yes*/
        {
            return;
        }
    }
    // Commit document before refactoring starts
    GuiEditor editor = DesignerToolWindowManager.getInstance(project).getActiveFormEditor();
    if (editor != null) {
        editor.refreshAndSave(false);
    }
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) {
        return;
    }
    final RenameProcessor processor = new RenameProcessor(project, oldField, newName, true, true);
    processor.run();
}
Also used : Project(com.intellij.openapi.project.Project) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor)

Example 2 with GuiEditor

use of com.intellij.uiDesigner.designSurface.GuiEditor in project intellij-community by JetBrains.

the class ShowHintAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final GuiEditor editor = myManager.getEditor();
    if (editor == null)
        return;
    // 1. Show light bulb
    myManager.showIntentionHint();
    // 2. Commit possible non committed value and show popup
    final PropertyInspector propertyInspector = DesignerToolWindowManager.getInstance(myManager.getEditor()).getPropertyInspector();
    if (propertyInspector != null && propertyInspector.isEditing()) {
        propertyInspector.stopEditing();
    }
    myManager.showIntentionPopup();
}
Also used : PropertyInspector(com.intellij.uiDesigner.propertyInspector.PropertyInspector) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor)

Example 3 with GuiEditor

use of com.intellij.uiDesigner.designSurface.GuiEditor in project intellij-community by JetBrains.

the class AbstractGuiEditorAction method update.

public final void update(AnActionEvent e) {
    GuiEditor editor = FormEditingUtil.getEditorFromContext(e.getDataContext());
    if (editor == null) {
        e.getPresentation().setVisible(false);
        e.getPresentation().setEnabled(false);
    } else {
        e.getPresentation().setVisible(true);
        e.getPresentation().setEnabled(true);
        final ArrayList<RadComponent> selection = FormEditingUtil.getSelectedComponents(editor);
        update(editor, selection, e);
    }
}
Also used : RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor)

Example 4 with GuiEditor

use of com.intellij.uiDesigner.designSurface.GuiEditor in project intellij-community by JetBrains.

the class AbstractGuiEditorAction method actionPerformed.

public final void actionPerformed(final AnActionEvent e) {
    final GuiEditor editor = FormEditingUtil.getEditorFromContext(e.getDataContext());
    if (editor != null) {
        final ArrayList<RadComponent> selection = FormEditingUtil.getSelectedComponents(editor);
        if (myModifying) {
            if (!editor.ensureEditable())
                return;
        }
        InplaceEditingLayer editingLayer = editor.getInplaceEditingLayer();
        if (editingLayer.isEditing()) {
            editingLayer.finishInplaceEditing();
        }
        Runnable runnable = () -> {
            actionPerformed(editor, selection, e);
            if (myModifying) {
                editor.refreshAndSave(true);
            }
        };
        if (getCommandName() != null) {
            CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, getCommandName(), null);
        } else {
            runnable.run();
        }
    }
}
Also used : InplaceEditingLayer(com.intellij.uiDesigner.designSurface.InplaceEditingLayer) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor)

Example 5 with GuiEditor

use of com.intellij.uiDesigner.designSurface.GuiEditor in project intellij-community by JetBrains.

the class ChooseLocaleAction method createPopupActionGroup.

@NotNull
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
    DefaultActionGroup group = new DefaultActionGroup();
    GuiEditor editor = myLastEditor;
    if (editor != null) {
        Locale[] locales = FormEditingUtil.collectUsedLocales(editor.getModule(), editor.getRootContainer());
        if (locales.length > 1 || (locales.length == 1 && locales[0].getDisplayName().length() > 0)) {
            Arrays.sort(locales, (o1, o2) -> o1.getDisplayName().compareTo(o2.getDisplayName()));
            for (Locale locale : locales) {
                group.add(new SetLocaleAction(editor, locale, true));
            }
        } else {
            group.add(new SetLocaleAction(editor, new Locale(""), false));
        }
    }
    return group;
}
Also used : Locale(java.util.Locale) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GuiEditor (com.intellij.uiDesigner.designSurface.GuiEditor)21 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)8 QuickFix (com.intellij.uiDesigner.quickFixes.QuickFix)4 SelectionState (com.intellij.uiDesigner.SelectionState)3 IComponent (com.intellij.uiDesigner.lw.IComponent)3 RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)3 Presentation (com.intellij.openapi.actionSystem.Presentation)2 Project (com.intellij.openapi.project.Project)2 ListPopup (com.intellij.openapi.ui.popup.ListPopup)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 CaptionSelection (com.intellij.uiDesigner.CaptionSelection)2 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)2 ComponentTreeBuilder (com.intellij.uiDesigner.componentTree.ComponentTreeBuilder)2 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)2 IProperty (com.intellij.uiDesigner.lw.IProperty)2 ComponentItem (com.intellij.uiDesigner.palette.ComponentItem)2 NotNull (org.jetbrains.annotations.NotNull)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 CommandProcessor (com.intellij.openapi.command.CommandProcessor)1