Package org.osgi.framework

Examples of org.osgi.framework.Bundle


          n = startLevel.getBundleStartLevel(b[i]);
        } catch (Exception ignored) {
        }
        if (p > n) {
          x = i - 1;
          Bundle t = b[x];
          b[x] = b[i];
          b[i] = t;
        } else {
          p = n;
        }
View Full Code Here


  public static int getId(Event e) {
    return e.hashCode();
  }

  public static Bundle getBundle(Event e) {
    Bundle b = (Bundle)e.getProperty("bundle");
    return b;
  }
View Full Code Here

      final Bundle[] bl      = Activator.getBundles();

      Bundle[] selbl = Activator.desktop.getSelectedBundles();
      if(selbl != null && selbl.length > 0) {
        int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
        Bundle b = selbl[0];
        JMenuItem item = makeBundleItem(b, "#" + b.getBundleId() + " " + Util.getBundleName(b));
        menu.add(item);
        menu.add(new JPopupMenu.Separator());
      }

      {
        JMenuItem item = new JMenuItem("New window");

        item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
              addWindow();
            }
          });

        menu.add(item);
        menu.add(new JPopupMenu.Separator());
      }

      menu.add(new JMenuItem(Activator.desktop.actionStopBundles));
      menu.add(new JMenuItem(Activator.desktop.actionStartBundles));
      menu.add(new JMenuItem(Activator.desktop.actionUpdateBundles));
      menu.add(new JMenuItem(Activator.desktop.actionUninstallBundles));
      menu.add(new JMenuItem(Activator.desktop.actionRefreshBundles));

      menu.add(new JPopupMenu.Separator());

      autorefreshCB = new JCheckBoxMenuItem("Automatic view refresh", true);
      autorefreshCB.setModel(autorefreshModel);

      JMenuItem refreshItem = new JMenuItem("Refresh view");
      refreshItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            if(Activator.desktop != null &&
               Activator.desktop.pm != null) {
              Activator.desktop.pm.refresh();
              for(Iterator it = views.iterator(); it.hasNext(); ) {
                JSoftGraphBundle view = (JSoftGraphBundle)it.next();
                view.startFade();
              }
            }
          }
        });

      menu.add(autorefreshCB);
      menu.add(refreshItem);

      menu.add(new JPopupMenu.Separator());


      for(int i = 0; bl != null && i < bl.length; i++) {
        bundles.put(new Long(bl[i].getBundleId()), bl[i]);
      }


      Map buckets = Activator.desktop.makeBundleBuckets();

      for(Iterator it = buckets.keySet().iterator(); it.hasNext(); ) {
        Object key = it.next();
        Object val = buckets.get(key);
        if(val instanceof Collection) {
          Collection bucket = (Collection)val;
          JMenu subMenu = new JMenu(key.toString());
          for(Iterator it2 = bucket.iterator(); it2.hasNext(); ) {
            Bundle bundle = (Bundle)it2.next();
            JMenuItem item = makeBundleItem(bundle, null);
            subMenu.add(item);
          }
          menu.add(subMenu);
        } else if(val instanceof Bundle) {
          Bundle bundle = (Bundle)val;
          JMenuItem item = makeBundleItem(bundle, null);
          menu.add(item);
        } else {
          throw new RuntimeException("Unknown object=" + val);
        }
View Full Code Here

    public JMainBundles() {
      this(null);
    }

    void addWindow() {
      Bundle newB;
      Bundle[] bl = Activator.desktop.getSelectedBundles();
      if(bl != null && bl.length > 0) {
        newB = bl[0];
      } else {
        newB = Activator.getTargetBC_getBundle(0);
View Full Code Here

    }

    public void removeBundle(Bundle b) {
      if(b.equals(bundle)) {
        if(bundleHistory.removeBundle(b)) {
          Bundle last = bundleHistory.getLastBundle();
          if(last != null) {
            setBundle(last);
          }
        }
      }
View Full Code Here

     * @param se
     *            the service event that has occured.
     */
    public void serviceChanged(ServiceEvent se) {
        ServiceReference sr = se.getServiceReference();
        Bundle bundle = sr.getBundle();
        String msg = null;
        int level = LogService.LOG_INFO;
        switch (se.getType()) {
        case ServiceEvent.REGISTERED:
            msg = "ServiceEvent REGISTERED";
View Full Code Here

  private void computeBidFilters() {
    final Bundle[] bundles = bc.getBundles();
    synchronized (bidFilters) {
      bidFilters.clear();
      for (int i = bundles.length - 1; 0 <= i; i--) {
        final Bundle bundle = bundles[i];
        computeBidFilter(bundle);
      }
    }
  }
View Full Code Here

     * </p>
     */
    void valueChanged(long bid) {
      try {
        if(bid >= 0) {
          Bundle b = bc.getBundle(bid);
          if(b != null) {
            OBRNode obrNode = getOBRNode(b);
            if(obrNode != null) {
              if (obrNode != brSelected) {
                TreePath tp = new TreePath(obrNode.getPath());
View Full Code Here

        (String)br.getAttribute(BundleRecord.BUNDLE_UPDATELOCATION);

      // Check if bundle already is installed. If so,
      // ask user if it should be updated, installed again or
      // if the operation should be cancelled.
      Bundle b = getBundle(br);
      if(b != null) {

        boolean bIsRepoBundle = Util.isInRepo(b, updateURL);

        String[] options = bIsRepoBundle
          ? (new String[] { "Update", "Cancel",          })
          : (new String[] { "Update", "Install again", "Cancel"});

        String msg = bIsRepoBundle
          ?
          "The selected bundle is already installed\n" +
          "from the repository.\n" +
          "\n" +
          "It can be updated from the repository."
          :
          "The selected bundle is already installed.\n" +
          "\n" +
          "It can be updated from the repository, or\n" +
          "a new instance can be installed from the\n" +
          "repository";

        int n = JOptionPane
          .showOptionDialog(recordTree,
                            msg,
                            "Bundle is installed", // title
                            JOptionPane.YES_NO_CANCEL_OPTION,
                            JOptionPane.QUESTION_MESSAGE,
                            null, // icon
                            options,
                            options[0]);

        if(bIsRepoBundle) {
          if(n == 0) {        // update
            obrNode.appendLog("update.\n");
          } else if(n == 1) { // Cancel
            return;
          }
        } else {
          if(n == 0) { // Update
            InputStream in = null;
            try {
              URL url = new URL(updateURL);
              in = new BufferedInputStream(url.openStream());
              b.update(in);
              obrNode.appendLog("Updated from " + url + "\n");
            } catch (Exception e) {
              obrNode.appendLog("Update failed: " + e + "\n");
            } finally {
              try { in.close(); } catch (Exception ignored) { }
View Full Code Here

     * Set the selected bundle by settingt the HTML detail string.
     */
    void setSelected(TreeNode node) {
      if(node != null && (node instanceof OBRNode)) {
        brSelected = (OBRNode)node;
        Bundle b = getBundle(brSelected.getBundleRecord());
        if(b != null) {
          gotoBid(b.getBundleId());
        } else {
          getBundleSelectionModel().clearSelection();
        }
      } else {
        brSelected = null;
View Full Code Here

TOP

Related Classes of org.osgi.framework.Bundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.