Search in sources :

Example 1 with EXCLUSION

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.EXCLUSION in project m2e-core-tests by tesla.

the class ExcludeArtifactRefactoringTest method hasExclusionSet.

/*
   * The editor has the given exclusion set
   */
protected static boolean hasExclusionSet(MavenPomEditor editor, final ArtifactKey dependencyKey, final ArtifactKey excluded) throws Exception {
    final boolean[] found = new boolean[1];
    found[0] = false;
    performOnDOMDocument(new OperationTuple(editor.getDocument(), document -> {
        Element dep = findChild(findChild(document.getDocumentElement(), DEPENDENCIES), DEPENDENCY, childEquals(GROUP_ID, dependencyKey.getGroupId()), childEquals(ARTIFACT_ID, dependencyKey.getArtifactId()), childEquals(VERSION, dependencyKey.getVersion()));
        if (dep != null) {
            Element exclusion = findChild(findChild(dep, EXCLUSIONS), EXCLUSION, childEquals(GROUP_ID, excluded.getGroupId()), childEquals(ARTIFACT_ID, excluded.getArtifactId()));
            found[0] = exclusion != null;
        }
    }, true));
    return found[0];
}
Also used : ArtifactKey(org.eclipse.m2e.core.embedder.ArtifactKey) ParentGatherer(org.eclipse.m2e.core.ui.internal.util.ParentGatherer) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) ExcludeArtifactRefactoring(org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring) CoreException(org.eclipse.core.runtime.CoreException) IStatus(org.eclipse.core.runtime.IStatus) PomEdits.performOnDOMDocument(org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument) ARTIFACT_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.ARTIFACT_ID) PartInitException(org.eclipse.ui.PartInitException) After(org.junit.After) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) AbstractMavenProjectTestCase(org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase) PomEdits.childEquals(org.eclipse.m2e.core.ui.internal.editing.PomEdits.childEquals) Assert.fail(org.junit.Assert.fail) Change(org.eclipse.ltk.core.refactoring.Change) PomResourceImpl(org.eclipse.m2e.model.edit.pom.util.PomResourceImpl) RefactoringStatusEntry(org.eclipse.ltk.core.refactoring.RefactoringStatusEntry) NLS(org.eclipse.osgi.util.NLS) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) MavenPomEditor(org.eclipse.m2e.editor.pom.MavenPomEditor) EXCLUSIONS(org.eclipse.m2e.core.ui.internal.editing.PomEdits.EXCLUSIONS) Status(org.eclipse.core.runtime.Status) Display(org.eclipse.swt.widgets.Display) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DocumentChange(org.eclipse.ltk.core.refactoring.DocumentChange) List(java.util.List) Resource(org.eclipse.emf.ecore.resource.Resource) Model(org.eclipse.m2e.model.edit.pom.Model) EXCLUSION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.EXCLUSION) DEPENDENCY(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DEPENDENCY) Dependency(org.eclipse.m2e.model.edit.pom.Dependency) Exclusion(org.eclipse.m2e.model.edit.pom.Exclusion) URI(org.eclipse.emf.common.util.URI) HashMap(java.util.HashMap) ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) IDocument(org.eclipse.jface.text.IDocument) IProject(org.eclipse.core.resources.IProject) VERSION(org.eclipse.m2e.core.ui.internal.editing.PomEdits.VERSION) GROUP_ID(org.eclipse.m2e.core.ui.internal.editing.PomEdits.GROUP_ID) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) PomEdits.findChild(org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChild) IFile(org.eclipse.core.resources.IFile) PomResourceFactoryImpl(org.eclipse.m2e.model.edit.pom.util.PomResourceFactoryImpl) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) DEPENDENCIES(org.eclipse.m2e.core.ui.internal.editing.PomEdits.DEPENDENCIES) Element(org.w3c.dom.Element) StructuredModelManager(org.eclipse.wst.sse.core.StructuredModelManager) ParentHierarchyEntry(org.eclipse.m2e.core.ui.internal.util.ParentHierarchyEntry) MavenPlugin(org.eclipse.m2e.core.MavenPlugin) Assert.assertEquals(org.junit.Assert.assertEquals) OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) Element(org.w3c.dom.Element)

Aggregations

HashMap (java.util.HashMap)1 List (java.util.List)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 URI (org.eclipse.emf.common.util.URI)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IDocument (org.eclipse.jface.text.IDocument)1 Change (org.eclipse.ltk.core.refactoring.Change)1 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)1 DocumentChange (org.eclipse.ltk.core.refactoring.DocumentChange)1 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)1 RefactoringStatusEntry (org.eclipse.ltk.core.refactoring.RefactoringStatusEntry)1 TextFileChange (org.eclipse.ltk.core.refactoring.TextFileChange)1 MavenPlugin (org.eclipse.m2e.core.MavenPlugin)1 ArtifactKey (org.eclipse.m2e.core.embedder.ArtifactKey)1 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)1 ResolverConfiguration (org.eclipse.m2e.core.project.ResolverConfiguration)1