Examples of GridData


Examples of org.eclipse.swt.layout.GridData

      GridLayout layout = new GridLayout();
      layout.numColumns = 3;
     
      shell.setLayout (layout);
     
      GridData gridData;
     
      // info
     
      Label info_label = new Label(shell,SWT.NULL);
      Messages.setLanguageText(info_label, "security.certtruster.intro");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 3;
      info_label.setLayoutData(gridData);
     
      // resource
     
      Label resource_label = new Label(shell,SWT.NULL);
      Messages.setLanguageText(resource_label, "security.certtruster.resource");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      resource_label.setLayoutData(gridData);
     
      Label resource_value = new Label(shell,SWT.NULL);
      resource_value.setText(resource.replaceAll("&", "&&"));
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      resource_value.setLayoutData(gridData);
     
      // issued by
     
      Label issued_by_label = new Label(shell,SWT.NULL);
      Messages.setLanguageText(issued_by_label, "security.certtruster.issuedby");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      issued_by_label.setLayoutData(gridData);
     
      Label issued_by_value = new Label(shell,SWT.NULL);
      issued_by_value.setText(extractCN(cert.getIssuerDN().getName()).replaceAll("&", "&&"));
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      issued_by_value.setLayoutData(gridData);
     
      // issued to
     
      Label issued_to_label = new Label(shell,SWT.NULL);
      Messages.setLanguageText(issued_to_label, "security.certtruster.issuedto");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      issued_to_label.setLayoutData(gridData);
     
      Label issued_to_value = new Label(shell,SWT.NULL);
      issued_to_value.setText(extractCN(cert.getSubjectDN().getName()).replaceAll("&", "&&"));
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      issued_to_value.setLayoutData(gridData);
     
      // prompt
     
      Label prompt_label = new Label(shell,SWT.NULL);
      Messages.setLanguageText(prompt_label, "security.certtruster.prompt");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 3;
      prompt_label.setLayoutData(gridData);
     
        // line
     
      Label labelSeparator = new Label(shell,SWT.SEPARATOR | SWT.HORIZONTAL);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      gridData.horizontalSpan = 3;
      labelSeparator.setLayoutData(gridData);
     
        // buttons
     
      new Label(shell,SWT.NULL);
     
      Composite comp = new Composite(shell,SWT.NULL);
      gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_FILL);
      gridData.grabExcessHorizontalSpace = true;
      gridData.horizontalSpan = 2;
      comp.setLayoutData(gridData);
      GridLayout layoutButtons = new GridLayout();
      layoutButtons.numColumns = 2;
      comp.setLayout(layoutButtons);
     
     
     
      Button bYes = new Button(comp,SWT.PUSH);
      bYes.setText(MessageText.getString("security.certtruster.yes"));
      gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_FILL);
      gridData.grabExcessHorizontalSpace = true;
      gridData.widthHint = 70;
      bYes.setLayoutData(gridData);
      bYes.addListener(SWT.Selection,new Listener() {
        public void handleEvent(Event e) {
          close(true);
        }
      });
     
      Button bNo = new Button(comp,SWT.PUSH);
      bNo.setText(MessageText.getString("security.certtruster.no"));
      gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
      gridData.grabExcessHorizontalSpace = false;
      gridData.widthHint = 70;
      bNo.setLayoutData(gridData);   
      bNo.addListener(SWT.Selection,new Listener() {
        public void handleEvent(Event e) {
View Full Code Here

Examples of org.eclipse.swt.layout.GridData

    return 1;
  }


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

    final Composite cDisplay = new Composite(parent, SWT.NULL);

    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL
        | GridData.HORIZONTAL_ALIGN_FILL);
    cDisplay.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    cDisplay.setLayout(layout);

    final PlatformManager platform = PlatformManagerFactory.getPlatformManager();
   
    int userMode = COConfigurationManager.getIntParameter("User Mode");
   
      // ***** start group
   
    boolean can_ral = platform.hasCapability(PlatformManagerCapabilities.RunAtLogin );
       
    if ( can_ral ){
     
      Group gStartStop = new Group(cDisplay, SWT.NULL);
      Messages.setLanguageText(gStartStop, LBLKEY_PREFIX + "start");
      layout = new GridLayout(2, false);
      gStartStop.setLayout(layout);
      gStartStop.setLayoutData(new GridData( GridData.FILL_HORIZONTAL ));
 
      if ( can_ral ){
 
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter start_on_login = new BooleanParameter(gStartStop, "Start On Login", LBLKEY_PREFIX + "start.onlogin");
       
        try{
          start_on_login.setSelected( platform.getRunAtLogin());
         
          start_on_login.addChangeListener(
            new ParameterChangeAdapter()
            {
              public void
              booleanParameterChanging(
                Parameter p,
                boolean toValue)
              {
                try{
                  platform.setRunAtLogin( toValue );
                 
                }catch( Throwable e ){
                 
                  Debug.out( e );
                }
              }
            });
         
        }catch( Throwable e ){
         
          start_on_login.setEnabled( false );
         
          Debug.out( e );
        }
       
        start_on_login.setLayoutData(gridData);
      }
     
    }
       
    if ( userMode > 0 ){
       
      Group gPR = new Group(cDisplay, SWT.NULL);
      Messages.setLanguageText(gPR, LBLKEY_PREFIX + "pauseresume");
      layout = new GridLayout(2, false);
      gPR.setLayout(layout);
      gPR.setLayoutData(new GridData( GridData.FILL_HORIZONTAL ));

      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter pauseOnExit = new BooleanParameter(gPR,
          "Pause Downloads On Exit", "ConfigView.label.pause.downloads.on.exit");
      pauseOnExit.setLayoutData(gridData);
 
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter resumeOnStart = new BooleanParameter(gPR,
          "Resume Downloads On Start", "ConfigView.label.resume.downloads.on.start");
      resumeOnStart.setLayoutData(gridData);
    }
   
    if ( userMode >= 0 ){
     
      Group gStop = new Group(cDisplay, SWT.NULL);
      Messages.setLanguageText(gStop, LBLKEY_PREFIX + "stop");
      layout = new GridLayout(2, false);
      gStop.setLayout(layout);
      gStop.setLayoutData(new GridData( GridData.FILL_HORIZONTAL ));

        // done downloading
     
      gridData = new GridData();
      label = new Label(gStop, SWT.NULL);
        Messages.setLanguageText(label, "ConfigView.label.stop.downcomp");
        label.setLayoutData( gridData );
     
        int  shutdown_types = platform.getShutdownTypes();
       
      List<String>  l_action_values = new ArrayList<String>();
      List<String>  l_action_descs   = new ArrayList<String>();

      l_action_values.add( "Nothing" );
      l_action_values.add( "QuitVuze" );
     
      if (( shutdown_types & PlatformManager.SD_SLEEP ) != 0 ){
       
        l_action_values.add( "Sleep" );
      }
      if (( shutdown_types & PlatformManager.SD_HIBERNATE ) != 0 ){
       
        l_action_values.add( "Hibernate" );
      }
      if (( shutdown_types & PlatformManager.SD_SHUTDOWN ) != 0 ){
       
        l_action_values.add( "Shutdown" );
      }
     
      String[] action_values = l_action_values.toArray( new String[ l_action_values.size()]);
         
      for ( String s: action_values ){
       
        l_action_descs.add( MessageText.getString( "ConfigView.label.stop." + s ));
      }
     
      String[] action_descs = l_action_descs.toArray( new String[ l_action_descs.size()]);

      new StringListParameter(gStop, "On Downloading Complete Do", "Nothing", action_descs, action_values );

        // done seeding
     
      gridData = new GridData();
        label = new Label(gStop, SWT.NULL);
        Messages.setLanguageText(label, "ConfigView.label.stop.seedcomp");
        label.setLayoutData( gridData );
             
      new StringListParameter(gStop, "On Seeding Complete Do", "Nothing", action_descs, action_values );
     
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter resetOnTrigger =
        new BooleanParameter(
          gStop, "Stop Triggers Auto Reset",
          "!" + MessageText.getString(
            "ConfigView.label.stop.autoreset",
            new String[]{ MessageText.getString( "ConfigView.label.stop.Nothing" )})+ "!");
       
      resetOnTrigger.setLayoutData(gridData);
    }
   
    if ( userMode > 0 && platform.hasCapability( PlatformManagerCapabilities.AccessExplicitVMOptions )){
     
      Group gJVM = new Group(cDisplay, SWT.NULL);
      Messages.setLanguageText(gJVM, LBLKEY_PREFIX + "jvm");
      layout = new GridLayout(2, false);
      gJVM.setLayout(layout);
      gJVM.setLayoutData(new GridData( GridData.FILL_HORIZONTAL ));
     
        // wiki link
     
      gridData = new GridData();
      gridData.horizontalSpan = 2;

      LinkLabel link = new LinkLabelgJVM, gridData, "ConfigView.label.please.visit.here",
                      "http://wiki.vuze.com/w/Java_VM_memory_usage");
     
        // info
     
      label = new Label(gJVM, SWT.NULL);
      Messages.setLanguageText(label, "jvm.info");
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      label.setLayoutData( gridData );
     
      try{
        final File option_file = platform.getVMOptionFile();
        
        final Group gJVMOptions = new Group(gJVM, SWT.NULL);
        layout = new GridLayout(3, false);
        gJVMOptions.setLayout(layout);
        gridData = new GridData( GridData.FILL_HORIZONTAL );
        gridData.horizontalSpan = 2;
        gJVMOptions.setLayoutData( gridData );
       
        buildOptions( cDisplay, platform, gJVMOptions, false );
       
          // show option file
       
        label = new Label(gJVM, SWT.NULL);
        Messages.setLanguageText(label, "jvm.show.file", new String[]{ option_file.getAbsolutePath() });

        Button show_folder_button = new Button( gJVM, SWT.PUSH );
       
         Messages.setLanguageText( show_folder_button, "MyTorrentsView.menu.explore");
        
         show_folder_button.addSelectionListener(
           new SelectionAdapter()
           {
             public void
             widgetSelected(
               SelectionEvent e )
             {
               ManagerUtils.open( option_file );
             }
           });

         label = new Label(gJVM, SWT.NULL);     
        Messages.setLanguageText(label, "jvm.reset");

        Button reset_button = new Button( gJVM, SWT.PUSH );
       
         Messages.setLanguageText( reset_button, "Button.reset");
        
         reset_button.addSelectionListener(
           new SelectionAdapter()
           {
             public void
             widgetSelected(
               SelectionEvent event )
             {
               try{
                 platform.setExplicitVMOptions( new String[0] );
                
                 buildOptions( cDisplay, platform, gJVMOptions, true );
                
               }catch( Throwable e ){
                
                 Debug.out( e );
               }
             }
           });
        
      }catch( Throwable e ){
       
        Debug.out( e );
       
        label = new Label(gJVM, SWT.NULL);
        Messages.setLanguageText(label, "jvm.error", new String[]{ Debug.getNestedExceptionMessage(e) });
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        label.setLayoutData( gridData );
      }
    }

View Full Code Here

Examples of org.eclipse.swt.layout.GridData

     
      long  max_mem = AEMemoryMonitor.getJVMLongOption( options, "-Xmx" );
     
      final int MIN_MAX_JVM = 32*1024*1024;
 
      GridData gridData = new GridData();
      Label label = new Label(area, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label,  "jvm.max.mem", new String[]{encodeDisplayLong(MIN_MAX_JVM)});
 
      gridData = new GridData();
      gridData.widthHint = 125;
      final StringParameter max_vm = new StringParameter(area, "jvm.max.mem", "", false );
      max_vm.setLayoutData(gridData);
       
      max_vm.setValue( max_mem == -1?"":encodeDisplayLong( max_mem ));
     
      max_vm.addChangeListener(
        new ParameterChangeAdapter()
        {
          private String  last_value;
         
          public void
          parameterChanged(
            Parameter  p,
            boolean    caused_internally )
          {
            if ( max_vm.isDisposed()){
             
              max_vm.removeChangeListener( this );
             
              return;
            }
           
            String val = max_vm.getValue();
           
            if ( last_value != null && last_value.equals( val )){
             
              return;
            }
           
            last_value = val;
                     
            try{
              long max_mem = decodeDisplayLong( val );
             
              if ( max_mem < MIN_MAX_JVM ){
               
                throw( new Exception( "Min=" + encodeDisplayLong( MIN_MAX_JVM )));
              }
                         
              String[] options = platform.getExplicitVMOptions();
             
              options = AEMemoryMonitor.setJVMLongOption( options, "-Xmx", max_mem );
 
              long  min_mem = AEMemoryMonitor.getJVMLongOption( options, "-Xms" );
 
              if ( min_mem == -1 || min_mem > max_mem ){
               
                options = AEMemoryMonitor.setJVMLongOption( options, "-Xms", max_mem );
              }
             
              platform.setExplicitVMOptions( options );
             
              buildOptions( parent, platform, area, true );
             
            }catch( Throwable e ){
             
              String param_name = MessageText.getString( "jvm.max.mem" );
             
              int  pos = param_name.indexOf( '[' );
             
              if ( pos != -1 ){
               
                param_name = param_name.substring( 0, pos ).trim();
              }
             
              MessageBoxShell mb =
                new MessageBoxShell(
                  SWT.ICON_ERROR | SWT.OK,
                  MessageText.getString( "ConfigView.section.invalid.value.title"),
                  MessageText.getString(
                    "ConfigView.section.invalid.value",
                    new String[]{ val, param_name, Debug.getNestedExceptionMessage(e)}));
             
                  mb.setParent( parent.getShell());
                  mb.open(null);
            }
          }
        });
     
      label = new Label(area, SWT.NULL);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      label.setLayoutData(gridData);
     
      Long max_heap_mb = AEMemoryMonitor.getMaxHeapMB();
     
      if ( max_heap_mb > 0 ){
       
        Messages.setLanguageText(label,  "jvm.max.mem.current", new String[]{ DisplayFormatters.formatByteCountToKiBEtc( max_heap_mb*1024*1024, true )});
      }
    }
   
    {
        // min mem
     
      final int MIN_MIN_JVM = 8*1024*1024;
 
      long  min_mem = AEMemoryMonitor.getJVMLongOption( options, "-Xms" );
 
      GridData gridData = new GridData();
      Label label = new Label(area, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label,  "jvm.min.mem", new String[]{encodeDisplayLong(MIN_MIN_JVM)});
 
      gridData = new GridData();
      gridData.widthHint = 125;
      final StringParameter min_vm = new StringParameter(area, "jvm.min.mem", "", false );
      min_vm.setLayoutData(gridData);
       
      min_vm.setValue( min_mem == -1?"":encodeDisplayLong( min_mem ));
     
      min_vm.addChangeListener(
        new ParameterChangeAdapter()
        {
          private String  last_value;
         
          public void
          parameterChanged(
            Parameter  p,
            boolean    caused_internally )
          {
            if ( min_vm.isDisposed()){
             
              min_vm.removeChangeListener( this );
             
              return;
            }
           
            String val = min_vm.getValue();
           
            if ( last_value != null && last_value.equals( val )){
             
              return;
            }
           
            last_value = val;
                     
            try{
              long min_mem = decodeDisplayLong( val );
             
              if ( min_mem < MIN_MIN_JVM ){
               
                throw( new Exception( "Min=" + encodeDisplayLong( MIN_MIN_JVM )));
              }
                         
              String[] options = platform.getExplicitVMOptions();
             
              options = AEMemoryMonitor.setJVMLongOption( options, "-Xms", min_mem );
 
              long  max_mem = AEMemoryMonitor.getJVMLongOption( options, "-Xmx" );
 
              if ( max_mem == -1 || max_mem < min_mem ){
               
                options = AEMemoryMonitor.setJVMLongOption( options, "-Xmx", min_mem );
              }
             
              platform.setExplicitVMOptions( options );
             
              buildOptions( parent, platform, area, true );
             
            }catch( Throwable e ){
             
              String param_name = MessageText.getString( "jvm.min.mem" );
             
              int  pos = param_name.indexOf( '[' );
             
              if ( pos != -1 ){
               
                param_name = param_name.substring( 0, pos ).trim();
              }
             
              MessageBoxShell mb =
                new MessageBoxShell(
                  SWT.ICON_ERROR | SWT.OK,
                  MessageText.getString( "ConfigView.section.invalid.value.title"),
                  MessageText.getString(
                    "ConfigView.section.invalid.value",
                    new String[]{ val, param_name, Debug.getNestedExceptionMessage(e)}));
             
                  mb.setParent( parent.getShell());
                  mb.open(null);
            }
          }
        });
     
      label = new Label(area, SWT.NULL);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      label.setLayoutData(gridData);
    }
   
    {
        // max DIRECT mem
     
      final int MIN_DIRECT_JVM = 32*1024*1024;
     
      final String OPTION_KEY = "-XX:MaxDirectMemorySize=";
     
      long  max_direct = AEMemoryMonitor.getJVMLongOption( options, OPTION_KEY );
 
      GridData gridData = new GridData();
      Label label = new Label(area, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label,  "jvm.max.direct.mem", new String[]{encodeDisplayLong(MIN_DIRECT_JVM)});
 
      gridData = new GridData();
      gridData.widthHint = 125;
      final StringParameter max_direct_vm = new StringParameter(area, "jvm.max.direct.mem", "", false );
      max_direct_vm.setLayoutData(gridData);
       
      max_direct_vm.setValue( max_direct == -1?"":encodeDisplayLong( max_direct ));
     
      max_direct_vm.addChangeListener(
        new ParameterChangeAdapter()
        {
          private String  last_value;
         
          public void
          parameterChanged(
            Parameter  p,
            boolean    caused_internally )
          {
            if ( max_direct_vm.isDisposed()){
             
              max_direct_vm.removeChangeListener( this );
             
              return;
            }
           
            String val = max_direct_vm.getValue();
           
            if ( last_value != null && last_value.equals( val )){
             
              return;
            }
           
            last_value = val;
                     
            try{
              long max_direct = decodeDisplayLong( val );
             
              if ( max_direct < MIN_DIRECT_JVM ){
               
                throw( new Exception( "Min=" + encodeDisplayLong( MIN_DIRECT_JVM )));
              }
                         
              String[] options = platform.getExplicitVMOptions();
             
              options = AEMemoryMonitor.setJVMLongOption( options, OPTION_KEY, max_direct );
               
              platform.setExplicitVMOptions( options );
             
              buildOptions( parent, platform, area, true );
             
            }catch( Throwable e ){
             
              String param_name = MessageText.getString( "jvm.max.direct.mem" );
             
              int  pos = param_name.indexOf( '[' );
             
              if ( pos != -1 ){
               
                param_name = param_name.substring( 0, pos ).trim();
              }
             
              MessageBoxShell mb =
                new MessageBoxShell(
                  SWT.ICON_ERROR | SWT.OK,
                  MessageText.getString( "ConfigView.section.invalid.value.title"),
                  MessageText.getString(
                    "ConfigView.section.invalid.value",
                    new String[]{ val, param_name, Debug.getNestedExceptionMessage(e)}));
             
                  mb.setParent( parent.getShell());
                  mb.open(null);
            }
          }
        });
     
      label = new Label(area, SWT.NULL);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label,  "jvm.max.direct.mem.info" );
    }   
   
      // all options

    Label label = new Label(area, SWT.NULL);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    label.setLayoutData(gridData);
    Messages.setLanguageText(label,  "jvm.options.summary" );

    for ( String option: options ){
     
      label = new Label(area, SWT.NULL);
      label.setText( option );
      gridData = new GridData( );
      gridData.horizontalSpan = 3;
      gridData.horizontalIndent = 20;
      label.setLayoutData( gridData );
    }
   
View Full Code Here

Examples of org.eclipse.swt.layout.GridData

      GridLayout layout = new GridLayout();
      layout.numColumns = 3;
     
      shell.setLayout (layout);
     
      GridData gridData;
     
      // info
     
      Label info_label = new Label(shell,SWT.NULL);
      Messages.setLanguageText(info_label, "security.certcreate.intro");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 3;
      info_label.setLayoutData(gridData);
     
      // alias
     
      Label alias_label = new Label(shell,SWT.NULL);
      Messages.setLanguageText(alias_label, "security.certcreate.alias");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      alias_label.setLayoutData(gridData);
     
      final Text alias_field =new Text(shell,SWT.BORDER);
     
      alias_field.setText( SESecurityManager.DEFAULT_ALIAS );
     
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      alias_field.setLayoutData(gridData);
     
      // strength
     
      Label strength_label = new Label(shell,SWT.NULL);
      Messages.setLanguageText(strength_label, "security.certcreate.strength");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      strength_label.setLayoutData(gridData);
     
      final Combo strength_combo = new Combo(shell, SWT.SINGLE | SWT.READ_ONLY);
        
      final int[] strengths = { 512, 1024, 1536, 2048 };
                    
      for (int i=0;i<strengths.length;i++){
       
        strength_combo.add(""+strengths[i]);
      }
           
      strength_combo.select(1);
     
      new Label(shell,SWT.NULL);
           
      // first + last name
     
      String[]  field_names = {
                  "security.certcreate.firstlastname",
                  "security.certcreate.orgunit",
                  "security.certcreate.org",
                  "security.certcreate.city",
                  "security.certcreate.state",
                  "security.certcreate.country"
                };
     
      final String[]    field_rns = {"CN", "OU", "O", "L", "ST", "C" };
     
      final Text[]    fields = new Text[field_names.length];
     
      for (int i=0;i<fields.length;i++){
       
        Label resource_label = new Label(shell,SWT.NULL);
        Messages.setLanguageText(resource_label, field_names[i]);
        gridData = new GridData(GridData.FILL_BOTH);
        gridData.horizontalSpan = 1;
        resource_label.setLayoutData(gridData);
       
        Text field = fields[i] = new Text(shell,SWT.BORDER);
        gridData = new GridData(GridData.FILL_BOTH);
        gridData.horizontalSpan = 2;
        field.setLayoutData(gridData);
      }

        // line
     
      Label labelSeparator = new Label(shell,SWT.SEPARATOR | SWT.HORIZONTAL);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      gridData.horizontalSpan = 3;
      labelSeparator.setLayoutData(gridData);
     
        // buttons
     
      new Label(shell,SWT.NULL);
     
      Composite comp = new Composite(shell,SWT.NULL);
      gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_FILL);
      gridData.grabExcessHorizontalSpace = true;
      gridData.horizontalSpan = 2;
      comp.setLayoutData(gridData);
      GridLayout layoutButtons = new GridLayout();
      layoutButtons.numColumns = 2;
      comp.setLayout(layoutButtons);
     
     
     
      Button bYes = new Button(comp,SWT.PUSH);
      Messages.setLanguageText(bYes, "security.certcreate.ok");
      gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_FILL);
      gridData.grabExcessHorizontalSpace = true;
      gridData.widthHint = 70;
      bYes.setLayoutData(gridData);
      bYes.addListener(SWT.Selection,new Listener() {
        public void handleEvent(Event e) {
         
          String  alias  = alias_field.getText().trim();
         
          int    strength  = strengths[strength_combo.getSelectionIndex()];
         
          String  dn = "";
         
          for (int i=0;i<fields.length;i++){
           
            String  rn = fields[i].getText().trim();
           
            if ( rn.length() == 0 ){
             
              rn = "Unknown";
            }
           
            dn += (dn.length()==0?"":",") + field_rns[i] + "=" + rn;
          }
                   
          try{
            SESecurityManager.createSelfSignedCertificate( alias, dn, strength );
           
            close(true );
           
            Logger.log(new LogAlert(LogAlert.UNREPEATABLE,
                LogAlert.AT_INFORMATION, MessageText
                    .getString("security.certcreate.createok")
                    + "\n" + alias + ":" + strength + "\n"
                    + dn + "\n" + SystemTime.getCurrentTime()));
           
          }catch( Throwable f ){
           
            Logger.log(new LogAlert(LogAlert.UNREPEATABLE, MessageText
                .getString("security.certcreate.createfail")
                + "\n" + SystemTime.getCurrentTime(), f));
          }
        }
      });
     
      Button bNo = new Button(comp,SWT.PUSH);
      Messages.setLanguageText(bNo, "security.certcreate.cancel");
      gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
      gridData.grabExcessHorizontalSpace = false;
      gridData.widthHint = 70;
      bNo.setLayoutData(gridData);   
      bNo.addListener(SWT.Selection,new Listener() {
        public void handleEvent(Event e) {
View Full Code Here

Examples of org.eclipse.swt.layout.GridData

      shellForChildren = parent;
  }

  private void openWindow(Shell parent) {
    boolean bTorrentInClipboard = false;
    GridData gridData;
    Label label;
    Composite cArea;

    shell = ShellFactory.createShell(parent, SWT.RESIZE | SWT.DIALOG_TRIM);

    shellForChildren = shell;

    shell.setText(MessageText.getString("OpenTorrentWindow.title"));
    Utils.setShellIcon(shell);

    GridLayout layout = FixupLayout(new GridLayout(), false);
    shell.setLayout(layout);
    shell.addListener(SWT.Resize, new Listener() {
      public void handleEvent(Event e) {
        resizeTables(3);
      }
    });

    Clipboard clipboard = new Clipboard(shell.getDisplay());

    String sClipText = (String) clipboard.getContents(TextTransfer.getInstance());
    if (sClipText != null)
      bTorrentInClipboard = addTorrentsFromTextList(sClipText, true) > 0;

    //    label = new Label(shell, SWT.BORDER | SWT.WRAP);
    //    Messages.setLanguageText(label, "OpenTorrentWindow.message");
    //    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    //    label.setLayoutData(gridData);

    // Torrents
    // ========

    Composite cButtons = new Composite(shell, SWT.NONE);
    RowLayout rLayout = new RowLayout(SWT.HORIZONTAL);
    rLayout.marginBottom = 0;
    rLayout.marginLeft = 0;
    rLayout.marginRight = 0;
    rLayout.marginTop = 0;
    cButtons.setLayout(rLayout);

    // Buttons for tableTorrents

    Button browseTorrent = new Button(cButtons, SWT.PUSH);
    Messages.setLanguageText(browseTorrent, "OpenTorrentWindow.addFiles");
    browseTorrent.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        FileDialog fDialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
        fDialog.setFilterExtensions(new String[] {
          "*.torrent",
          "*.tor",
          Constants.FILE_WILDCARD
        });
        fDialog.setFilterNames(new String[] {
          "*.torrent",
          "*.tor",
          Constants.FILE_WILDCARD
        });
        fDialog.setFilterPath(TorrentOpener.getFilterPathTorrent());
        fDialog.setText(MessageText.getString("MainWindow.dialog.choose.file"));
        String fileName = TorrentOpener.setFilterPathTorrent(fDialog.open());
        if (fileName != null) {
          addTorrents(fDialog.getFilterPath(), fDialog.getFileNames());
        }
      }
    });

    Utils.setGridData(cButtons, GridData.FILL_HORIZONTAL, browseTorrent,
        MIN_BUTTON_HEIGHT);

    Button browseURL = new Button(cButtons, SWT.PUSH);
    Messages.setLanguageText(browseURL, "OpenTorrentWindow.addFiles.URL");
    browseURL.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        browseURL();
      }
    });

    Button browseFolder = new Button(cButtons, SWT.PUSH);
    Messages.setLanguageText(browseFolder, "OpenTorrentWindow.addFiles.Folder");
    browseFolder.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        DirectoryDialog fDialog = new DirectoryDialog(shell, SWT.NULL);
        fDialog.setFilterPath(TorrentOpener.getFilterPathTorrent());
        fDialog.setMessage(MessageText.getString("MainWindow.dialog.choose.folder"));
        String path = TorrentOpener.setFilterPathTorrent(fDialog.open());
        if (path != null) {
          addTorrents(path, null);
        }
      }
    });

    if (bTorrentInClipboard) {
      Button pasteOpen = new Button(cButtons, SWT.PUSH);
      Messages.setLanguageText(pasteOpen,
          "OpenTorrentWindow.addFiles.Clipboard");
      pasteOpen.setToolTipText(sClipText);
      pasteOpen.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
          Clipboard clipboard = new Clipboard(shell.getDisplay());

          String sClipText = (String) clipboard.getContents(TextTransfer.getInstance());
          if (sClipText != null) {
            addTorrentsFromTextList(sClipText.trim(), false);
          }
        }
      });
    }

    Group gTorrentsArea = new Group(shell, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gTorrentsArea.setLayoutData(gridData);
    layout = FixupLayout(new GridLayout(), true);
    gTorrentsArea.setLayout(layout);
    Messages.setLanguageText(gTorrentsArea, "OpenTorrentWindow.torrentLocation");

    Composite cTorrentList = new Composite(gTorrentsArea, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    cTorrentList.setLayoutData(gridData);

    createTorrentListArea(cTorrentList);

    Composite cTorrentOptions = new Composite(gTorrentsArea, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    cTorrentOptions.setLayoutData(gridData);
    layout = FixupLayout(new GridLayout(), true);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    cTorrentOptions.setLayout(layout);

    label = new Label(cTorrentOptions, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    label.setLayoutData(gridData);
    Messages.setLanguageText(label, "OpenTorrentWindow.torrent.options");

    int userMode = COConfigurationManager.getIntParameter("User Mode");
    if (userMode > 0) {
      Composite cTorrentModes = new Composite(cTorrentOptions, SWT.NONE);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      cTorrentModes.setLayoutData(gridData);
      layout = new GridLayout();
      layout.numColumns = 4;
      layout.marginWidth = 0;
      layout.marginHeight = 0;
      cTorrentModes.setLayout(layout);

      label = new Label(cTorrentModes, SWT.NONE);
      gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label, "OpenTorrentWindow.startMode");

      cmbStartMode = new Combo(cTorrentModes, SWT.BORDER | SWT.READ_ONLY);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      cmbStartMode.setLayoutData(gridData);
      updateStartModeCombo();
      cmbStartMode.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
          setSelectedStartMode(cmbStartMode.getSelectionIndex());
        }
      });

      label = new Label(cTorrentModes, SWT.NONE);
      gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label, "OpenTorrentWindow.addPosition");

      cmbQueueLocation = new Combo(cTorrentModes, SWT.BORDER | SWT.READ_ONLY);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      cmbQueueLocation.setLayoutData(gridData);
      updateQueueLocationCombo();
      cmbQueueLocation.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
          setSelectedQueueLocation(cmbQueueLocation.getSelectionIndex());
        }
      });
    }

    // Save To..
    // =========

    cSaveTo = new Composite(cTorrentOptions, SWT.NONE);
    layout = FixupLayout(new GridLayout(), false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.numColumns = 2;
    cSaveTo.setLayout(layout);

    Label lblDataDir = new Label(cSaveTo, SWT.NONE);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 2;
    lblDataDir.setLayoutData(gridData);
    Messages.setLanguageText(lblDataDir, "OpenTorrentWindow.dataLocation");

    cmbDataDir = new Combo(cSaveTo, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    cmbDataDir.setLayoutData(gridData);

    cmbDataDir.addModifyListener(new ModifyListener() {
      public void modifyText(ModifyEvent e) {
        cmbDataDirChanged();
      }
    });
    cmbDataDir.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        cmbDataDirChanged();
      }
    });

    updateDataDirCombo();
    dirList = COConfigurationManager.getStringListParameter("saveTo_list");
    StringIterator iter = dirList.iterator();
    while (iter.hasNext()) {
      String s = iter.next();
      if (!s.equals(sDestDir)) {
        cmbDataDir.add(s);
      }
    }

    Button browseData = new Button(cSaveTo, SWT.PUSH);
    Messages.setLanguageText(browseData, "ConfigView.button.browse");

    browseData.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        String sSavePath;
        String sDefPath = cmbDataDir.getText();

        File f = new File(sDefPath);
        if (sDefPath.length() > 0) {
          while (!f.exists()) {
            f = f.getParentFile();
            if (f == null) {
              f = new File(sDefPath);
              break;
            }
          }
        }

        DirectoryDialog dDialog = new DirectoryDialog(shell, SWT.SYSTEM_MODAL);
        dDialog.setFilterPath(f.getAbsolutePath());
        dDialog.setMessage(MessageText.getString("MainWindow.dialog.choose.savepath_forallfiles"));
        sSavePath = dDialog.open();

        if (sSavePath != null) {
          cmbDataDir.setText(sSavePath);
        }
      }
    });

    gridData = new GridData(GridData.FILL_HORIZONTAL);
    cSaveTo.setLayoutData(gridData);

    // File List
    // =========

    Group gFilesArea = new Group(shell, SWT.NONE);
    gridData = new GridData(GridData.FILL_BOTH);
    gFilesArea.setLayoutData(gridData);
    layout = FixupLayout(new GridLayout(), true);
    gFilesArea.setLayout(layout);
    Messages.setLanguageText(gFilesArea, "OpenTorrentWindow.fileList");

    createTableDataFiles(gFilesArea);

    // Ok, cancel

    cArea = new Composite(shell, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.numColumns = 2;
    cArea.setLayout(layout);

    ok = new Button(cArea, SWT.PUSH);
    Messages.setLanguageText(ok, "Button.ok");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gridData.widthHint = 70;
    ok.setLayoutData(gridData);
    shell.setDefaultButton(ok);
    ok.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        okPressed();
      }
    });

    checkSeedingMode();

    Button cancel = new Button(cArea, SWT.PUSH);
    Messages.setLanguageText(cancel, "Button.cancel");
    gridData = new GridData();
    gridData.widthHint = 70;
    cancel.setLayoutData(gridData);
    cancel.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        close(true, true);
View Full Code Here

Examples of org.eclipse.swt.layout.GridData

      torrentList.clear();
    }
  }

  private void createTorrentListArea(Composite cArea) {
    GridData gridData;
    TableColumn tc;

    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    cArea.setLayout(layout);

    torrentTable = new Table(cArea, SWT.MULTI | SWT.BORDER
        | SWT.FULL_SELECTION | SWT.VIRTUAL);
    gridData = new GridData(GridData.FILL_HORIZONTAL
        | GridData.VERTICAL_ALIGN_FILL);
    gridData.heightHint = 50;
    gridData.widthHint = 450;
    torrentTable.setLayoutData(gridData);

    tc = new TableColumn(torrentTable, SWT.NULL);
    Messages.setLanguageText(tc, "OpenTorrentWindow.torrentTable.name");
    tc.setWidth(150);
    tc = new TableColumn(torrentTable, SWT.NULL);
    Messages.setLanguageText(tc, "OpenTorrentWindow.torrentTable.saveLocation");
    tc.setWidth(150);
    tc = new TableColumn(torrentTable, SWT.NULL);
    Messages.setLanguageText(tc, "OpenTorrentWindow.startMode");
    tc.setWidth(70);
    tc = new TableColumn(torrentTable, SWT.NULL);
    Messages.setLanguageText(tc, "OpenTorrentWindow.addPosition");
    tc.setWidth(80);

    if (Utils.LAST_TABLECOLUMN_EXPANDS)
      tc.setData("Width", new Long(80));

    torrentTable.addListener(SWT.SetData, new Listener() {
      public void handleEvent(Event event) {
        if (bClosed)
          return;

        TableItem item = (TableItem) event.item;
        int index = torrentTable.indexOf(item);
        if (index < 0)
          return;

        TorrentInfo info = (TorrentInfo) torrentList.get(index);

        item.setText(new String[] {
          info.getTorrentName(),
          info.getDataDir(),
          MessageText.getString("OpenTorrentWindow.startMode."
              + startModes[info.iStartID]),
          MessageText.getString("OpenTorrentWindow.addPosition."
              + queueLocations[info.iQueueLocation])
        });
        if (!info.isValid) {
          item.setForeground(Colors.red);
          Font font = item.getFont();
          FontData[] fd = font.getFontData();
          for (int i = 0; i < fd.length; i++) {
            fd[i].setStyle(SWT.ITALIC);
          }
          font = new Font(item.getDisplay(), fd);
          disposeList.add(font);
          item.setFont(font);
        }
        Utils.alternateRowBackground(item);
      }
    });

    torrentTable.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        dataFiles.clear();
        int[] indexes = torrentTable.getSelectionIndices();
        for (int i = 0; i < indexes.length; i++) {
          TorrentInfo info = (TorrentInfo) torrentList.get(indexes[i]);
          TorrentFileInfo[] files = info.getFiles();
          dataFiles.addAll(Arrays.asList(files));
        }

        updateDataDirCombo();
        updateStartModeCombo();
        updateQueueLocationCombo();

        dataFileTable.setItemCount(dataFiles.size());
        dataFileTable.clearAll();
        editCell(-1);
        updateSize();
        resizeTables(2);
      }
    });

    torrentTable.addKeyListener(new KeyAdapter() {
      public void keyPressed(KeyEvent e) {
        if (e.character == SWT.DEL) {
          deleteSelected(torrentTable, torrentList);
          e.doit = false;
        }
      }
    });

    torrentTable.setHeaderVisible(true);

    // Menu for tableTorrents

    String sTitle;
    Menu menu = new Menu(torrentTable.getShell());
    MenuItem item;
    sTitle = MessageText.getString("OpenTorrentWindow.startMode");

    int userMode = COConfigurationManager.getIntParameter("User Mode");
    for (int i = 0; i < startModes.length; i++) {
      if (i == STARTMODE_FORCESTARTED && userMode == 0)
        continue;

      item = new MenuItem(menu, SWT.PUSH);
      item.setData("Value", new Long(i));
      item.setText(sTitle
          + ": "
          + MessageText.getString("OpenTorrentWindow.startMode."
              + startModes[i]));

      item.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
          Long l = (Long) e.widget.getData("Value");
          if (l != null) {
            setSelectedStartMode(l.intValue());
            checkSeedingMode();
          }
        }
      });
    }

    item = new MenuItem(menu, SWT.SEPARATOR);
    sTitle = MessageText.getString("OpenTorrentWindow.addPosition");

    for (int i = 0; i < queueLocations.length; i++) {
      item = new MenuItem(menu, SWT.PUSH);
      item.setData("Value", new Long(i));
      item.setText(sTitle
          + ": "
          + MessageText.getString("OpenTorrentWindow.addPosition."
              + queueLocations[i]));

      item.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
          Long l = (Long) e.widget.getData("Value");
          if (l != null) {
            setSelectedQueueLocation(l.intValue());
          }
        }
      });
    }

    item = new MenuItem(menu, SWT.SEPARATOR);

    item = new MenuItem(menu, SWT.PUSH);
    // steal text
    Messages.setLanguageText(item, "MyTorrentsView.menu.remove");
    item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        deleteSelected(torrentTable, torrentList);
      }
    });

    item = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(item,
        "OpenTorrentWindow.fileList.changeDestination");
    item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        int[] indexes = torrentTable.getSelectionIndices();
        String sDefPath = sDestDir;

        for (int i = 0; i < indexes.length; i++) {
          TorrentInfo info = (TorrentInfo) torrentList.get(indexes[i]);

          TorrentFileInfo[] files = info.getFiles();
          if (files.length == 1 && info.torrent.isSimpleTorrent()) {
            changeFileDestination(new int[] {
              0
            });
          } else {
            DirectoryDialog dDialog = new DirectoryDialog(shellForChildren,
                SWT.SYSTEM_MODAL);

            dDialog.setFilterPath(sDefPath);
            dDialog.setMessage(MessageText.getString("MainWindow.dialog.choose.savepath")
                + " (" + info.getTorrentName() + ")");
            String sNewDir = dDialog.open();

            if (sNewDir == null)
              return;

            File newDir = new File(sNewDir).getAbsoluteFile();
           
            if(newDir.isDirectory())
              sDefPath = sNewDir;

            info.sDestDir = newDir.getParent();
            if (info.sDestDir == null)
              info.sDestDir = newDir.getPath();
            info.sDestSubDir = newDir.getName();

            for (int j = 0; j < files.length; j++) {
              TorrentFileInfo fileInfo = files[j];
              fileInfo.setDestFileName(null);
            }
          }

        } // for i

        checkSeedingMode();
        updateDataDirCombo();
        diskFreeInfoRefreshPending = true;
      }
    });

    torrentTable.setMenu(menu);

    Composite cTorrentListRight = new Composite(cArea, SWT.NONE);
    gridData = new GridData();
    cTorrentListRight.setLayoutData(gridData);
    RowLayout rLayout = new RowLayout(SWT.VERTICAL);
    rLayout.marginBottom = 0;
    rLayout.marginLeft = 0;
    rLayout.marginRight = 0;
View Full Code Here

Examples of org.eclipse.swt.layout.GridData

  private static final int EDIT_COLUMN_INDEX = 1;
 
 
  private void createTableDataFiles(Composite cArea) {
    GridData gridData;
    TableColumn tc;

    dataFileTable = new Table(cArea, SWT.BORDER | SWT.CHECK
        | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.MULTI);
    dataFileTableEditor = new TableEditor(dataFileTable);
    dataFileTableEditor.grabHorizontal = true;
    dataFileTableEditor.minimumWidth = 50;
   
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 80;
    gridData.widthHint = 100;
    dataFileTable.setLayoutData(gridData);
   
   

    tc = new TableColumn(dataFileTable, SWT.NULL);
    Messages.setLanguageText(tc, "OpenTorrentWindow.fileTable.fileName");
    tc.setWidth(150);
    tc = new TableColumn(dataFileTable, SWT.NULL);
    Messages.setLanguageText(tc, "OpenTorrentWindow.fileTable.destinationName");
    tc.setWidth(140);
    tc = new TableColumn(dataFileTable, SWT.NULL);
    Messages.setLanguageText(tc, "OpenTorrentWindow.fileTable.size");
    tc.setAlignment(SWT.TRAIL);
    tc.setWidth(90);

    if (Utils.LAST_TABLECOLUMN_EXPANDS)
      tc.setData("Width", new Long(90));

    dataFileTable.addListener(SWT.SetData, new Listener() {
      public void handleEvent(Event event) {
        if (bClosed)
          return;
       
        final TableItem item = (TableItem) event.item;
       
        int index = dataFileTable.indexOf(item);
        final TorrentFileInfo file = (TorrentFileInfo) dataFiles.get(index);

        item.setText(new String[] {
          file.orgFullName,
          file.isLinked() ? file.getDestFileFullName().toString() : file.getDestFileName(),
          DisplayFormatters.formatByteCountToKiBEtc(file.lSize)
        });
        if (!file.isValid) {
          item.setForeground(Colors.red);
          Font font = item.getFont();
          FontData[] fd = font.getFontData();
          for (int i = 0; i < fd.length; i++) {
            fd[i].setStyle(SWT.ITALIC);
          }
          font = new Font(item.getDisplay(), fd);
          disposeList.add(font);
          item.setFont(font);
        }
        Utils.alternateRowBackground(item);
        Utils.setCheckedInSetData(item, file.bDownload);

        item.setGrayed(!file.okToDisable());
      }
    });

    dataFileTable.addSelectionListener(new SelectionAdapter() {

      public void widgetSelected(SelectionEvent event) {
        if (event.detail == SWT.CHECK) {
          TableItem item = (TableItem) event.item;
          int index = dataFileTable.indexOf(item);
          TorrentFileInfo file = (TorrentFileInfo) dataFiles.get(index);
          // don't allow disabling of small files
          // XXX Maybe warning prompt instead?
          if (!item.getChecked() && !file.okToDisable())
            item.setChecked(true);
          else
            file.bDownload = item.getChecked();

          updateSize();
        }
      }

    });
   
    dataFileTable.addMouseListener(new MouseAdapter() {
      public void mouseDown(MouseEvent e) {
        editCell(-1); // cleanup
        if(e.button != 1)
          return;

        TableItem[] items = dataFileTable.getItems();
        boolean found = false;
        int i;
        outer: for (i = 0; i < items.length; i++)
        {
          TableItem item = items[i];
          Rectangle rect = item.getBounds();
          if (e.y < rect.y || (rect.y + rect.height) < e.y)
            continue;
          for (int j = 0; j < dataFileTable.getColumnCount(); j++)
          {
            if (!item.getBounds(j).contains(e.x, e.y))
              continue;
            found = j == EDIT_COLUMN_INDEX;
            break outer;
          }
        }
        if(found)
          editCell(i);
      }
    });
   
   

    dataFileTable.setHeaderVisible(true);

    Menu menu = new Menu(dataFileTable);
    dataFileTable.setMenu(menu);

    MenuItem item;

    item = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(item,
        "OpenTorrentWindow.fileList.changeDestination");
    item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        int[] indexes = dataFileTable.getSelectionIndices();
        changeFileDestination(indexes);
      }
    });

    Composite cBottomArea = new Composite(cArea, SWT.NONE);
    GridLayout gLayout = new GridLayout();
    gLayout.marginHeight = 0;
    gLayout.marginWidth = 0;
    gLayout.numColumns = 2;
    gLayout.verticalSpacing = 0;
    cBottomArea.setLayout(gLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    cBottomArea.setLayoutData(gridData);

    Composite cButtons = new Composite(cBottomArea, SWT.NONE);
    RowLayout rLayout = new RowLayout(SWT.HORIZONTAL);
    rLayout.wrap = false;
    rLayout.marginBottom = 0;
    rLayout.marginLeft = 0;
    rLayout.marginRight = 0;
    rLayout.marginTop = 0;
    cButtons.setLayout(rLayout);
    gridData = new GridData(SWT.END, SWT.BEGINNING, false, false);
    gridData.verticalSpan = 2;
    cButtons.setLayoutData(gridData);

    Button btnSelectAll = new Button(cButtons, SWT.PUSH);
    Messages.setLanguageText(btnSelectAll, "Button.selectAll");
    btnSelectAll.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        dataFileTable.selectAll();
      }
    });

    Button btnMarkSelected = new Button(cButtons, SWT.PUSH);
    Messages.setLanguageText(btnMarkSelected, "Button.markSelected");
    btnMarkSelected.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        int[] indexes = dataFileTable.getSelectionIndices();
        for (int i = 0; i < indexes.length; i++) {
          TorrentFileInfo file = (TorrentFileInfo) dataFiles.get(indexes[i]);
          file.bDownload = true;
        }
        dataFileTable.clearAll();
        updateSize();
      }
    });

    Button btnUnmarkSelected = new Button(cButtons, SWT.PUSH);
    Messages.setLanguageText(btnUnmarkSelected, "Button.unmarkSelected");
    btnUnmarkSelected.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        int[] indexes = dataFileTable.getSelectionIndices();
        for (int i = 0; i < indexes.length; i++) {
          TorrentFileInfo file = (TorrentFileInfo) dataFiles.get(indexes[i]);
          if (file.okToDisable())
            file.bDownload = false;
        }
        dataFileTable.clearAll();
        updateSize();
      }
    });

    dataFileTableLabel = new Label(cBottomArea, SWT.WRAP);
    dataFileTableLabel.setAlignment(SWT.RIGHT);
    gridData = new GridData(SWT.END, SWT.BEGINNING, true, false);
    dataFileTableLabel.setLayoutData(gridData);

    diskspaceComp = new Composite(cBottomArea, SWT.NONE);
    gLayout = new GridLayout(2, false);
    gLayout.marginHeight = gLayout.marginWidth = 1;
    gLayout.verticalSpacing = 0;
    gLayout.horizontalSpacing = 15;
    diskspaceComp.setLayout(gLayout);
    gridData = new GridData(SWT.END, SWT.BEGINNING, true, false);
    diskspaceComp.setLayoutData(gridData);

  }
View Full Code Here

Examples of org.eclipse.swt.layout.GridData

        Label l;
        l = new Label(diskspaceComp, SWT.NONE);
        l.setForeground(filesTooBig ? Colors.colorError : null);
        l.setText(part.root.getPath());
        l.setLayoutData(new GridData(SWT.END, SWT.TOP, false, false));
        l = new Label(diskspaceComp, SWT.NONE);
        l.setForeground(filesTooBig ? Colors.colorError : null);
        l.setText(MessageText.getString("OpenTorrentWindow.diskUsage",
            new String[] {
              DisplayFormatters.formatByteCountToKiBEtc(part.bytesToConsume),
              DisplayFormatters.formatByteCountToKiBEtc(part.freeSpace)
            }));
        l.setLayoutData(new GridData(SWT.END, SWT.TOP, false, false));
      }

      diskspaceComp.update();
      diskspaceComp.getParent().getParent().getParent().layout(true, true);
View Full Code Here

Examples of org.eclipse.swt.layout.GridData

    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 = 3;
    panel.setLayout(layout);

    Label label = new Label(panel, SWT.WRAP);
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    gridData.widthHint = 380;
    label.setLayoutData(gridData);
    Messages.setLanguageText(label, "exportTorrentWizard.exportfile.message");
 
    label = new Label(panel,SWT.NULL);
    Messages.setLanguageText(label, "exportTorrentWizard.exportfile.path");
 
    final Text textPath = new Text(panel,SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    textPath.setLayoutData(gridData);
    textPath.setText(((ExportTorrentWizard)wizard).getExportFile());
 
    Button browse = new Button(panel,SWT.PUSH);
    Messages.setLanguageText(browse, "exportTorrentWizard.exportfile.browse");
View Full Code Here

Examples of org.eclipse.swt.layout.GridData

  public void configSectionDelete() {
  }

  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) {
      Label label = new Label(cSection, SWT.WRAP);
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      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;
    }

    //////////////////////  PROXY GROUP /////////////////
   
    Group gProxyTracker = new Group(cSection, SWT.NULL);
    Messages.setLanguageText(gProxyTracker, CFG_PREFIX + "group.tracker");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gProxyTracker.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    gProxyTracker.setLayout(layout);
   
    final BooleanParameter enableProxy = new BooleanParameter(gProxyTracker,
        "Enable.Proxy", CFG_PREFIX + "enable_proxy");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    enableProxy.setLayoutData(gridData);

    final BooleanParameter enableSocks = new BooleanParameter(gProxyTracker,
        "Enable.SOCKS", CFG_PREFIX + "enable_socks");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    enableSocks.setLayoutData(gridData);

    Label lHost = new Label(gProxyTracker, SWT.NULL);
    Messages.setLanguageText(lHost, CFG_PREFIX + "host");
    StringParameter pHost = new StringParameter(gProxyTracker, "Proxy.Host", "");
    gridData = new GridData();
    gridData.widthHint = 105;
    pHost.setLayoutData(gridData);

    Label lPort = new Label(gProxyTracker, SWT.NULL);
    Messages.setLanguageText(lPort, CFG_PREFIX + "port");
    StringParameter pPort = new StringParameter(gProxyTracker, "Proxy.Port", "");
    gridData = new GridData();
    gridData.widthHint = 40;
    pPort.setLayoutData(gridData);

    Label lUser = new Label(gProxyTracker, SWT.NULL);
    Messages.setLanguageText(lUser, CFG_PREFIX + "username");
    StringParameter pUser = new StringParameter(gProxyTracker, "Proxy.Username" );
    gridData = new GridData();
    gridData.widthHint = 105;
    pUser.setLayoutData(gridData);

    Label lPass = new Label(gProxyTracker, SWT.NULL);
    Messages.setLanguageText(lPass, CFG_PREFIX + "password");
    StringParameter pPass = new StringParameter(gProxyTracker, "Proxy.Password", "");
    gridData = new GridData();
    gridData.widthHint = 105;
    pPass.setLayoutData(gridData);

    ////////////////////////////////////////////////
   
    Group gProxyPeer = new Group(cSection, SWT.NULL);
    Messages.setLanguageText(gProxyPeer, CFG_PREFIX + "group.peer");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gProxyPeer.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    gProxyPeer.setLayout(layout);

    final BooleanParameter enableSocksPeer = new BooleanParameter(gProxyPeer,
        "Proxy.Data.Enable", CFG_PREFIX + "enable_socks.peer");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    enableSocksPeer.setLayoutData(gridData);

    final BooleanParameter socksPeerInform = new BooleanParameter(gProxyPeer,
        "Proxy.Data.SOCKS.inform", CFG_PREFIX + "peer.informtracker");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    socksPeerInform.setLayoutData(gridData);

    Label lSocksVersion = new Label(gProxyPeer, SWT.NULL);
    Messages.setLanguageText(lSocksVersion, CFG_PREFIX + "socks.version");
    String[] socks_types = { "V4", "V4a", "V5" };
    String dropLabels[] = new String[socks_types.length];
    String dropValues[] = new String[socks_types.length];
    for (int i = 0; i < socks_types.length; i++) {
      dropLabels[i] = socks_types[i];
      dropValues[i] = socks_types[i];
    }
    final StringListParameter socksType = new StringListParameter(gProxyPeer,
        "Proxy.Data.SOCKS.version", "V4", dropLabels, dropValues);

    final BooleanParameter sameConfig = new BooleanParameter(gProxyPeer,
        "Proxy.Data.Same", CFG_PREFIX + "peer.same");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    sameConfig.setLayoutData(gridData);

    Label lDataHost = new Label(gProxyPeer, SWT.NULL);
    Messages.setLanguageText(lDataHost, CFG_PREFIX + "host");
    StringParameter pDataHost = new StringParameter(gProxyPeer,
        "Proxy.Data.Host", "");
    gridData = new GridData();
    gridData.widthHint = 105;
    pDataHost.setLayoutData(gridData);

    Label lDataPort = new Label(gProxyPeer, SWT.NULL);
    Messages.setLanguageText(lDataPort, CFG_PREFIX + "port");
    StringParameter pDataPort = new StringParameter(gProxyPeer,
        "Proxy.Data.Port", "");
    gridData = new GridData();
    gridData.widthHint = 40;
    pDataPort.setLayoutData(gridData);

    Label lDataUser = new Label(gProxyPeer, SWT.NULL);
    Messages.setLanguageText(lDataUser, CFG_PREFIX + "username");
    StringParameter pDataUser = new StringParameter(gProxyPeer,
        "Proxy.Data.Username");
    gridData = new GridData();
    gridData.widthHint = 105;
    pDataUser.setLayoutData(gridData);

    Label lDataPass = new Label(gProxyPeer, SWT.NULL);
    Messages.setLanguageText(lDataPass, CFG_PREFIX + "password");
    StringParameter pDataPass = new StringParameter(gProxyPeer,
        "Proxy.Data.Password", "");
    gridData = new GridData();
    gridData.widthHint = 105;
    pDataPass.setLayoutData(gridData);

    final Control[] proxy_controls = new Control[] { enableSocks.getControl(),
        lHost, pHost.getControl(), lPort, pPort.getControl(), lUser,
        pUser.getControl(), lPass, pPass.getControl(), };

    IAdditionalActionPerformer proxy_enabler = new GenericActionPerformer(
        new Control[] {}) {
      public void performAction() {
        for (int i = 0; i < proxy_controls.length; i++) {

          proxy_controls[i].setEnabled(enableProxy.isSelected());
        }
      }
    };

    final Control[] proxy_peer_controls = new Control[] { lDataHost,
        pDataHost.getControl(), lDataPort, pDataPort.getControl(), lDataUser,
        pDataUser.getControl(), lDataPass, pDataPass.getControl() };

    final Control[] proxy_peer_details = new Control[] {
        sameConfig.getControl(), socksPeerInform.getControl(),
        socksType.getControl(), lSocksVersion };

    IAdditionalActionPerformer proxy_peer_enabler = new GenericActionPerformer(
        new Control[] {}) {
      public void performAction() {
        for (int i = 0; i < proxy_peer_controls.length; i++) {

          proxy_peer_controls[i].setEnabled(enableSocksPeer.isSelected()
              && !sameConfig.isSelected());
        }

        for (int i = 0; i < proxy_peer_details.length; i++) {

          proxy_peer_details[i].setEnabled(enableSocksPeer.isSelected());
        }
      }
    };

    enableSocks.setAdditionalActionPerformer(proxy_enabler);
    enableProxy.setAdditionalActionPerformer(proxy_enabler);
    enableSocksPeer.setAdditionalActionPerformer(proxy_peer_enabler);
    sameConfig.setAdditionalActionPerformer(proxy_peer_enabler);

    final BooleanParameter checkOnStart = new BooleanParameter(cSection,
        "Proxy.Check.On.Start", CFG_PREFIX + "check.on.start");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    checkOnStart.setLayoutData(gridData);

    Label label = new Label(cSection, SWT.WRAP);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    label.setLayoutData(gridData);
    label.setText(MessageText.getString(CFG_PREFIX+"username.info" ));
   
    return cSection;
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.