Examples of SelectionAdapter


Examples of org.eclipse.swt.events.SelectionAdapter

      start_button = new Button( control, SWT.PUSH );
       
       Messages.setLanguageText( start_button, "ConfigView.section.start");
      
       start_button.addSelectionListener(
         new SelectionAdapter()
         {
           public void
           widgetSelected(
             SelectionEvent e )
           {
             start_button.setEnabled( false );
            
             cancel_button.setEnabled( true );
            
             startTest();
           }
         });
      
         // cancel
      
       cancel_button = new Button( control, SWT.PUSH );
      
       Messages.setLanguageText( cancel_button, "UpdateWindow.cancel");
      
       cancel_button.addSelectionListener(
         new SelectionAdapter()
         {
           public void
           widgetSelected(
             SelectionEvent e )
           {
View Full Code Here

Examples of org.eclipse.swt.events.SelectionAdapter

    Menu menuBrowserTB = new Menu(menuDebug.getParent(), SWT.DROP_DOWN);
    item.setMenu(menuBrowserTB);

    item = new MenuItem(menuBrowserTB, SWT.NONE);
    item.setText("popup check");
    item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        boolean oldDebug = DonationWindow.DEBUG;
        DonationWindow.DEBUG = true;
        DonationWindow.checkForDonationPopup();
        DonationWindow.DEBUG = oldDebug;
      }
    });
    item = new MenuItem(menuBrowserTB, SWT.NONE);
    item.setText("show");
    item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        boolean oldDebug = DonationWindow.DEBUG;
        DonationWindow.DEBUG = true;
        DonationWindow.open(true, "debug");
        DonationWindow.DEBUG = oldDebug;
      }
    });

    item = new MenuItem(menuDebug, SWT.NONE);
    item.setText("Alerts");
    item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        String text = "This is a  long message with lots of information and "
            + "stuff you really should read.  Are you still reading? Good, because "
            + "reading <a href=\"http://moo.com\">stimulates</a> the mind.\n\nYeah Baby.";

        LogAlert logAlert = new LogAlert(true, LogAlert.AT_INFORMATION, "Simple");
        Logger.log(logAlert);
        logAlert = new LogAlert(true, LogAlert.AT_WARNING, text);
        logAlert.details = "Details: \n\n" + text;
        Logger.log(logAlert);
        logAlert = new LogAlert(true, LogAlert.AT_ERROR, "ShortText");
        logAlert.details = "Details";
        Logger.log(logAlert);
      }
    });

    item = new MenuItem(menuDebug, SWT.NONE);
    item.setText("MsgBox");
    item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        VuzeMessageBox box = new VuzeMessageBox("Title", "Text", new String[] { "Ok", "Cancel" }, 0);
        box.setListener(new VuzeMessageBoxListener() {
          public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
            SWTSkin skin = soExtra.getSkin();
            skin.createSkinObject("dlg.generic.test", "dlg.generic.test", soExtra);
            skin.layout(soExtra);
            shell.layout(true, true);
          }
        });
        box.open(null);
      }
    });

    item = new MenuItem(menuDebug, SWT.CASCADE);
    item.setText("Size");
    Menu menuSize = new Menu(menuDebug.getParent(), SWT.DROP_DOWN);
    item.setMenu(menuSize);

    int[] sizes = {
      640, 430,
      800, 550,
      1024, 718,
      1280, 700,
    };
    for (int i = 0; i < sizes.length; i += 2) {
      final int x = sizes[i];
      final int y = sizes[i + 1];
      item = new MenuItem(menuSize, SWT.NONE);
      item.setText("" + x + "," + y);
      item.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
          UIFunctionsManagerSWT.getUIFunctionsSWT().getMainShell().setSize(x, y);
        }
      });
    }
View Full Code Here

Examples of org.eclipse.swt.events.SelectionAdapter

    min_file_size_units.setData("KB", 1024 * 1024L);
    min_file_size_units.setData("MB", 1024 * 1024 * 1024L);
    min_file_size_units.setData("GB", 1024 * 1024 * 1024 * 1024L);
    min_file_size_units.select(0);
   
    min_file_size_units.addSelectionListener(new SelectionAdapter() {

      public void widgetSelected(SelectionEvent arg0) {
        updated_file_size = true;
      }
     
    });
   
    layout_data = new GridData();
    layout_data.grabExcessHorizontalSpace = true;
    layout_data.horizontalAlignment = GridData.FILL;
    new Label(file_size_options,SWT.NONE).setLayoutData(layout_data);
   
    label = new Label(file_size_options,SWT.NONE);
    label.setText(_._("advancedsearchwindow.label.max_size") + " : ");
   
    max_file_size = new Text(file_size_options,SWT.BORDER);
   
    max_file_size.addVerifyListener(new VerifyListener() {     
      public void verifyText(VerifyEvent e) {
        try {
          String str = max_file_size.getText().substring(0, e.start)+e.text+max_file_size.getText().substring(e.end);
          double value = Double.parseDouble(str);
          double x = (100 * value) / 1024D;
         
          if (x>100) {
            e.doit = false;
            return ;
          }
         
          long min_unit = (Long)min_file_size_units.getData(min_file_size_units.getText());
          long max_unit = (Long)max_file_size_units.getData(max_file_size_units.getText());
          double min = formatSize(file_size_slider.getDownValue(), min_unit);
          double max = formatSize(x, max_unit);
          if (min>max) { e.doit = false; return ;}
          e.doit = true;
          file_size_slider.setUpValue(x);       
        }catch(Exception t) {
          e.doit = false;
        }
      }
    });
   
    max_file_size_units = new Combo(file_size_options,SWT.READ_ONLY);
    max_file_size_units.add("Bytes");
    max_file_size_units.add("KB");
    max_file_size_units.add("MB");
    max_file_size_units.add("GB");
   
    max_file_size_units.setData("Bytes", 1024L);
    max_file_size_units.setData("KB", 1024 * 1024L);
    max_file_size_units.setData("MB", 1024 * 1024 * 1024L);
    max_file_size_units.setData("GB", 1024 * 1024 * 1024 * 1024L);
    max_file_size_units.select(0);
   
    max_file_size_units.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        updated_file_size = true;
      }
    });
   
    Composite slider_composite = new Composite(shell,SWT.NONE);
    layout_data = new GridData();
    layout_data.grabExcessHorizontalSpace = true;
    layout_data.horizontalAlignment = GridData.FILL;
    slider_composite.setLayoutData(layout_data);
    slider_composite.setLayout(new GridLayout(1,true));
    file_size_slider = new ExSlider(slider_composite){
      public boolean validate(double upValue, double downValue) {
        long min_unit = (Long)min_file_size_units.getData(min_file_size_units.getText());
        long max_unit = (Long)max_file_size_units.getData(max_file_size_units.getText());
        double min = formatSize(downValue, min_unit);
        double max = formatSize(upValue, max_unit);
       
        return max>min;
      }
    };
   
    file_size_slider.setBarBackgroundColor(SWTThread.getDisplay().getSystemColor(SWT.COLOR_BLUE));
    file_size_slider.setBarUsedSegmentColor(SWTThread.getDisplay().getSystemColor(SWT.COLOR_RED));
    file_size_slider.setPointerColor(SWTThread.getDisplay().getSystemColor(SWT.COLOR_BLACK));
   
    file_size_slider.setUpValue(0);
    file_size_slider.setUpValue(100);
   
    layout_data = new GridData(GridData.FILL_HORIZONTAL);
    layout_data.heightHint = 30;
    file_size_slider.setLayoutData(layout_data);
   
    file_size_slider.addModifyListener(new ExSliderModifyListener() {

      public void downValueChanged(double downValue) {
        updated_file_size = true;
        DecimalFormat formatter = new DecimalFormat("0.00");
       
        downValue = Math.round(downValue);
        double u = 1024 / 100D;
       
        min_file_size.setText(formatter.format(u * downValue));
       
      }

      public void upValueChanged(double upValue) {
        updated_file_size = true;
        DecimalFormat formatter = new DecimalFormat("0.00");
       
        upValue = Math.round(upValue);
        double u = 1024 / 100D;
       
        max_file_size.setText(formatter.format(u * upValue));
      }
    });
       
    Composite options_composite = new Composite(shell,SWT.NONE);
    layout_data = new GridData();
    layout_data.grabExcessHorizontalSpace = true;
    layout_data.horizontalAlignment = GridData.FILL;
    options_composite.setLayoutData(layout_data);
    options_composite.setLayout(new GridLayout(4,false));
   
    label = new Label(options_composite,SWT.NONE);
    label.setText("File type : ");
    layout_data = new GridData();
    layout_data.horizontalAlignment = SWT.RIGHT;
    label.setLayoutData(layout_data);
   
    file_type = new Combo(options_composite,SWT.READ_ONLY);
    // must be same order as filetypes
    file_type.add(_._("advancedsearchwindow.file_type.any"));
    file_type.add(_._("advancedsearchwindow.file_type.archive"));
    file_type.add(_._("advancedsearchwindow.file_type.audio"));
    file_type.add(_._("advancedsearchwindow.file_type.cd_image"));
    file_type.add(_._("advancedsearchwindow.file_type.document"));
    file_type.add(_._("advancedsearchwindow.file_type.pictures"));
    file_type.add(_._("advancedsearchwindow.file_type.program"));
    file_type.add(_._("advancedsearchwindow.file_type.video"));
   
    file_type.select(0);
    file_type.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout_data = new GridData();
    file_type.setLayoutData(layout_data);
       
    label = new Label(options_composite,SWT.NONE);
    label.setText(_._("advancedsearchwindow.label.extension") + " : ");
    layout_data = new GridData();
    layout_data.horizontalAlignment = SWT.RIGHT;
    label.setLayoutData(layout_data);
   
    file_extension = new Text(options_composite,SWT.BORDER);
   
    label = new Label(options_composite,SWT.NONE);
    label.setText(_._("advancedsearchwindow.label.availability") + " : ");
    layout_data = new GridData();
    layout_data.horizontalAlignment = SWT.RIGHT;
    label.setLayoutData(layout_data);
   
    av_spinner = new Spinner(options_composite,SWT.BORDER);
    av_spinner.setMaximum(1000);
   
    label = new Label(options_composite,SWT.NONE);
    label.setText(_._("advancedsearchwindow.label.complete_sources") + " : ");
    layout_data = new GridData();
    layout_data.horizontalAlignment = SWT.RIGHT;
    label.setLayoutData(layout_data);
    cmp_src_spinner = new Spinner(options_composite,SWT.BORDER);
    cmp_src_spinner.setMaximum(1000);
   
   
    Composite button_composite = new Composite(shell,SWT.BORDER);
    layout_data = new GridData();
    layout_data.verticalAlignment = GridData.END;
    layout_data.horizontalAlignment = GridData.FILL;
    layout_data.grabExcessHorizontalSpace = true;
    layout_data.grabExcessVerticalSpace=true;
    button_composite.setLayoutData(layout_data);
   
    layout = new GridLayout(3,false);
    button_composite.setLayout(layout);
   
    Button button_clear = new Button(button_composite,SWT.NONE);
    button_clear.setText(_._("advancedsearchwindow.button.clear"));
    button_clear.setImage(SWTImageRepository.getImage("remove_all.png"));
    button_clear.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        min_file_size.setText("0.0");
        min_file_size_units.select(0);
       
        max_file_size.setText("1024.00");
        max_file_size_units.select(0);
       
        file_extension.setText("");
        file_type.select(0);
       
        av_spinner.setSelection(0);
        cmp_src_spinner.setSelection(0);
       
        updated_file_size = false;
      }
    });
   
    Button button_ok = new Button(button_composite,SWT.NONE);
    button_ok.setText(_._("advancedsearchwindow.button.ok"));
    button_ok.setImage(skin.getButtonImage(Skin.OK_BUTTON_IMAGE));
   
    layout_data = new GridData();
    layout_data.grabExcessHorizontalSpace=true;
    layout_data.horizontalAlignment = SWT.RIGHT;
    button_ok.setLayoutData(layout_data);
   
    button_ok.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        long min_unit = (Long)min_file_size_units.getData(min_file_size_units.getText());
        long max_unit = (Long)max_file_size_units.getData(max_file_size_units.getText());
        double min = formatSize(file_size_slider.getDownValue(), min_unit);
        double max = formatSize(file_size_slider.getUpValue(), max_unit);
        if (updated_file_size)
          save((long)min, (long)max, file_types[file_type.getSelectionIndex()],file_extension.getText(), av_spinner.getSelection(), cmp_src_spinner.getSelection());
        else
          save((long)0, (long)0, file_types[file_type.getSelectionIndex()],file_extension.getText(), av_spinner.getSelection(), cmp_src_spinner.getSelection());
        shell.close();
      }
    });
   
    Button button_cancel = new Button(button_composite,SWT.NONE);
    button_cancel.setText(_._("advancedsearchwindow.button.cancel"));
    button_cancel.setImage(skin.getButtonImage(Skin.CANCEL_BUTTON_IMAGE));
    button_cancel.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        shell.close();
      }
    });
   
View Full Code Here

Examples of org.eclipse.swt.events.SelectionAdapter

    GridData grid_data = new GridData();
    grid_data.horizontalAlignment = GridData.END;
    grid_data.widthHint = 60;
    grid_data.grabExcessHorizontalSpace = true;
    button_ok.setLayoutData(grid_data);
    button_ok.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(final SelectionEvent e) {
        String selection = file_quality_combo.getItem(file_quality_combo.getSelectionIndex());
        FileQuality quality = (FileQuality) file_quality_combo.getData(selection);
        shared_file.setFileQuality(quality);
        remove_refreshable();
        shell.close();
      }
    });
   
    button_cancel.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(final SelectionEvent e) {
        remove_refreshable();
        shell.close();
      }
    });
View Full Code Here

Examples of org.eclipse.swt.events.SelectionAdapter

    popup_menu = new Menu(peers_table);
   
    MenuItem column_setup = new MenuItem(popup_menu,SWT.NONE);
    column_setup.setText(_._("downloadinfowindow.tab.peerlist.menu.column_setup"));
    column_setup.setImage(SWTImageRepository.getImage("columns_setup.png"));
    column_setup.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        peers_table.showColumnEditorWindow();
      }
    });
  }
View Full Code Here

Examples of org.eclipse.swt.events.SelectionAdapter

    search_query.setLayoutData(layout_data);
   
    Button search_button = new Button(basic_search_controls,SWT.PUSH);
   
    search_button.setText(Localizer._("mainwindow.searchtab.button.search"));
    search_button.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        search();
      }
    });
   
View Full Code Here

Examples of org.eclipse.swt.events.SelectionAdapter

    button_close.setLayoutData(grid_data);
   
    button_close.setFont(skin.getButtonFont());
    button_close.setText(Localizer._("downloadinfowindow.button.close"));
   
    button_close.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected( SelectionEvent e ) {
        for(Refreshable refreshable : tabs) {
          GUIUpdater.getInstance().removeRefreshable(refreshable);
        }
        shell.close();
View Full Code Here

Examples of org.eclipse.swt.events.SelectionAdapter

    no_items_menu = new Menu(search_results);

    MenuItem no_items_close_tab = new MenuItem(no_items_menu, SWT.PUSH);
    no_items_close_tab.setText(_._("mainwindow.searchtab.popupmenu.close"));
    no_items_close_tab.setImage(SWTImageRepository.getImage("cancel.png"));
    no_items_close_tab.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        search_tab.dispose();
      }

    });

    MenuItem no_items_column_setup_item = new MenuItem(no_items_menu,
        SWT.PUSH);
    no_items_column_setup_item.setText(_
        ._("mainwindow.searchtab.popupmenu.column_setup"));
    no_items_column_setup_item.setImage(SWTImageRepository
        .getImage("columns_setup.png"));
    no_items_column_setup_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        search_results.showColumnEditorWindow();
      }
    });

    pop_up_menu = new Menu(search_results);

    download_item = new MenuItem(pop_up_menu, SWT.PUSH);
    download_item.setText(_._("mainwindow.searchtab.popupmenu.download"));
    download_item.setImage(SWTImageRepository
        .getImage("start_download.png"));
    download_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        start_download();
      }
    });

    MenuItem try_again = new MenuItem(pop_up_menu, SWT.PUSH);
    try_again.setText(_._("mainwindow.searchtab.popupmenu.try_again"));
    try_again.setImage(SWTImageRepository.getImage("refresh.png"));
    try_again.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        retry();
      }
    });

    MenuItem copy_ed2k_item = new MenuItem(pop_up_menu, SWT.PUSH);
    copy_ed2k_item.setText(_
        ._("mainwindow.searchtab.popupmenu.copy_ed2k_link"));
    copy_ed2k_item.setImage(SWTImageRepository.getImage("ed2k_link.png"));
    copy_ed2k_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        copyED2KLinks();
      }
    });

    MenuItem close_item = new MenuItem(pop_up_menu, SWT.PUSH);
    close_item.setText(_._("mainwindow.searchtab.popupmenu.close"));
    close_item.setImage(SWTImageRepository.getImage("cancel.png"));
    close_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        search_tab.dispose();
      }

    });

    MenuItem column_setup_item = new MenuItem(pop_up_menu, SWT.PUSH);
    column_setup_item.setText(_
        ._("mainwindow.searchtab.popupmenu.column_setup"));
    column_setup_item.setImage(SWTImageRepository
        .getImage("columns_setup.png"));
    column_setup_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        search_results.showColumnEditorWindow();
      }

    });

    new MenuItem(pop_up_menu, SWT.SEPARATOR);

    properties_item = new MenuItem(pop_up_menu, SWT.PUSH);
    properties_item.setText(_
        ._("mainwindow.searchtab.popupmenu.properties"));
    properties_item.setImage(SWTImageRepository.getImage("info.png"));
    properties_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        SearchPropertiesWindow window = new SearchPropertiesWindow(
            search_results.getSelectedObject());
        window.getCoreComponents();
        window.initUIComponents();
View Full Code Here

Examples of org.eclipse.swt.events.SelectionAdapter

    no_uploads_menu = new Menu(this);
   
    MenuItem column_setup = new MenuItem(no_uploads_menu,SWT.PUSH);
    column_setup.setText(Localizer._("mainwindow.transferstab.uploads.popupmenu.columnsetup"));
    column_setup.setImage(SWTImageRepository.getImage("columns_setup.png"));
    column_setup.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected( SelectionEvent e ) {
        showColumnEditorWindow();
      }
    });
   
    upload_selected_menu = new Menu(this);
   
    open_shared_file = new MenuItem(upload_selected_menu,SWT.PUSH);
    open_shared_file.setText(_._("mainwindow.sharedtab.popupmenu.open"));
    open_shared_file.setImage(SWTImageRepository.getImage("open_file.png"));
    open_shared_file.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected( SelectionEvent e ) {
        SharedFile shared_file = getSelectedObject().getSharedFile();
        String extension = FileFormatter.getFileExtension(shared_file.getSharingName());
        Program program = Program.findProgram(extension);
        if (program == null) return;
        program.execute(shared_file.getAbsolutePath());
      }
    });
   
    new MenuItem(upload_selected_menu,SWT.SEPARATOR);
   
    MenuItem upload_details = new MenuItem(upload_selected_menu,SWT.PUSH);
    upload_details.setText(Localizer._("mainwindow.transferstab.uploads.popupmenu.details"));
    upload_details.setImage(SWTImageRepository.getImage("info.png"));
    upload_details.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected( SelectionEvent e ) {
        UploadInfoWindow window = new UploadInfoWindow(getSelectedObject());
        window.getCoreComponents();
        window.initUIComponents();
      }
    });
   
    new MenuItem(upload_selected_menu,SWT.SEPARATOR);
    column_setup = new MenuItem(upload_selected_menu,SWT.PUSH);
    column_setup.setText(Localizer._("mainwindow.transferstab.uploads.popupmenu.columnsetup"));
    column_setup.setImage(SWTImageRepository.getImage("columns_setup.png"));
    column_setup.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected( SelectionEvent e ) {
        showColumnEditorWindow();
      }
    });
   
View Full Code Here

Examples of org.eclipse.swt.events.SelectionAdapter

    add_button.setFont(skin.getButtonFont());
    add_button.setImage(SWTImageRepository.getImage("add.png"));
    add_button.setText(_._("mainwindow.sharedtab.button.add"));
    add_button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    add_button.setAlignment(SWT.LEFT);
    add_button.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        DirectoryDialog dir_dialog = new DirectoryDialog (getShell(),SWT.MULTI | SWT.OPEN);
        String directory = dir_dialog.open();
        if (directory == null) return ;
        java.util.List<File> shared_dirs = null;
        try {
          shared_dirs = config_manager.getSharedFolders();
        } catch (ConfigurationManagerException e) {
          e.printStackTrace();
        }
        java.util.List<File> newDirs = new LinkedList<File>();
        if (shared_dirs == null)
          shared_dirs = new CopyOnWriteArrayList<File>();
        else
          shared_dirs = new CopyOnWriteArrayList<File>(shared_dirs);
       
        java.util.List<File> already_exist_list = org.jmule.core.utils.FileUtils.extractNewFolders(new File[]{new File(directory)},shared_dirs,newDirs);
                  
        if (already_exist_list.size()!=0) {
          AlreadyExistDirsWindow window = new AlreadyExistDirsWindow(already_exist_list);
          window.getCoreComponents();
          window.initUIComponents();
        }
        shared_dirs.addAll(newDirs);
        try {
          config_manager.setSharedFolders(shared_dirs);
        } catch (ConfigurationManagerException e) {
          e.printStackTrace();
        }
    } });
   
   
    remove_button = new Button(control_block,SWT.NONE);
    remove_button.setFont(skin.getButtonFont());
    remove_button.setText(_._("mainwindow.sharedtab.button.remove"));
    remove_button.setImage(SWTImageRepository.getImage("remove.png"));
    remove_button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    remove_button.setAlignment(SWT.LEFT);
    remove_button.setEnabled(false);
    remove_button.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        removeSelectedDir();
    } });
   
    clear_button = new Button(control_block,SWT.NONE);
    clear_button.setFont(skin.getButtonFont());
    clear_button.setText(_._("mainwindow.sharedtab.button.clear"));
    clear_button.setImage(SWTImageRepository.getImage("remove_all.png"));
    clear_button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    clear_button.setAlignment(SWT.LEFT);
    clear_button.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        clearDirList();
    } });
   
    Button reload_button = new Button(control_block,SWT.NONE);
    reload_button.setFont(skin.getButtonFont());
    reload_button.setText(_._("mainwindow.sharedtab.button.reload"));
    reload_button.setImage(SWTImageRepository.getImage("refresh.png"));
    reload_button.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        sharing_manager.loadCompletedFiles();
      }
    });
   
    shared_dir_list = new List (dir_list_content, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);
    shared_dir_list.setLayoutData(new GridData(GridData.FILL_BOTH));
   
    shared_dir_list.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        String selected_dir = shared_dir_list.getSelection()[0];
        if (selected_dir.equals(last_selection)) return ;
        last_selection = selected_dir;
        updateFileList(selected_dir);
       
        int selection_id = shared_dir_list.getSelectionIndex();
        if ((selection_id>=no_remove_id_start)&&(selection_id<=no_remove_id_end)) {
          remove_button.setEnabled(false);
          return;
        }
        remove_button.setEnabled(true);
      }
    });

    shared_files.setLayout(new FillLayout());
    shared_files_group = new Group(shared_files,SWT.NONE);
    shared_files_group.setText(_._("mainwindow.sharedtab.group.shared_files"));
    shared_files_group.setLayout(new FillLayout());
    shared_files_table = new JMTable<SharedFile>(shared_files_group, SWT.NONE){
      protected int compareObjects(SharedFile object1, SharedFile object2,
          int columnID, boolean order) {
        if (columnID == SWTConstants.SHARED_LIST_FILE_NAME_COLUMN_ID) {
          return Misc.compareAllObjects(object1, object2, "getSharingName", order);
        }
       
        if (columnID == SWTConstants.SHARED_LIST_FILE_SIZE_COLUMN_ID) {
          return Misc.compareAllObjects(object1, object2, "length", order);
        }
       
        if (columnID == SWTConstants.SHARED_LIST_FILE_TYPE_COLUMN_ID) {
          String type1 = FileFormatter.formatMimeType(object1.getMimeType());
          String type2 = FileFormatter.formatMimeType(object2.getMimeType());
          int result = type1.compareTo(type2);
          if (order)
            return result;
          else
            return Misc.reverse(result);
        }
       
        if (columnID == SWTConstants.SHARED_LIST_COMPLETED_COLUMN_ID) {
          double value1 = 100;
          double value2 = 100;
          if (object1 instanceof PartialFile)
            value1 = ((PartialFile)object1).getPercentCompleted();
          if (object2 instanceof PartialFile)
            value2 = ((PartialFile)object2).getPercentCompleted();
          int result = 0;
          if (value1>value2)
            result = 1;
          if (value2>value1)
            result = -1;
          if (order)
            return result;
          else
            return Misc.reverse(result);
        }
       
        if (columnID == SWTConstants.SHARED_LIST_FILE_ID_COLUMN_ID) {
          String hash1 = object1.getFileHash().getAsString();
          String hash2 = object2.getFileHash().getAsString();
          int result = hash1.compareTo(hash2);
          if (order)
            return result;
          else
            return Misc.reverse(result);
         
        }
       
        return 0;
      }

      protected Menu getPopUpMenu() {
        if (getSelectionCount()<1)
          return no_items_menu;
       
        SharedFile shared_file = shared_files_table.getSelectedObject();
        if (shared_file.isCompleted()) {
          rating_menu.setEnabled(true);
          rating_menu.setVisible(true);
          file_not_rated.setSelection(false);
          file_fake.setSelection(false);
          file_poor.setSelection(false);
          file_fair.setSelection(false);
          file_good.setSelection(false);
          file_excellent.setSelection(false);
         
          switch (shared_file.getFileQuality()) {
            case FAKE : file_fake.setSelection(true); break;
            case POOR : file_poor.setSelection(true); break;
            case FAIR : file_fair.setSelection(true); break;
            case GOOD : file_good.setSelection(true); break;
            case EXCELLENT : file_excellent.setSelection(true); break;
            default : file_not_rated.setSelection(true); break;
          }
         
        } else  { rating_menu.setEnabled(false); }
       
       
       
        properties_menu_item.setEnabled(true);
        copy_ed2k_link_menu_item.setEnabled(true);
        remove_from_disk_menu_item.setEnabled(true);
        if (getSelectedObject().getHashSet() == null) {
          properties_menu_item.setEnabled(false);
          copy_ed2k_link_menu_item.setEnabled(false);
          remove_from_disk_menu_item.setEnabled(false);
        }
        if (getSelectionCount()>1)
          properties_menu_item.setEnabled(false);
        open_selected_menu_item.setEnabled(false);
        if (selectedRunnableFiles())
          open_selected_menu_item.setEnabled(true);
        return select_completed_file_menu;
      }

      int HASHED     = 0x01;
      int UNHASHED   = 0x02;
      int HASHING    = 0x03;
     
      public void updateRow(SharedFile object) {
        int status = HASHED;
       
        java.util.List<CompletedFile> file_list = sharing_manager.getUnhashedFiles();
        if (file_list != null) {
          for(CompletedFile unhashed_file : file_list) {
            if (unhashed_file.getFile().equals(object.getFile())) {
              status = UNHASHED;
              break;
            }
          }
        }
       
        SharedFile hashing_file = sharing_manager.getCurrentHashingFile();
        if (hashing_file != null)
          if (object.getFile().equals(hashing_file.getFile()))
            status = HASHING;

        Image icon = SWTImageRepository.getIconByExtension(object.getSharingName());
        setRowImage(object, SWTConstants.SHARED_LIST_FILE_NAME_COLUMN_ID, icon);
       
        String text = object.getSharingName();
       
        setRowText(object,  SWTConstants.SHARED_LIST_FILE_NAME_COLUMN_ID, text);
        long file_size = object.getFile().length();
        setRowText(object, SWTConstants.SHARED_LIST_FILE_SIZE_COLUMN_ID, FileFormatter.formatFileSize(file_size));
        String mime_type = FileFormatter.formatMimeType(object.getMimeType());
        setRowText(object,SWTConstants.SHARED_LIST_FILE_TYPE_COLUMN_ID,mime_type);
        double percent_completed = 100d;
        if (object instanceof PartialFile) {
          PartialFile partial_file = (PartialFile)object;
          percent_completed = partial_file.getPercentCompleted();
        }
        if (status == HASHED) {
            setRowText(object,SWTConstants.SHARED_LIST_COMPLETED_COLUMN_ID,FileFormatter.formatProgress(percent_completed));
            setRowText(object,SWTConstants.SHARED_LIST_FILE_ID_COLUMN_ID, object.getFileHash().getAsString());
        } else
          if (status == HASHING)
            setRowText(object,SWTConstants.SHARED_LIST_FILE_ID_COLUMN_ID, _._("mainwindow.sharedtab.label.hashing"));
          else
            setRowText(object,SWTConstants.SHARED_LIST_FILE_ID_COLUMN_ID, _._("mainwindow.sharedtab.label.waiting_to_hash"));
      }
   
    };

    int width;
   
    width = SWTPreferences.getInstance().getColumnWidth(SWTConstants.SHARED_LIST_FILE_NAME_COLUMN_ID);
    shared_files_table.addColumn(SWT.LEFT,  SWTConstants.SHARED_LIST_FILE_NAME_COLUMN_ID, _._("mainwindow.sharedtab.column.filename"), "", width);
   
    width = SWTPreferences.getInstance().getColumnWidth(SWTConstants.SHARED_LIST_FILE_SIZE_COLUMN_ID);
    shared_files_table.addColumn(SWT.RIGHT, SWTConstants.SHARED_LIST_FILE_SIZE_COLUMN_ID, _._("mainwindow.sharedtab.column.filesize"), "", width);
   
    width = SWTPreferences.getInstance().getColumnWidth(SWTConstants.SHARED_LIST_FILE_TYPE_COLUMN_ID);
    shared_files_table.addColumn(SWT.LEFT,  SWTConstants.SHARED_LIST_FILE_TYPE_COLUMN_ID, _._("mainwindow.sharedtab.column.filetype"), "",width);
   
    width = SWTPreferences.getInstance().getColumnWidth(SWTConstants.SHARED_LIST_FILE_ID_COLUMN_ID);
    shared_files_table.addColumn(SWT.LEFT,  SWTConstants.SHARED_LIST_FILE_ID_COLUMN_ID,   _._("mainwindow.sharedtab.column.fileid"), "", width);
   
    width = SWTPreferences.getInstance().getColumnWidth(SWTConstants.SHARED_LIST_COMPLETED_COLUMN_ID);
    shared_files_table.addColumn(SWT.RIGHT,  SWTConstants.SHARED_LIST_COMPLETED_COLUMN_ID, _._("mainwindow.sharedtab.column.completed"), "", width);
   
    shared_files_table.updateColumnSettings();
   
    no_items_menu = new Menu(shared_files_table);
   
    MenuItem column_setup_menu_item = new MenuItem(no_items_menu,SWT.PUSH);
    column_setup_menu_item.setText(_._("mainwindow.sharedtab.popupmenu.column_setup"));
    column_setup_menu_item.setImage(SWTImageRepository.getImage("columns_setup.png"));
    column_setup_menu_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        shared_files_table.showColumnEditorWindow();
    }});
   
    select_completed_file_menu = new Menu(shared_files_table);
   
    open_selected_menu_item = new MenuItem(select_completed_file_menu,SWT.PUSH);
    open_selected_menu_item.setText(_._("mainwindow.sharedtab.popupmenu.open"));
    open_selected_menu_item.setImage(SWTImageRepository.getImage("open_file.png"));
    open_selected_menu_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        openSelected();
    }});
   
    copy_ed2k_link_menu_item = new MenuItem(select_completed_file_menu,SWT.PUSH);
    copy_ed2k_link_menu_item.setText(_._("mainwindow.sharedtab.popupmenu.copy_ed2k_link"));
    copy_ed2k_link_menu_item.setImage(SWTImageRepository.getImage("ed2k_link.png"));
    copy_ed2k_link_menu_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        copyED2KLink();
    }});

    remove_from_disk_menu_item = new MenuItem(select_completed_file_menu,SWT.PUSH);
    remove_from_disk_menu_item.setText(_._("mainwindow.sharedtab.popupmenu.remove_from_disk"));
    remove_from_disk_menu_item.setImage(SWTImageRepository.getImage("cancel.png"));
    remove_from_disk_menu_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        removeFromDisk();
    }});
   
    MenuItem selected_column_setup_menu_item = new MenuItem(select_completed_file_menu,SWT.PUSH);
    selected_column_setup_menu_item.setText(_._("mainwindow.sharedtab.popupmenu.column_setup"));
    selected_column_setup_menu_item.setImage(SWTImageRepository.getImage("columns_setup.png"));
    selected_column_setup_menu_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        shared_files_table.showColumnEditorWindow();
    }});

   
    rating_menu_item = new MenuItem(select_completed_file_menu, SWT.CASCADE);
    rating_menu_item.setText(_._("mainwindow.searchtab.popupmenu.rating_submenu"));
    rating_menu = new Menu(select_completed_file_menu);
    rating_menu_item.setMenu(rating_menu);
   
    file_not_rated = new MenuItem(rating_menu, SWT.RADIO);
    file_not_rated.setText(_._("mainwindow.searchtab.popupmenu.rating_submenu.not_rated"));
    file_not_rated.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
            file_fake.setSelection(false);
            file_poor.setSelection(false);
            file_fair.setSelection(false);
            file_good.setSelection(false);
            file_excellent.setSelection(false);
            SharedFile shared_file = shared_files_table.getSelectedObject();
            shared_file.setFileQuality(FileQuality.NOTRATED);
          }
        });
    }});
   
    file_fake = new MenuItem(rating_menu, SWT.RADIO);
    file_fake.setText(_._("mainwindow.searchtab.popupmenu.rating_submenu.fake"));
    file_fake.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
        file_not_rated.setSelection(false);
        file_poor.setSelection(false);
        file_fair.setSelection(false);
        file_good.setSelection(false);
        file_excellent.setSelection(false);
        SharedFile shared_file = shared_files_table.getSelectedObject();
        shared_file.setFileQuality(FileQuality.FAKE);
          }});
    }});

    file_poor = new MenuItem(rating_menu, SWT.RADIO);
    file_poor.setText(_._("mainwindow.searchtab.popupmenu.rating_submenu.poor"));
    file_poor.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
        file_not_rated.setSelection(false);
        file_fake.setSelection(false);
        file_fair.setSelection(false);
        file_good.setSelection(false);
        file_excellent.setSelection(false)
        SharedFile shared_file = shared_files_table.getSelectedObject();
        shared_file.setFileQuality(FileQuality.POOR);
          }});
    }});
   
    file_fair = new MenuItem(rating_menu, SWT.RADIO);
    file_fair.setText(_._("mainwindow.searchtab.popupmenu.rating_submenu.fair"));
    file_fair.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
        file_not_rated.setSelection(false);
        file_fake.setSelection(false);
        file_poor.setSelection(false);
        file_good.setSelection(false);
        file_excellent.setSelection(false);
        SharedFile shared_file = shared_files_table.getSelectedObject();
        shared_file.setFileQuality(FileQuality.FAIR);
          }});
    }});
   
    file_good = new MenuItem(rating_menu, SWT.RADIO);
    file_good.setText(_._("mainwindow.searchtab.popupmenu.rating_submenu.good"));
    file_good.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
        file_not_rated.setSelection(false);
        file_fake.setSelection(false);
        file_poor.setSelection(false);
        file_fair.setSelection(false);
        file_excellent.setSelection(false)
        SharedFile shared_file = shared_files_table.getSelectedObject();
        shared_file.setFileQuality(FileQuality.GOOD);
          }});
    }});
   
    file_excellent = new MenuItem(rating_menu, SWT.RADIO);
    file_excellent.setText(_._("mainwindow.searchtab.popupmenu.rating_submenu.excellent"));
    file_excellent.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
        file_not_rated.setSelection(false);
        file_fake.setSelection(false);
        file_poor.setSelection(false);
        file_fair.setSelection(false);
        file_good.setSelection(false);
        SharedFile shared_file = shared_files_table.getSelectedObject();
        shared_file.setFileQuality(FileQuality.EXCELLENT);
          }});
    }});
    new MenuItem(select_completed_file_menu,SWT.SEPARATOR);
    properties_menu_item = new MenuItem(select_completed_file_menu,SWT.PUSH);
    properties_menu_item.setText(_._("mainwindow.sharedtab.popupmenu.properties"));
    properties_menu_item.setImage(SWTImageRepository.getImage("info.png"));
    properties_menu_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        SharedFile shared_file = shared_files_table.getSelectedObject();
        SharedFilePropertiesWindow window = new SharedFilePropertiesWindow(shared_file);
        window.getCoreComponents();
        window.initUIComponents();
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.