本文整理汇总了Java中com.intellij.uiDesigner.FormEditingUtil类的典型用法代码示例。如果您正苦于以下问题:Java FormEditingUtil类的具体用法?Java FormEditingUtil怎么用?Java FormEditingUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FormEditingUtil类属于com.intellij.uiDesigner包,在下文中一共展示了FormEditingUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(myProject);
PsiFile formFile = null;
if (myTextField.getText().length() > 0) {
VirtualFile formVFile = ResourceFileUtil.findResourceFileInScope(myTextField.getText(), myProject, ProjectScope.getAllScope(myProject));
if (formVFile != null) {
formFile = PsiManager.getInstance(myProject).findFile(formVFile);
}
}
TreeFileChooser fileChooser = factory.createFileChooser(myTitle, formFile, null, myFilter, true, true);
fileChooser.showDialog();
PsiFile file = fileChooser.getSelectedFile();
if (file != null) {
myTextField.setText(FormEditingUtil.buildResourceName(file));
}
}
示例2: checkCreateBindingFromText
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
public static void checkCreateBindingFromText(final RadComponent component, final String text) {
if (!component.isDefaultBinding()) {
return;
}
RadRootContainer root = (RadRootContainer)FormEditingUtil.getRoot(component);
PsiField boundField = findBoundField(root, component.getBinding());
if (boundField == null || !isFieldUnreferenced(boundField)) {
return;
}
String binding = suggestBindingFromText(component, text);
if (binding != null) {
new BindingProperty(component.getProject()).setValueEx(component, binding);
// keep the binding marked as default
component.setDefaultBinding(true);
}
}
示例3: updateLabelForBinding
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
void updateLabelForBinding(final RadComponent component) {
String value = getValue(component);
String text = FormInspectionUtil.getText(component.getModule(), component);
if (text != null && value != null) {
RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
if (root != null) {
RadComponent valueComponent = (RadComponent)FormEditingUtil.findComponent(root, value);
if (valueComponent != null) {
if (valueComponent instanceof RadScrollPane && ((RadScrollPane) valueComponent).getComponentCount() == 1) {
valueComponent = ((RadScrollPane) valueComponent).getComponent(0);
}
BindingProperty.checkCreateBindingFromText(valueComponent, text);
}
}
}
}
示例4: retargetComponentProperties
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
private static void retargetComponentProperties(final GuiEditor editor, final RadComponent c, final RadComponent newComponent) {
FormEditingUtil.iterate(editor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
RadComponent rc = (RadComponent) component;
for(IProperty p: component.getModifiedProperties()) {
if (p instanceof IntroComponentProperty) {
IntroComponentProperty icp = (IntroComponentProperty) p;
final String value = icp.getValue(rc);
if (value.equals(c.getId())) {
try {
icp.setValue((RadComponent)component, newComponent.getId());
}
catch (Exception e) {
// ignore
}
}
}
}
return true;
}
});
}
示例5: actionPerformed
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
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;
}
Runnable runnable = new Runnable() {
public void run() {
actionPerformed(editor, selection, e);
if (myModifying) {
editor.refreshAndSave(true);
}
}
};
if (getCommandName() != null) {
CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, getCommandName(), null);
}
else {
runnable.run();
}
}
}
示例6: setPreviewBindings
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
public static void setPreviewBindings(final LwRootContainer rootContainer, final String classToBindName) {
// 1. Prepare form to preview. We have to change container so that it has only one binding.
rootContainer.setClassToBind(classToBindName);
FormEditingUtil.iterate(
rootContainer,
new FormEditingUtil.ComponentVisitor<LwComponent>() {
public boolean visit(final LwComponent iComponent) {
iComponent.setBinding(null);
return true;
}
}
);
if (rootContainer.getComponentCount() == 1) {
//noinspection HardCodedStringLiteral
((LwComponent)rootContainer.getComponent(0)).setBinding(PREVIEW_BINDING_FIELD);
}
}
示例7: createPopupActionGroup
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
@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, new Comparator<Locale>() {
public int compare(final Locale o1, final Locale o2) {
return 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;
}
示例8: haveCustomComponents
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
private static boolean haveCustomComponents(final GuiEditor editor) {
// quick & dirty check
if (editor.isFormInvalid()) {
return true;
}
final Ref<Boolean> result = new Ref<Boolean>();
FormEditingUtil.iterate(editor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
if (component instanceof RadErrorComponent || !component.getComponentClassName().startsWith("javax.swing")) {
result.set(Boolean.TRUE);
return false;
}
return true;
}
});
return !result.isNull();
}
示例9: actionPerformed
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
Processor<ComponentItem> processor = new Processor<ComponentItem>() {
public boolean process(final ComponentItem selectedValue) {
if (selectedValue != null) {
myLastCreatedComponent = selectedValue;
editor.getMainProcessor().startInsertProcessor(selectedValue, getCreateLocation(editor, selection));
}
return true;
}
};
PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastCreatedComponent, processor,
UIDesignerBundle.message("create.component.title"));
final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
if (selection.size() > 0) {
FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
}
else {
listPopup.showInCenterOf(editor.getRootContainer().getDelegee());
}
}
示例10: flattenSimple
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
private static void flattenSimple(final RadContainer container) {
RadContainer parent = container.getParent();
RadComponent child = null;
Object childLayoutConstraints = null;
if (container.getComponentCount() == 1) {
child = container.getComponent(0);
childLayoutConstraints = container.getCustomLayoutConstraints();
child.getConstraints().restore(container.getConstraints());
container.removeComponent(child);
}
int childIndex = parent.indexOfComponent(container);
FormEditingUtil.deleteComponents(Collections.singletonList(container), false);
if (child != null) {
if (childLayoutConstraints != null) {
child.setCustomLayoutConstraints(childLayoutConstraints);
}
parent.addComponent(child, childIndex);
child.revalidate();
}
}
示例11: doPaste
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
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(),
new Runnable() {
public void run() {
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();
}
}
示例12: areCellsAdjacent
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
private static boolean areCellsAdjacent(final IContainer parent, final GridConstraints c1, final GridConstraints c2) {
if (parent instanceof RadContainer) {
final RadContainer container = (RadContainer)parent;
if (!container.getLayoutManager().isGrid()) return false;
if (c1.getRow() == c2.getRow()) {
return FormEditingUtil.prevCol(container, c1.getColumn()) == c2.getColumn() ||
FormEditingUtil.nextCol(container, c1.getColumn()) == c2.getColumn();
}
if (c1.getColumn() == c2.getColumn()) {
return FormEditingUtil.prevRow(container, c1.getRow()) == c2.getRow() ||
FormEditingUtil.nextRow(container, c1.getRow()) == c2.getRow();
}
}
return (c1.getRow() == c2.getRow() && Math.abs(c1.getColumn() - c2.getColumn()) == 1) ||
(c1.getColumn() == c2.getColumn() && Math.abs(c1.getRow() - c2.getRow()) == 1);
}
示例13: findSourceFile
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
private static VirtualFile findSourceFile(final CompileContext context, final VirtualFile formFile, final String className) {
final Module module = context.getModuleByFile(formFile);
if (module == null) {
return null;
}
final PsiClass aClass = FormEditingUtil.findClassToBind(module, className);
if (aClass == null) {
return null;
}
final PsiFile containingFile = aClass.getContainingFile();
if (containingFile == null){
return null;
}
return containingFile.getVirtualFile();
}
示例14: createBoundFields
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
private void createBoundFields(final PsiClass formClass) throws IncorrectOperationException {
final Module module = myEditor.getRootContainer().getModule();
final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
final PsiManager psiManager = PsiManager.getInstance(myEditor.getProject());
final Ref<IncorrectOperationException> exception = new Ref<IncorrectOperationException>();
FormEditingUtil.iterate(myEditor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
if (component.getBinding() != null) {
final PsiClass fieldClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
if (fieldClass != null) {
PsiType fieldType = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createType(fieldClass);
try {
PsiField field = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createField(component.getBinding(), fieldType);
formClass.add(field);
}
catch (IncorrectOperationException e) {
exception.set(e);
return false;
}
}
}
return true;
}
});
if (!exception.isNull()) {
throw exception.get();
}
}
示例15: bindToElement
import com.intellij.uiDesigner.FormEditingUtil; //导入依赖的package包/类
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
if (!(element instanceof PsiFile)) { //should be icon file or nested form
throw new IncorrectOperationException();
}
updateRangeText(FormEditingUtil.buildResourceName((PsiFile)element));
return myFile;
}