# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: C:\Users\mkleint\src\core-main2 # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: maven.hints/src/org/netbeans/modules/maven/hints/pom/MoveToDependencyManagementHint.java --- maven.hints/src/org/netbeans/modules/maven/hints/pom/MoveToDependencyManagementHint.java Base (BASE) +++ maven.hints/src/org/netbeans/modules/maven/hints/pom/MoveToDependencyManagementHint.java Locally Modified (Based On LOCAL) @@ -105,11 +105,9 @@ if (comp1 == null || comp2 == null) { //#157213 return err; } - String exp1 = model.getXPathExpression(comp1); - String exp2 = model.getXPathExpression(comp2); - boolean inDepManag = exp1.contains("dependencyManagement") || exp2.contains("dependencyManagement"); //NOI18N - boolean inPlugin = exp1.contains("plugin") || exp2.contains("plugin"); //NOI18N - if (!inDepManag && !inPlugin && exp1.contains("dependencies") && exp2.contains("dependencies")) { //NOI18N + + List deps = getSelectedDependencies(model, selectionStart, selectionEnd); + if (deps != null && !deps.isEmpty()) { //NOI18N try { Line line = NbEditorUtilities.getLine(model.getBaseDocument(), selectionEnd, false); err.add(ErrorDescriptionFactory.createErrorDescription( @@ -170,22 +168,10 @@ fl = FileUtil.toFile(obj); } assert fl != null; - DocumentComponent comp1 = mdl.findComponent(start); - - POMComponent pc = findEnclosing(comp1); - List dps = null; - if (pc instanceof org.netbeans.modules.maven.model.pom.Project) { - org.netbeans.modules.maven.model.pom.Project modprj = (org.netbeans.modules.maven.model.pom.Project)pc; - dps = modprj.getDependencies(); - } else if (pc instanceof Profile) { - Profile prf = (Profile)pc; - dps = prf.getDependencies(); - } - if (dps == null) { + List deps = getSelectedDependencies(mdl, start, end); + if (deps == null || deps.isEmpty()) { return; } - List deps = extractSelectedDeps(dps, start, end); - MoveToDependencyManagementPanel pnl = new MoveToDependencyManagementPanel(fl, project); DialogDescriptor dd = new DialogDescriptor(pnl, NbBundle.getMessage(MoveToDependencyManagementHint.class, "TIT_MoveDepMan")); Object ret = DialogDisplayer.getDefault().notify(dd); @@ -255,6 +241,24 @@ } } + private static List getSelectedDependencies(POMModel mdl, int start, int end) { + DocumentComponent comp1 = mdl.findComponent(start); + + POMComponent pc = findEnclosing(comp1); + List dps = null; + if (pc instanceof org.netbeans.modules.maven.model.pom.Project) { + org.netbeans.modules.maven.model.pom.Project modprj = (org.netbeans.modules.maven.model.pom.Project) pc; + dps = modprj.getDependencies(); + } else if (pc instanceof Profile) { + Profile prf = (Profile) pc; + dps = prf.getDependencies(); + } + if (dps == null) { + return null; + } + return extractSelectedDeps(dps, start, end); + } + private static void openParent(final int offset, final POMModel model) { SwingUtilities.invokeLater(new Runnable() { @Override @@ -274,7 +278,8 @@ List toRet = new ArrayList(); for (Dependency d : dps) { int pos = d.findPosition(); - if (pos >= selectionStart && pos <= selectionEnd) { + int endPos = d.findEndPosition(); + if (pos >= selectionStart && endPos <= selectionEnd) { if (d.getVersion() != null) { toRet.add(d); } Index: maven.model/src/org/netbeans/modules/maven/model/pom/POMComponent.java --- maven.model/src/org/netbeans/modules/maven/model/pom/POMComponent.java Base (BASE) +++ maven.model/src/org/netbeans/modules/maven/model/pom/POMComponent.java Locally Modified (Based On LOCAL) @@ -43,14 +43,14 @@ import java.util.List; import javax.xml.namespace.QName; -import org.netbeans.modules.xml.xam.dom.DocumentComponent; +import org.netbeans.modules.xml.xam.dom.DocumentComponent2; /** * Interface for all the components in the model. * * @author mkleint */ -public interface POMComponent extends DocumentComponent { +public interface POMComponent extends DocumentComponent2 { public static final String EXTENSIBILITY_ELEMENT_PROPERTY = "extensibilityElement"; // NOI18N