⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 desktop.java

📁 OSGI这是一个中间件,与UPNP齐名,是用于移植到嵌入式平台之上
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    boolean bEnabled = bl.length > 0;    itemStartBundles.setEnabled(bEnabled);    itemStopBundles.setEnabled(bEnabled);    itemUninstallBundles.setEnabled(bEnabled);    itemUpdateBundles.setEnabled(bEnabled);    toolStartBundles.setEnabled(bEnabled);    toolStopBundles.setEnabled(bEnabled);    toolUninstallBundles.setEnabled(bEnabled);    toolUpdateBundles.setEnabled(bEnabled);    toolBar.invalidate();    menuBar.invalidate();    StartLevel sls = (StartLevel)slTracker.getService();    if(bl.length == 1 && sls != null) {      if(levelMenuLabel != null) {        levelMenuLabel.setText("No bundle selected");        for(Iterator it = levelCheckBoxes.keySet().iterator(); it.hasNext(); ) {          Integer I = (Integer)it.next();          AbstractButton jrb = (AbstractButton)levelCheckBoxes.get(I);          jrb.setSelected(false);        }      }      try {        Integer I = new Integer(sls.getBundleStartLevel(bl[0]));        AbstractButton jrb = (AbstractButton)levelCheckBoxes.get(I);        jrb.setSelected(true);        levelMenuLabel.setText("Bundle #" + bl[0].getBundleId());      } catch (Exception e) {        if(levelMenuLabel != null) {          levelMenuLabel.setText("Not managed");        }      }    }  }  int divloc = 0;  JMenuBar makeMenuBar() {    return new JMenuBar() {        {          add(makeFileMenu());          add(makeEditMenu());          add(makeBundleMenu());          add(viewMenu = makeViewMenu(null));          add(makeHelpMenu());        }      };  }  JMenu makeFileMenu() {    return new JMenu(Strings.get("menu_file")) {        {          add(new JMenuItem(Strings.get("menu_openbundles"), openIcon) {              {                setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,                                                      ActionEvent.CTRL_MASK));                setMnemonic(KeyEvent.VK_O);                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      addBundle();                    }                  });              }});          add(new JMenuItem(Strings.get("menu_openbundleurl"), openURLIcon) {              {                setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U,                                                      ActionEvent.CTRL_MASK));                setMnemonic(KeyEvent.VK_U);                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      addBundleURL();                    }                  });              }});          add(new JMenuItem(Strings.get("menu_save"), saveIcon) {              {                setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,                                                      ActionEvent.CTRL_MASK));                setMnemonic(KeyEvent.VK_S);                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      save();                    }                  });              }});          add(menuRemote = new JMenuItem(Strings.get("menu_remotefw"), connectIcon) {              {                setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,                                                      ActionEvent.CTRL_MASK));                setMnemonic(KeyEvent.VK_F);                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      doConnect();                    }                  });              }            });          add(new JMenuItem("Quit framework...") {              {                setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,                                                      ActionEvent.CTRL_MASK));                setMnemonic(KeyEvent.VK_Q);                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      stopFramework();                    }                  });              }});        }      };  }  JMenuItem itemStopBundles;  JMenuItem itemStartBundles;  JMenuItem itemUpdateBundles;  JMenuItem itemUninstallBundles;  JMenu makeBundleMenu() {    return new JMenu(Strings.get("menu_bundles")) {        {          add(itemStopBundles = new JMenuItem(Strings.get("item_stopbundles"),                                              stopIcon) {              {                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      stopBundles(getSelectedBundles());                    }                  });              }            });          add(itemStartBundles = new JMenuItem(Strings.get("item_startbundles"),                                               startIcon) {              {                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      startBundles(getSelectedBundles());                    }                  });              }            });          add(itemUpdateBundles = new JMenuItem(Strings.get("item_updatebundles"),                                                updateIcon) {              {                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      updateBundles(getSelectedBundles());                    }                  });              }            });          add(itemUninstallBundles = new JMenuItem(Strings.get("item_uninstallbundles"),                                                   uninstallIcon) {              {                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      uninstallBundles(getSelectedBundles());                    }                  });              }            });          add(new JMenuItem(Strings.get("menu_refreshbundles")) {              {                setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,                                                      ActionEvent.CTRL_MASK));                setMnemonic(KeyEvent.VK_R);                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      refreshBundle(null);                    }                  });              }});          StartLevel sls = (StartLevel)slTracker.getService();          if(sls != null) {            add(makeStartLevelMenu());          }        }      };  }  // Integer -> AbstractButton  Map    levelCheckBoxes = new HashMap();  JLabel levelMenuLabel  = null;  JMenu makeStartLevelMenu() {    return new JMenu(Strings.get("menu_startlevel")) {        {          ButtonGroup group = new ButtonGroup();          add(levelMenuLabel = new JLabel(""));          add(new JSeparator());          for(int i = levelMin; i <= levelMax; i++) {            final AbstractButton jrb = new JRadioButtonMenuItem(Integer.toString(i));            group.add(jrb);            add(jrb);            jrb.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent ev) {                  StartLevel sls = (StartLevel)slTracker.getService();                  Bundle[] bl = getSelectedBundles();                  if(bl.length == 1 && null != sls) {                    int level = Integer.parseInt(jrb.getText());                    sls.setBundleStartLevel(bl[0], level);                  }                }              });            levelCheckBoxes.put(new Integer(i), jrb);          }        }      };  }  JMenu viewMenu = null;  JMenu makeViewMenu(JMenu oldMenu) {    JMenu menu;    if(oldMenu != null) {      oldMenu.removeAll();      menu = oldMenu;    } else {      menu = new JMenu(Strings.get("menu_view"));    }    final ButtonGroup group = new ButtonGroup();    menu.add(new JCheckBoxMenuItem(Strings.get("menu_view_console")) {        {          setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1,                                                ActionEvent.ALT_MASK));          addActionListener(new SplitAction(splitPane,                                            consoleSwing.getJComponent()));          setState(true);        }      });    menu.add(new JCheckBoxMenuItem(Strings.get("menu_view_bundles")) {        {          setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2,                                                ActionEvent.ALT_MASK));          addActionListener(new SplitAction(splitPaneHoriz,                                            bundlePanel));          setState(true);        }      });    menu.add(new JCheckBoxMenuItem(Strings.get("menu_view_info")) {        {          setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3,                                                ActionEvent.ALT_MASK));          addActionListener(new SplitAction(splitPaneHoriz,                                            detailPanel));          setState(true);        }      });    menu.add(new JCheckBoxMenuItem(Strings.get("menu_view_toolbar")) {        {          setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4,                                                ActionEvent.ALT_MASK));          addActionListener(new ActionListener() {              public void actionPerformed(ActionEvent ev) {                toolBar.setVisible(getState());              }            });          setState(true);        }      });    menu.add(new JCheckBoxMenuItem(Strings.get("menu_view_statusbar")) {        {          setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_5,                                                ActionEvent.ALT_MASK));          addActionListener(new ActionListener() {              public void actionPerformed(ActionEvent ev) {                statusBar.setVisible(getState());              }            });          setState(false);        }      });    statusBar.setVisible(false);    menu.add(new JSeparator());    int count = 0;    for(Iterator it = displayMap.keySet().iterator(); it.hasNext(); ) {      ServiceReference     sr   = (ServiceReference)it.next();      SwingBundleDisplayer disp = (SwingBundleDisplayer)displayMap.get(sr);      final String   name = (String)sr.getProperty(SwingBundleDisplayer.PROP_NAME);      final int c2 = count++;      menu.add(new JRadioButtonMenuItem(name) {          {            setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1 + c2,                                                  ActionEvent.CTRL_MASK));            setMnemonic(KeyEvent.VK_1 + c2);            addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent ev) {                  bundlePanel.showTab(name);                }              });            group.add(this);          }});    }    lfMenu = new LookAndFeelMenu(Strings.get("menu_lookandfeel"), lfManager);    lfMenu.addRoot(SwingUtilities.getRoot(frame));    menu.add(new JSeparator());    menu.add(lfMenu);    return menu;  }  JMenu makeHelpMenu() {    return new JMenu(Strings.get("menu_help")) {        {          add(new JMenuItem(Strings.get("str_about")) {              {                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      showVersion();                    }                  });              }            });          add(new JMenuItem(Strings.get("menu_tips")) {              {                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      showTips();                    }                  });              }            });          add(new JSeparator());          add(new JMenuItem(Strings.get("str_fwinfo")) {              {                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      showInfo();                    }                  });              }            });        }      };  }  JMenu makeEditMenu() {    return new JMenu(Strings.get("menu_edit")) {        {          add(new JMenuItem(Strings.get("item_selectall")) {              {                setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,                                                      ActionEvent.CTRL_MASK));                setMnemonic(KeyEvent.VK_A);                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      contentPane.invalidate();                    }                  });              }            });          add(new JMenuItem(Strings.get("item_unselectall")) {              {                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      bundleSelModel.clearSelection();                      contentPane.invalidate();                    }                  });              }            });          add(new JMenuItem(Strings.get("item_clear_console")) {              {                addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent ev) {                      consoleSwing.clearConsole();                    }                  });              }            });        }      };  }  /**   * Helper command class to show/hide splitpane components   */  class SplitAction implements ActionListener {    int        divloc = 0;    JSplitPane pane;    JComponent target;    SplitAction(JSplitPane pane, JComponent target) {      this.pane   = pane;      this.target = target;    }    public void actionPerformed(ActionEvent ev) {      boolean b = target.isVisible();      if(b) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -