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();
}
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();
}
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);
}
}
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();
}
}
}
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;
}
Aggregations