changeset 70:ec8520fde2d9

Rename BundleInformation to Bundle New name follows the name used in xml more closely
author Omair Majid <omajid@redhat.com>
date Fri, 03 Jan 2014 16:42:12 -0500
parents 69f2305c7471
children 58eeda7dda95
files src/com/redhat/thermostat/plugin/eclipse/BundleInformationExtractor.java src/com/redhat/thermostat/plugin/eclipse/editor/CommandEditPage.java src/com/redhat/thermostat/plugin/eclipse/editor/ExtensionEditPage.java src/com/redhat/thermostat/plugin/eclipse/editor/NewBundleDialog.java src/com/redhat/thermostat/plugin/eclipse/model/Bundle.java src/com/redhat/thermostat/plugin/eclipse/model/BundleInformation.java src/com/redhat/thermostat/plugin/eclipse/model/Command.java src/com/redhat/thermostat/plugin/eclipse/model/Extension.java src/com/redhat/thermostat/plugin/eclipse/model/PluginModel.java test/com/redhat/thermostat/plugin/eclipse/model/CommandTest.java test/com/redhat/thermostat/plugin/eclipse/model/PluginModelTest.java
diffstat 11 files changed, 77 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/redhat/thermostat/plugin/eclipse/BundleInformationExtractor.java	Fri Jan 03 16:34:14 2014 -0500
+++ b/src/com/redhat/thermostat/plugin/eclipse/BundleInformationExtractor.java	Fri Jan 03 16:42:12 2014 -0500
@@ -6,18 +6,19 @@
 import java.util.jar.Attributes;
 import java.util.jar.JarInputStream;
 
-import com.redhat.thermostat.plugin.eclipse.model.BundleInformation;
+import com.redhat.thermostat.plugin.eclipse.model.Bundle;
 
 public class BundleInformationExtractor {
 
-    public BundleInformation extract(String path) throws FileNotFoundException, IOException {
+    public Bundle extract(String path) throws FileNotFoundException, IOException {
 
         try (JarInputStream in = new JarInputStream(new FileInputStream(path))) {
             Attributes attr = in.getManifest().getMainAttributes();
             String name = attr.getValue("Bundle-SymbolicName");
             String version = attr.getValue("Bundle-Version");
 
-            return new BundleInformation(name, version);
+            return new Bundle(name, version);
         }
     }
+
 }
--- a/src/com/redhat/thermostat/plugin/eclipse/editor/CommandEditPage.java	Fri Jan 03 16:34:14 2014 -0500
+++ b/src/com/redhat/thermostat/plugin/eclipse/editor/CommandEditPage.java	Fri Jan 03 16:42:12 2014 -0500
@@ -31,7 +31,7 @@
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
-import com.redhat.thermostat.plugin.eclipse.model.BundleInformation;
+import com.redhat.thermostat.plugin.eclipse.model.Bundle;
 import com.redhat.thermostat.plugin.eclipse.model.Command;
 import com.redhat.thermostat.plugin.eclipse.model.Environments;
 import com.redhat.thermostat.plugin.eclipse.model.PluginModel;
@@ -50,7 +50,7 @@
     private Button cli;
     private Button shell;
 
-    // uses a List<BundleInformation> as the backing model
+    // uses a List<Bundle> as the backing model
     private TableViewer bundlesTableViewer;
 
     private DataBindingContext bindingContext;
@@ -227,7 +227,7 @@
         remove.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-                BundleInformation selectedItem = (BundleInformation)
+                Bundle selectedItem = (Bundle)
                         ((IStructuredSelection)bundlesTableViewer.getSelection()).getFirstElement();
                 commandModel.removeBundle(selectedItem);
             }
--- a/src/com/redhat/thermostat/plugin/eclipse/editor/ExtensionEditPage.java	Fri Jan 03 16:34:14 2014 -0500
+++ b/src/com/redhat/thermostat/plugin/eclipse/editor/ExtensionEditPage.java	Fri Jan 03 16:42:12 2014 -0500
@@ -25,7 +25,7 @@
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
-import com.redhat.thermostat.plugin.eclipse.model.BundleInformation;
+import com.redhat.thermostat.plugin.eclipse.model.Bundle;
 import com.redhat.thermostat.plugin.eclipse.model.Extension;
 import com.redhat.thermostat.plugin.eclipse.model.PluginModel;
 
@@ -177,7 +177,7 @@
         remove.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-                BundleInformation selectedItem = (BundleInformation)
+                Bundle selectedItem = (Bundle)
                         ((IStructuredSelection)bundlesTableViewer.getSelection()).getFirstElement();
                 extensionModel.removeBundle(selectedItem);
             }
--- a/src/com/redhat/thermostat/plugin/eclipse/editor/NewBundleDialog.java	Fri Jan 03 16:34:14 2014 -0500
+++ b/src/com/redhat/thermostat/plugin/eclipse/editor/NewBundleDialog.java	Fri Jan 03 16:42:12 2014 -0500
@@ -17,7 +17,7 @@
 import org.eclipse.swt.widgets.Text;
 
 import com.redhat.thermostat.plugin.eclipse.BundleInformationExtractor;
-import com.redhat.thermostat.plugin.eclipse.model.BundleInformation;
+import com.redhat.thermostat.plugin.eclipse.model.Bundle;
 
 /**
  * Prompt the user to enter or select a bundle name/version.
@@ -26,7 +26,7 @@
  */
 public class NewBundleDialog extends TitleAreaDialog {
 
-    private BundleInformation bundleInfo;
+    private Bundle bundleInfo;
 
     private Button manualSelectionButton;
     private Text nameText;
@@ -104,7 +104,7 @@
             }
         });
         fromJarButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
-        fromJarButton.setText("Extract from Jar/BundleInformation on disk");
+        fromJarButton.setText("Extract from Jar/Bundle on disk");
 
         Label locationLabel = new Label(container, SWT.NONE);
         locationLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
@@ -142,7 +142,7 @@
 
     private void saveInput() {
         if (manualSelectionButton.getSelection()) {
-            bundleInfo = new BundleInformation(nameText.getText(), versionText.getText());
+            bundleInfo = new Bundle(nameText.getText(), versionText.getText());
         } else {
             try {
                 BundleInformationExtractor extractor = new BundleInformationExtractor();
@@ -154,7 +154,8 @@
         }
     }
 
-    public BundleInformation getBundle() {
+    public Bundle getBundle() {
         return bundleInfo;
     }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/redhat/thermostat/plugin/eclipse/model/Bundle.java	Fri Jan 03 16:42:12 2014 -0500
@@ -0,0 +1,40 @@
+package com.redhat.thermostat.plugin.eclipse.model;
+
+import java.util.Objects;
+
+public class Bundle {
+
+    private final String name;
+    private final String version;
+
+    public Bundle(String name, String version) {
+        this.name = name;
+        this.version = version;
+    }
+
+    public String getSymbolicName() {
+        return this.name;
+    }
+
+    public String getVersion() {
+        return this.version;
+    }
+
+    public String toString() {
+        return this.name + " (" + this.version + ")";
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof Bundle)) {
+            return false;
+        }
+        Bundle other = (Bundle) obj;
+        return Objects.equals(this.name, other.name) && Objects.equals(this.version, other.version);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(this.name, this.version);
+    }
+}
--- a/src/com/redhat/thermostat/plugin/eclipse/model/BundleInformation.java	Fri Jan 03 16:34:14 2014 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-package com.redhat.thermostat.plugin.eclipse.model;
-
-import java.util.Objects;
-
-public class BundleInformation {
-
-    private final String name;
-    private final String version;
-
-    public BundleInformation(String name, String version) {
-        this.name = name;
-        this.version = version;
-    }
-
-    public String getSymbolicName() {
-        return this.name;
-    }
-
-    public String getVersion() {
-        return this.version;
-    }
-
-    public String toString() {
-        return this.name + " (" + this.version + ")";
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (!(obj instanceof BundleInformation)) {
-            return false;
-        }
-        BundleInformation other = (BundleInformation) obj;
-        return Objects.equals(this.name, other.name) && Objects.equals(this.version, other.version);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(this.name, this.version);
-    }
-}
--- a/src/com/redhat/thermostat/plugin/eclipse/model/Command.java	Fri Jan 03 16:34:14 2014 -0500
+++ b/src/com/redhat/thermostat/plugin/eclipse/model/Command.java	Fri Jan 03 16:42:12 2014 -0500
@@ -11,7 +11,7 @@
     private List<String> arguments;
     private List<Option> options;
     private Environments environments;
-    private List<BundleInformation> bundles;
+    private List<Bundle> bundles;
 
     public Command() {
         // no-arg java bean constructor
@@ -19,7 +19,7 @@
 
     public Command(String name, String description, String usage,
             List<String> arguments, List<Option> options,
-            Environments environments, List<BundleInformation> bundles) {
+            Environments environments, List<Bundle> bundles) {
         this.name = name;
         this.description = description;
         this.usage = usage;
@@ -88,20 +88,20 @@
         firePropertyChange("environments", this.environments, this.environments = environments);
     }
 
-    public List<BundleInformation> getBundles() {
+    public List<Bundle> getBundles() {
         return bundles;
     }
 
-    public void setBundles(List<BundleInformation> bundles) {
+    public void setBundles(List<Bundle> bundles) {
         this.bundles = bundles;
     }
 
-    public void addBundle(BundleInformation bundle) {
+    public void addBundle(Bundle bundle) {
         this.bundles.add(bundle);
         firePropertyChange("bundles", null, this.bundles);
     }
 
-    public void removeBundle(BundleInformation bundle) {
+    public void removeBundle(Bundle bundle) {
         this.bundles.remove(bundle);
         firePropertyChange("bundles", null, this.bundles);
     }
--- a/src/com/redhat/thermostat/plugin/eclipse/model/Extension.java	Fri Jan 03 16:34:14 2014 -0500
+++ b/src/com/redhat/thermostat/plugin/eclipse/model/Extension.java	Fri Jan 03 16:42:12 2014 -0500
@@ -6,11 +6,11 @@
 public class Extension extends ModelObject {
 
     private String name;
-    private List<BundleInformation> bundles;
+    private List<Bundle> bundles;
 
     public Extension() {}
 
-    public Extension(String name, List<BundleInformation> bundles) {
+    public Extension(String name, List<Bundle> bundles) {
         this.name = name;
         this.bundles = bundles;
     }
@@ -24,20 +24,20 @@
     }
 
     /** Do not modify the returned list */
-    public List<BundleInformation> getBundles() {
+    public List<Bundle> getBundles() {
         return this.bundles;
     }
 
-    public void setBundles(List<BundleInformation> bundles) {
+    public void setBundles(List<Bundle> bundles) {
         firePropertyChange("bundles", this.bundles, this.bundles = bundles);
     }
 
-    public void addBundle(BundleInformation bundle) {
+    public void addBundle(Bundle bundle) {
         bundles.add(bundle);
         firePropertyChange("bundles", null, bundles);
     }
 
-    public void removeBundle(BundleInformation bundle) {
+    public void removeBundle(Bundle bundle) {
         bundles.remove(bundle);
         firePropertyChange("bundles", null, bundles);
     }
--- a/src/com/redhat/thermostat/plugin/eclipse/model/PluginModel.java	Fri Jan 03 16:34:14 2014 -0500
+++ b/src/com/redhat/thermostat/plugin/eclipse/model/PluginModel.java	Fri Jan 03 16:42:12 2014 -0500
@@ -161,7 +161,7 @@
             List<String> arguments = parseArguments(commandNode);
             List<Option> options = parseOptions(commandNode);
             Environments environments = parseEnvironments(commandNode);
-            List<BundleInformation> bundles = parseBundles(commandNode);
+            List<Bundle> bundles = parseBundles(commandNode);
 
             return new Command(name, description, usage, arguments, options, environments, bundles);
         } catch (XPathExpressionException e) {
@@ -370,7 +370,7 @@
         checkName(name);
 
         XPath xpath = xPathfactory.newXPath();
-        List<BundleInformation> bundles = Collections.emptyList();
+        List<Bundle> bundles = Collections.emptyList();
 
         try {
             String expressionString = "/plugin/extensions/extension[name/text() = '" + name + "']";
@@ -509,11 +509,11 @@
 
     }
 
-    private List<BundleInformation> parseBundles(Node commandNode) throws XPathExpressionException {
+    private List<Bundle> parseBundles(Node commandNode) throws XPathExpressionException {
         String expressionString = "bundles/bundle";
         XPathExpression expr = xPathfactory.newXPath().compile(expressionString);
         NodeList nodes = (NodeList) expr.evaluate(commandNode, XPathConstants.NODESET);
-        List<BundleInformation> bundles = new ArrayList<>();
+        List<Bundle> bundles = new ArrayList<>();
         for (int i = 0; i < nodes.getLength(); i++) {
             NodeList children = nodes.item(i).getChildNodes();
 
@@ -530,13 +530,13 @@
                 }
             }
 
-            bundles.add(new BundleInformation(symbolicName, version));
+            bundles.add(new Bundle(symbolicName, version));
         }
         return bundles;
     }
 
 
-    private void updateBundles(List<BundleInformation> bundles, Node commandNode, Node bundlesNode) {
+    private void updateBundles(List<Bundle> bundles, Node commandNode, Node bundlesNode) {
         if (bundlesNode == null) {
             bundlesNode = doc.createElement("bundles");
             commandNode.appendChild(bundlesNode);
@@ -550,7 +550,7 @@
         }
 
         // add new children
-        for (BundleInformation bundle : bundles) {
+        for (Bundle bundle : bundles) {
             Element bundleNode = doc.createElement("bundle");
 
             Element nameNode = doc.createElement("symbolic-name");
--- a/test/com/redhat/thermostat/plugin/eclipse/model/CommandTest.java	Fri Jan 03 16:34:14 2014 -0500
+++ b/test/com/redhat/thermostat/plugin/eclipse/model/CommandTest.java	Fri Jan 03 16:42:12 2014 -0500
@@ -29,7 +29,7 @@
                 Collections.<String> emptyList(),
                 Collections.<Option> emptyList(),
                 new Environments(),
-                Collections.<BundleInformation> emptyList());
+                Collections.<Bundle> emptyList());
 
         assertNotNull(command);
 
--- a/test/com/redhat/thermostat/plugin/eclipse/model/PluginModelTest.java	Fri Jan 03 16:34:14 2014 -0500
+++ b/test/com/redhat/thermostat/plugin/eclipse/model/PluginModelTest.java	Fri Jan 03 16:42:12 2014 -0500
@@ -55,10 +55,10 @@
         assertTrue(foo.getEnvironments().isCli());
         assertFalse(foo.getEnvironments().isShell());
 
-        List<BundleInformation> bundles = foo.getBundles();
+        List<Bundle> bundles = foo.getBundles();
         assertEquals(1, bundles.size());
 
-        BundleInformation bundle = bundles.get(0);
+        Bundle bundle = bundles.get(0);
         assertEquals("foo", bundle.getSymbolicName());
         assertEquals("1", bundle.getVersion());
     }