Search in sources :

Example 6 with GuiEditor

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

the class MorphAction method actionPerformed.

protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
    Processor<ComponentItem> processor = selectedValue -> {
        Runnable runnable = () -> {
            for (RadComponent c : selection) {
                if (!morphComponent(editor, c, selectedValue))
                    break;
            }
            editor.refreshAndSave(true);
        };
        CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, UIDesignerBundle.message("morph.component.command"), null);
        IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
            IdeFocusManager.getGlobalInstance().requestFocus(editor.getGlassLayer(), true);
        });
        return true;
    };
    PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastMorphComponent, processor, UIDesignerBundle.message("morph.component.title"));
    step.hideNonAtomic();
    if (selection.size() == 1) {
        step.hideComponentClass(selection.get(0).getComponentClassName());
    }
    final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
    FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
}
Also used : PsiType(com.intellij.psi.PsiType) UIDesignerBundle(com.intellij.uiDesigner.UIDesignerBundle) RadAtomicComponent(com.intellij.uiDesigner.radComponents.RadAtomicComponent) JavaPsiFacade(com.intellij.psi.JavaPsiFacade) ChangeFieldTypeFix(com.intellij.uiDesigner.quickFixes.ChangeFieldTypeFix) ArrayList(java.util.ArrayList) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor) Palette(com.intellij.uiDesigner.palette.Palette) PsiElementFactory(com.intellij.psi.PsiElementFactory) IProperty(com.intellij.uiDesigner.lw.IProperty) Logger(com.intellij.openapi.diagnostic.Logger) IntroComponentProperty(com.intellij.uiDesigner.propertyInspector.properties.IntroComponentProperty) IncorrectOperationException(com.intellij.util.IncorrectOperationException) ComponentItem(com.intellij.uiDesigner.palette.ComponentItem) BindingProperty(com.intellij.uiDesigner.propertyInspector.properties.BindingProperty) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) FormEditingUtil(com.intellij.uiDesigner.FormEditingUtil) CommandProcessor(com.intellij.openapi.command.CommandProcessor) ListPopup(com.intellij.openapi.ui.popup.ListPopup) List(java.util.List) IComponent(com.intellij.uiDesigner.lw.IComponent) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) Processor(com.intellij.util.Processor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) PsiField(com.intellij.psi.PsiField) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer) NotNull(org.jetbrains.annotations.NotNull) InsertComponentProcessor(com.intellij.uiDesigner.designSurface.InsertComponentProcessor) FormInspectionUtil(com.intellij.uiDesigner.inspections.FormInspectionUtil) IntrospectedProperty(com.intellij.uiDesigner.propertyInspector.IntrospectedProperty) ComponentItem(com.intellij.uiDesigner.palette.ComponentItem) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Example 7 with GuiEditor

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

the class PreviewFormAction method update.

public void update(final AnActionEvent e) {
    final GuiEditor editor = FormEditingUtil.getActiveEditor(e.getDataContext());
    if (editor == null) {
        e.getPresentation().setVisible(false);
        return;
    }
    final VirtualFile file = editor.getFile();
    e.getPresentation().setVisible(FileDocumentManager.getInstance().getDocument(file) != null && file.getFileType() == StdFileTypes.GUI_DESIGNER_FORM);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor)

Example 8 with GuiEditor

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

the class DataBindingWizardAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final Project project;
    final VirtualFile formFile;
    GuiEditor editor = FormEditingUtil.getActiveEditor(e.getDataContext());
    if (editor == null) {
        return;
    }
    project = editor.getProject();
    formFile = editor.getFile();
    try {
        final WizardData wizardData = new WizardData(project, formFile);
        final Module module = ModuleUtilCore.findModuleForFile(formFile, wizardData.myProject);
        LOG.assertTrue(module != null);
        final LwRootContainer[] rootContainer = new LwRootContainer[1];
        Generator.exposeForm(wizardData.myProject, formFile, rootContainer);
        final String classToBind = rootContainer[0].getClassToBind();
        if (classToBind == null) {
            Messages.showInfoMessage(project, UIDesignerBundle.message("info.form.not.bound"), UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }
        final PsiClass boundClass = FormEditingUtil.findClassToBind(module, classToBind);
        if (boundClass == null) {
            Messages.showErrorDialog(project, UIDesignerBundle.message("error.bound.to.not.found.class", classToBind), UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }
        Generator.prepareWizardData(wizardData, boundClass);
        if (!hasBinding(rootContainer[0])) {
            Messages.showInfoMessage(project, UIDesignerBundle.message("info.no.bound.components"), UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }
        if (!wizardData.myBindToNewBean) {
            final String[] variants = new String[] { UIDesignerBundle.message("action.alter.data.binding"), UIDesignerBundle.message("action.bind.to.another.bean"), CommonBundle.getCancelButtonText() };
            final int result = Messages.showYesNoCancelDialog(project, UIDesignerBundle.message("info.data.binding.regenerate", wizardData.myBeanClass.getQualifiedName()), UIDesignerBundle.message("title.data.binding"), variants[0], variants[1], variants[2], Messages.getQuestionIcon());
            if (result == Messages.YES) {
            // do nothing here
            } else if (result == Messages.NO) {
                wizardData.myBindToNewBean = true;
            } else {
                return;
            }
        }
        final DataBindingWizard wizard = new DataBindingWizard(project, wizardData);
        wizard.show();
    } catch (Generator.MyException exc) {
        Messages.showErrorDialog(project, exc.getMessage(), CommonBundle.getErrorTitle());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiClass(com.intellij.psi.PsiClass) WizardData(com.intellij.uiDesigner.wizard.WizardData) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor) LwRootContainer(com.intellij.uiDesigner.lw.LwRootContainer) Project(com.intellij.openapi.project.Project) DataBindingWizard(com.intellij.uiDesigner.wizard.DataBindingWizard) Module(com.intellij.openapi.module.Module) Generator(com.intellij.uiDesigner.wizard.Generator)

Example 9 with GuiEditor

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

the class ExpandSelectionAction method update.

public void update(final AnActionEvent e) {
    final Presentation presentation = e.getPresentation();
    final GuiEditor editor = FormEditingUtil.getEditorFromContext(e.getDataContext());
    if (editor == null) {
        presentation.setEnabled(false);
        return;
    }
    final SelectionState selectionState = editor.getSelectionState();
    selectionState.setInsideChange(true);
    final Stack<ComponentPtr[]> history = selectionState.getSelectionHistory();
    presentation.setEnabled(!history.isEmpty());
}
Also used : GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor) Presentation(com.intellij.openapi.actionSystem.Presentation) SelectionState(com.intellij.uiDesigner.SelectionState)

Example 10 with GuiEditor

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

the class ShowComponentTagsAction method update.

public void update(final AnActionEvent e) {
    super.update(e);
    GuiEditor editor = FormEditingUtil.getEditorFromContext(e.getDataContext());
    e.getPresentation().setEnabled(editor != null);
}
Also used : GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor)

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