Package org.gudy.azureus2.plugins.ui.model

Examples of org.gudy.azureus2.plugins.ui.model.BasicPluginViewModel


   
    int userMode = COConfigurationManager.getIntParameter("User Mode");
    int maxUsermode = 0;
    try
    {
      ConfigSection sect = sections.get(section);
      if (sect instanceof UISWTConfigSection)
      {
        maxUsermode = ((UISWTConfigSection) sect).maxUserMode();
      }
    } catch (Error e)
View Full Code Here


   
    for (int i=0;i<items.length;i++){
     
      TreeItem  item = items[i];
             
      ConfigSection section = (ConfigSection)item.getData("ConfigSectionSWT");
       
      if ( section != null && section.getClass() == config_section_class ){
         
        tree.setSelection( new TreeItem[]{ item });
       
        showSection( item );
       
View Full Code Here

 
  public BasicPluginViewModel
  createBasicPluginViewModel(
    String      name )
  {
    final BasicPluginViewModel  model = new BasicPluginViewModelImpl( this, name );
       
    fireEvent( pi, UIManagerEvent.ET_PLUGIN_VIEW_MODEL_CREATED, model );
   
    return( model );
  }
View Full Code Here

  
  public BasicPluginViewModel createLoggingViewModel(
      LoggerChannel channel, boolean use_plugin_name
  ) {
    String log_view_name = (use_plugin_name) ? pi.getPluginName() : channel.getName();
    BasicPluginViewModel model = createBasicPluginViewModel(log_view_name);
    model.getActivity().setVisible(false);
    model.getProgress().setVisible(false);
    model.getStatus().setVisible(false);
    model.attachLoggerChannel(channel);
    return model;
  }
View Full Code Here

    log = plugin_interface.getLogger().getTimeStampedChannel(PLUGIN_NAME);
   
    UIManager  ui_manager = plugin_interface.getUIManager();

    final BasicPluginViewModel model =
      ui_manager.createBasicPluginViewModel( PLUGIN_RESOURCE_ID );

    model.setConfigSectionID(PLUGIN_CONFIGSECTION_ID);
   
    BasicPluginConfigModel  config = ui_manager.createBasicPluginConfigModel(ConfigSection.SECTION_PLUGINS, PLUGIN_CONFIGSECTION_ID);
     
    config.addLabelParameter2( "dht.info" );
   
    final BooleanParameter  enabled_param = config.addBooleanParameter2( "dht.enabled", "dht.enabled", true );
   
    plugin_interface.getPluginconfig().addListener(
        new PluginConfigListener()
        {
          public void
          configSaved()
          {
            int  new_dht_data_port = UDPNetworkManager.getSingleton().getUDPNonDataListeningPortNumber();
           
            if ( new_dht_data_port != dht_data_port ){
             
              changePort( new_dht_data_port );
            }
          }
        });
   
    LabelParameter  reseed_label = config.addLabelParameter2( "dht.reseed.label" );
   
    final StringParameter  reseed_ip  = config.addStringParameter2( "dht.reseed.ip", "dht.reseed.ip", "" );
    final IntParameter    reseed_port  = config.addIntParameter2( "dht.reseed.port", "dht.reseed.port", 0 );
   
    reseed = config.addActionParameter2( "dht.reseed.info", "dht.reseed");

    reseed.setEnabled( false );
   
    config.createGroup( "dht.reseed.group",
        new Parameter[]{ reseed_label, reseed_ip, reseed_port, reseed });
   
    final BooleanParameter ipfilter_logging_param = config.addBooleanParameter2( "dht.ipfilter.log", "dht.ipfilter.log", true );
    ipfilter_logging[0] = ipfilter_logging_param.getValue();
    ipfilter_logging_param.addListener(new ParameterListener() {
      public void parameterChanged(Parameter p) {
        ipfilter_logging[0] = ipfilter_logging_param.getValue();
      }
    });

    warn_user = config.addBooleanParameter2( "dht.warn.user", "dht.warn.user", true );

    final BooleanParameter  advanced = config.addBooleanParameter2( "dht.advanced", "dht.advanced", false );

    LabelParameter  advanced_label = config.addLabelParameter2( "dht.advanced.label" );

    final StringParameter  override_ip  = config.addStringParameter2( "dht.override.ip", "dht.override.ip", "" );

    config.createGroup( "dht.advanced.group",
        new Parameter[]{ advanced_label, override_ip });

    advanced.addEnabledOnSelection( advanced_label );
    advanced.addEnabledOnSelection( override_ip );
   
    final StringParameter  command = config.addStringParameter2( "dht.execute.command", "dht.execute.command", "print" );
   
    ActionParameter  execute = config.addActionParameter2( "dht.execute.info", "dht.execute");
   
    final BooleanParameter  logging = config.addBooleanParameter2( "dht.logging", "dht.logging", false );
   
    config.createGroup( "dht.diagnostics.group",
        new Parameter[]{ command, execute, logging });

    logging.addListener(
      new ParameterListener()
      {
        public void
        parameterChanged(
          Parameter  param )
        {
          if ( dhts != null ){
           
            for (int i=0;i<dhts.length;i++){
             
              dhts[i].setLogging( logging.getValue());
            }
          }
        }
      });
   
    final DHTPluginOperationListener log_polistener =
      new DHTPluginOperationListener()
      {
        public void
        diversified()
        {
        }
       
        public void
        starts(
          byte[]         key)
        {
        }
       
        public void
        valueRead(
          DHTPluginContact  originator,
          DHTPluginValue    value )
        {
          log.log( "valueRead: " + new String(value.getValue()) + " from " + originator.getName());
         
          if ( ( value.getFlags() & DHTPlugin.FLAG_STATS ) != 0 ){
           
            DHTPluginKeyStats stats = decodeStats( value );
           
            log.log( "    stats: size=" + stats.getSize());
          }
        }
       
        public void
        valueWritten(
          DHTPluginContact  target,
          DHTPluginValue    value )
        {
          log.log( "valueWritten:" + new String( value.getValue()) + " to " + target.getName());
        }
       
        public void
        complete(
          byte[]  key,
          boolean  timeout_occurred )
        {
          log.log( "complete: timeout = " + timeout_occurred );
        }
      };
     
    execute.addListener(
      new ParameterListener()
      {
        public void
        parameterChanged(
          Parameter  param )
        {
          AEThread2 t =
            new AEThread2( "DHT:commandrunner", true )
            {
              public void
              run()
              {
                if ( dhts == null ){
                 
                  return;
                }
               
                for (int i=0;i<dhts.length;i++){

                  DHT  dht = dhts[i].getDHT();
                 
                  DHTTransportUDP  transport = (DHTTransportUDP)dht.getTransport();
                 
                  String  c = command.getValue().trim();
                 
                  String  lc = c.toLowerCase();
                 
                  if ( lc.equals("print")){
                   
                    dht.print( true );
                   
                    dhts[i].logStats();
                   
                  }else if ( lc.equals( "pingall" )){
                   
                    if ( i == 1 ){
                     
                      dht.getControl().pingAll();
                    }
                   
                  }else if ( lc.equals( "versions" )){
                   
                    List<DHTRouterContact> contacts = dht.getRouter().getAllContacts();
                   
                    Map<Byte,Integer>  counts = new TreeMap<Byte, Integer>();
                   
                    for ( DHTRouterContact r: contacts ){
                     
                      DHTControlContact contact = (DHTControlContact)r.getAttachment();
                     
                      byte v = contact.getTransportContact().getProtocolVersion();
                     
                      Integer count = counts.get( v );
                     
                      if ( count == null ){
                       
                        counts.put( v, 1 );
                       
                      }else{
                       
                        counts.put( v, count+1 );
                      }
                    }
                   
                    log.log( "Net " + dht.getTransport().getNetwork());
                   
                    int  total = contacts.size();
                   
                    if ( total == 0 ){
                     
                      log.log( "   no contacts" );
                     
                    }else{
                     
                      String ver = "";
                     
                      for ( Map.Entry<Byte, Integer> entry: counts.entrySet()){
                     
                        ver += (ver.length()==0?"":", " ) + entry.getKey() + "=" + 100*entry.getValue()/total + "%";
                      }
                     
                      log.log( "    contacts=" + total + ": " + ver );
                    }
                  }else if ( lc.equals( "testca" )){
                               
                    ((DHTTransportUDPImpl)transport).testExternalAddressChange();
                   
                  }else if ( lc.equals( "testnd" )){
                   
                    ((DHTTransportUDPImpl)transport).testNetworkAlive( false );
                   
                  }else if ( lc.equals( "testna" )){
                   
                    ((DHTTransportUDPImpl)transport).testNetworkAlive( true );
       
                  }else{
                   
                    int pos = c.indexOf( ' ' );
                   
                    if ( pos != -1 ){
                     
                      String  lhs = lc.substring(0,pos);
                      String  rhs = c.substring(pos+1);
                     
                      if ( lhs.equals( "set" )){
                       
                        pos  = rhs.indexOf( '=' );
                       
                        if ( pos != -1 ){
                         
                          DHTPlugin.this.put(
                              rhs.substring(0,pos).getBytes(),
                              "DHT Plugin: set",
                              rhs.substring(pos+1).getBytes(),
                              (byte)0,
                              log_polistener );
                        }
                      }else if ( lhs.equals( "get" )){
                       
                        DHTPlugin.this.get(
                          rhs.getBytes(), "DHT Plugin: get", (byte)0, 1, 10000, true, false, log_polistener );
 
                      }else if ( lhs.equals( "query" )){
                       
                        DHTPlugin.this.get(
                          rhs.getBytes(), "DHT Plugin: get", DHTPlugin.FLAG_STATS, 1, 10000, true, false, log_polistener );

                      }else if ( lhs.equals( "punch" )){

                        Map  originator_data = new HashMap();
                       
                        originator_data.put( "hello", "mum" );

                        DHTNATPuncher puncher = dht.getNATPuncher();
                       
                        if ( puncher != null ){
                       
                          puncher.punch( "Test", transport.getLocalContact(), null, originator_data );
                        }
                      }else if ( lhs.equals( "stats" )){
                       
                        try{
                          pos = rhs.lastIndexOf( ":" );
                         
                          DHTTransportContact  contact;
                         
                          if ( pos == -1 ){
                         
                            contact = transport.getLocalContact();
                           
                          }else{
                           
                            String  host = rhs.substring(0,pos);
                            int    port = Integer.parseInt( rhs.substring(pos+1));
                           
                            contact =
                                transport.importContact(
                                    new InetSocketAddress( host, port ),
                                    transport.getProtocolVersion());
                          }
                         
                          log.log( "Stats request to " + contact.getName());
                         
                          DHTTransportFullStats stats = contact.getStats();
                           
                          log.log( "Stats:" + (stats==null?"<null>":stats.getString()));
                           
                          DHTControlActivity[] activities = dht.getControl().getActivities();
                           
                          for (int j=0;j<activities.length;j++){
                             
                            log.log( "    act:" + activities[j].getString());
                          }
                     
                        }catch( Throwable e ){
                         
                          Debug.printStackTrace(e);
                        }
                      }
                    }
                  }
                }
              }
            };
                     
          t.start();
        }
      });
   
    reseed.addListener(
        new ParameterListener()
        {
          public void
          parameterChanged(
            Parameter  param )
          {
            reseed.setEnabled( false );           

            AEThread2 t =
              new AEThread2( "DHT:reseeder", true )
              {
                public void
                run()
                {
                  try{
                    String  ip   = reseed_ip.getValue().trim();

                    if ( dhts == null ){
                     
                      return;
                    }
                 
                    int    port = reseed_port.getValue();
                 
                    for (int i=0;i<dhts.length;i++){
                     
                      DHTPluginImpl  dht = dhts[i];
                   
                      if ( ip.length() == 0 || port == 0 ){
                       
                        dht.checkForReSeed( true );
                       
                      }else{
                       
                        if ( dht.importSeed( ip, port ) != null ){
                         
                          dht.integrateDHT( false, null );
                        }
                      }
                    }
                   
                  }finally{
                   
                    reseed.setEnabled( true );
                  }
                }
              };
                         
            t.start();
          }
        });
   
    model.getActivity().setVisible( false );
    model.getProgress().setVisible( false );
   
    log.addListener(
        new LoggerChannelListener()
        {
          public void
          messageLogged(
            int    type,
            String  message )
          {
            model.getLogArea().appendText( message+"\n");
          }
         
          public void
          messageLogged(
            String    str,
            Throwable  error )
          {
            model.getLogArea().appendText( error.toString()+"\n");
          }
        });

    dht_log =
      new DHTLogger()
      {
        public void
        log(
          String  str )
        {
          log.log( str );
        }
     
        public void
        log(
          Throwable e )
        {
          log.log( e );
        }
       
        public void
        log(
          int    log_type,
          String  str )
        {
          if ( isEnabled( log_type )){
           
            log.log( str );
          }
        }
     
        public boolean
        isEnabled(
          int  log_type )
        {
          if ( log_type == DHTLogger.LT_IP_FILTER ){
           
            return ipfilter_logging[0];
          }
         
          return( true );
        }
         
        public PluginInterface
        getPluginInterface()
        {
          return( log.getLogger().getPluginInterface());
        }
      };
   
   
    if (!enabled_param.getValue()){
     
      model.getStatus().setText( "Disabled" );

      status  = STATUS_DISABLED;
     
      init_sem.releaseForever();
     
      return;
    }
   
    setPluginInfo();
   
    plugin_interface.addListener(
      new PluginListener()
      {
        public void
        initializationComplete()
        {
          PluginInterface pi_upnp = plugin_interface.getPluginManager().getPluginInterfaceByClass( UPnPPlugin.class );
         
          if ( pi_upnp == null ){

            log.log( "UPnP plugin not found, can't map port" );
           
          }else{
           
            upnp_mapping = ((UPnPPlugin)pi_upnp.getPlugin()).addMapping(
                    plugin_interface.getPluginName(),
                    false,
                    dht_data_port,
                    true );
          }

          String  ip = null;
         
          if ( advanced.getValue()){
           
            ip = override_ip.getValue().trim();
           
            if ( ip.length() == 0 ){
             
              ip = null;
            }
          }
         
          initComplete( model.getStatus(), logging.getValue(), ip );
        }
       
        public void
        closedownInitiated()
        {
View Full Code Here

   
    dm_stats = plugin_interface.getDownloadManager().getStats();
   
    log  = plugin_interface.getLogger().getTimeStampedChannel( "External Seeds" );
   
    final BasicPluginViewModel  view_model =
      plugin_interface.getUIManager().createBasicPluginViewModel( "Plugin.extseed.name" );

   
    view_model.getActivity().setVisible( false );
    view_model.getProgress().setVisible( false );
   
    log.addListener(
        new LoggerChannelListener()
        {
          public void
          messageLogged(
            int    type,
            String  content )
          {
            view_model.getLogArea().appendText( content + "\n" );
          }
         
          public void
          messageLogged(
            String    str,
            Throwable  error )
          {
            if ( str.length() > 0 ){
              view_model.getLogArea().appendText( str + "\n" );
            }
           
            StringWriter sw = new StringWriter();
           
            PrintWriter  pw = new PrintWriter( sw );
           
            error.printStackTrace( pw );
           
            pw.flush();
           
            view_model.getLogArea().appendText( sw.toString() + "\n" );
          }
        });   
   
    status_field = view_model.getStatus();
   
    setStatus( "Initialising" );
   
    download_mon  = plugin_interface.getUtilities().getMonitor();
   
View Full Code Here

        break;
      }
      case UIManagerEvent.ET_PLUGIN_VIEW_MODEL_CREATED:
      {
        if ( data instanceof BasicPluginViewModel ){
          BasicPluginViewModel model = (BasicPluginViewModel)data;
         
          // property bundles can't handle spaces in keys
          //
          // If this behaviour changes, change the openView(model)
          // method lower down.
          String sViewID = model.getName().replaceAll(" ", ".");
          BasicPluginViewImpl view = new BasicPluginViewImpl(model);
          addView(UISWTInstance.VIEW_MAIN, sViewID, view);
        }
       
        break;
      }
      case UIManagerEvent.ET_PLUGIN_VIEW_MODEL_DESTROYED:
      {
        if ( data instanceof BasicPluginViewModel ){
          BasicPluginViewModel model = (BasicPluginViewModel)data;
          // property bundles can't handle spaces in keys
          //
          // If this behaviour changes, change the openView(model)
          // method lower down.
          String sViewID = model.getName().replaceAll(" ", ".");
          removeViews(UISWTInstance.VIEW_MAIN, sViewID);
        }
       
        break;
      }
      case UIManagerEvent.ET_PLUGIN_CONFIG_MODEL_CREATED:
      {
        if ( data instanceof BasicPluginConfigModel ){
         
          BasicPluginConfigModel  model = (BasicPluginConfigModel)data;
         
          BasicPluginConfigImpl view = new BasicPluginConfigImpl( new WeakReference<BasicPluginConfigModel>( model ));
            
          config_view_map.put( model, view );
         
          model.getPluginInterface().addConfigSection( view );
        }
       
        break;
      }
      case UIManagerEvent.ET_PLUGIN_CONFIG_MODEL_DESTROYED:
      {
        if ( data instanceof BasicPluginConfigModel ){
         
          BasicPluginConfigModel  model = (BasicPluginConfigModel)data;
         
          BasicPluginConfigImpl view = (BasicPluginConfigImpl)config_view_map.get( model );
            
          if ( view != null ){
           
            model.getPluginInterface().removeConfigSection( view );
          }
        }
       
        break;
      }
View Full Code Here

   
    BasicPluginConfigModel  config = ui_manager.createBasicPluginConfigModel( ConfigSection.SECTION_PLUGINS, PLUGIN_CONFIGSECTION_ID );

    config.addLabelParameter2( "Plugin.trackerpeerauth.info" );   
   
    final BasicPluginViewModel  view_model =
      plugin_interface.getUIManager().createBasicPluginViewModel( "Plugin.trackerpeerauth.name" );

    view_model.setConfigSectionID(PLUGIN_CONFIGSECTION_ID);
    view_model.getActivity().setVisible( false );
    view_model.getProgress().setVisible( false );
   
    log.addListener(
        new LoggerChannelListener()
        {
          public void
          messageLogged(
            int    type,
            String  content )
          {
            view_model.getLogArea().appendText( content + "\n" );
          }
         
          public void
          messageLogged(
            String    str,
            Throwable  error )
          {
            if ( str.length() > 0 ){
              view_model.getLogArea().appendText( str + "\n" );
            }
           
            StringWriter sw = new StringWriter();
           
            PrintWriter  pw = new PrintWriter( sw );
           
            error.printStackTrace( pw );
           
            pw.flush();
           
            view_model.getLogArea().appendText( sw.toString() + "\n" );
          }
        });
   
    System.out.println( "**** tracker peer auth disabled ****" );
   
View Full Code Here

    enabled.addEnabledOnSelection( subnets );
    enabled.addEnabledOnSelection( lp2 );
    enabled.addEnabledOnSelection( autoadd );
    */
   
    final BasicPluginViewModel  view_model =
      plugin_interface.getUIManager().createBasicPluginViewModel( "Plugin.localtracker.name" );

    view_model.setConfigSectionID(PLUGIN_CONFIGSECTION_ID);
    view_model.getActivity().setVisible( false );
    view_model.getProgress().setVisible( false );
   
    log.addListener(
        new LoggerChannelListener()
        {
          public void
          messageLogged(
            int    type,
            String  content )
          {
            view_model.getLogArea().appendText( content + "\n" );
          }
         
          public void
          messageLogged(
            String    str,
            Throwable  error )
          {
            if ( str.length() > 0 ){
              view_model.getLogArea().appendText( str + "\n" );
            }
           
            StringWriter sw = new StringWriter();
           
            PrintWriter  pw = new PrintWriter( sw );
           
            error.printStackTrace( pw );
           
            pw.flush();
           
            view_model.getLogArea().appendText( sw.toString() + "\n" );
          }
        });
   
    plugin_start_time = plugin_interface.getUtilities().getCurrentSystemTime();

View Full Code Here

            && (!(currentContent[0] instanceof ISelectedVuzeFileContent))
            && currentContent[0].getDownloadManager() == null
            && (currentContent[0].getHash() != null || currentContent[0].getDownloadInfo() != null));
 
      if (tv != null) {
        TableColumn tc = tv.getTableColumn(RankItem.COLUMN_ID);
        if (tc != null && !tc.isVisible()) {
          mapNewToolbarStates.put("up", false);
          mapNewToolbarStates.put("down", false);
        }
      }
     
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.ui.model.BasicPluginViewModel

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.