Package org.jmule.core

Examples of org.jmule.core.JMRunnable


    }});
   
  }

  public void downloadStopped(final FileHash fileHash) {
    SWTThread.getDisplay().asyncExec(new JMRunnable() {
      public void JMRun() {
        DownloadSession downloadSession;
        try {
          downloadSession = download_manager.getDownload(fileHash);
        } catch (DownloadManagerException e) {
View Full Code Here


        dialog.open();
        String filename = dialog.getFileName();
        if (filename == null) return ;
        final String full_path = (dialog.getFilterPath() + File.separator + filename);
        final String content = log_content.getText();
        new Thread( new JMRunnable() {
          public void JMRun() {
            try {
              FileWriter file_writer = new FileWriter(full_path);
              file_writer.write(content);
              file_writer.close();
View Full Code Here

   
    Listener sort_listener = new Listener() {
      private int sort_order = 0;
      public void handleEvent(final Event e) {
       
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
          if (!enabled_sorting) return ;
          TableColumn column = (TableColumn)e.widget;
          int column_id = (Integer)column.getData(SWTConstants.COLUMN_NAME_KEY);
          if (is_sorted)
View Full Code Here

 
  private JMThread sort_thread;
  protected void sortColumn(final int columnID,final boolean sortOrder) {
    if (sort_thread!=null)
      if (sort_thread.isAlive()) return ;
    sort_thread = new JMThread(new JMRunnable() {
      public void JMRun() {
        last_sort_column = columnID;
        last_sort_dir = sortOrder;
        Collections.sort(line_list, new Comparator() {
            public int compare(Object arg0, Object arg1) {
              BufferedTableRow row1 = (BufferedTableRow)arg0;
              BufferedTableRow row2 = (BufferedTableRow)arg1;
               
              T object1 = (T) row1.getData(SWTConstants.ROW_OBJECT_KEY);
              T object2 = (T) row2.getData(SWTConstants.ROW_OBJECT_KEY);
              return compareObjects(object1,object2,columnID,sortOrder);
          } });
        SWTThread.getDisplay().syncExec(new JMRunnable() {
          public void JMRun() {
            clearAll();
            updateIndexes();
            setItemCount(line_list.size());
          }
View Full Code Here

  private JMThread reset_order_thread;
 
  private void resetOrdering() {
    if (reset_order_thread != null)
      if (reset_order_thread.isAlive()) return ;
    reset_order_thread =  new JMThread(new JMRunnable() {
      public void JMRun() {
        for(int i = 0;i<default_line_list.size(); i++) {
          line_list.set(i, default_line_list.get(i));
        }
        SWTThread.getDisplay().syncExec(new JMRunnable() {
          public void JMRun() {
            clearAll();
            updateIndexes();
            setItemCount(line_list.size());
          }
View Full Code Here

        Thread.sleep(1000);
      } catch (InterruptedException e) {
        if (stop) return ;
      }
      if (!process_refreshables) {
      SwingUtilities.invokeLater(new JMRunnable() {
        public void JMRun() {
          process_refreshables = true;
          for(Refreshable refreshable : refreshable_list) {
            try {
              refreshable.refresh();
View Full Code Here

        file_chooser.setMultiSelectionEnabled(false);
        file_chooser.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if(event.getActionCommand() == JFileChooser.APPROVE_SELECTION) { 
                  final File file = file_chooser.getSelectedFile();
                  (new JMThread(new JMRunnable() {
                   public void JMRun() {
                    try {
                   _server_manager.importList(file.getAbsolutePath());
                 } catch (Throwable e) {
                   e.printStackTrace();
View Full Code Here

        return this;
       }
     });
     paste_ed2k_links.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent event) {
            (new JMThread(new JMRunnable() {
               public void JMRun() {
               try
                 Object clipboard_contents = clipboard.getData(DataFlavor.stringFlavor);
                 List<ED2KFileLink> clipboard_file_links = ED2KFileLink.extractLinks(clipboard_contents.toString());
               if( clipboard_file_links.size() != 0
View Full Code Here

  }
 
  public void initUIComponents() {
    final Display display = SWTThread.getDisplay();
    final MainWindow instance = this;
    display.asyncExec(new JMRunnable() {
            public void JMRun() {
   
              shell = new Shell(display);
             
        shell.setSize(800, 500);  
              Utils.centreWindow(shell);
             
              shell.setText(JMConstants.JMULE_FULL_NAME);
              shell.setImage(SWTImageRepository.getImage("jmule.png"));
             
              GridLayout gridLayout = new GridLayout(1,true);
              gridLayout.marginHeight = 2;
              gridLayout.marginWidth = 2;
              shell.setLayout(gridLayout);
              //Setup main_menu
              main_menu = new MainMenu(shell,instance);
              //Setup tool bar
              toolbar = new Toolbar(shell,_core,instance);
   
              window_content = new ScrolledComposite(shell,SWT.NONE);
              window_content.setExpandHorizontal(true);
              window_content.setExpandVertical(true);
              window_content.setLayout(new FillLayout());
              GridData gridData = new GridData(GridData.FILL_BOTH);
              window_content.setLayoutData(gridData);
   
              new Label(shell,SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
             
              status_bar = new StatusBar(shell,_core);
             
              LogsTab logs_tab = new LogsTab(window_content);
              logger = logs_tab;
              tab_list.add(logs_tab);
              tab_list.add(new ServerListTab(window_content,_core));
              tab_list.add(new KadTab(window_content,_core));
              tab_list.add(new TransfersTab(window_content,_core));
              tab_list.add(new SearchTab(window_content,_core));
              tab_list.add(new SharedTab(window_content,_core));
              tab_list.add(new StatisticsTab(window_content));
   
              setTab(AbstractTab.JMULE_TABS.SERVERLIST);
             
              if (!SWTPreferences.getInstance().isStatusBarVisible())
              statusBarToogleVisibility();
             
            if (!SWTPreferences.getInstance().isToolBarVisible())
              toolbarToogleVisibility();

              shell.open ();

              if (SWTPreferences.getInstance().isConnectAtStartup()) {
                try {
            _core.getServerManager().connect();
          } catch (ServerManagerException e1) {
            e1.printStackTrace();
         
              }
             
              if (JMConstants.IS_NIGHTLY_BUILD)
                if (SWTPreferences.getInstance().isNightlyBuildWarning()){
                  NightlyBuildWarningWindow warning_window = new NightlyBuildWarningWindow(shell);
                  warning_window.getCoreComponents();
                  warning_window.initUIComponents();
              }
             
              // show log messages
              new JMThread(new JMRunnable() {
                public void JMRun() {
                  logger.fine(Localizer._("mainwindow.logtab.message_jmule_started",  JMConstants.JMULE_FULL_NAME));
                  logger.fine(Localizer._("mainwindow.logtab.message_servers_loaded", _core.getServerManager().getServersCount() + ""));
                  logger.fine(Localizer._("mainwindow.logtab.message_shared_loaded", _core.getSharingManager().getFileCount() + ""));
                  logger.fine(Localizer._("mainwindow.logtab.message_partial_loaded", _core.getDownloadManager().getDownloadCount() + ""));
                }}).start();
             
              _core.addEventListener(new JMuleCoreEventListener() {
          public void eventOccured(JMuleCoreEvent event, final EventDescriptor eventDescriptor) {
            if( event == JMuleCoreEvent.NOT_ENOUGH_SPACE ) {
              display.syncExec(new JMRunnable() {
                NotEnoughSpaceDownloadingFile nes = (NotEnoughSpaceDownloadingFile)eventDescriptor;
                public void JMRun() {
                  Utils.showErrorMessage(shell,
                      _._("mainwindow.not_enough_space_dialog.title"),
                      _._("mainwindow.not_enough_space_dialog.message",
                          nes.getFileName(),
                          FileFormatter.formatFileSize( nes.getTotalSpace() ),
                          FileFormatter.formatFileSize( nes.getFreeSpace() )));
                }
              });
            }
          }
              });
              // Update checker
              if (SWTPreferences.getInstance().updateCheckAtStartup()) {
                new JMThread(new JMRunnable() {
                  public void JMRun() {
                    try {
                JMUpdater.getInstance().checkForUpdates();
                if (JMUpdater.getInstance().isNewVersionAvailable())
                  SWTThread.getDisplay().asyncExec(new JMRunnable() {
                          public void JMRun() {
                            if (JMUpdater.getInstance().isNewVersionAvailable()) {
                        if (Utils.showConfirmMessage(shell, _._("mainwindow.new_version_available.title"), _._("mainwindow.new_version_available"))) {
                          UpdaterWindow window = new UpdaterWindow();
                          window.getCoreComponents();
                          window.initUIComponents();
                        } }
                        }});
              } catch (JMUpdaterException e) {}
                  }
                }).start();
              }
              shell.addListener(SWT.Close, new Listener() {
          public void handleEvent(Event arg0) {
            boolean exit = SWTPreferences.getInstance().promptOnExit() ?
                Utils.showConfirmMessage(shell, _._("mainwindow.exit_prompt_title"), _._("mainwindow.exit_prompt")) : true;
            arg0.doit = exit;
          }
              });
              shell.addDisposeListener(new DisposeListener() {
          public void widgetDisposed(DisposeEvent arg0) {
            new JMThread(new JMRunnable() {
              public void JMRun() {
                try {
                  JMuleUIManager.getSingleton().shutdown();
                } catch (JMuleUIManagerException e) {
                  e.printStackTrace();
View Full Code Here

    MenuItem open_support_item = new MenuItem (submenu, SWT.PUSH);
    open_support_item.setText(Localizer._("mainwindow.mainmenu.help.open_support"));
    open_support_item.setImage(SWTImageRepository.getMenuImage("world_link.png"));
    open_support_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
            Program.launch(JMConstants.OPEN_SUPPORT);
          }
        })
      }
    });
   
    MenuItem bugtracker_item = new MenuItem (submenu, SWT.PUSH);
    bugtracker_item.setText(Localizer._("mainwindow.mainmenu.help.bug_tracker"));
    bugtracker_item.setImage(SWTImageRepository.getMenuImage("world_link.png"));
    bugtracker_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
            Program.launch(JMConstants.JMULE_BUG_TRACKER);
          }
        })
      }
    });
   
    /*MenuItem help_contents_item = new MenuItem (submenu, SWT.PUSH);
    help_contents_item.setText(Localizer._("mainwindow.mainmenu.help.contents"));
    help_contents_item.setImage(SWTImageRepository.getMenuImage("world_link.png"));
    help_contents_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
            Program.launch(JMConstants.ONLINE_HELP_WEB_SITE);
          }
        }); 
      }
    });*/
   
    MenuItem forum_item = new MenuItem (submenu, SWT.PUSH);
    forum_item.setText(Localizer._("mainwindow.mainmenu.help.forum"));
    forum_item.setImage(SWTImageRepository.getMenuImage("world_link.png"));
    forum_item.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        SWTThread.getDisplay().asyncExec(new JMRunnable() {
          public void JMRun() {
            Program.launch(JMConstants.JMULE_FORUMS);
          }
        });
      }
View Full Code Here

TOP

Related Classes of org.jmule.core.JMRunnable

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.