Пример #1
0
  public ILaunchConfiguration getSelectedLaunchConfiguration() {
    if (!fLaunchConfigButton.getSelection()) return null;

    String configName = fLaunchConfigCombo.getText();
    try {
      ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
      ILaunchConfigurationType type =
          manager.getLaunchConfigurationType(EclipseLaunchShortcut.CONFIGURATION_TYPE);
      ILaunchConfigurationType type2 =
          manager.getLaunchConfigurationType(IPDELauncherConstants.OSGI_CONFIGURATION_TYPE);
      ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
      ILaunchConfiguration[] configs2 = manager.getLaunchConfigurations(type2);
      ILaunchConfiguration[] configurations =
          new ILaunchConfiguration[configs.length + configs2.length];
      System.arraycopy(configs, 0, configurations, 0, configs.length);
      System.arraycopy(configs2, 0, configurations, configs.length, configs2.length);
      for (int i = 0; i < configurations.length; i++) {
        if (configurations[i].getName().equals(configName)
            && !DebugUITools.isPrivate(configurations[i])) return configurations[i];
      }
    } catch (CoreException e) {
      PDEPlugin.logException(e);
    }
    return null;
  }
 /**
  * Returns the given input stream as a byte array
  *
  * @param stream the stream to get as a byte array
  * @param length the length to read from the stream or -1 for unknown
  * @return the given input stream as a byte array
  * @throws IOException
  */
 public static byte[] getInputStreamAsByteArray(InputStream stream, int length)
     throws IOException {
   byte[] contents;
   if (length == -1) {
     contents = new byte[0];
     int contentsLength = 0;
     int amountRead = -1;
     do {
       // read at least 8K
       int amountRequested = Math.max(stream.available(), 8192);
       // resize contents if needed
       if (contentsLength + amountRequested > contents.length) {
         System.arraycopy(
             contents,
             0,
             contents = new byte[contentsLength + amountRequested],
             0,
             contentsLength);
       }
       // read as many bytes as possible
       amountRead = stream.read(contents, contentsLength, amountRequested);
       if (amountRead > 0) {
         // remember length of contents
         contentsLength += amountRead;
       }
     } while (amountRead != -1);
     // resize contents if necessary
     if (contentsLength < contents.length) {
       System.arraycopy(contents, 0, contents = new byte[contentsLength], 0, contentsLength);
     }
   } else {
     contents = new byte[length];
     int len = 0;
     int readSize = 0;
     while ((readSize != -1) && (len != length)) {
       // See PR 1FMS89U
       // We record first the read size. In this case length is the actual
       // read size.
       len += readSize;
       readSize = stream.read(contents, len, length - len);
     }
   }
   return contents;
 }
 private void handleDelete() {
   IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
   if (ssel.size() > 0) {
     Object[] objects = ssel.toArray();
     IProductPlugin[] plugins = new IProductPlugin[objects.length];
     System.arraycopy(objects, 0, plugins, 0, objects.length);
     getProduct().removePlugins(plugins);
     updateRemoveButtons(true, true);
   }
 }