Package org.eclipse.swt.layout

Examples of org.eclipse.swt.layout.GridLayout


  }


  public Composite configSectionCreate(final Composite parent) {
    GridData gridData;
    GridLayout layout;
    Label label;

    Composite cSection = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL
        | GridData.HORIZONTAL_ALIGN_FILL);
    cSection.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    cSection.setLayout(layout);

    int userMode = COConfigurationManager.getIntParameter("User Mode");

    //  store the initial d/l speed so we can do something sensible later
    final int[] manual_max_download_speed = { COConfigurationManager
        .getIntParameter("Max Download Speed KBs") };

    //  max upload speed
    gridData = new GridData();
    label = new Label(cSection, SWT.NULL);
    label.setLayoutData(gridData);
    Messages.setLanguageText(label, "ConfigView.label.maxuploadspeed");

    gridData = new GridData();
    final IntParameter paramMaxUploadSpeed = new IntParameter(cSection,
        "Max Upload Speed KBs", 0, -1);
    paramMaxUploadSpeed.setLayoutData(gridData);

    //  max upload speed when seeding
    final Composite cMaxUploadSpeedOptionsArea = new Composite(cSection, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 3;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    cMaxUploadSpeedOptionsArea.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalIndent = 15;
    gridData.horizontalSpan = 2;
    cMaxUploadSpeedOptionsArea.setLayoutData(gridData);

    ImageLoader imageLoader = ImageLoader.getInstance();
    Image img = imageLoader.getImage("subitem");

    label = new Label(cMaxUploadSpeedOptionsArea, SWT.NULL);
    img.setBackground(label.getBackground());
    gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    label.setLayoutData(gridData);
    label.setImage(img);

    gridData = new GridData();
    final BooleanParameter enable_seeding_rate = new BooleanParameter(
        cMaxUploadSpeedOptionsArea, "enable.seedingonly.upload.rate",
        "ConfigView.label.maxuploadspeedseeding");
    enable_seeding_rate.setLayoutData(gridData);

    gridData = new GridData();
    final IntParameter paramMaxUploadSpeedSeeding = new IntParameter(
        cMaxUploadSpeedOptionsArea, "Max Upload Speed Seeding KBs", 0, -1);
    paramMaxUploadSpeedSeeding.setLayoutData(gridData);
    enable_seeding_rate
        .setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
            paramMaxUploadSpeedSeeding.getControl()));

    if (userMode < 2) {
      // wiki link

      Composite cWiki = new Composite(cSection, SWT.COLOR_GRAY);
      gridData = new GridData(GridData.VERTICAL_ALIGN_FILL
          | GridData.HORIZONTAL_ALIGN_FILL);
      gridData.horizontalSpan = 2;
      cWiki.setLayoutData(gridData);
      layout = new GridLayout();
      layout.numColumns = 4;
      layout.marginHeight = 0;
      cWiki.setLayout(layout);

      gridData = new GridData();
      gridData.horizontalIndent = 6;
      gridData.horizontalSpan = 2;
      label = new Label(cWiki, SWT.NULL);
      label.setLayoutData(gridData);
      label.setText(MessageText.getString("Utils.link.visit") + ":");

      gridData = new GridData();
      gridData.horizontalIndent = 10;
      gridData.horizontalSpan = 2;
      new LinkLabel(cWiki, gridData, "ConfigView.section.transfer.speeds.wiki",
          "http://wiki.vuze.com/w/Good_settings");
    }

    if ( userMode > 1 ){
   
      gridData = new GridData();
      label = new Label(cSection, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label, "ConfigView.label.maxuploadswhenbusymin" );

      gridData = new GridData();
      new IntParameter(cSection, "max.uploads.when.busy.inc.min.secs", 0, -1).setLayoutData(gridData);
    }
   
    // max download speed
    gridData = new GridData();
    label = new Label(cSection, SWT.NULL);
    label.setLayoutData(gridData);
    Messages.setLanguageText(label, "ConfigView.label.maxdownloadspeed");
   
    gridData = new GridData();
    final IntParameter paramMaxDownSpeed = new IntParameter(cSection,
        "Max Download Speed KBs", 0, -1);
    paramMaxDownSpeed.setLayoutData(gridData);
       
      // max upload/download limit dependencies
   
    Listener l = new Listener() {
 
      public void handleEvent(Event event) {
        boolean disableAuto = false;
        boolean disableAutoSeeding = false;
       
        if(enable_seeding_rate.isSelected())
        {
          disableAutoSeeding = event.widget == paramMaxUploadSpeedSeeding.getControl();
          disableAuto = event.widget == paramMaxDownSpeed.getControl() || event.widget == paramMaxUploadSpeed.getControl();
        } else
        {
          disableAuto = true;
          disableAutoSeeding = true;
        }
         
         
        if(disableAuto)
          COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY, false);
        if(disableAutoSeeding)
          COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_SEEDING_ENABLED_CONFIGKEY, false);
      }
    };
   
    paramMaxDownSpeed.getControl().addListener(SWT.Selection, l);
    paramMaxUploadSpeed.getControl().addListener(SWT.Selection, l);
    paramMaxUploadSpeedSeeding.getControl().addListener(SWT.Selection, l);
   
   
    paramMaxUploadSpeed.addChangeListener(new ParameterChangeAdapter() {
      ParameterChangeAdapter me = this;

      public void parameterChanged(Parameter p, boolean internal) {
        CoreWaiterSWT.waitForCoreRunning(new AzureusCoreRunningListener() {

          public void azureusCoreRunning(AzureusCore core) {
            if (paramMaxUploadSpeed.isDisposed()) {
              paramMaxUploadSpeed.removeChangeListener(me);
              return;
            }

            // we don't want to police these limits when auto-speed is running as
            // they screw things up bigtime

            if (TransferSpeedValidator.isAutoSpeedActive(core.getGlobalManager())) {

              return;
            }

            int up_val = paramMaxUploadSpeed.getValue();
            int down_val = paramMaxDownSpeed.getValue();

            if (up_val != 0
                && up_val < COConfigurationManager.CONFIG_DEFAULT_MIN_MAX_UPLOAD_SPEED) {

              if ((down_val == 0) || down_val > (up_val * 2)) {

                paramMaxDownSpeed.setValue(up_val * 2);
              }
            } else {

              if (down_val != manual_max_download_speed[0]) {

                paramMaxDownSpeed.setValue(manual_max_download_speed[0]);
              }
            }
          }

        });
      };
    });

    paramMaxDownSpeed.addChangeListener(new ParameterChangeAdapter() {
      ParameterChangeAdapter me = this;

      public void parameterChanged(Parameter p, boolean internal) {
        CoreWaiterSWT.waitForCoreRunning(new AzureusCoreRunningListener() {

          public void azureusCoreRunning(AzureusCore core) {
            if (paramMaxDownSpeed.isDisposed()) {
              paramMaxDownSpeed.removeChangeListener(me);
              return;
            }

            // we don't want to police these limits when auto-speed is running as
            // they screw things up bigtime

            if (TransferSpeedValidator.isAutoSpeedActive(core.getGlobalManager())) {

              return;
            }

            int up_val = paramMaxUploadSpeed.getValue();
            int down_val = paramMaxDownSpeed.getValue();

            manual_max_download_speed[0] = down_val;

            if (up_val < COConfigurationManager.CONFIG_DEFAULT_MIN_MAX_UPLOAD_SPEED) {

              if (up_val != 0 && up_val < (down_val * 2)) {

                paramMaxUploadSpeed.setValue((down_val + 1) / 2);

              } else if (down_val == 0) {

                paramMaxUploadSpeed.setValue(0);
              }
            }
          }
        });
      }
    });
   
    if (userMode > 0) {
     
        // bias upload to incomplete
     
      BooleanParameter bias_upload = new BooleanParameter(
          cSection,
          "Bias Upload Enable",
          "ConfigView.label.xfer.bias_up" );
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      bias_upload.setLayoutData(gridData);
     

      final Composite bias_slack_area = new Composite(cSection, SWT.NULL);
      layout = new GridLayout();
      layout.numColumns = 3;
      layout.marginWidth = 0;
      layout.marginHeight = 0;
      bias_slack_area.setLayout(layout);
      gridData = new GridData();
      gridData.horizontalIndent = 15;
      gridData.horizontalSpan = 2;
      bias_slack_area.setLayoutData(gridData);

      label = new Label(bias_slack_area, SWT.NULL);
      gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      label.setLayoutData(gridData);
      label.setImage(img);
     
      label = new Label(bias_slack_area, SWT.NULL);
      Messages.setLanguageText(label, "ConfigView.label.xfer.bias_slack");

      IntParameter bias_slack = new IntParameter(
          bias_slack_area, "Bias Upload Slack KBs", 1, -1);
     
     
      final Composite bias_unlimited_area = new Composite(cSection, SWT.NULL);
      layout = new GridLayout();
      layout.numColumns = 2;
      layout.marginWidth = 0;
      layout.marginHeight = 0;
      bias_unlimited_area.setLayout(layout);
      gridData = new GridData();
      gridData.horizontalIndent = 15;
      gridData.horizontalSpan = 2;
      bias_unlimited_area.setLayoutData(gridData);

      label = new Label(bias_unlimited_area, SWT.NULL);
      gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      label.setLayoutData(gridData);
      label.setImage(img);

     
      BooleanParameter bias_no_limit = new BooleanParameter(
          bias_unlimited_area,
          "Bias Upload Handle No Limit",
          "ConfigView.label.xfer.bias_no_limit" );
           
      bias_upload.setAdditionalActionPerformer(
          new ChangeSelectionActionPerformer(
          new Parameter[]{ bias_slack, bias_no_limit} ));
    }

    if (userMode > 0) {
     
        // AUTO GROUP
     
      Group auto_group = new Group(cSection, SWT.NULL);
     
      Messages.setLanguageText(auto_group, "group.auto");
     
      GridLayout auto_layout = new GridLayout();
     
      auto_layout.numColumns = 2;

      auto_group.setLayout(auto_layout);

      gridData = new GridData(GridData.FILL_HORIZONTAL);
      gridData.horizontalSpan = 2;
      auto_group.setLayoutData(gridData);

      BooleanParameter auto_adjust = new BooleanParameter(
          auto_group,
          "Auto Adjust Transfer Defaults",
          "ConfigView.label.autoadjust" );
     
      gridData = new GridData();
      gridData.horizontalSpan = 2;

      auto_adjust.setLayoutData( gridData );

      // max uploads
      gridData = new GridData();
      label = new Label(auto_group, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label, "ConfigView.label.maxuploads");

      gridData = new GridData();
      IntParameter paramMaxUploads = new IntParameter(auto_group, "Max Uploads",
          2, -1);
      paramMaxUploads.setLayoutData(gridData);

        // max uploads when seeding
     
      final Composite cMaxUploadsOptionsArea = new Composite(auto_group, SWT.NULL);
      layout = new GridLayout();
      layout.numColumns = 3;
      layout.marginWidth = 0;
      layout.marginHeight = 0;
      cMaxUploadsOptionsArea.setLayout(layout);
      gridData = new GridData();
      gridData.horizontalIndent = 15;
      gridData.horizontalSpan = 2;
      cMaxUploadsOptionsArea.setLayoutData(gridData);
      label = new Label(cMaxUploadsOptionsArea, SWT.NULL);
      img.setBackground(label.getBackground());
      gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      label.setLayoutData(gridData);
      label.setImage(img);
     
      gridData = new GridData();
      BooleanParameter enable_seeding_uploads = new BooleanParameter(
          cMaxUploadsOptionsArea, "enable.seedingonly.maxuploads",
          "ConfigView.label.maxuploadsseeding");
      enable_seeding_uploads.setLayoutData(gridData);

      gridData = new GridData();
      final IntParameter paramMaxUploadsSeeding = new IntParameter(
          cMaxUploadsOptionsArea, "Max Uploads Seeding", 2, -1);
      paramMaxUploadsSeeding.setLayoutData(gridData);

     
     
      ////

      gridData = new GridData();
      label = new Label(auto_group, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label, "ConfigView.label.max_peers_per_torrent");

      gridData = new GridData();
      IntParameter paramMaxClients = new IntParameter(auto_group,
          "Max.Peer.Connections.Per.Torrent");
      paramMaxClients.setLayoutData(gridData);

     
      /////
     
        // max peers when seeding
     
      final Composite cMaxPeersOptionsArea = new Composite(auto_group, SWT.NULL);
      layout = new GridLayout();
      layout.numColumns = 3;
      layout.marginWidth = 0;
      layout.marginHeight = 0;
      cMaxPeersOptionsArea.setLayout(layout);
      gridData = new GridData();
      gridData.horizontalIndent = 15;
      gridData.horizontalSpan = 2;
      cMaxPeersOptionsArea.setLayoutData(gridData);
      label = new Label(cMaxPeersOptionsArea, SWT.NULL);
      img.setBackground(label.getBackground());
      gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      label.setLayoutData(gridData);
      label.setImage(img);
     
      gridData = new GridData();
      BooleanParameter enable_max_peers_seeding = new BooleanParameter(
          cMaxPeersOptionsArea, "Max.Peer.Connections.Per.Torrent.When.Seeding.Enable",
          "ConfigView.label.maxuploadsseeding");
      enable_max_peers_seeding.setLayoutData(gridData);

      gridData = new GridData();
      final IntParameter paramMaxPeersSeeding = new IntParameter(
          cMaxPeersOptionsArea, "Max.Peer.Connections.Per.Torrent.When.Seeding", 0, -1);
      paramMaxPeersSeeding.setLayoutData(gridData)
     
      /////

      gridData = new GridData();
      label = new Label(auto_group, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label, "ConfigView.label.max_peers_total");

      gridData = new GridData();
      IntParameter paramMaxClientsTotal = new IntParameter(auto_group,
          "Max.Peer.Connections.Total");
      paramMaxClientsTotal.setLayoutData(gridData);
     
      gridData = new GridData();
      label = new Label(auto_group, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label, "ConfigView.label.maxseedspertorrent");

      gridData = new GridData();
      IntParameter max_seeds_per_torrent = new IntParameter(auto_group,"Max Seeds Per Torrent");
      max_seeds_per_torrent.setLayoutData(gridData);

      final Parameter[] parameters = {
          paramMaxUploads, enable_seeding_uploads, paramMaxUploadsSeeding,
          paramMaxClients, enable_max_peers_seeding, paramMaxPeersSeeding,
          paramMaxClientsTotal, max_seeds_per_torrent,
      };
     
        IAdditionalActionPerformer f_enabler =
            new GenericActionPerformer( new Control[0])
          {
              public void
              performAction()
              {
                boolean auto = COConfigurationManager.getBooleanParameter( "Auto Adjust Transfer Defaults" );
               
                for ( Parameter p: parameters ){
                 
                  Control[] c = p.getControls();
                 
                  for ( Control x: c ){
                   
                    x.setEnabled( !auto );
                  }
                }
                 
                if ( !auto ){
                 
                  paramMaxUploadsSeeding.getControl().setEnabled( COConfigurationManager.getBooleanParameter( "enable.seedingonly.maxuploads" ));
                 
                  paramMaxPeersSeeding.getControl().setEnabledCOConfigurationManager.getBooleanParameter( "Max.Peer.Connections.Per.Torrent.When.Seeding.Enable" ));
                }
              }
            };
     
        f_enabler.performAction();
       
      enable_seeding_uploads.setAdditionalActionPerformer( f_enabler );
      enable_max_peers_seeding.setAdditionalActionPerformer( f_enabler );
      auto_adjust.setAdditionalActionPerformer( f_enabler );
     
        // END AUTO GROUP
     
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter useReqLimiting = new BooleanParameter(cSection, "Use Request Limiting",
        "ConfigView.label.userequestlimiting");
      useReqLimiting.setLayoutData(gridData);

      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter useReqLimitingPrios = new BooleanParameter(cSection, "Use Request Limiting Priorities",
        "ConfigView.label.userequestlimitingpriorities");
      useReqLimitingPrios.setLayoutData(gridData);
      useReqLimiting
      .setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          useReqLimitingPrios.getControl()));
     
     

      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter allowSameIP = new BooleanParameter(cSection,
          "Allow Same IP Peers", "ConfigView.label.allowsameip");
      allowSameIP.setLayoutData(gridData);

      // lazy bit field
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter lazybf = new BooleanParameter(cSection,
          "Use Lazy Bitfield", "ConfigView.label.lazybitfield");
      lazybf.setLayoutData(gridData);

      // prioritise first/last pieces
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter firstPiece = new BooleanParameter(cSection,
          "Prioritize First Piece",
          "ConfigView.label.prioritizefirstpiece");
      firstPiece.setLayoutData(gridData);

      // Further prioritize High priority files according to % complete and size of file
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter mostCompletedFiles = new BooleanParameter(cSection,
          "Prioritize Most Completed Files",
          "ConfigView.label.prioritizemostcompletedfiles");
      mostCompletedFiles.setLayoutData(gridData);

      // ignore ports

      Composite cMiniArea = new Composite(cSection, SWT.NULL);
      layout = new GridLayout();
      layout.numColumns = 2;
      layout.marginHeight = 0;
      layout.marginWidth = 0;
      cMiniArea.setLayout(layout);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
View Full Code Here


public class TrackerChangerWindow {
  public TrackerChangerWindow(final Display display, final DownloadManager[] dms ) {
    final Shell shell = ShellFactory.createShell(display);
    shell.setText(MessageText.getString("TrackerChangerWindow.title"));
    Utils.setShellIcon(shell);
    GridLayout layout = new GridLayout();
    shell.setLayout(layout);

    Label label = new Label(shell, SWT.NONE);
    Messages.setLanguageText(label, "TrackerChangerWindow.newtracker");   
    GridData gridData = new GridData();
    gridData.widthHint = 200;
    label.setLayoutData(gridData);

    final Text url = new Text(shell, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 300;
    url.setLayoutData(gridData);
    Utils.setTextLinkFromClipboard(shell, url, false);

    Composite panel = new Composite(shell, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 3;
    panel.setLayout(layout);       
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    panel.setLayoutData(gridData);
View Full Code Here

  initialize(
    Composite composite)
  {
    this.parent = composite;
   
    GridLayout layout;
   
    // cheap trick to allow datasource changes.  Normally we'd just
    // refill the components with new info, but I didn't write this and
    // I don't want to waste my time :) [tux]
    if (panel != null && !panel.isDisposed()) {
      Utils.disposeComposite(panel, false);
    } else {
      panel = new Composite(composite, SWT.NULL);

      layout = new GridLayout();
      layout.marginHeight = 0;
      layout.marginWidth = 0;
      layout.numColumns = 1;
      panel.setLayout(layout);
     
      Layout parentLayout = parent.getLayout();
      if (parentLayout instanceof FormLayout) {
        panel.setLayoutData(Utils.getFilledFormData());
      } else {
        panel.setLayoutData(new GridData(GridData.FILL_BOTH));
      }
    }

   
    if (managers == null) {
      return;
    }

    int userMode = COConfigurationManager.getIntParameter("User Mode");

      // header
   
    Composite cHeader = new Composite(panel, SWT.BORDER);
    GridLayout configLayout = new GridLayout();
    configLayout.marginHeight = 3;
    configLayout.marginWidth = 0;
    cHeader.setLayout(configLayout);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
    cHeader.setLayoutData(gridData);
   
    Display d = panel.getDisplay();
    cHeader.setBackground(d.getSystemColor(SWT.COLOR_LIST_SELECTION));
    cHeader.setForeground(d.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
   
    Label lHeader = new Label(cHeader, SWT.NULL);
    lHeader.setBackground(d.getSystemColor(SWT.COLOR_LIST_SELECTION));
    lHeader.setForeground(d.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
    FontData[] fontData = lHeader.getFont().getFontData();
    fontData[0].setStyle(SWT.BOLD);
    int fontHeight = (int)(fontData[0].getHeight() * 1.2);
    fontData[0].setHeight(fontHeight);
    headerFont = new Font(d, fontData);
    lHeader.setFont(headerFont);
   
    if ( managers.length == 1 ){
      lHeader.setText( " " + MessageText.getString( "authenticator.torrent" ) + " : " + managers[0].getDisplayName().replaceAll("&", "&&"));
    }else{
      String  str = "";
     
      for (int i=0;i<Math.min( 3, managers.length ); i ++ ){
       
        str += (i==0?"":", ") + managers[i].getDisplayName().replaceAll("&", "&&");
      }
     
      if ( managers.length > 3 ){
       
        str += "...";
      }
     
      lHeader.setText( " " + managers.length + " " + MessageText.getString( "ConfigView.section.torrents" ) + " : " + str );
    }
   
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
    lHeader.setLayoutData(gridData);
   
    Group gTorrentOptions = new Group(panel, SWT.NULL);
    Messages.setLanguageText(gTorrentOptions, "ConfigView.section.transfer");
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    gTorrentOptions.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    gTorrentOptions.setLayout(layout);

    //Disabled for release. Need to convert from user-specified units to
      //KB/s before restoring the following line
      //String k_unit = DisplayFormatters.getRateUnit(DisplayFormatters.UNIT_KB).trim()
      String k_unit = DisplayFormatters.getRateUnitBase10(DisplayFormatters.UNIT_KB).trim();

      // max upload speed
   
    Label label = new Label(gTorrentOptions, SWT.NULL);
    gridData = new GridData();
    label.setLayoutData( gridData );
    label.setText(k_unit + " " + MessageText.getString( "GeneralView.label.maxuploadspeed.tooltip" ));

    GenericIntParameter max_upload = new GenericIntParameter(
        adhoc_param_adapter, gTorrentOptions, MAX_UPLOAD);
    adhoc_parameters.put( MAX_UPLOAD, max_upload );
    gridData = new GridData();
    max_upload.setLayoutData(gridData);
   
    if ( userMode > 0) {

        // max upload when busy
     
      label = new Label(gTorrentOptions, SWT.NULL);
      gridData = new GridData();
      label.setLayoutData( gridData );
      Messages.setLanguageText(label, TEXT_PREFIX + "max.uploads.when.busy");
     
      GenericIntParameter max_upload_when_busy = new GenericIntParameter(
          ds_param_adapter, gTorrentOptions,
          DownloadManagerState.PARAM_MAX_UPLOAD_WHEN_BUSY);
      ds_parameters.put( DownloadManagerState.PARAM_MAX_UPLOAD_WHEN_BUSY, max_upload_when_busy );
      gridData = new GridData();
      max_upload_when_busy.setLayoutData(gridData);
    }
   
      // max download speed
   
    label = new Label(gTorrentOptions, SWT.NULL);
    gridData = new GridData();
    label.setLayoutData( gridData );
    label.setText(k_unit + " " + MessageText.getString( "GeneralView.label.maxdownloadspeed.tooltip" ));
      
    GenericIntParameter max_download = new GenericIntParameter(
        adhoc_param_adapter, gTorrentOptions, MAX_DOWNLOAD);
    adhoc_parameters.put( MAX_DOWNLOAD, max_download );
    gridData = new GridData();
    max_download.setLayoutData(gridData);
   
      // max uploads
   
    if (userMode > 0) {
      label = new Label(gTorrentOptions, SWT.NULL);
      gridData = new GridData();
      label.setLayoutData( gridData );
      Messages.setLanguageText(label, TEXT_PREFIX + "max.uploads" );
     
      GenericIntParameter max_uploads = new GenericIntParameter(
          ds_param_adapter, gTorrentOptions,
          DownloadManagerState.PARAM_MAX_UPLOADS);
      ds_parameters.put( DownloadManagerState.PARAM_MAX_UPLOADS, max_uploads );
      max_uploads.setMinimumValue(2);
      gridData = new GridData();
      max_uploads.setLayoutData(gridData);
     
        //  max uploads when seeding enabled
     
      final Composite cMaxUploadsOptionsArea = new Composite(gTorrentOptions, SWT.NULL);
      layout = new GridLayout();
      layout.numColumns = 3;
      layout.marginWidth = 0;
      layout.marginHeight = 0;
      cMaxUploadsOptionsArea.setLayout(layout);
      gridData = new GridData();
      gridData.horizontalIndent = 15;
      gridData.horizontalSpan = 2;
      cMaxUploadsOptionsArea.setLayoutData(gridData);
     
      label = new Label(cMaxUploadsOptionsArea, SWT.NULL);
      ImageLoader.getInstance().setLabelImage(label, "subitem");
      gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      label.setLayoutData(gridData);
 
      gridData = new GridData();
      GenericBooleanParameter  max_uploads_when_seeding_enabled =
        new GenericBooleanParameter(
            ds_param_adapter,
            cMaxUploadsOptionsArea,
            DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING_ENABLED,
            false,
            TEXT_PREFIX + "alternative.value.enable");
      ds_parameters.put( DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING_ENABLED, max_uploads_when_seeding_enabled );
      max_uploads_when_seeding_enabled.setLayoutData( gridData );
     
 
      GenericIntParameter max_uploads_when_seeding = new GenericIntParameter(
          ds_param_adapter, cMaxUploadsOptionsArea,
          DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING);
      ds_parameters.put( DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING, max_uploads_when_seeding );
      gridData = new GridData();
      max_uploads_when_seeding.setMinimumValue(2);
      max_uploads_when_seeding.setLayoutData(gridData);
     
      max_uploads_when_seeding_enabled.setAdditionalActionPerformer(
          new ChangeSelectionActionPerformer( max_uploads_when_seeding.getControl()));
         
        // max peers
     
      label = new Label(gTorrentOptions, SWT.NULL);
      gridData = new GridData();
      label.setLayoutData( gridData );
      Messages.setLanguageText(label, TEXT_PREFIX + "max.peers");
     
      GenericIntParameter max_peers = new GenericIntParameter(ds_param_adapter,
          gTorrentOptions, DownloadManagerState.PARAM_MAX_PEERS);
      ds_parameters.put( DownloadManagerState.PARAM_MAX_PEERS, max_peers );
      gridData = new GridData();
      max_peers.setLayoutData(gridData);
 
        // max peers when seeding
     
      final Composite cMaxPeersOptionsArea = new Composite(gTorrentOptions, SWT.NULL);
      layout = new GridLayout();
      layout.numColumns = 3;
      layout.marginWidth = 0;
      layout.marginHeight = 0;
      cMaxPeersOptionsArea.setLayout(layout);
      gridData = new GridData();
View Full Code Here

    }
    createFileInfoPanel(composite);
  }

  private Composite createFileInfoPanel(Composite parent) {
    GridLayout layout;
    GridData gridData;

    // Peer Info section contains
    // - Peer's Block display
    // - Peer's Datarate
    fileInfoComposite = new Composite(parent, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    fileInfoComposite.setLayout(layout);
    gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
    fileInfoComposite.setLayoutData(gridData);

    new Label(fileInfoComposite, SWT.NULL).setLayoutData(new GridData());

    topLabel = new Label(fileInfoComposite, SWT.NULL);
    gridData = new GridData(SWT.FILL, SWT.DEFAULT, false, false);
    topLabel.setLayoutData(gridData);

    sc = new ScrolledComposite(fileInfoComposite, SWT.V_SCROLL);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    layout = new GridLayout();
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    sc.setLayout(layout);
View Full Code Here

  {
  wizard.setTitle(MessageText.getString("installPluginsWizard.installMode.title"));
  wizard.setErrorMessage("");
 
  Composite rootPanel = wizard.getPanel();
  GridLayout layout = new GridLayout();
  layout.numColumns = 1;
  rootPanel.setLayout(layout);

  Composite panel = new Composite(rootPanel, SWT.NULL);
  GridData gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.FILL_HORIZONTAL);
  panel.setLayoutData(gridData);
  layout = new GridLayout();
  layout.numColumns = 1;
  panel.setLayout(layout);

    // default is shared installation
 
View Full Code Here

    Composite cSection = new Composite(parent, SWT.NULL);

    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL + GridData.VERTICAL_ALIGN_FILL);
    cSection.setLayoutData(gridData);
    GridLayout advanced_layout = new GridLayout();
    cSection.setLayout(advanced_layout);

    int userMode = COConfigurationManager.getIntParameter("User Mode");
    if (userMode < REQUIRED_MODE) {
      Label label = new Label(cSection, SWT.WRAP);
      gridData = new GridData();
      label.setLayoutData(gridData);

      final String[] modeKeys = { "ConfigView.section.mode.beginner",
          "ConfigView.section.mode.intermediate",
          "ConfigView.section.mode.advanced" };

      String param1, param2;
      if (REQUIRED_MODE < modeKeys.length)
        param1 = MessageText.getString(modeKeys[REQUIRED_MODE]);
      else
        param1 = String.valueOf(REQUIRED_MODE);
         
      if (userMode < modeKeys.length)
        param2 = MessageText.getString(modeKeys[userMode]);
      else
        param2 = String.valueOf(userMode);

      label.setText(MessageText.getString("ConfigView.notAvailableForMode",
          new String[] { param1, param2 } ));

      return cSection;
    }
   
    Group gCrypto = new Group(cSection, SWT.NULL);
    Messages.setLanguageText(gCrypto, CFG_PREFIX + "encrypt.group");
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gCrypto.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    gCrypto.setLayout(layout);
   
    Label lcrypto = new Label(gCrypto, SWT.WRAP);
    Messages.setLanguageText(lcrypto, CFG_PREFIX + "encrypt.info");
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    gridData.widthHint = 200// needed for wrap
    lcrypto.setLayoutData(gridData);

    gridData = new GridData();
    gridData.horizontalSpan = 2;
    new LinkLabel(gCrypto, gridData, CFG_PREFIX
        + "encrypt.info.link",
        "http://wiki.vuze.com/w/Avoid_traffic_shaping");
   
    final BooleanParameter require = new BooleanParameter(gCrypto,  "network.transport.encrypted.require", CFG_PREFIX + "require_encrypted_transport");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    require.setLayoutData(gridData);
   
    String[] encryption_types = { "Plain", "RC4" };
    String dropLabels[] = new String[encryption_types.length];
    String dropValues[] = new String[encryption_types.length];
    for (int i = 0; i < encryption_types.length; i++) {
      dropLabels[i] = encryption_types[i];
      dropValues[i] = encryption_types[i];
    }
   
    Composite cEncryptLevel = new Composite(gCrypto, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 2;
    cEncryptLevel.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    cEncryptLevel.setLayout(layout);
   
View Full Code Here

    final Shell s = org.gudy.azureus2.ui.swt.components.shell.ShellFactory
        .createShell(shell, SWT.RESIZE | SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
    Utils.setShellIcon(s);
    s.setText(MessageText.getString("LocaleUtil.title")); //$NON-NLS-1$
    GridData gridData;
    s.setLayout(new GridLayout(1, true));
   
    Label label = new Label(s, SWT.LEFT);
    Messages.setLanguageText(label, "LocaleUtil.label.chooseencoding"); //$NON-NLS-1$

    final Table table = new Table(s, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
    gridData = new GridData( GridData.FILL_BOTH );
    table.setLayoutData(gridData);
   
    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    String[] titlesPieces = { "encoding", "text" };
    for (int i = 0; i < titlesPieces.length; i++) {
      TableColumn column = new TableColumn(table, SWT.LEFT);
      Messages.setLanguageText(column, "LocaleUtil.column." + titlesPieces[i]);
    }

    // add candidates to table
    for (int i = 0; i < candidates.length; i++) {
      TableItem item = new TableItem(table, SWT.NULL);
      String name = candidates[i].getDecoder().getName();
      item.setText(0, name);
      item.setText(1, candidates[i].getValue());
    }
    int lastSelectedIndex = 0;
    for (int i = 1; i < candidates.length; i++) {
      if(candidates[i].getValue() != null && candidates[i].getDecoder() == rememberedDecoder ) {
        lastSelectedIndex = i;
        break;
      }
    }
    table.select(lastSelectedIndex);

    // resize all columns to fit the widest entry
    table.getColumn(0).pack();
    table.getColumn(1).pack();

    label = new Label(s, SWT.LEFT);
    Messages.setLanguageText(label, "LocaleUtil.label.hint.doubleclick"); //$NON-NLS-1$

    Composite composite = new Composite(s,SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    composite.setLayoutData(gridData);
   
    GridLayout subLayout  = new GridLayout();
    subLayout.numColumns = 2;
   
    composite.setLayout(subLayout);
   
    final Button checkBox = new Button(composite, SWT.CHECK);
View Full Code Here

  {
    wizard.setTitle(MessageText.getString("installPluginsWizard.list.title"));
    wizard.setErrorMessage("");
   
  Composite rootPanel = wizard.getPanel();
  GridLayout layout = new GridLayout();
  layout.numColumns = 1;
  rootPanel.setLayout(layout);

  Composite panel = new Composite(rootPanel, SWT.NULL);
  GridData gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.FILL_HORIZONTAL);
  panel.setLayoutData(gridData);
  layout = new GridLayout();
  layout.numColumns = 1;
  panel.setLayout(layout);
 
  final Label lblStatus = new Label(panel,SWT.NULL);
  GridData data = new GridData(GridData.FILL_HORIZONTAL);
View Full Code Here

  }


  public Composite configSectionCreate(final Composite parent) {
    GridData gridData;
    GridLayout layout;

    Composite cSection = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL
        | GridData.HORIZONTAL_ALIGN_FILL);
    cSection.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    cSection.setLayout(layout);

    int userMode = COConfigurationManager.getIntParameter("User Mode");
    if (userMode < REQUIRED_MODE) {
View Full Code Here

  public void show() {
  final NewTorrentWizard wizard = (NewTorrentWizard)this.wizard;
    wizard.setTitle(MessageText.getString("wizard.mode"));
    wizard.setCurrentInfo(MessageText.getString("wizard.singlefile.help"));
    Composite rootPanel = wizard.getPanel();
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    rootPanel.setLayout(layout);

    Composite panel = new Composite(rootPanel, SWT.NO_RADIO_GROUP);
    GridData gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.FILL_HORIZONTAL);
    panel.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 4;
    panel.setLayout(layout);

    //Line :
    // O use embedded tracker []Use SSL
   
    final Button btnLocalTracker = new Button(panel, SWT.RADIO);  
    Messages.setLanguageText(btnLocalTracker, "wizard.tracker.local");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    btnLocalTracker.setLayoutData(gridData);   

    final Button btnSSL = new Button(panel, SWT.CHECK);
    Messages.setLanguageText(btnSSL, "wizard.tracker.ssl");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gridData.horizontalSpan = 2;
    btnSSL.setLayoutData( gridData );
       
    //Line :
    //Announce URL : <local announce>

    final String localTrackerHost = COConfigurationManager.getStringParameter("Tracker IP", "");
    final int localTrackerPort   = COConfigurationManager.getIntParameter("Tracker Port", TRHost.DEFAULT_PORT );
    final int localTrackerPortSSL = COConfigurationManager.getIntParameter("Tracker Port SSL", TRHost.DEFAULT_PORT_SSL );
    final boolean SSLEnabled = COConfigurationManager.getBooleanParameter("Tracker Port SSL Enable", false );

    final String[] localTrackerUrl = new String[1];

    // there's a potential oversize issue with the howToLocal string, and attemtping to force wrap has no effect -
    // therefore, provide more room and remove extraneous labeling
   
    final boolean showLocal = TRTrackerUtils.isTrackerEnabled();
   
    final Label labelLocalAnnounce = (showLocal) ? new Label(panel, SWT.NULL) : null;
   
    final Label localTrackerValue = new Label(panel, SWT.NULL);
   
    if ( showLocal ){
     
      Messages.setLanguageText(labelLocalAnnounce, "wizard.announceUrl");
     
      localTrackerUrl[0] = "http://" + UrlUtils.convertIPV6Host(localTrackerHost) + ":" + localTrackerPort + "/announce";
      localTrackerValue.setText(localTrackerUrl[0]);
      btnSSL.setEnabled( SSLEnabled );

      gridData = new GridData();
      gridData.horizontalSpan = 3;
     
    } else {
     
      localTrackerUrl[0] = "";
      Messages.setLanguageText(localTrackerValue, "wizard.tracker.howToLocal");
      btnLocalTracker.setSelection(false);
      btnSSL.setEnabled(false);
      btnLocalTracker.setEnabled(false);
      localTrackerValue.setEnabled(true);
     
      if ( wizard.getTrackerType() == NewTorrentWizard.TT_LOCAL ){
       
        wizard.setTrackerType( NewTorrentWizard.TT_EXTERNAL );
      }

      gridData = new GridData();
      gridData.horizontalSpan = 4;
    }
   
    localTrackerValue.setLayoutData(gridData);

    int  tracker_type = wizard.getTrackerType();
   
    if (tracker_type == NewTorrentWizard.TT_LOCAL) {
     
      setTrackerUrl(localTrackerUrl[0]);
     
    }else if ( tracker_type == NewTorrentWizard.TT_EXTERNAL ){
     
      setTrackerUrl( NewTorrentWizard.TT_EXTERNAL_DEFAULT );
     
    }else{
     
      setTrackerUrl( NewTorrentWizard.TT_DECENTRAL_DEFAULT );
    }

    //Line:
    // O use external Tracker  
   
    final Button btnExternalTracker = new Button(panel, SWT.RADIO);
    Messages.setLanguageText(btnExternalTracker, "wizard.tracker.external");
    gridData = new GridData();
    gridData.horizontalSpan = 4;
    btnExternalTracker.setLayoutData(gridData);

    //Line:
    // [External Tracker Url ]V

    final Label labelExternalAnnounce = new Label(panel, SWT.NULL);
    Messages.setLanguageText(labelExternalAnnounce, "wizard.announceUrl");
   
    btnLocalTracker.setSelection(tracker_type==NewTorrentWizard.TT_LOCAL);
    if(showLocal) localTrackerValue.setEnabled(tracker_type==NewTorrentWizard.TT_LOCAL);
    btnSSL.setEnabled(SSLEnabled&&tracker_type==NewTorrentWizard.TT_LOCAL);
   
    btnExternalTracker.setSelection(tracker_type==NewTorrentWizard.TT_EXTERNAL);
    labelExternalAnnounce.setEnabled(tracker_type==NewTorrentWizard.TT_EXTERNAL);

   
   
    tracker = new Combo(panel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    tracker.setLayoutData(gridData);
    List trackers = TrackersUtil.getInstance().getTrackersList();
    Iterator iter = trackers.iterator();
    while (iter.hasNext()) {
      tracker.add((String) iter.next());
    }
   
    tracker.addModifyListener(new ModifyListener() {
      /*
       * (non-Javadoc)
       *
       * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
       */
      public void modifyText(ModifyEvent arg0) {
        String text = tracker.getText();       
        setTrackerUrl(text);
       
        boolean valid = true;
        String errorMessage = "";
        try {
          new URL(text);
        } catch (MalformedURLException e) {
          valid = false;
          errorMessage = MessageText.getString("wizard.invalidurl");
        }
        wizard.setErrorMessage(errorMessage);
        wizard.setNextEnabled(valid);

      }
    });
   
    tracker.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event e) {
        String text = tracker.getText();       
        setTrackerUrl(text);
       
        boolean valid = true;
        String errorMessage = "";
        try {
          new URL(text);
        } catch (MalformedURLException ex) {
          valid = false;
          errorMessage = MessageText.getString("wizard.invalidurl");
        }
        wizard.setErrorMessage(errorMessage);
        wizard.setNextEnabled(valid);
      }
    });
   
    updateTrackerURL();
   
    tracker.setEnabled( tracker_type == NewTorrentWizard.TT_EXTERNAL );
   
    new Label(panel,SWT.NULL);

    // O decentral tracking
    // has to be on same no-radio-group panel otherwise weird things happen regarding selection of
    // "external tracker" button *even if* we set it up so that "dht tracker" should be selected....
   
    final Button btnDHTTracker = new Button(panel, SWT.RADIO);
    Messages.setLanguageText(btnDHTTracker, "wizard.tracker.dht");
    gridData = new GridData();
    gridData.horizontalSpan = 4;
    btnDHTTracker.setLayoutData(gridData);
   
    btnDHTTracker.setSelection(tracker_type==NewTorrentWizard.TT_DECENTRAL);

   
    // add another panel due to control oversize issues
    panel = new Composite(rootPanel, SWT.NO_RADIO_GROUP);
    gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.FILL_HORIZONTAL);
    panel.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 4;
    panel.setLayout(layout);
       
    //Line:
    // ------------------------------
   
    Label label = new Label(panel, SWT.SEPARATOR | SWT.HORIZONTAL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 4;
    label.setLayoutData(gridData);

    //Line:
    // [] add Multi-tracker information [] webseed
   
    final Button btnMultiTracker = new Button(panel,SWT.CHECK);
    Messages.setLanguageText(btnMultiTracker, "wizard.multitracker");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    btnMultiTracker.setLayoutData(gridData);
    btnMultiTracker.addListener(SWT.Selection, new Listener() {

      public void handleEvent(Event arg0) {
        ((NewTorrentWizard) wizard).useMultiTracker = btnMultiTracker.getSelection();
      }
    });
    btnMultiTracker.setSelection(((NewTorrentWizard) wizard).useMultiTracker);
   
    btnMultiTracker.setEnabled( tracker_type != NewTorrentWizard.TT_DECENTRAL);
   
    final Button btnWebSeed = new Button(panel,SWT.CHECK);
    Messages.setLanguageText(btnWebSeed, "wizard.webseed");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    btnWebSeed.setLayoutData(gridData);
    btnWebSeed.addListener(SWT.Selection, new Listener() {

      public void handleEvent(Event arg0) {
        ((NewTorrentWizard) wizard).useWebSeed = btnWebSeed.getSelection();
      }
    });
    btnWebSeed.setSelection(((NewTorrentWizard) wizard).useWebSeed);
       
    //Line:
    // include hashes for other networks (

    final Button btnExtraHashes = new Button(panel,SWT.CHECK);
    Messages.setLanguageText(btnExtraHashes, "wizard.createtorrent.extrahashes");
    gridData = new GridData();
    gridData.horizontalSpan = 4;
    btnExtraHashes.setLayoutData(gridData);
    btnExtraHashes.addListener(SWT.Selection, new Listener() {

      public void handleEvent(Event arg0) {
        ((NewTorrentWizard) wizard).setAddOtherHashes( btnExtraHashes.getSelection());
      }
    });
    btnExtraHashes.setSelection(((NewTorrentWizard) wizard).getAddOtherHashes());

    // add another panel due to control oversize issues
    // the "hack" is staying until a more satisfactory solution can be found
    panel = new Composite(rootPanel, SWT.NONE);
    gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.FILL_HORIZONTAL);
    panel.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 4;
    panel.setLayout(layout);

    //Line:
    // ------------------------------
View Full Code Here

TOP

Related Classes of org.eclipse.swt.layout.GridLayout

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.