Author: adietish
Date: 2012-05-16 03:44:36 -0400 (Wed, 16 May 2012)
New Revision: 41038
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/EmbedCartridgesOperation.java
Log:
[JBIDE-10852] cleanup
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/EmbedCartridgesOperation.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/EmbedCartridgesOperation.java 2012-05-16
07:38:57 UTC (rev 41037)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/EmbedCartridgesOperation.java 2012-05-16
07:44:36 UTC (rev 41038)
@@ -53,14 +53,10 @@
return Collections.emptyList();
}
- List<IEmbeddableCartridge> cartridgesToAdd = new
ArrayList<IEmbeddableCartridge>();
- List<IEmbeddableCartridge> cartridgesToRemove = new
ArrayList<IEmbeddableCartridge>();
- computeRemovals(selectedCartridges, application.getEmbeddedCartridges(),
cartridgesToRemove);
- computeAdditions(selectedCartridges, application.getEmbeddedCartridges(),
cartridgesToAdd);
-
- removeEmbeddedCartridges(cartridgesToRemove, application);
- final List<IEmbeddedCartridge> addedCartridges =
addEmbeddedCartridges(cartridgesToAdd, application);
- return addedCartridges;
+ removeEmbeddedCartridges(
+ getRemovedCartridges(selectedCartridges, application.getEmbeddedCartridges()),
application);
+ return addEmbeddedCartridges(
+ getAddedCartridges(selectedCartridges, application.getEmbeddedCartridges()),
application);
}
private void removeEmbeddedCartridges(List<IEmbeddableCartridge>
cartridgesToRemove, final IApplication application)
@@ -87,22 +83,26 @@
return application.addEmbeddableCartridges(cartridgesToAdd);
}
- private void computeAdditions(List<IEmbeddableCartridge> selectedCartridges,
- List<IEmbeddedCartridge> embeddedCartridges, List<IEmbeddableCartridge>
addedCartridges) {
- for (IEmbeddableCartridge cartridge : selectedCartridges){
- if (!embeddedCartridges.contains(cartridge)){
- addedCartridges.add(cartridge);
+ private List<IEmbeddableCartridge>
getAddedCartridges(List<IEmbeddableCartridge> selectedCartridges,
+ List<IEmbeddedCartridge> embeddedCartridges) {
+ List<IEmbeddableCartridge> cartridgesToAdd = new
ArrayList<IEmbeddableCartridge>();
+ for (IEmbeddableCartridge cartridge : selectedCartridges) {
+ if (!embeddedCartridges.contains(cartridge)) {
+ cartridgesToAdd.add(cartridge);
}
}
+ return cartridgesToAdd;
}
- private void computeRemovals(List<IEmbeddableCartridge> selectedCartridges,
- List<IEmbeddedCartridge> embeddedCartridges, List<IEmbeddableCartridge>
removedCartridges) {
- for (IEmbeddableCartridge cartridge : embeddedCartridges){
- if (!selectedCartridges.contains(cartridge)){
- removedCartridges.add(cartridge);
+ private List<IEmbeddableCartridge>
getRemovedCartridges(List<IEmbeddableCartridge> selectedCartridges,
+ List<IEmbeddedCartridge> embeddedCartridges) {
+ List<IEmbeddableCartridge> cartridgesToRemove = new
ArrayList<IEmbeddableCartridge>();
+ for (IEmbeddableCartridge cartridge : embeddedCartridges) {
+ if (!selectedCartridges.contains(cartridge)) {
+ cartridgesToRemove.add(cartridge);
}
}
+ return cartridgesToRemove;
}
private static class CartridgeAddRemovePriorityComparator implements
Comparator<IEmbeddableCartridge> {