Package org.eclipse.swt.layout

Examples of org.eclipse.swt.layout.GridData


  /**
   * Below the panel, taking up the entire width of the window, is the detail section
   */
  private void createDetailSection(IProgressReport pReport) {
    Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

    detailSection = new TwistieSection(this, TwistieLabel.NONE);
    detailSection.setTitle(MessageText.getString("Progress.reporting.action.label.detail"));
    Composite sectionContent = detailSection.getContent();

    detailSectionData = new GridData(SWT.FILL, SWT.FILL, true, true);
    detailSection.setLayoutData(detailSectionData);

    GridLayout sectionLayout = new GridLayout();
    sectionLayout.marginHeight = 0;
    sectionLayout.marginWidth = 0;
    sectionContent.setLayout(sectionLayout);
    detailSection.setEnabled(false);

    detailListWidget = new StyledText(sectionContent, SWT.BORDER | SWT.V_SCROLL
        | SWT.WRAP);
    detailListWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    /*
     * Add a default message instead of an empty box if there is no history;
     * remove this later when a real detail message arrive
     */
 
View Full Code Here


    }
   
    ((NewTorrentWizard)wizard).savePath = target_file;
   
    file.setText(((NewTorrentWizard)wizard).savePath);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    file.setLayoutData(gridData);
    Button browse = new Button(panel,SWT.PUSH);
    browse.addListener(SWT.Selection,new Listener() {
      /* (non-Javadoc)
       * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
       */
      public void handleEvent(Event arg0) {
        FileDialog fd = new FileDialog(wizard.getWizardWindow(),SWT.SAVE);
        final String path = ((NewTorrentWizard)wizard).savePath;
        if(wizard.getErrorMessage().equals("") && !path.equals("")) {
            File fsPath = new File(path);
            if(!path.endsWith(File.separator)) {
                fd.setFilterPath(fsPath.getParent());
                fd.setFileName(fsPath.getName());
            }
            else {
                fd.setFileName(path);
            }
        }
        String f = fd.open();
        if (f != null){
            file.setText(f);
           
            File  ff = new File(f);

            String  parent = ff.getParent();

            if ( parent != null )
                ((NewTorrentWizard) wizard).setDefaultSaveDir( parent );
          }
      }
    });  
    Messages.setLanguageText(browse,"wizard.browse");
      // ----------------------
   
    label = new Label(panel, SWT.SEPARATOR | SWT.HORIZONTAL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    label.setLayoutData(gridData);
 
    Composite gFileStuff = new Composite(panel, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 3;
    gFileStuff.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 4;
    gFileStuff.setLayout(layout);
   
      // file size
   
    label = new Label(gFileStuff, SWT.NULL);
    Messages.setLanguageText(label, "wizard.maketorrent.filesize");
   
    Label file_size_label = new Label(gFileStuff, SWT.NULL);
    file_size_label.setText( DisplayFormatters.formatByteCountToKiBEtc(file_size));
    label = new Label(gFileStuff, SWT.NULL);
    label = new Label(gFileStuff, SWT.NULL);
   
      // piece count
   
    label = new Label(gFileStuff, SWT.NULL);
    Messages.setLanguageText(label, "wizard.maketorrent.piececount");
   
    final Label piece_count_label = new Label(gFileStuff, SWT.NULL);
    piece_count_label.setText( ""+piece_count );
    label = new Label(gFileStuff, SWT.NULL);
    label = new Label(gFileStuff, SWT.NULL);
   
       // piece size
   
    label = new Label(gFileStuff, SWT.NULL);
    Messages.setLanguageText(label, "wizard.maketorrent.piecesize");
   
    final Label piece_size_label = new Label(gFileStuff, SWT.NULL);
    gridData = new GridData();
    gridData.widthHint = 75;
    piece_size_label.setLayoutData(gridData);
    piece_size_label.setText( DisplayFormatters.formatByteCountToKiBEtc( piece_size ));
   
    final Combo manual = new Combo(gFileStuff, SWT.SINGLE | SWT.READ_ONLY);
    final long[] sizes = TOTorrentFactory.STANDARD_PIECE_SIZES;
    manual.add( MessageText.getString( "wizard.maketorrent.auto"));
   
    for (int i=0;i<sizes.length;i++){
      manual.add(DisplayFormatters.formatByteCountToKiBEtc(sizes[i]));
    }
   
    manual.select(0);
   
    manual.addListener(SWT.Selection, new Listener() {
      public void
      handleEvent(
          Event e)
      {
        int  index = manual.getSelectionIndex();
       
        if ( index == 0 ){
         
          _wizard.setPieceSizeComputed();
         
          piece_size = TOTorrentFactory.getComputedPieceSize( file_size );
         
         }else{
          piece_size = sizes[index-1];
         
          _wizard.setPieceSizeManual(piece_size)
        }
       
        piece_count = TOTorrentFactory.getPieceCount( file_size, piece_size );
        piece_size_label.setText( DisplayFormatters.formatByteCountToKiBEtc(piece_size));
        piece_count_label.setText( ""+piece_count );
      }
    });
   
    label = new Label(gFileStuff, SWT.NULL);
   
    // ------------------------
    label = new Label(panel, SWT.SEPARATOR | SWT.HORIZONTAL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    label.setLayoutData(gridData);
   
    final Button bAutoOpen = new Button(panel,SWT.CHECK);
    Messages.setLanguageText(bAutoOpen,"wizard.maketorrents.autoopen");
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    bAutoOpen.setLayoutData(gridData);
   
    final Button bAutoHost = new Button(panel,SWT.CHECK);
    Messages.setLanguageText(bAutoHost,"wizard.maketorrents.autohost");
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    bAutoHost.setLayoutData(gridData);
    bAutoHost.setEnabled( false );
   
    bAutoOpen.addListener(SWT.Selection,new Listener() {
        public void handleEvent(Event event) {
          _wizard.autoOpen = bAutoOpen.getSelection();
         
          bAutoHost.setEnabled( _wizard.autoOpen && _wizard.getTrackerType() != NewTorrentWizard.TT_EXTERNAL );
        }
      });
   
    bAutoHost.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event event) {
        _wizard.autoHost = bAutoHost.getSelection();
      }
    });
   
    final Button bPrivateTorrent = new Button(panel,SWT.CHECK);
    Messages.setLanguageText(bPrivateTorrent,"ConfigView.section.sharing.privatetorrent");
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
  bPrivateTorrent.setLayoutData(gridData);
  
   
    final Button bAllowDHT = new Button(panel,SWT.CHECK);
    Messages.setLanguageText(bAllowDHT,"ConfigView.section.sharing.permitdht");
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    bAllowDHT.setLayoutData(gridData);
    bAllowDHT.setSelection( true );
   
    bAllowDHT.addListener(SWT.Selection,new Listener() {
View Full Code Here

    if (!Constants.isOSX) {
      ImageLoader imageLoader = ImageLoader.getInstance();
      imgOpenFolder = imageLoader.getImage("openFolderButton");     
    }

    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.marginWidth = 0;
    //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();
      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;
    }

    Composite cArea = new Composite(cSection, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 4;
    cArea.setLayout(layout);
    cArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    BooleanParameter d_play_sound = new BooleanParameter(cArea,
        "Play Download Finished", LBLKEY_PREFIX + "playdownloadfinished");

    // OS X counterpart for alerts (see below for what is disabled)
    if (Constants.isOSX) {
      // download info

      gridData = new GridData();
      gridData.horizontalSpan = 3;
      gridData.widthHint = 0;
      gridData.heightHint = 0;
      Composite d_filler = new Composite(cArea, SWT.NONE);
      d_filler.setSize(0, 0);
      d_filler.setLayoutData(gridData);

      final BooleanParameter d_speechEnabledParameter = new BooleanParameter(
          cArea, "Play Download Finished Announcement", LBLKEY_PREFIX
              + "playdownloadspeech");

      final StringParameter d_speechParameter = new StringParameter(cArea,
          "Play Download Finished Announcement Text");
      gridData = new GridData();
      gridData.horizontalSpan = 3;
      gridData.widthHint = 150;
      d_speechParameter.setLayoutData(gridData);
      ((Text) d_speechParameter.getControl()).setTextLimit(40);

      d_speechEnabledParameter.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          d_speechParameter.getControls()));

      final Label d_speechInfo = new Label(cArea, SWT.NONE);
      gridData = new GridData();
      gridData.horizontalSpan = 4;
      gridData.horizontalIndent = 24;
      d_speechInfo.setLayoutData(gridData);

      Messages.setLanguageText(d_speechInfo, LBLKEY_PREFIX
          + "playdownloadspeech.info");
    }

    //Option disabled on OS X, as impossible to make it work correctly
    if (!Constants.isOSX) {

      // download info

      gridData = new GridData(GridData.FILL_HORIZONTAL);

      final StringParameter d_pathParameter = new StringParameter(cArea,
          "Play Download Finished File", "");

      if (d_pathParameter.getValue().length() == 0) {

        d_pathParameter.setValue("<default>");
      }

      d_pathParameter.setLayoutData(gridData);

      Button d_browse = new Button(cArea, SWT.PUSH);

      d_browse.setImage(imgOpenFolder);

      imgOpenFolder.setBackground(d_browse.getBackground());

      d_browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));

      d_browse.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
          FileDialog dialog = new FileDialog(parent.getShell(),
              SWT.APPLICATION_MODAL);
          dialog.setFilterExtensions(new String[] { "*.wav"
          });
          dialog.setFilterNames(new String[] { "*.wav"
          });

          dialog.setText(MessageText.getString(INTERFACE_PREFIX + "wavlocation"));

          final String path = dialog.open();

          if (path != null) {

            d_pathParameter.setValue(path);

            new AEThread("SoundTest") {
              public void runSupport() {
                try {
                  Applet.newAudioClip(new File(path).toURL()).play();

                  Thread.sleep(2500);

                } catch (Throwable e) {

                }
              }
            }.start();
          }
        }
      });

      Label d_sound_info = new Label(cArea, SWT.WRAP);
      Messages.setLanguageText(d_sound_info, INTERFACE_PREFIX
          + "wavlocation.info");
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      gridData.widthHint = 100;
      d_sound_info.setLayoutData(gridData);

      d_play_sound.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          d_pathParameter.getControls()));
      d_play_sound.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          new Control[] {
            d_browse,
            d_sound_info
          }));

      //
    }

    BooleanParameter f_play_sound = new BooleanParameter(cArea,
        "Play File Finished", LBLKEY_PREFIX + "playfilefinished");

    // OS X counterpart for alerts (see below for what is disabled)

    if (Constants.isOSX) {

      // per-file info

      gridData = new GridData();
      gridData.horizontalSpan = 3;
      gridData.widthHint = 0;
      gridData.heightHint = 0;
      Composite f_filler = new Composite(cArea, SWT.NONE);
      f_filler.setSize(0, 0);
      f_filler.setLayoutData(gridData);

      final BooleanParameter f_speechEnabledParameter = new BooleanParameter(
          cArea, "Play File Finished Announcement", LBLKEY_PREFIX
              + "playfilespeech");

      final StringParameter f_speechParameter = new StringParameter(cArea,
          "Play File Finished Announcement Text");
      gridData = new GridData();
      gridData.horizontalSpan = 3;
      gridData.widthHint = 150;
      f_speechParameter.setLayoutData(gridData);
      ((Text) f_speechParameter.getControl()).setTextLimit(40);

      f_speechEnabledParameter.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          f_speechParameter.getControls()));

      final Label speechInfo = new Label(cArea, SWT.NONE);
      gridData = new GridData();
      gridData.horizontalSpan = 4;
      gridData.horizontalIndent = 24;
      speechInfo.setLayoutData(gridData);

      Messages.setLanguageText(speechInfo, LBLKEY_PREFIX
          + "playfilespeech.info");
    }

    //Option disabled on OS X, as impossible to make it work correctly
    if (!Constants.isOSX) {

      // file info

      gridData = new GridData(GridData.FILL_HORIZONTAL);

      final StringParameter f_pathParameter = new StringParameter(cArea,
          "Play File Finished File", "");

      if (f_pathParameter.getValue().length() == 0) {

        f_pathParameter.setValue("<default>");
      }

      f_pathParameter.setLayoutData(gridData);

      Button f_browse = new Button(cArea, SWT.PUSH);

      f_browse.setImage(imgOpenFolder);

      imgOpenFolder.setBackground(f_browse.getBackground());

      f_browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));

      f_browse.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
          FileDialog dialog = new FileDialog(parent.getShell(),
              SWT.APPLICATION_MODAL);
          dialog.setFilterExtensions(new String[] { "*.wav"
          });
          dialog.setFilterNames(new String[] { "*.wav"
          });

          dialog.setText(MessageText.getString(INTERFACE_PREFIX + "wavlocation"));

          final String path = dialog.open();

          if (path != null) {

            f_pathParameter.setValue(path);

            new AEThread("SoundTest") {
              public void runSupport() {
                try {
                  Applet.newAudioClip(new File(path).toURL()).play();

                  Thread.sleep(2500);

                } catch (Throwable e) {

                }
              }
            }.start();
          }
        }
      });

      Label f_sound_info = new Label(cArea, SWT.WRAP);
      Messages.setLanguageText(f_sound_info, INTERFACE_PREFIX
          + "wavlocation.info");
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      gridData.widthHint = 100;
      f_sound_info.setLayoutData(gridData);

      f_play_sound.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          f_pathParameter.getControls()));
      f_play_sound.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          new Control[] {
            f_browse,
            f_sound_info
          }));
    }

    cArea = new Composite(cSection, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    cArea.setLayout(layout);
    cArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    BooleanParameter popup_dl_added = new BooleanParameter(cArea,
        "Popup Download Added", LBLKEY_PREFIX + "popupdownloadadded");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    popup_dl_added.setLayoutData(gridData);
   
    BooleanParameter popup_dl_completed = new BooleanParameter(cArea,
        "Popup Download Finished", LBLKEY_PREFIX + "popupdownloadfinished");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    popup_dl_completed.setLayoutData(gridData);

    BooleanParameter popup_file_completed = new BooleanParameter(cArea,
        "Popup File Finished", LBLKEY_PREFIX + "popupfilefinished");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    popup_file_completed.setLayoutData(gridData);

    BooleanParameter disable_sliding = new BooleanParameter(cArea,
        "GUI_SWT_DisableAlertSliding", STYLE_PREFIX + "disableAlertSliding");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    disable_sliding.setLayoutData(gridData);

    // Timestamps for popup alerts.
    BooleanParameter show_alert_timestamps = new BooleanParameter(cArea,
        "Show Timestamp For Alerts", LBLKEY_PREFIX + "popup.timestamp");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    show_alert_timestamps.setLayoutData(gridData);

    // Auto-hide popup setting.
    Label label = new Label(cArea, SWT.WRAP);
    Messages.setLanguageText(label, LBLKEY_PREFIX + "popup.autohide");
    label.setLayoutData(new GridData());
    IntParameter auto_hide_alert = new IntParameter(cArea,
        "Message Popup Autoclose in Seconds", 0, 86400);
    gridData = new GridData();
    gridData.horizontalSpan = 1;
    auto_hide_alert.setLayoutData(gridData);
   
    return cSection;
  }
View Full Code Here

    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);

    //Line :
    // Web Seed Configuration
   
    final Label labelTitle = new Label(panel,SWT.NULL);
    Messages.setLanguageText(labelTitle, "wizard.webseed.configuration");
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    labelTitle.setLayoutData(gridData)
   
    configList = new Combo(panel,SWT.READ_ONLY);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    configList.setLayoutData(gridData);
    configList.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event e) {               
        updateWebSeeds();
        refreshDetails();
      }
    });
          
    btnNew = new Button(panel, SWT.PUSH);  
    Messages.setLanguageText(btnNew, "wizard.multitracker.new");
    gridData = new GridData();
    gridData.widthHint = 100;
    btnNew.setLayoutData(gridData);
    btnNew.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event e) {
      Map webseeds = new HashMap();
         webseeds.put( "getright", new ArrayList());
         webseeds.put( "webseed", new ArrayList());
        new WebSeedsEditor(null,webseeds,WebSeedPanel.this);
      }
    });
   
    btnEdit = new Button(panel, SWT.PUSH);  
    Messages.setLanguageText(btnEdit, "wizard.multitracker.edit");
    gridData = new GridData();
    gridData.widthHint = 100;
    btnEdit.setLayoutData(gridData);
    btnEdit.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event e) {
        int selection = configList.getSelectionIndex();
        String selected = configList.getItem(selection);
        Map webseeds = TrackersUtil.getInstance().getWebSeeds();
        new WebSeedsEditor(selected,(Map)webseeds.get(selected),WebSeedPanel.this);
      }
    });
   
    btnDelete = new Button(panel, SWT.PUSH);  
    Messages.setLanguageText(btnDelete, "wizard.multitracker.delete");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gridData.widthHint = 100;   
    btnDelete.setLayoutData(gridData);
    btnDelete.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event e) {
        int selection = configList.getSelectionIndex();
        String selected = configList.getItem(selection);
        TrackersUtil.getInstance().removeWebSeed(selected);
        refreshList("");
        refreshDetails();
        setEditDeleteEnable();
      }
    });
    final Label labelSeparator = new Label(panel,SWT.SEPARATOR | SWT.HORIZONTAL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    labelSeparator.setLayoutData(gridData);
   
    configDetails = new Tree(panel,SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.heightHint = 150;
    gridData.horizontalSpan = 3;
    configDetails.setLayoutData(gridData);   
   
    refreshList(((NewTorrentWizard)wizard).webSeedConfig);
View Full Code Here

        c5.setLayoutData(gridData);

    }

    private void createResultData(Composite panel,String label, int rate){
        GridData gridData;

        //spacer column
        Label c1 = new Label(panel, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        c1.setLayoutData(gridData);

        //label
        Label c2 = new Label(panel, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        gridData.horizontalAlignment = GridData.END;
        c2.setLayoutData(gridData);
        c2.setText( label );


        //bytes
        Label c3 = new Label(panel, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        gridData.horizontalAlignment = GridData.CENTER;
        c3.setLayoutData(gridData);
        c3.setText( DisplayFormatters.formatByteCountToKiBEtcPerSec(rate) );

        //bits
        Label c4 = new Label(panel, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        gridData.horizontalAlignment = GridData.CENTER;
        c4.setLayoutData(gridData);
        c4.setText( DisplayFormatters.formatByteCountToBitsPerSec(rate) );

        //spacer column
        Label c5 = new Label(panel, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        c5.setLayoutData(gridData);
    }
View Full Code Here

    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.torrentfile.message");
 
    label = new Label(panel,SWT.NULL);
    Messages.setLanguageText(label, "exportTorrentWizard.torrentfile.path");
 
    final Text textPath = new Text(panel,SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    textPath.setLayoutData(gridData);
    textPath.setText("");
 
    Button browse = new Button(panel,SWT.PUSH);
    Messages.setLanguageText(browse, "exportTorrentWizard.torrentfile.browse");
View Full Code Here

    sc = new ScrolledComposite(composite, SWT.V_SCROLL | SWT.H_SCROLL );
    sc.getVerticalBar().setIncrement(16);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true, 1, 1);
    sc.setLayoutData(gridData)
   
    outer_panel = sc;
   
    Composite panel = new Composite(sc, SWT.NULL);
   
    sc.setContent( panel );
   
   
   
    GridLayout  layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 1;
    panel.setLayout(layout);

    //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 = 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);
    lHeader.setText( " " + MessageText.getString( "authenticator.torrent" ) + " : " + download_manager.getDisplayName().replaceAll("&", "&&"));
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
    lHeader.setLayoutData(gridData);
   
    Composite gTorrentInfo = new Composite(panel, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    gTorrentInfo.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    gTorrentInfo.setLayout(layout);

      // torrent encoding
   
   
    Label label = new Label(gTorrentInfo, SWT.NULL);
    gridData = new GridData();
    label.setLayoutData( gridData );
    label.setText( MessageText.getString( TEXT_PREFIX + "torrent.encoding" ) + ": " );

    TOTorrent  torrent = download_manager.getTorrent();
    BufferedLabel blabel = new BufferedLabel(gTorrentInfo, SWT.NULL);
    gridData = new GridData();
   
    blabel.setLayoutData( gridData );
    blabel.setText(torrent==null?"":LocaleTorrentUtil.getCurrentTorrentEncoding( torrent ));
   
      // trackers
   
    label = new Label(gTorrentInfo, SWT.NULL);
    gridData = new GridData();
    label.setLayoutData( gridData );
    label.setText( MessageText.getString( "MyTrackerView.tracker" ) + ": " );

    String  trackers = "";
   
    if ( torrent != null ){
     
      TOTorrentAnnounceURLGroup group = torrent.getAnnounceURLGroup();
     
      TOTorrentAnnounceURLSet[]  sets = group.getAnnounceURLSets();
     
      List  tracker_list = new ArrayList();
     
      URL  url = torrent.getAnnounceURL();
     
      tracker_list.add( url.getHost() + (url.getPort()==-1?"":(":"+url.getPort())));
       
      for (int i=0;i<sets.length;i++){
                   
        TOTorrentAnnounceURLSet  set = sets[i];
       
        URL[]  urls = set.getAnnounceURLs();
       
        for (int j=0;j<urls.length;j++){
       
          url = urls[j];
         
          String  str = url.getHost() + (url.getPort()==-1?"":(":"+url.getPort()));
         
          if ( !tracker_list.contains(str )){
           
            tracker_list.add(str);
          }
        }
      }
       
      TRTrackerAnnouncer announcer = download_manager.getTrackerClient();
     
      URL  active_url = null;
     
      if ( announcer != null ){
       
        active_url = announcer.getTrackerURL();
       
      }else{
       
        TRTrackerScraperResponse scrape = download_manager.getTrackerScrapeResponse();
       
        if ( scrape != null ){
         
          active_url = scrape.getURL();
        }
      }
     
      if ( active_url == null ){
       
        active_url = torrent.getAnnounceURL();
      }
     
      trackers = active_url.getHost() + (active_url.getPort()==-1?"":(":"+active_url.getPort()));
   
      tracker_list.remove( trackers );
     
      if ( tracker_list.size() > 0 ){
       
        trackers += " (";
       
        for (int i=0;i<tracker_list.size();i++){
         
          trackers += (i==0?"":", ") + tracker_list.get(i);
        }
       
        trackers += ")";
      }
    }
   
    blabel = new BufferedLabel(gTorrentInfo, SWT.NULL);
    gridData = new GridData();
    blabel.setLayoutData( gridData );
    blabel.setText( trackers );

   
      // columns
        
    Group gColumns = new Group(panel, SWT.NULL);
    Messages.setLanguageText(gColumns, TEXT_PREFIX + "columns" );
    gridData = new GridData(GridData.FILL_BOTH);
    gColumns.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 4;
    gColumns.setLayout(layout);
   
    Map<String, FakeTableCell>  usable_cols = new HashMap<String, FakeTableCell>();
   
    TableColumnManager col_man = TableColumnManager.getInstance();
   
    TableColumnCore[][] cols_sets = {
      col_man.getAllTableColumnCoreAsArray(DownloadTypeIncomplete.class,
          TableManager.TABLE_MYTORRENTS_INCOMPLETE),
      col_man.getAllTableColumnCoreAsArray(DownloadTypeComplete.class,
          TableManager.TABLE_MYTORRENTS_COMPLETE),
    };
       
    for (int i=0;i<cols_sets.length;i++){
     
      TableColumnCore[]  cols = cols_sets[i];
     
      for (int j=0;j<cols.length;j++){
       
        TableColumnCore  col = cols[j];
       
        String id = col.getName();
     
        if (usable_cols.containsKey(id)) {
         
          continue;
        }
       
        FakeTableCell fakeTableCell = null;
        try {
          fakeTableCell = new FakeTableCell(col);
          fakeTableCell.setOrentation(SWT.LEFT);
          fakeTableCell.setWrapText(false);
          fakeTableCell.setDataSource(download_manager);
          col.invokeCellAddedListeners(fakeTableCell);
          // One refresh to see if it throws up
          fakeTableCell.refresh();
          usable_cols.put(id, fakeTableCell);
        } catch (Throwable t) {
          //System.out.println("not usable col: " + id + " - " + Debug.getCompressedStackTrace());
          try {
            if (fakeTableCell != null) {
              fakeTableCell.dispose();
            }
          } catch (Throwable t2) {
            //ignore;
          }
        }
      }
    }
   
    Collection<FakeTableCell> values = usable_cols.values();
   
    cells = new FakeTableCell[values.size()];
   
    values.toArray( cells );
   
    Arrays.sort(
        cells,
        new Comparator<FakeTableCell>()
        {
          public int compare(FakeTableCell o1, FakeTableCell o2) {
            TableColumnCore  c1 = (TableColumnCore) o1.getTableColumn();
            TableColumnCore  c2 = (TableColumnCore) o2.getTableColumn();

            String key1 = MessageText.getString(c1.getTitleLanguageKey());
            String key2 = MessageText.getString(c2.getTitleLanguageKey());
           
            return key1.compareToIgnoreCase(key2);
          }
        });
           
    for (int i=0;i<cells.length;i++){
     
      final FakeTableCell  cell = cells[i];
     
      label = new Label(gColumns, SWT.NULL);
      gridData = new GridData();
      if ( i%2 == 1 ){
        gridData.horizontalIndent = 16;
      }
      label.setLayoutData( gridData );
      String key = ((TableColumnCore) cell.getTableColumn()).getTitleLanguageKey();
      label.setText(MessageText.getString(key) + ": ");
      label.setToolTipText(MessageText.getString(key + ".info", ""));

      final Composite c = new Composite(gColumns, SWT.NONE);
      gridData = new GridData( GridData.FILL_HORIZONTAL);
      gridData.heightHint = 16;
      c.setLayoutData(gridData);
      cell.setControl(c);
      cell.invalidate();
      cell.refresh();
View Full Code Here

      Messages.setLanguageText(lblNotAvail, "core.not.available");
      return cSection;
    }

    GridLayout layout;
    GridData gridData;

    Label label;
   
    ImageLoader imageLoader = ImageLoader.getInstance();
    imgRedLed = imageLoader.getImage("redled");
    imgGreenLed = imageLoader.getImage("greenled");

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

    infoGroup.setLayout(new GridLayout());

    String sep = System.getProperty("file.separator");

    File fUserPluginDir = FileUtil.getUserFile("plugins");
   
    String sUserPluginDir;
   
    try{
      sUserPluginDir = fUserPluginDir.getCanonicalPath();
    }catch( Throwable e ){
      sUserPluginDir = fUserPluginDir.toString();
    }
   
    if (!sUserPluginDir.endsWith(sep)) {
      sUserPluginDir += sep;
    }

    File fAppPluginDir = FileUtil.getApplicationFile("plugins");
   
    String sAppPluginDir;
   
    try{
      sAppPluginDir = fAppPluginDir.getCanonicalPath();
    }catch( Throwable e ){
      sAppPluginDir = fAppPluginDir.toString();
    }

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

    label = new Label(infoGroup, SWT.WRAP);
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Messages.setLanguageText(label, "ConfigView.pluginlist.whereToPut");

    label = new Label(infoGroup, SWT.WRAP);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalIndent = 10;
    label.setLayoutData(gridData);
    label.setText(sUserPluginDir.replaceAll("&", "&&"));
    label.setForeground(Colors.blue);
    label.setCursor(label.getDisplay().getSystemCursor(SWT.CURSOR_HAND));

    final String _sUserPluginDir = sUserPluginDir;

    label.addMouseListener(new MouseAdapter() {
      public void mouseUp(MouseEvent arg0) {
        if (_sUserPluginDir.endsWith("/plugins/")
            || _sUserPluginDir.endsWith("\\plugins\\")) {
          File f = new File(_sUserPluginDir);
          String dir = _sUserPluginDir;
          if (!(f.exists() && f.isDirectory())) {
            dir = _sUserPluginDir.substring(0, _sUserPluginDir
                .length() - 9);
          }
          Utils.launch(dir);
        }
      }
    });

    label = new Label(infoGroup, SWT.WRAP);
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Messages.setLanguageText(label, "ConfigView.pluginlist.whereToPutOr");

    label = new Label(infoGroup, SWT.WRAP);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalIndent = 10;
    label.setLayoutData(gridData);
    label.setText(sAppPluginDir.replaceAll("&", "&&"));
    label.setForeground(Colors.blue);
    label.setCursor(label.getDisplay().getSystemCursor(SWT.CURSOR_HAND));

    final String _sAppPluginDir = sAppPluginDir;

    //TODO : Fix it for windows
    label.addMouseListener(new MouseAdapter() {
      public void mouseUp(MouseEvent arg0) {
        if (_sAppPluginDir.endsWith("/plugins/")
            || _sAppPluginDir.endsWith("\\plugins\\")) {
          File f = new File(_sAppPluginDir);
          if (f.exists() && f.isDirectory()) {
            Utils.launch(_sAppPluginDir);
          } else {
            String azureusDir = _sAppPluginDir.substring(0, _sAppPluginDir
                .length() - 9);
            System.out.println(azureusDir);
            Utils.launch(azureusDir);
          }
        }
      }
    });

    pluginIFs = rebuildPluginIFs();

    Collections.sort(pluginIFs, new Comparator() {
      public int compare(Object o1, Object o2) {
        return (((PluginInterface) o1).getPluginName()
            .compareToIgnoreCase(((PluginInterface) o2).getPluginName()));
      }
    });

    Label labelInfo = new Label(infoGroup, SWT.WRAP);
    labelInfo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Messages.setLanguageText(labelInfo, "ConfigView.pluginlist.info");

    table = new Table(infoGroup, SWT.BORDER | SWT.SINGLE | SWT.CHECK
        | SWT.VIRTUAL | SWT.FULL_SELECTION);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 200;
    gridData.widthHint = 200;
    table.setLayoutData(gridData);
    for (int i = 0; i < COLUMN_HEADERS.length; i++) {
      final TableColumn tc = new TableColumn(table, COLUMN_ALIGNS[i]);
      tc.setWidth(COLUMN_SIZES[i]);
      tc.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
          boolean ascending = comparator.setField(table.indexOf(tc));
          try {
            table.setSortColumn(tc);
            table.setSortDirection(ascending ? SWT.UP : SWT.DOWN);
          } catch (NoSuchMethodError ignore) {
            // Ignore Pre 3.0
          }
          Collections.sort(pluginIFs, comparator);
          table.clearAll();
        }
      });
      Messages.setLanguageText(tc, HEADER_PREFIX + COLUMN_HEADERS[i]);
    }
    table.setHeaderVisible(true);
   
    Composite cButtons = new Composite(infoGroup, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 3;
    cButtons.setLayout(layout);
    cButtons.setLayoutData(new GridData());
   
    final Button btnUnload = new Button(cButtons, SWT.PUSH);
    btnUnload.setLayoutData(new GridData());
    Messages.setLanguageText(btnUnload, "ConfigView.pluginlist.unloadSelected");
    btnUnload.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        final int[] items = table.getSelectionIndices();

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

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

        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;
        layout.makeColumnsEqualWidth=true;
        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,"SpeedTestWizard.finish.panel.click.close");

        //show the setting for upload speed
        SpeedManagerLimitEstimate upEst = speedManager.getEstimatedUploadCapacityBytesPerSec();
        int maxUploadKbs = upEst.getBytesPerSec()/1024;
        SpeedManagerLimitEstimate downEst = speedManager.getEstimatedDownloadCapacityBytesPerSec();
        int maxDownloadKbs = downEst.getBytesPerSec()/1024;

        //boolean setting.
        boolean autoSpeedEnabled = COConfigurationManager.getBooleanParameter( TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY );
        boolean autoSpeedSeedingEnabled = COConfigurationManager.getBooleanParameter( TransferSpeedValidator.AUTO_UPLOAD_SEEDING_ENABLED_CONFIGKEY );

        //spacer 2
        Label s2 = new Label(panel, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan = 3;
        s2.setLayoutData(gridData);

        String autoSpeed = MessageText.getString("SpeedTestWizard.finish.panel.auto.speed");
        createStatusLine(panel, autoSpeed, autoSpeedEnabled);

        String autoSpeedWhileSeeding = MessageText.getString("SpeedTestWizard.finish.panel.auto.speed.seeding");
        createStatusLine(panel, autoSpeedWhileSeeding, autoSpeedSeedingEnabled);

        //spacer 1
        Label s1 = new Label(panel, SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan = 3;
        s1.setLayoutData(gridData);

        //displays a bytes/sec column and a bits/sec column
        createHeaderLine(panel);
View Full Code Here

    }//show

    //private static final String colSpace = "  ";

    private void createHeaderLine(Composite panel){
        GridData gridData;
        Label c1 = new Label(panel, SWT.NULL);//label
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        c1.setLayoutData(gridData);
        c1.setText(" ");


        Label c2 = new Label(panel,SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        gridData.horizontalAlignment = GridData.CENTER;
        c2.setLayoutData(gridData);
        c2.setText( MessageText.getString("SpeedTestWizard.set.upload.bytes.per.sec") );


        Label c3 = new Label(panel,SWT.NULL);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        gridData.horizontalAlignment = GridData.BEGINNING;
        c3.setLayoutData(gridData);
        c3.setText( MessageText.getString("SpeedTestWizard.set.upload.bits.per.sec") );
    }
View Full Code Here

TOP

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

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.