use of com.intellij.uiDesigner.designSurface.GuiEditor in project intellij-community by JetBrains.
the class ShrinkSelectionAction method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
final GuiEditor editor = FormEditingUtil.getEditorFromContext(e.getDataContext());
assert editor != null;
final SelectionState selectionState = editor.getSelectionState();
selectionState.setInsideChange(true);
ComponentTreeBuilder builder = DesignerToolWindowManager.getInstance(editor).getComponentTreeBuilder();
builder.beginUpdateSelection();
try {
final Stack<ComponentPtr[]> history = selectionState.getSelectionHistory();
history.pop();
SelectionState.restoreSelection(editor, history.peek());
} finally {
builder.endUpdateSelection();
selectionState.setInsideChange(false);
}
}
use of com.intellij.uiDesigner.designSurface.GuiEditor in project intellij-community by JetBrains.
the class ShrinkSelectionAction 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 Stack<ComponentPtr[]> history = editor.getSelectionState().getSelectionHistory();
presentation.setEnabled(history.size() > 1);
}
use of com.intellij.uiDesigner.designSurface.GuiEditor in project intellij-community by JetBrains.
the class FormSpellCheckingInspection method checkStringDescriptor.
@Override
protected void checkStringDescriptor(Module module, final IComponent component, final IProperty prop, final StringDescriptor descriptor, final FormErrorCollector collector) {
final String value = descriptor.getResolvedValue();
if (value == null) {
return;
}
final SpellCheckerManager manager = SpellCheckerManager.getInstance(module.getProject());
PlainTextSplitter.getInstance().split(value, TextRange.allOf(value), textRange -> {
final String word = textRange.substring(value);
if (manager.hasProblem(word)) {
final List<String> suggestions = manager.getSuggestions(word);
if (!suggestions.isEmpty() && prop instanceof IntroStringProperty) {
EditorQuickFixProvider changeToProvider = new EditorQuickFixProvider() {
@Override
public QuickFix createQuickFix(final GuiEditor editor, final RadComponent component1) {
return new PopupQuickFix<String>(editor, "Change to...", component1) {
@Override
public void run() {
ListPopup popup = JBPopupFactory.getInstance().createListPopup(getPopupStep());
popup.showUnderneathOf(component1.getDelegee());
}
@Override
public ListPopupStep<String> getPopupStep() {
return new BaseListPopupStep<String>("Select Replacement", suggestions) {
@Override
public PopupStep onChosen(String selectedValue, boolean finalChoice) {
FormInspectionUtil.updateStringPropertyValue(editor, component1, (IntroStringProperty) prop, descriptor, selectedValue);
return FINAL_CHOICE;
}
};
}
};
}
};
EditorQuickFixProvider acceptProvider = new EditorQuickFixProvider() {
@Override
public QuickFix createQuickFix(final GuiEditor editor, RadComponent component1) {
return new QuickFix(editor, "Save '" + word + "' to dictionary", component1) {
@Override
public void run() {
manager.acceptWordAsCorrect(word, editor.getProject());
}
};
}
};
collector.addError(getID(), component, prop, "Typo in word '" + word + "'", changeToProvider, acceptProvider);
} else {
collector.addError(getID(), component, prop, "Typo in word '" + word + "'");
}
}
});
}
use of com.intellij.uiDesigner.designSurface.GuiEditor in project intellij-community by JetBrains.
the class NoButtonGroupInspection method checkComponentProperties.
@Override
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
if (FormInspectionUtil.isComponentClass(module, component, JRadioButton.class)) {
final IRootContainer root = FormEditingUtil.getRoot(component);
if (root == null)
return;
if (root.getButtonGroupName(component) == null) {
EditorQuickFixProvider quickFixProvider = null;
IContainer parent = component.getParentContainer();
for (int i = 0; i < parent.getComponentCount(); i++) {
IComponent child = parent.getComponent(i);
if (child != component && FormInspectionUtil.isComponentClass(module, child, JRadioButton.class)) {
final GridConstraints c1 = component.getConstraints();
final GridConstraints c2 = child.getConstraints();
if (areCellsAdjacent(parent, c1, c2)) {
final String groupName = root.getButtonGroupName(child);
if (groupName == null) {
quickFixProvider = new EditorQuickFixProvider() {
@Override
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
return new CreateGroupQuickFix(editor, component, c1.getColumn() == c2.getColumn());
}
};
break;
} else {
quickFixProvider = new EditorQuickFixProvider() {
@Override
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
return new AddToGroupQuickFix(editor, component, groupName);
}
};
}
}
}
}
collector.addError(getID(), component, null, UIDesignerBundle.message("inspection.no.button.group.error"), quickFixProvider);
}
}
}
use of com.intellij.uiDesigner.designSurface.GuiEditor in project intellij-community by JetBrains.
the class I18nFormInspection method checkStringDescriptor.
@Override
protected void checkStringDescriptor(final Module module, final IComponent component, final IProperty prop, final StringDescriptor descriptor, final FormErrorCollector collector) {
if (isHardCodedStringDescriptor(descriptor)) {
if (isPropertyDescriptor(prop)) {
if (isSetterNonNls(module.getProject(), GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module), component.getComponentClassName(), prop.getName())) {
return;
}
}
EditorQuickFixProvider provider;
if (prop.getName().equals(BorderProperty.NAME)) {
provider = new EditorQuickFixProvider() {
@Override
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
return new I18nizeFormBorderQuickFix(editor, UIDesignerBundle.message("i18n.quickfix.border.title"), (RadContainer) component);
}
};
} else if (prop.getName().equals(ITabbedPane.TAB_TITLE_PROPERTY) || prop.getName().equals(ITabbedPane.TAB_TOOLTIP_PROPERTY)) {
provider = new EditorQuickFixProvider() {
@Override
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
return new I18nizeTabTitleQuickFix(editor, UIDesignerBundle.message("i18n.quickfix.tab.title", prop.getName()), component, prop.getName());
}
};
} else {
provider = new EditorQuickFixProvider() {
@Override
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
return new I18nizeFormPropertyQuickFix(editor, UIDesignerBundle.message("i18n.quickfix.property", prop.getName()), component, (IntrospectedProperty) prop);
}
};
}
collector.addError(getID(), component, prop, UIDesignerBundle.message("inspection.i18n.message.in.form", descriptor.getValue()), provider);
}
}
Aggregations