Package org.gudy.azureus2.ui.swt.shells

Examples of org.gudy.azureus2.ui.swt.shells.MessageSlideShell$PopupParams


          shell.dispose();
        }
        URLInfo hitUrl = spText.getHitUrl(e.x, e.y);
        if (hitUrl != null) {
          if (hitUrl.url.equals("details")) {
            MessageBoxShell mb = new MessageBoxShell(Constants.APP_NAME,
                logAlert.details, new String[] {
                  MessageText.getString("Button.ok")
                }, 0);
            mb.setUseTextBox(true);
            mb.setParent(Utils.findAnyShell());
            mb.open(null);
          } else {
            Utils.launch(hitUrl.url);
          }
        }
      }
View Full Code Here


            new Listener()
          {
                public void
            handleEvent(Event event)
                {
                  MessageBoxShell mb = new MessageBoxShell(
                      SWT.ICON_WARNING | SWT.OK | SWT.CANCEL,
                      MessageText.getString("ConfigView.section.security.resetkey.warning.title"),
                      MessageText.getString("ConfigView.section.security.resetkey.warning"));
                  mb.setDefaultButtonUsingStyle(SWT.CANCEL);
                  mb.setParent(parent.getShell());

                  mb.open(new UserPrompterResultListener() {
                    public void prompterClosed(int returnVal) {
                      if (returnVal != SWT.OK) {
                        return;
                      }
                     
                      try{
                        crypt_man.getECCHandler().resetKeys( "Manual key reset" );
                       
                      }catch( Throwable e ){
                       
                        MessageBoxShell mb = new MessageBoxShell(
                            SWT.ICON_ERROR | SWT.OK,
                            MessageText.getString( "ConfigView.section.security.resetkey.error.title"),
                            getError( e ));
                        mb.setParent(parent.getShell());
                        mb.open(null);
                      }
                    }
                  });
                }
            });
       
        new Label(crypto_group, SWT.NULL );
         
          // unlock
       
        Label priv_key_label = new Label(crypto_group, SWT.NULL );
        Messages.setLanguageText(priv_key_label, "ConfigView.section.security.unlockkey");
 
        Button priv_key_button = new Button(crypto_group, SWT.PUSH);
        Messages.setLanguageText(priv_key_button, "ConfigView.section.security.unlockkey.button");
 
        priv_key_button.addListener(SWT.Selection,
            new Listener()
          {
                public void
            handleEvent(Event event)
                {
                  try{
                    crypt_man.getECCHandler().getEncryptedPrivateKey( "Manual unlock" );
                   
                  }catch( Throwable e ){
                   
                 MessageBoxShell mb = new MessageBoxShell(
                   SWT.ICON_ERROR | SWT.OK,
                   MessageText.getString( "ConfigView.section.security.resetkey.error.title" ),
                   getError( e ));
                 mb.setParent(parent.getShell());
                 mb.open(null);
                  };

                }
            });
       
        new Label(crypto_group, SWT.NULL );
       
          // backup
       
        Label backup_keys_label = new Label(crypto_group, SWT.NULL );
        Messages.setLanguageText(backup_keys_label, "ConfigView.section.security.backupkeys");
 
        final Button backup_keys_button = new Button(crypto_group, SWT.PUSH);
        Messages.setLanguageText(backup_keys_button, "ConfigView.section.security.backupkeys.button");
 
        backup_keys_button.addListener(SWT.Selection,
            new Listener()
          {
                public void
            handleEvent(Event event)
                {
                  FileDialog dialog = new FileDialog( backup_keys_button.getShell(), SWT.APPLICATION_MODAL );
                 
                  String  target = dialog.open();
                 
                  if ( target != null ){
                   
                    try{
                      String  keys = crypt_man.getECCHandler().exportKeys();
                     
                      PrintWriter pw = new PrintWriter(new FileWriter( target ));
                     
                      pw.println( keys );
                     
                      pw.close();
                   
                    }catch( Throwable e ){
                   
                      MessageBoxShell mb = new MessageBoxShell(
                          SWT.ICON_ERROR | SWT.OK,
                          MessageText.getString( "ConfigView.section.security.op.error.title" ),
                          MessageText.getString( "ConfigView.section.security.op.error",
                              new String[]{ getError(e) }));
                      mb.setParent(parent.getShell());
                      mb.open(null);
                    }
                  }
                }
            });
       
        new Label(crypto_group, SWT.NULL );
       
          // restore
       
        Label restore_keys_label = new Label(crypto_group, SWT.NULL );
        Messages.setLanguageText(restore_keys_label, "ConfigView.section.security.restorekeys");
 
        final Button restore_keys_button = new Button(crypto_group, SWT.PUSH);
        Messages.setLanguageText(restore_keys_button, "ConfigView.section.security.restorekeys.button");
 
        restore_keys_button.addListener(SWT.Selection,
            new Listener()
          {
                public void
            handleEvent(Event event)
                {
                  FileDialog dialog = new FileDialog( backup_keys_button.getShell(), SWT.APPLICATION_MODAL );
                 
                  String  target = dialog.open();
                 
                  if ( target != null ){
                   
                    try{
                      LineNumberReader reader = new LineNumberReadernew FileReader( target ));
                     
                      String  str = "";
                     
                      while( true ){
                       
                        String  line = reader.readLine();
                       
                        if ( line == null ){
                         
                          break;
                        }
                       
                        str += line + "\r\n";
                      }
                     
                      boolean restart = crypt_man.getECCHandler().importKeys(str);
           
                      if ( restart ){
                       
                        MessageBoxShell mb = new MessageBoxShell(
                            SWT.ICON_INFORMATION | SWT.OK,
                            MessageText.getString( "ConfigView.section.security.restart.title" ),
                            MessageText.getString( "ConfigView.section.security.restart.msg" ));
                        mb.setParent(parent.getShell());
                        mb.open(null);
 
                       
                        UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
                       
                          if ( uiFunctions != null ){
                           
                            uiFunctions.dispose(true, false);
                          }
                      }
                    }catch( Throwable e ){
                   
                      MessageBoxShell mb = new MessageBoxShell
                        SWT.ICON_ERROR | SWT.OK,
                        MessageText.getString( "ConfigView.section.security.op.error.title" ),
                        MessageText.getString( "ConfigView.section.security.op.error",
                            new String[]{ getError( e )}));
                      mb.setParent(parent.getShell());
                      mb.open(null);
                    }
                  }
                }
            });
       
View Full Code Here

    dDialog.setText(MessageText.getString("FilesView.rename.choose.path.dir"));
    return dDialog.open();
  }

  private static boolean askCanOverwrite(File file) {
    MessageBoxShell mb = new MessageBoxShell(SWT.OK | SWT.CANCEL,
        MessageText.getString("FilesView.rename.confirm.delete.title"),
        MessageText.getString("FilesView.rename.confirm.delete.text",
            new String[] {
              file.toString()
            }));
    mb.setDefaultButtonUsingStyle(SWT.OK);
    mb.setRememberOnlyIfButton(0);
    mb.setRemember("FilesView.messagebox.rename.id", true, null);
    mb.setLeftImage(SWT.ICON_WARNING);
    mb.open(null);
    return mb.waitUntilClosed() == SWT.OK;
  }
View Full Code Here

      if (!fOriginal.isFile() || !fOriginal.exists()) {
        Utils.execSWTThread(new AERunnable() {
          public void runSupport() {
            if (shell == null)
              new MessageSlideShell(Display.getCurrent(), SWT.ICON_ERROR,
                  "OpenTorrentWindow.mb.openError", fOriginal.toString(), new String[] {
                    UrlUtils.decode(sOriginatingLocation),
                    "Not a File"
                  }, -1 );
            else {
              MessageBoxShell mb = new MessageBoxShell(SWT.OK,
                  "OpenTorrentWindow.mb.openError", new String[] {
                    sOriginatingLocation,
                    "Not a File"
                  });
              mb.open(null);
            }
          }
        });
        return null;
      }

      if (fOriginal.length() > 20*1024*1024) {
        Utils.execSWTThread(new AERunnable() {
          public void runSupport() {
            if (shell == null)
              new MessageSlideShell(Display.getCurrent(), SWT.ICON_ERROR,
                  "OpenTorrentWindow.mb.openError", fOriginal.toString(), new String[] {
                    UrlUtils.decode(sOriginatingLocation),
                    "Too large to be a torrent"
                  }, -1 );
            else {
              MessageBoxShell mb = new MessageBoxShell(SWT.OK,
                  "OpenTorrentWindow.mb.openError", new String[] {
                    sOriginatingLocation,
                    "Too large to be a torrent"
                  });
              mb.open(null);
            }
          }
        });
        return null;
      }

      torrentFile = TorrentUtils.copyTorrentFileToSaveDir(fOriginal, true);
      bDeleteFileOnCancel = !fOriginal.equals(torrentFile);
      // TODO if the files are still equal, and it isn't in the save
      //       dir, we should copy it to a temp file in case something
      //       re-writes it.  No need to copy a torrent coming from the
      //       downloader though..
    } catch (IOException e1) {
      // Use torrent in wherever it is and hope for the best
      // XXX Should error instead?
      torrentFile = new File(sFileName);
    }

    VuzeFileHandler vfh = VuzeFileHandler.getSingleton();
   
    VuzeFile vf = vfh.loadVuzeFile( torrentFile );
   
    if ( vf != null ){
     
        vfh.handleFiles( new VuzeFile[]{ vf }, VuzeFileComponent.COMP_TYPE_NONE );

        return null;
    }
   
    // Do a quick check to see if it's a torrent
    if (!TorrentUtil.isFileTorrent(torrentFile, shellForChildren,
        torrentFile.getName())) {
      if (bDeleteFileOnCancel) {
        torrentFile.delete();
      }
      return null;
    }

    // Load up the torrent, see it it's real
    try {
      torrent = TorrentUtils.readFromFile(torrentFile, false);
    } catch (final TOTorrentException e) {
     
      Utils.execSWTThread(new AERunnable() {
        public void runSupport() {
          if (shell == null)
            new MessageSlideShell(Display.getCurrent(), SWT.ICON_ERROR,
                "OpenTorrentWindow.mb.openError", Debug.getStackTrace(e),
                new String[] {
                  sOriginatingLocation,
                  e.getMessage()
                }, -1 );
          else {
            MessageBoxShell mb = new MessageBoxShell(SWT.OK,
                "OpenTorrentWindow.mb.openError", new String[] {
                  sOriginatingLocation,
                  e.getMessage()
                });
            mb.open(null);
          }
        }
      });

      if (bDeleteFileOnCancel)
        torrentFile.delete();

      return null;
    }

    String sExistingName = null;
    try {
      HashWrapper hash = torrent.getHashWrapper();
      if (hash != null) {
        for (int i = 0; i < torrentList.size(); i++) {
          try {
            TorrentInfo existing = (TorrentInfo) torrentList.get(i);
            if (existing.torrent.getHashWrapper().equals(hash)) {
              //sExistingName = existing.sOriginatingLocation;

              // Exit without warning when it already exists in list
              if (bDeleteFileOnCancel)
                torrentFile.delete();

              return null;
            }
          } catch (Exception e) {
          }
        }
      }
    } catch (Exception e) {
    }

    DownloadManager existingDownload = null;
    if (sExistingName == null) {
      // Check if torrent already exists in gm, and add if not
      existingDownload = (gm == null) ? null : gm.getDownloadManager(torrent);
      if (existingDownload != null) {
        sExistingName = existingDownload.getDisplayName();
      }
    }

    if (sExistingName == null) {
      info = new TorrentInfo(torrentFile.getAbsolutePath(), torrent,
          bDeleteFileOnCancel);
      info.sOriginatingLocation = sOriginatingLocation;
      torrentList.add(info);

    } else {

      final String sfExistingName = sExistingName;
      final DownloadManager fExistingDownload = existingDownload;
      Utils.execSWTThread(new AERunnable() {
        public void runSupport() {
          Shell mainShell = UIFunctionsManagerSWT.getUIFunctionsSWT().getMainShell();
          if (Display.getDefault().getActiveShell() == null || !mainShell.isVisible() || mainShell.getMinimized() ) {
            new MessageSlideShell(Display.getCurrent(), SWT.ICON_INFORMATION,
                MSG_ALREADY_EXISTS, null, new String[] {
                  ":" + sOriginatingLocation,
                  sfExistingName,
                  MessageText.getString(MSG_ALREADY_EXISTS_NAME),
                }, new Object[] {
View Full Code Here

          dm.setForceStart(true);
        }

      } catch (Exception e) {
        if (shell == null)
          new MessageSlideShell(Display.getCurrent(), SWT.ICON_ERROR,
              "OpenTorrentWindow.mb.openError", Debug.getStackTrace(e),
              new String[] {
                info.sOriginatingLocation,
                e.getMessage()
              }, -1 );
View Full Code Here

              } else {
                torrent = (TOTorrent) LogRelationUtils.queryForClass(
                    relatedObjects, TOTorrent.class);
              }

              MessageSlideShell shell = (MessageSlideShell) skinnableObject;

              byte[] contentThumbnail = PlatformTorrentUtils.getContentThumbnail(torrent);
              GC gc = new GC(image);
              try {
                gc.setBackground(gc.getDevice().getSystemColor(
                    SWT.COLOR_WIDGET_BACKGROUND));
                gc.fillRectangle(image.getBounds());

                if (contentThumbnail != null) {

                  try {
                    ByteArrayInputStream bis = new ByteArrayInputStream(
                        contentThumbnail);
                    final Image img = new Image(Display.getDefault(), bis);
                    Rectangle imgBounds = img.getBounds();
                    double pct = 35.0 / imgBounds.height;
                    int w = (int) (imgBounds.width * pct);

                    try {
                      gc.setAdvanced(true);
                      gc.setInterpolation(SWT.HIGH);
                    } catch (Exception e) {
                      // not important if we can't set advanced
                    }

                    gc.drawImage(img, 0, 0, imgBounds.width, imgBounds.height,
                        0, 265, w, 35);
                    img.dispose();
                  } catch (Exception e) {

                  }

                }
              } finally {
                gc.dispose();
              }
              shell.setImgPopup(image);

              composite.addListener(SWT.Dispose, new Listener() {
                public void handleEvent(Event event) {
                  if (!image.isDisposed()) {
                    image.dispose();
View Full Code Here

          case STATUSICON_ERROR:
            swtIconID = SWT.ICON_ERROR;
            break;
        }
       
        new MessageSlideShell(SWTThread.getInstance().getDisplay(), swtIconID,
            title, text, details, relatedObjects, timeoutSecs);
       
      }
    });
  }
View Full Code Here

      if (dataReceive >= 1024) {
        maxBandwidth = dataReceive / 1024;
      }
    }

    SpeedScaleShell speedScale = new SpeedScaleShell() {
      public String getStringValue(int value, String sValue) {
        if (sValue != null) {
          return prefix + ": " + sValue;
        }
        if (value == 0) {
          return MessageText.getString("MyTorrentsView.menu.setSpeed.unlimited");
        }
        if (value == -1) {
          return MessageText.getString("ConfigView.auto");
        }
        return prefix
            + ": "
            + (value == 0 ? MessageText.getString("ConfigView.unlimited")
                : DisplayFormatters.formatByteCountToKiBEtcPerSec(
                    getValue() * 1024, true));
      }
    };
    int max = unlim ? (isUpSpeed ? 100 : 800) : maxBandwidth * 5;
    if (max < 50) {
      max = 50;
    }
    speedScale.setMaxValue(max);
    speedScale.setMaxTextValue(9999999);

    final String config_prefix = "config.ui.speed.partitions.manual."
        + (isUpSpeed ? "upload" : "download") + ".";
    int lastValue = COConfigurationManager.getIntParameter(config_prefix
        + "last", -10);

    Integer[] speed_limits;
    if (COConfigurationManager.getBooleanParameter(config_prefix + "enabled",
        false)) {
      speed_limits = parseSpeedPartitionString(COConfigurationManager.getStringParameter(
          config_prefix + "values", ""));
    } else {
      speed_limits = getGenericSpeedList(6, maxBandwidth);
    }
    if (speed_limits != null) {
      for (int i = 0; i < speed_limits.length; i++) {
        int value = speed_limits[i].intValue();
        if (value > 0) {
          speedScale.addOption(DisplayFormatters.formatByteCountToKiBEtcPerSec(
              value * 1024, true), value);
          if (value == lastValue) {
            lastValue = -10;
          }
        }
      }
    }
    speedScale.addOption(
        MessageText.getString("MyTorrentsView.menu.setSpeed.unlimited"), 0);
    speedScale.addOption(MessageText.getString("ConfigView.auto"), -1);

    if (lastValue > 0) {
      speedScale.addOption(DisplayFormatters.formatByteCountToKiBEtcPerSec(
          lastValue * 1024, true), lastValue);
    }

    // SWT BUG: on windows/linux, if mouse is down on shell open, all mouse events
    // will not reflect this
    if (speedScale.open(auto ? -1 : maxBandwidth, Constants.isWindows
        || Constants.isLinux)) {
      int value = speedScale.getValue();

      if (!speedScale.wasMenuChosen() || lastValue == value) {
        COConfigurationManager.setParameter(config_prefix + "last",
            maxBandwidth);
      }

      if (value >= 0) {
View Full Code Here

            return noErr;
          case kHICommandNatTest:
            new NatTestWindow();
            return noErr;
          case kHICommandSpeedTest:
            new SpeedTestWizard();
            return noErr;

          case kAEQuitApplication:
            UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
            if (uiFunctions != null) {
View Full Code Here

    } else if (sel == sel_wizardMenuSelected_) {
      new ConfigureWizard(false,ConfigureWizard.WIZARD_MODE_FULL);
    } else if (sel == sel_natMenuSelected_) {
      new NatTestWindow();
    } else if (sel == sel_speedMenuSelected_) {
      new SpeedTestWizard();
    } else if (sel == sel_toolbarButtonClicked_) {
      try {
        Field fldsel_window = osCls.getField("sel_window");
        Object windowId = invoke(osCls, "objc_msgSend", new Object[] {
          wrapPointer(arg0),
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.ui.swt.shells.MessageSlideShell$PopupParams

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.