use of com.intellij.uiDesigner.lw.IComponent in project intellij-community by JetBrains.
the class SelectAllComponentsAction method actionPerformed.
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
final ComponentTreeBuilder builder = DesignerToolWindowManager.getInstance(editor).getComponentTreeBuilder();
builder.beginUpdateSelection();
try {
FormEditingUtil.iterate(editor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
((RadComponent) component).setSelected(true);
return true;
}
});
} finally {
builder.endUpdateSelection();
}
}
use of com.intellij.uiDesigner.lw.IComponent in project intellij-community by JetBrains.
the class ComponentEditor method collectFilteredComponents.
protected RadComponent[] collectFilteredComponents(final RadComponent component) {
final ArrayList<RadComponent> result = new ArrayList<>();
result.add(null);
RadContainer container = component.getParent();
while (container.getParent() != null) {
container = container.getParent();
}
FormEditingUtil.iterate(container, new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
RadComponent radComponent = (RadComponent) component;
final JComponent delegee = radComponent.getDelegee();
if (!myPropertyType.isInstance(delegee)) {
return true;
}
if (myFilter == null || myFilter.value(radComponent)) {
result.add(radComponent);
}
return true;
}
});
return result.toArray(new RadComponent[result.size()]);
}
use of com.intellij.uiDesigner.lw.IComponent in project intellij-community by JetBrains.
the class AssignMnemonicFix method fillMnemonicVariants.
private String[] fillMnemonicVariants(final String value) {
final StringBuffer usedMnemonics = new StringBuffer();
RadContainer container = myComponent.getParent();
if (container != null) {
while (container.getParent() != null) {
container = container.getParent();
}
FormEditingUtil.iterate(container, new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
SupportCode.TextWithMnemonic twm = DuplicateMnemonicInspection.getTextWithMnemonic(myEditor.getModule(), component);
if (twm != null) {
usedMnemonics.append(twm.getMnemonicChar());
}
return true;
}
});
}
ArrayList<String> variants = new ArrayList<>();
// try upper-case and word start characters
for (int i = 0; i < value.length(); i++) {
final char ch = value.charAt(i);
if (i == 0 || Character.isUpperCase(ch) || (i > 0 && value.charAt(i - 1) == ' ')) {
if (Character.isLetter(ch) && usedMnemonics.indexOf(String.valueOf(ch).toUpperCase()) < 0) {
variants.add(value.substring(0, i) + "&" + value.substring(i));
}
}
}
if (variants.size() == 0) {
// try any unused characters
for (int i = 0; i < value.length(); i++) {
final char ch = value.charAt(i);
if (Character.isLetter(ch) && usedMnemonics.indexOf(String.valueOf(ch).toUpperCase()) < 0) {
variants.add(value.substring(0, i) + "&" + value.substring(i));
}
}
}
if (variants.size() == 0) {
variants.add(value);
}
return ArrayUtil.toStringArray(variants);
}
use of com.intellij.uiDesigner.lw.IComponent in project intellij-community by JetBrains.
the class BaseFormInspection method checkFile.
@Override
@Nullable
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (!file.getFileType().equals(StdFileTypes.GUI_DESIGNER_FORM)) {
return null;
}
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return null;
}
final Module module = ModuleUtil.findModuleForFile(virtualFile, file.getProject());
if (module == null) {
return null;
}
final LwRootContainer rootContainer;
try {
rootContainer = Utils.getRootContainer(file.getText(), new PsiPropertiesProvider(module));
} catch (Exception e) {
return null;
}
if (rootContainer.isInspectionSuppressed(getShortName(), null)) {
return null;
}
final FormFileErrorCollector collector = new FormFileErrorCollector(file, manager, isOnTheFly);
startCheckForm(rootContainer);
FormEditingUtil.iterate(rootContainer, new FormEditingUtil.ComponentVisitor() {
@Override
public boolean visit(final IComponent component) {
if (!rootContainer.isInspectionSuppressed(getShortName(), component.getId())) {
checkComponentProperties(module, component, collector);
}
return true;
}
});
doneCheckForm(rootContainer);
return collector.result();
}
use of com.intellij.uiDesigner.lw.IComponent in project intellij-community by JetBrains.
the class PasteProcessor method doPaste.
private void doPaste(final ComponentDropLocation location) {
if (location.canDrop(myPastedComponentList) && myEditor.ensureEditable()) {
final RadComponent[] componentsToPaste = myComponentsToPaste.toArray(new RadComponent[myComponentsToPaste.size()]);
CommandProcessor.getInstance().executeCommand(myEditor.getProject(), () -> {
location.processDrop(myEditor, componentsToPaste, null, myPastedComponentList);
for (RadComponent c : componentsToPaste) {
FormEditingUtil.iterate(c, new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
if (component.getBinding() != null) {
InsertComponentProcessor.createBindingField(myEditor, (RadComponent) component);
}
return true;
}
});
}
FormEditingUtil.selectComponents(myEditor, myComponentsToPaste);
myEditor.refreshAndSave(true);
}, UIDesignerBundle.message("command.paste"), null);
endPaste();
}
}
Aggregations