Package omschaub.aztrackerfind.main

Source Code of omschaub.aztrackerfind.main.ManualAdd

/*
* Created on Jan 3, 2005
* Created by omschaub
*
*/
package omschaub.aztrackerfind.main;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.gudy.azureus2.plugins.PluginInterface;

/**
* @author marc
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ManualAdd {

    public static void openShell(final Display display, final PluginInterface pluginInterface){
        final Shell shell = new Shell(display,SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    shell.setLayout(layout);
      shell.setText("Manually Add a IP to test");
     
       
    Label topLabel = new Label(shell, SWT.NULL);
    topLabel.setText("In the format of IP address:port (11.22.33.44:1234)");
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL );
    gridData.horizontalSpan = 3;
    topLabel.setLayoutData(gridData);
   
    final Text IPLabel = new Text(shell, SWT.BORDER);
    //IPLabel.setText("In the format of IP address:port (11.22.33.44:1234)");
    gridData = new GridData(GridData.FILL_HORIZONTAL );
    gridData.horizontalSpan = 3;
    IPLabel.setLayoutData(gridData);
    IPLabel.setEditable(true);
   
   
   
    Button go = new Button(shell, SWT.PUSH);
    go.setText("Submit");
    go.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event e) {
          if (shell!=null && !shell.isDisposed())
          {
              String inet_address;
             
             
              String pluginDir =  pluginInterface.getPluginDirectoryName();
            String bookmark_file = pluginDir + System.getProperty("file.separator");
            String url_to_go = IPLabel.getText();
            if(url_to_go.startsWith("http")){
                url_to_go = url_to_go.substring(7,url_to_go.length());
                inet_address = url_to_go.substring(0,url_to_go.indexOf(":"));
            }else {
                inet_address = url_to_go.substring(0,url_to_go.indexOf(":"));   
            }
            //System.out.println(inet_address + " : " + "http://" +  url_to_go + "  :  " + bookmark_file + "manual_add");
              Downloader.generic_getter(inet_address,"http://" +  url_to_go,bookmark_file,"manual_add",pluginInterface, display );
              Downloader.rss_tester("http://" + url_to_go + "/rss_feed.xml",pluginInterface);
              shell.dispose();
          }
      }
    });
   
   
    Button cancel = new Button(shell, SWT.PUSH);
    cancel.setText("Cancel");
    cancel.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event e) {
          if (shell!=null && !shell.isDisposed())
          {
              shell.dispose();
          }
      }
    });
   
   
   
   
   
    //Pack Shell
    shell.pack();
   
    //Center Shell
    Monitor primary = display.getPrimaryMonitor ();
    Rectangle bounds = display.getBounds ();
    Rectangle rect = shell.getBounds ();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    shell.setLocation (x, y);
   
    //Open Shell
    shell.open();
    }
}
TOP

Related Classes of omschaub.aztrackerfind.main.ManualAdd

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.