Examples of PluginInterface


Examples of org.gudy.azureus2.plugins.PluginInterface

          run()
          {
            for (int i = 0; i < items.length; i++) {
              int index = items[i];
              if (index >= 0 && index < pluginIFs.size()) {
                PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
                if (pluginIF.getPluginState().isOperational()) {
                  if (pluginIF.getPluginState().isUnloadable()) {
                    try {
                      pluginIF.getPluginState().unload();
                    } catch (PluginException e1) {
                      // TODO Auto-generated catch block
                      e1.printStackTrace();
                    }
                  }
                }
               
                Utils.execSWTThread(
                  new Runnable()
                  {
                    public void
                    run()
                    {
                      pluginIFs = rebuildPluginIFs();
                      table.setItemCount(pluginIFs.size());
                      Collections.sort(pluginIFs, comparator);
                      table.clearAll();
                    }
                  });
              }
            }
          }
        }.start();
      }
    });
    btnUnload.setEnabled( false );
   
    final Button btnLoad = new Button(cButtons, SWT.PUSH);
    btnUnload.setLayoutData(new GridData());
    Messages.setLanguageText(btnLoad, "ConfigView.pluginlist.loadSelected");
    btnLoad.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        final int[] items = table.getSelectionIndices();

        new AEThread2( "load" ){
          public void
          run()
          {
            for (int i = 0; i < items.length; i++) {
              int index = items[i];
              if (index >= 0 && index < pluginIFs.size()) {
               
                PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
                if (pluginIF.getPluginState().isOperational()) {continue;} // Already loaded.
   
                // Re-enable disabled plugins, as long as they haven't failed on
                // initialise.
                if (pluginIF.getPluginState().isDisabled()) {
                  if (pluginIF.getPluginState().hasFailed()) {continue;}
                  pluginIF.getPluginState().setDisabled(false);
                }
               
                try {
                  pluginIF.getPluginState().reload();
                } catch (PluginException e1) {
                  // TODO Auto-generated catch block
                  Debug.printStackTrace(e1);
                }
               
                Utils.execSWTThread(
                  new Runnable()
                  {
                    public void
                    run()
                    {
                      pluginIFs = rebuildPluginIFs();
                      table.setItemCount(pluginIFs.size());
                      Collections.sort(pluginIFs, comparator);
                      table.clearAll();
                    }
                  });
              }
            }
          }
        }.start();
      }
    });
    btnLoad.setEnabled( false );
   
   
    final Button btnScan = new Button(cButtons, SWT.PUSH);
    btnScan.setLayoutData(new GridData());
    Messages.setLanguageText(btnScan, "ConfigView.pluginlist.scan");
    btnScan.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        AzureusCoreFactory.getSingleton().getPluginManager().refreshPluginList(false);
        pluginIFs = rebuildPluginIFs();
        table.setItemCount(pluginIFs.size());
        Collections.sort(pluginIFs, comparator);
        table.clearAll();
      }
    });


    table.addListener(SWT.SetData, new Listener() {
      public void handleEvent(Event event) {
        TableItem item = (TableItem) event.item;
        int index = table.indexOf(item);
        PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);

        for (int i = 0; i < COLUMN_HEADERS.length; i++) {
          if (i == FilterComparator.FIELD_NAME)
            item.setImage(i, pluginIF.getPluginState().isOperational()
                ? imgGreenLed : imgRedLed);
         
          String sText = comparator.getFieldValue(i, pluginIF);
          if (sText == null)
            sText = "";
          item.setText(i, sText);
        }

        item.setGrayed(pluginIF.getPluginState().isMandatory());
        boolean bEnabled = pluginIF.getPluginState().isLoadedAtStartup();
        Utils.setCheckedInSetData(item, bEnabled);
        item.setData("PluginID", pluginIF.getPluginID());
        Utils.alternateRowBackground(item);
      }
    });

    table.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        TableItem item = (TableItem) e.item;
        int index = table.indexOf(item);
        PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);

        if (e.detail == SWT.CHECK){
           
          if (item.getGrayed()) {
            if (!item.getChecked())
              item.setChecked(true);
            return;
          }

          pluginIF.getPluginState().setDisabled(!item.getChecked());
          pluginIF.getPluginState().setLoadedAtStartup(item.getChecked());
        }
       
        btnUnload.setEnabled(pluginIF.getPluginState().isOperational() && pluginIF.getPluginState().isUnloadable());
        btnLoad.setEnabled(!pluginIF.getPluginState().isOperational() && !pluginIF.getPluginState().hasFailed());
      }
    });

    table.setItemCount(pluginIFs.size());
   
View Full Code Here

Examples of org.gudy.azureus2.plugins.PluginInterface

   * @since 3.0.5.3
   */
  private List rebuildPluginIFs() {
    List pluginIFs = Arrays.asList(AzureusCoreFactory.getSingleton().getPluginManager().getPlugins());
    for (Iterator iter = pluginIFs.iterator(); iter.hasNext();) {
      PluginInterface pi = (PluginInterface) iter.next();
      // COConfigurationManager will not add the same listener twice
      COConfigurationManager.addParameterListener("PluginInfo."
          + pi.getPluginID() + ".enabled", this);
    }
    return pluginIFs;
  }
View Full Code Here

Examples of org.gudy.azureus2.plugins.PluginInterface

      if (!sAppPluginDir.endsWith(sep))
        sAppPluginDir += sep;
    }

    public int compare(Object arg0, Object arg1) {
      PluginInterface if0 = (PluginInterface) arg0;
      PluginInterfaceImpl if1 = (PluginInterfaceImpl) arg1;
      int result = 0;

      switch (field) {
        case FIELD_LOAD: {
          boolean b0 = if0.getPluginState().isLoadedAtStartup();
          boolean b1 = if1.getPluginState().isLoadedAtStartup();
          result = (b0 == b1 ? 0 : (b0 ? -1 : 1));
         
          // Use the plugin ID name to sort by instead.
          if (result == 0) {
            result = if0.getPluginID().compareToIgnoreCase(
                if1.getPluginID());
          }
          break;
        }

        case FIELD_TYPE:
        case FIELD_DIRECTORY: {
          result = getFieldValue(field, if0).compareToIgnoreCase(
              getFieldValue(field, if1));
          break;
        }

        case FIELD_VERSION: { // XXX Not really right..
          String s0 = if0.getPluginVersion();
          String s1 = if1.getPluginVersion();
          if (s0 == null)
            s0 = "";
          if (s1 == null)
            s1 = "";
          result = s0.compareToIgnoreCase(s1);
          break;
        }
       
        case FIELD_UNLOADABLE: {
          boolean b0 = if0.getPluginState().isUnloadable();
          boolean b1 = if1.getPluginState().isUnloadable();
          result = (b0 == b1 ? 0 : (b0 ? -1 : 1));
          break;
        }
      }

      if (result == 0)
        result = if0.getPluginName().compareToIgnoreCase(if1.getPluginName());

      if (!ascending)
        result *= -1;

      return result;
View Full Code Here

Examples of org.gudy.azureus2.plugins.PluginInterface

 
  TableColumn tcVersion = new TableColumn(pluginList,SWT.LEFT);
  Messages.setLanguageText(tcVersion,"installPluginsWizard.list.version");
  tcVersion.setWidth(150);

    PluginInterface plugins[] = new PluginInterface[0];
    try {
      plugins = core.getPluginManager().getPluginInterfaces();
     
      Arrays.sort(
          plugins,
        new Comparator()
      {
            public int
        compare(
          Object o1,
          Object o2)
            {
              return(((PluginInterface)o1).getPluginName().compareTo(((PluginInterface)o2).getPluginName()));
            }
      });
    } catch(final Exception e) {
     
      Debug.printStackTrace(e);
    }
    
      // one "plugin" can have multiple interfaces. We need to group by their id
   
    Map  pid_map = new HashMap();
   
    for(int i = 0 ; i < plugins.length ; i++){
     
        PluginInterface plugin = plugins[i];
               
        String  pid   = plugin.getPluginID();
       
        ArrayList  pis = (ArrayList)pid_map.get( pid );
       
        if ( pis == null ){
         
          pis = new ArrayList();
         
          pid_map.put( pid, pis );
        }
       
        pis.add( plugin );
    }
   
    ArrayList[]  pid_list = new ArrayList[pid_map.size()];
   
    pid_map.values().toArray( pid_list );
 
    Arrays.sort(
        pid_list,
        new Comparator()
      {
            public int
        compare(
          Object o1,
          Object o2)
            {
              ArrayList  l1 = (ArrayList)o1;
              ArrayList  l2 = (ArrayList)o2;
              return(((PluginInterface)l1.get(0)).getPluginName().compareToIgnoreCase(((PluginInterface)l2.get(0)).getPluginName()));
            }
      });
   
    for(int i = 0 ; i < pid_list.length ; i++){
     
      ArrayList  pis = pid_list[i];
     
      boolean  skip = false;
     
      String  display_name = "";
       
      for (int j=0;j<pis.size();j++){
       
        PluginInterface  pi = (PluginInterface)pis.get(j);
       
        if ( pi.getPluginState().isMandatory() || pi.getPluginState().isBuiltIn()){
         
          skip = true;
         
          break;
        }
       
        display_name += (j==0?"":",") + pi.getPluginName();
      }
     
      if ( skip ){
       
        continue;
      }
     
      PluginInterface plugin = (PluginInterface)pis.get(0);
     
      List  selected_plugins = ((UnInstallPluginWizard)wizard).getPluginList();
     
      TableItem item = new TableItem(pluginList,SWT.NULL);
      item.setData(plugin);
      item.setText(0, display_name);
      item.setChecked( selected_plugins.contains( plugin ));
      String version = plugin.getPluginVersion();
      if(version == null) version = MessageText.getString("installPluginsWizard.list.nullversion");
      item.setText(1,version);
    }
 
  pluginList.addListener(SWT.Selection,new Listener() {
View Full Code Here

Examples of org.gudy.azureus2.plugins.PluginInterface

    });
  }
 
  private static void _runMLABTest(final boolean allowShaperProbeLogic,
      final Runnable runWhenClosed) {
    PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID(
        "mlab");
    try {
      HashMap<String, Object> map = new HashMap<String, Object>();
      map.put("allowShaperProbeLogic", Boolean.valueOf(allowShaperProbeLogic));
      pi.getIPC().invoke("runTest", new Object[] {
        map,
        new IPCInterface() {
          public Object invoke(String methodName, Object[] params)
              throws IPCException {
            // we could set SpeedTest Completed when methodName == "results"
View Full Code Here

Examples of org.gudy.azureus2.plugins.PluginInterface

   
    String plugin_str = plugin_id + (plugin_name==null?"":( " (" + plugin_name + ")" ));
   
    // AZPluginConnection is called via reflection
    // Let's just assume that the Core is avail..
    PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID( plugin_id );
   
    if ( pi == null ){
     
      throw( new IOException( "Plugin id " + plugin_str + " not installed" ));
    }
   
    IPCInterface ipc = pi.getIPC();
   
    try{
      if ( ipc.canInvoke( "handleURLProtocol", new Object[]{ this, arg })){
         
        input_stream = (InputStream)ipc.invoke( "handleURLProtocol", new Object[]{ this, arg });
View Full Code Here

Examples of org.gudy.azureus2.plugins.PluginInterface

    });
    itemStop.setEnabled(stop);

    // share with friends

    PluginInterface bpi = PluginInitializer.getDefaultInterface().getPluginManager().getPluginInterfaceByClass(
        BuddyPlugin.class);

    int cat_type = category.getType();

    if (bpi != null && cat_type != Category.TYPE_UNCATEGORIZED) {

      final BuddyPlugin buddy_plugin = (BuddyPlugin) bpi.getPlugin();

      if (buddy_plugin.isEnabled()) {

        final Menu share_menu = new Menu(menu.getShell(), SWT.DROP_DOWN);
        final MenuItem share_item = new MenuItem(menu, SWT.CASCADE);
View Full Code Here

Examples of org.gudy.azureus2.plugins.PluginInterface

            // see if we can delete a corresponding share as users frequently share
            // stuff by mistake and then don't understand how to delete the share
            // properly
         
          try{
            PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getDefaultPluginInterface();
           
            ShareManager sm = pi.getShareManager();
           
            Tracker  tracker = pi.getTracker();
           
            ShareResource[] shares = sm.getShares();
           
            TOTorrent torrent = dm.getTorrent();
           
View Full Code Here

Examples of org.gudy.azureus2.plugins.PluginInterface

  private UIManagerImpl ui_manager;
 
  public MenuManagerImpl(UIManagerImpl _ui_manager) { ui_manager = _ui_manager; }
 
    public MenuItem addMenuItem(String menuID, String resource_key) {
      PluginInterface pi = ui_manager.getPluginInterface();
      MenuItemImpl item = new MenuItemImpl(pi, menuID, resource_key);
      UIManagerImpl.fireEvent(pi, UIManagerEvent.ET_ADD_MENU_ITEM, item);
      return item;
    }
View Full Code Here

Examples of org.gudy.azureus2.plugins.PluginInterface

 
  public static String
  getUpdaterPluginVersion()
  {
    try {
      PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID(AZUPDATER_PLUGIN_ID, false );
      if (pi != null) {
        String version = pi.getPluginVersion();
        if (version != null) {
          return version;
        }
      }
    } catch (Throwable t) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.