Lines 105-115
Link Here
|
105 |
if (comp1 == null || comp2 == null) { //#157213 |
105 |
if (comp1 == null || comp2 == null) { //#157213 |
106 |
return err; |
106 |
return err; |
107 |
} |
107 |
} |
108 |
String exp1 = model.getXPathExpression(comp1); |
108 |
|
109 |
String exp2 = model.getXPathExpression(comp2); |
109 |
List<Dependency> deps = getSelectedDependencies(model, selectionStart, selectionEnd); |
110 |
boolean inDepManag = exp1.contains("dependencyManagement") || exp2.contains("dependencyManagement"); //NOI18N |
110 |
if (deps != null && !deps.isEmpty()) { //NOI18N |
111 |
boolean inPlugin = exp1.contains("plugin") || exp2.contains("plugin"); //NOI18N |
|
|
112 |
if (!inDepManag && !inPlugin && exp1.contains("dependencies") && exp2.contains("dependencies")) { //NOI18N |
113 |
try { |
111 |
try { |
114 |
Line line = NbEditorUtilities.getLine(model.getBaseDocument(), selectionEnd, false); |
112 |
Line line = NbEditorUtilities.getLine(model.getBaseDocument(), selectionEnd, false); |
115 |
err.add(ErrorDescriptionFactory.createErrorDescription( |
113 |
err.add(ErrorDescriptionFactory.createErrorDescription( |
Lines 170-191
Link Here
|
170 |
fl = FileUtil.toFile(obj); |
168 |
fl = FileUtil.toFile(obj); |
171 |
} |
169 |
} |
172 |
assert fl != null; |
170 |
assert fl != null; |
173 |
DocumentComponent comp1 = mdl.findComponent(start); |
171 |
List<Dependency> deps = getSelectedDependencies(mdl, start, end); |
174 |
|
172 |
if (deps == null || deps.isEmpty()) { |
175 |
POMComponent pc = findEnclosing(comp1); |
|
|
176 |
List<Dependency> dps = null; |
177 |
if (pc instanceof org.netbeans.modules.maven.model.pom.Project) { |
178 |
org.netbeans.modules.maven.model.pom.Project modprj = (org.netbeans.modules.maven.model.pom.Project)pc; |
179 |
dps = modprj.getDependencies(); |
180 |
} else if (pc instanceof Profile) { |
181 |
Profile prf = (Profile)pc; |
182 |
dps = prf.getDependencies(); |
183 |
} |
184 |
if (dps == null) { |
185 |
return; |
173 |
return; |
186 |
} |
174 |
} |
187 |
List<Dependency> deps = extractSelectedDeps(dps, start, end); |
|
|
188 |
|
189 |
MoveToDependencyManagementPanel pnl = new MoveToDependencyManagementPanel(fl, project); |
175 |
MoveToDependencyManagementPanel pnl = new MoveToDependencyManagementPanel(fl, project); |
190 |
DialogDescriptor dd = new DialogDescriptor(pnl, NbBundle.getMessage(MoveToDependencyManagementHint.class, "TIT_MoveDepMan")); |
176 |
DialogDescriptor dd = new DialogDescriptor(pnl, NbBundle.getMessage(MoveToDependencyManagementHint.class, "TIT_MoveDepMan")); |
191 |
Object ret = DialogDisplayer.getDefault().notify(dd); |
177 |
Object ret = DialogDisplayer.getDefault().notify(dd); |
Lines 255-260
Link Here
|
255 |
} |
241 |
} |
256 |
} |
242 |
} |
257 |
|
243 |
|
|
|
244 |
private static List<Dependency> getSelectedDependencies(POMModel mdl, int start, int end) { |
245 |
DocumentComponent comp1 = mdl.findComponent(start); |
246 |
|
247 |
POMComponent pc = findEnclosing(comp1); |
248 |
List<Dependency> dps = null; |
249 |
if (pc instanceof org.netbeans.modules.maven.model.pom.Project) { |
250 |
org.netbeans.modules.maven.model.pom.Project modprj = (org.netbeans.modules.maven.model.pom.Project) pc; |
251 |
dps = modprj.getDependencies(); |
252 |
} else if (pc instanceof Profile) { |
253 |
Profile prf = (Profile) pc; |
254 |
dps = prf.getDependencies(); |
255 |
} |
256 |
if (dps == null) { |
257 |
return null; |
258 |
} |
259 |
return extractSelectedDeps(dps, start, end); |
260 |
} |
261 |
|
258 |
private static void openParent(final int offset, final POMModel model) { |
262 |
private static void openParent(final int offset, final POMModel model) { |
259 |
SwingUtilities.invokeLater(new Runnable() { |
263 |
SwingUtilities.invokeLater(new Runnable() { |
260 |
@Override |
264 |
@Override |
Lines 274-280
Link Here
|
274 |
List<Dependency> toRet = new ArrayList<Dependency>(); |
278 |
List<Dependency> toRet = new ArrayList<Dependency>(); |
275 |
for (Dependency d : dps) { |
279 |
for (Dependency d : dps) { |
276 |
int pos = d.findPosition(); |
280 |
int pos = d.findPosition(); |
277 |
if (pos >= selectionStart && pos <= selectionEnd) { |
281 |
int endPos = d.findEndPosition(); |
|
|
282 |
if (pos >= selectionStart && endPos <= selectionEnd) { |
278 |
if (d.getVersion() != null) { |
283 |
if (d.getVersion() != null) { |
279 |
toRet.add(d); |
284 |
toRet.add(d); |
280 |
} |
285 |
} |