public static DomFileEditor createDomFileEditor( final String name, @Nullable final Icon icon, final DomElement element, final Factory<? extends CommittablePanel> committablePanel) { final XmlFile file = DomUtil.getFile(element); final Factory<BasicDomElementComponent> factory = new Factory<BasicDomElementComponent>() { @Override public BasicDomElementComponent create() { CaptionComponent captionComponent = new CaptionComponent(name, icon); captionComponent.initErrorPanel(element); BasicDomElementComponent component = createComponentWithCaption(committablePanel.create(), captionComponent, element); Disposer.register(component, captionComponent); return component; } }; return new DomFileEditor<BasicDomElementComponent>( file.getProject(), file.getVirtualFile(), name, factory) { @Override public JComponent getPreferredFocusedComponent() { return null; } }; }
public DomFileEditor(final DomElement element, final String name, final T component) { this( element.getManager().getProject(), DomUtil.getFile(element).getVirtualFile(), name, component); }
@Override protected void wrapValueSetting( @NotNull final DomElement domElement, final Runnable valueSetter) { if (domElement.isValid()) { new WriteCommandAction(getProject(), DomUtil.getFile(domElement)) { @Override protected void run(@NotNull final Result result) throws Throwable { valueSetter.run(); } }.execute(); fireChanged(); } }
public DomElementsToggleAction(final DomModelTreeView treeView, final Class aClass) { myTreeView = treeView; myClass = aClass; Icon myIcon = ElementPresentationManager.getIcon(myClass); if (myIcon == null) { myIcon = AllIcons.Nodes.Pointcut; } this.myIcon = myIcon; myText = TypePresentationService.getService().getTypePresentableName(myClass); if (getHiders() == null) DomUtil.getFile(myTreeView.getRootElement()) .putUserData(AbstractDomElementNode.TREE_NODES_HIDERS_KEY, new HashMap<>()); if (getHiders().get(myClass) == null) getHiders().put(myClass, true); }
public static MavenDomParent updateMavenParent( MavenDomProjectModel mavenModel, MavenProject parentProject) { MavenDomParent result = mavenModel.getMavenParent(); VirtualFile pomFile = DomUtil.getFile(mavenModel).getVirtualFile(); Project project = mavenModel.getXmlElement().getProject(); MavenId parentId = parentProject.getMavenId(); result.getGroupId().setStringValue(parentId.getGroupId()); result.getArtifactId().setStringValue(parentId.getArtifactId()); result.getVersion().setStringValue(parentId.getVersion()); if (!Comparing.equal(pomFile.getParent().getParent(), parentProject.getDirectoryFile())) { result .getRelativePath() .setValue(PsiManager.getInstance(project).findFile(parentProject.getFile())); } return result; }
public DomElementsErrorPanel(final DomElement... domElements) { assert domElements.length > 0; myDomElements = domElements; final DomManager domManager = domElements[0].getManager(); myProject = domManager.getProject(); myAnnotationsManager = (DomElementAnnotationsManagerImpl) DomElementAnnotationsManager.getInstance(myProject); setPreferredSize(getDimension()); myErrorStripeRenderer = new DomElementsTrafficLightRenderer(DomUtil.getFile(domElements[0])); Disposer.register(this, myErrorStripeRenderer); addUpdateRequest(); domManager.addDomEventListener( new DomChangeAdapter() { protected void elementChanged(DomElement element) { addUpdateRequest(); } }, this); }
@Nullable public static VirtualFile getVirtualFile(@NotNull DomElement element) { PsiFile psiFile = DomUtil.getFile(element); return getVirtualFile(psiFile); }
@Override @NotNull public final XmlFile getFile() { return DomUtil.getFile(getInvocationElement()); }
protected boolean isRightFile(final VirtualFile file) { return myRootElement == null || (myRootElement.isValid() && file.equals(DomUtil.getFile(myRootElement).getVirtualFile())); }
private Map<Class, Boolean> getHiders() { return DomUtil.getFile(myTreeView.getRootElement()) .getUserData(BaseDomElementNode.TREE_NODES_HIDERS_KEY); }
public final boolean isMockElement(DomElement element) { return DomUtil.getFile(element).getUserData(MOCK) != null; }