Exemplo n.º 1
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    InstallOptions that = (InstallOptions) o;

    if (offline != that.offline) return false;
    if (controllerJson != null
        ? !controllerJson.equals(that.controllerJson)
        : that.controllerJson != null) return false;
    if (controllerUrl != null
        ? !controllerUrl.equals(that.controllerUrl)
        : that.controllerUrl != null) return false;
    if (environment != null ? !environment.equals(that.environment) : that.environment != null)
      return false;
    if (!Arrays.equals(excludeDependencyFilterPatterns, that.excludeDependencyFilterPatterns))
      return false;
    if (extractCmd != null ? !extractCmd.equals(that.extractCmd) : that.extractCmd != null)
      return false;
    if (id != null ? !id.equals(that.id) : that.id != null) return false;
    if (jarFiles != null ? !jarFiles.equals(that.jarFiles) : that.jarFiles != null) return false;
    if (!Arrays.equals(jvmOptions, that.jvmOptions)) return false;
    if (mainClass != null ? !mainClass.equals(that.mainClass) : that.mainClass != null)
      return false;
    if (name != null ? !name.equals(that.name) : that.name != null) return false;
    if (!Arrays.equals(optionalDependencyPatterns, that.optionalDependencyPatterns)) return false;
    if (properties != null ? !properties.equals(that.properties) : that.properties != null)
      return false;
    if (url != null ? !url.equals(that.url) : that.url != null) return false;

    return true;
  }
Exemplo n.º 2
0
  /**
   * Remove the given file. But we can't remove the last file.
   *
   * @param f the file to be removed
   */
  public void removeFile(File f) {

    URL url = null;
    try {
      url = f.toURI().toURL();
    } catch (MalformedURLException e) {
      LOG.warn("could not remove file ", e);
      return;
    }

    List<URL> urls = new ArrayList<URL>();
    for (URL u : getURLs()) {
      if (!url.equals(u)) {
        urls.add(u);
      }
    }

    // can't remove the last file
    if (urls.size() == 0) {
      return;
    }

    // can't remove from existing one so create new one.
    URL[] urlArray = new URL[urls.size()];
    urlArray = urls.toArray(urlArray);
    instance = new ImportClassLoader(urlArray);
  }
Exemplo n.º 3
0
 @Test
 public void testURI() throws Exception {
   URI uri = new URI("classpath:com/myapp/config.xml");
   System.out.println((uri));
   System.out.println(ReflectUtil.map(uri));
   URL.setURLStreamHandlerFactory(
       new URLStreamHandlerFactory() {
         public URLStreamHandler createURLStreamHandler(String protocol) {
           if (protocol.equals("classpath")) {
             return new URLStreamHandler() {
               @Override
               protected URLConnection openConnection(URL u) throws IOException {
                 return this.getClass().getResource("/" + u.getPath()).openConnection();
               }
             };
           } else {
             return null;
           }
         }
       });
   URL url1 = uri.toURL();
   URL url2 = new URL("classpath:com/myapp/config.xml");
   System.out.println(ReflectUtil.map(url1));
   System.out.println(ReflectUtil.map(url2));
   System.out.println(url1.equals(url2));
 }
Exemplo n.º 4
0
    /** {@inheritDoc} */
    @SuppressWarnings({"BigDecimalEquals", "EqualsHashCodeCalledOnUrl", "RedundantIfStatement"})
    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;

      TestObject that = (TestObject) o;

      if (id != that.id) return false;
      if (!Arrays.equals(arrVal, that.arrVal)) return false;
      if (bigVal != null ? !bigVal.equals(that.bigVal) : that.bigVal != null) return false;
      if (boolVal != null ? !boolVal.equals(that.boolVal) : that.boolVal != null) return false;
      if (byteVal != null ? !byteVal.equals(that.byteVal) : that.byteVal != null) return false;
      if (dateVal != null ? !dateVal.equals(that.dateVal) : that.dateVal != null) return false;
      if (doubleVal != null ? !doubleVal.equals(that.doubleVal) : that.doubleVal != null)
        return false;
      if (f1 != null ? !f1.equals(that.f1) : that.f1 != null) return false;
      if (f2 != null ? !f2.equals(that.f2) : that.f2 != null) return false;
      if (f3 != null ? !f3.equals(that.f3) : that.f3 != null) return false;
      if (floatVal != null ? !floatVal.equals(that.floatVal) : that.floatVal != null) return false;
      if (intVal != null ? !intVal.equals(that.intVal) : that.intVal != null) return false;
      if (longVal != null ? !longVal.equals(that.longVal) : that.longVal != null) return false;
      if (shortVal != null ? !shortVal.equals(that.shortVal) : that.shortVal != null) return false;
      if (strVal != null ? !strVal.equals(that.strVal) : that.strVal != null) return false;
      if (timeVal != null ? !timeVal.equals(that.timeVal) : that.timeVal != null) return false;
      if (tsVal != null ? !tsVal.equals(that.tsVal) : that.tsVal != null) return false;
      if (urlVal != null ? !urlVal.equals(that.urlVal) : that.urlVal != null) return false;

      return true;
    }
Exemplo n.º 5
0
 // TODO Document.
 public void enqueue(URL url, Synapse synapse) {
   if (url.equals(node.getURL())) {
     enqueue(synapse);
   } else {
     listOfExecutors.addLast(new EnvelopeExecutor(new Envelope(url, synapse)));
   }
 }
  public final boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    AbstractUrlResourceLocation that = (AbstractUrlResourceLocation) o;
    return codeSource.equals(that.codeSource);
  }
Exemplo n.º 7
0
 /*
  * Validate a URL can be read
  */
 @Test(enabled = true)
 public void test10() throws Exception {
   URL u = new URL("http://www.oracle.com/");
   ;
   Object[] values = {u};
   SQLInputImpl sqli = new SQLInputImpl(values, map);
   URL u2 = sqli.readURL();
   assertTrue(u2.equals(u));
   assertTrue(u2.sameFile(u));
 }
Exemplo n.º 8
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    SiteMapURL that = (SiteMapURL) o;

    if (!url.equals(that.url)) return false;

    return true;
  }
Exemplo n.º 9
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Endpoint endpoint = (Endpoint) o;

    if (callback == null || !callback.equals(endpoint.callback)) return false;
    if (!id.equals(endpoint.id)) return false;

    return true;
  }
Exemplo n.º 10
0
  public static void main(String args[]) throws Exception {
    int errorCnt = 0;

    URL url1 = new URL("ftp://he@host/file#ref");
    URL url2 = new URL("ftp://she@host/file#ref");

    if (url1.equals(url2)) {
      throw new RuntimeException("URLStreamHandler.equals failure.");
    } else {
      System.out.println("Success.");
    }
  }
Exemplo n.º 11
0
  @Override
  public void setIconURL(URL iconURL) {
    if (iconURL == null && this.iconURL == null) return;
    if (iconURL != null && iconURL.equals(this.iconURL)) return;

    synchronized (iconLock) {
      this.iconURL = iconURL;

      iconLoaded = iconURL == null;
      if (iconLoaded) icon = null;
    }
  }
    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;

      Expectation that = (Expectation) o;

      if (statusCode != that.statusCode) return false;
      if (!payload.equals(that.payload)) return false;
      if (!url.equals(that.url)) return false;

      return true;
    }
Exemplo n.º 13
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   PhotoJ_V07 other = (PhotoJ_V07) obj;
   if (ratings == null) {
     if (other.ratings != null) return false;
   } else if (!ratings.equals(other.ratings)) return false;
   if (sizeKb != other.sizeKb) return false;
   if (url == null) {
     if (other.url != null) return false;
   } else if (!url.equals(other.url)) return false;
   return true;
 }
  public URLConnection openConnection(URL url) throws IOException {
    if (expectedUrl == null) {
      throw new IllegalStateException("expectedUrl was not set");
    }

    // the caller copied the URL reusing a stream handler from a previous call
    if (!expectedUrl.equals(url)) {
      // the new url is supposed to be within our context, so it must have a jar protocol
      if (!url.getProtocol().equals("jar")) {
        throw new IllegalArgumentException("Unsupported protocol " + url.getProtocol());
      }

      // split the path at "!/" into the file part and entry part
      String path = url.getPath();
      String[] chunks = path.split("!/", 2);

      // if we only got only one chunk, it didn't contain the required "!/" delimiter
      if (chunks.length == 1) {
        throw new MalformedURLException("Url does not contain a '!' character: " + url);
      }

      String file = chunks[0];
      String entryPath = chunks[1];

      // this handler only supports jars on the local file system
      if (!file.startsWith("file:")) {
        // let the system handler deal with this
        return new URL(url.toExternalForm()).openConnection();
      }
      file = file.substring("file:".length());

      // again the new url is supposed to be within our context so it must reference the same jar
      // file
      if (!jarFile.getName().equals(file)) {
        // let the system handler deal with this
        return new URL(url.toExternalForm()).openConnection();
      }

      // get the entry
      JarEntry newEntry = jarFile.getJarEntry(entryPath);
      if (newEntry == null) {
        throw new FileNotFoundException("Entry not found: " + url);
      }
      return new JarFileUrlConnection(url, jarFile, newEntry);
    }

    return new JarFileUrlConnection(url, jarFile, jarEntry);
  }
Exemplo n.º 15
0
  /**
   * Called when the play button is pressed. This will toggle the playing state of the current
   * stream. If the stream URL in the text field has changed, it will update the audio play URL and
   * try and play the stream.
   */
  private void togglePlay() {
    URL streamURL;
    try {
      streamURL = new URL(streamURLField.getText());
    } catch (MalformedURLException e) {
      titleLabel.setText("<html><b>Error in stream URL</b> - Audio Player</html>");
      return;
    }

    AudioPlayer audioPlayer = AudioPlayer.getInstance();

    if (streamURL.equals(audioPlayer.getURL())) {
      audioPlayer.setPlaying(!audioPlayer.isPlaying());
    } else {
      audioPlayer.setURL(streamURL);
    }
  }
Exemplo n.º 16
0
  /**
   * Tests for equality between the specified object and this object. Two CodeSource objects are
   * considered equal if their locations are of identical value.
   *
   * @param obj the object to test for equality with this object.
   * @return true if the objects are considered equal, false otherwise.
   */
  public boolean equals(Object obj) {
    if (obj == this) return true;

    // objects types must be equal
    if (!(obj instanceof CodeSource)) return false;

    CodeSource cs = (CodeSource) obj;

    // URLs must match
    if (location == null) {
      // if location is null, then cs.location must be null as well
      return cs.location == null;
    } else {
      // if location is not null, then it must equal cs.location
      return location.equals(cs.location);
    }
  }
Exemplo n.º 17
0
 /** Update the service coverage component if the currently selected service URL has changed. */
 private void updateServiceCoverage() {
   if (hasCoverage_) {
     if (coverageModel_.isSelected()) {
       URL url = toUrl(urlField_.getText());
       if ((url == null && lastCoverageUrl_ != null)
           || (url != null && !url.equals(lastCoverageUrl_))) {
         Coverage cov = url == null ? null : service_.getCoverage(url);
         serviceCoverageView_.setCoverage(cov);
         lastCoverageUrl_ = url;
         updateOverlapCoverage();
       }
     } else {
       serviceCoverageView_.setCoverage(null);
       lastCoverageUrl_ = null;
     }
   }
 }
Exemplo n.º 18
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   SparqlEndpoint other = (SparqlEndpoint) obj;
   if (defaultGraphURIs == null) {
     if (other.defaultGraphURIs != null) return false;
   } else if (!defaultGraphURIs.equals(other.defaultGraphURIs)) return false;
   if (namedGraphURIs == null) {
     if (other.namedGraphURIs != null) return false;
   } else if (!namedGraphURIs.equals(other.namedGraphURIs)) return false;
   if (url == null) {
     if (other.url != null) return false;
   } else if (!url.equals(other.url)) return false;
   return true;
 }
Exemplo n.º 19
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   BuiltInOBRLink other = (BuiltInOBRLink) obj;
   if (bundleId == null) {
     if (other.bundleId != null) return false;
   } else if (!bundleId.equals(other.bundleId)) return false;
   if (label == null) {
     if (other.label != null) return false;
   } else if (!label.equals(other.label)) return false;
   if (url == null) {
     if (other.url != null) return false;
   } else if (!url.equals(other.url)) return false;
   return true;
 }
Exemplo n.º 20
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof Request)) return false;

    Request request = (Request) o;

    if (saveInCache != request.saveInCache) return false;
    if (archiveResult != request.archiveResult) return false;
    if (withParams != request.withParams) return false;
    if (!url.equals(request.url)) return false;
    if (suffix != null ? !suffix.equals(request.suffix) : request.suffix != null) return false;
    if (!params.equals(request.params)) return false;
    if (encoding != null ? !encoding.equals(request.encoding) : request.encoding != null)
      return false;
    if (content != null ? !content.equals(request.content) : request.content != null) return false;
    if (!headers.equals(request.headers)) return false;
    return method == request.method;
  }
  private void openedByBrowser(Item item, URL url) {
    if (url == null || item == null) {
      return;
    }

    WebBrowserEditorInput input = new WebBrowserEditorInput(url);
    // add for bug TDI-21189 at 2012-6-8,that a document exist is only opened one time in studio
    try {
      IWorkbenchPage page = getActivePage();
      IEditorReference[] iEditorReference = page.getEditorReferences();
      for (IEditorReference editors : iEditorReference) {
        if (WebBrowserEditor.WEB_BROWSER_EDITOR_ID.equals(editors.getId())) {
          IEditorPart iEditorPart = editors.getEditor(true);
          if (iEditorPart != null && iEditorPart instanceof WebBrowserEditor) {
            WebBrowserEditorInput webBrowserEditorInput =
                (WebBrowserEditorInput) iEditorPart.getEditorInput();
            if (webBrowserEditorInput != null && url.equals(webBrowserEditorInput.getURL())) {
              // page.activate(iEditorPart);
              iEditorPart.init(iEditorPart.getEditorSite(), webBrowserEditorInput);
              DocumentationUtil.setPartItemId(
                  (WebBrowserEditor) iEditorPart,
                  item.getProperty().getId(),
                  ERepositoryObjectType.getItemType(item));
              return;
            }
          }
        }
      }
      input.setName(item.getProperty().getLabel());
      input.setToolTipText(
          item.getProperty().getLabel() + " " + item.getProperty().getVersion()); // $NON-NLS-1$
      IEditorPart editorPart = page.openEditor(input, WebBrowserEditor.WEB_BROWSER_EDITOR_ID);
      if (editorPart != null && editorPart instanceof WebBrowserEditor) {
        DocumentationUtil.setPartItemId(
            (WebBrowserEditor) editorPart,
            item.getProperty().getId(),
            ERepositoryObjectType.getItemType(item));
      }
    } catch (PartInitException e) {
      MessageBoxExceptionHandler.process(e);
    }
  }
Exemplo n.º 22
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   XmlMessage other = (XmlMessage) obj;
   if (date == null) {
     if (other.date != null) return false;
   } else if (!date.equals(other.date)) return false;
   if (description == null) {
     if (other.description != null) return false;
   } else if (!description.equals(other.description)) return false;
   if (link == null) {
     if (other.link != null) return false;
   } else if (!link.equals(other.link)) return false;
   if (title == null) {
     if (other.title != null) return false;
   } else if (!title.equals(other.title)) return false;
   return true;
 }
Exemplo n.º 23
0
  static {
    // turn off logging in the reflections library - they talk too much
    Reflections.log = null;

    Set<URL> classPathUrls = new LinkedHashSet<URL>();

    URL cwd;
    try {
      cwd = new File(".").getAbsoluteFile().toURI().toURL();
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }

    // NOTE: Reflections also scans directories for classes.
    // Meanwhile some of the jar MANIFEST.MF Bundle-ClassPath properties contain "."
    // Do NOT let reflections scan the CWD where it often picks up test classes when
    // they weren't explicitly in the classpath, for example the UninstantiableWalker
    for (URL url : JVMUtils.getClasspathURLs()) if (!url.equals(cwd)) classPathUrls.add(url);

    defaultReflections =
        new Reflections(
            new ConfigurationBuilder().setUrls(classPathUrls).setScanners(new SubTypesScanner()));
  }
Exemplo n.º 24
0
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    GlideUrl glideUrl = (GlideUrl) o;
    if (stringUrl != null) {
      if (glideUrl.stringUrl != null) {
        return stringUrl.equals(glideUrl.stringUrl);
      } else {
        return stringUrl.equals(glideUrl.url.toString());
      }
    } else {
      if (glideUrl.stringUrl != null) {
        return url.toString().equals(glideUrl.stringUrl);
      } else {
        return url.equals(glideUrl.url);
      }
    }
  }
Exemplo n.º 25
0
  /**
   * Handles the object invocation.
   *
   * @param proxy the proxy object to invoke
   * @param method the method to call
   * @param args the arguments to the proxy object
   */
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    String methodName = method.getName();
    Class[] params = method.getParameterTypes();

    // equals and hashCode are special cased
    if (methodName.equals("equals") && params.length == 1 && params[0].equals(Object.class)) {
      Object value = args[0];
      if (value == null || !Proxy.isProxyClass(value.getClass())) return new Boolean(false);

      BurlapProxy handler = (BurlapProxy) Proxy.getInvocationHandler(value);

      return new Boolean(_url.equals(handler.getURL()));
    } else if (methodName.equals("hashCode") && params.length == 0)
      return new Integer(_url.hashCode());
    else if (methodName.equals("getBurlapType"))
      return proxy.getClass().getInterfaces()[0].getName();
    else if (methodName.equals("getBurlapURL")) return _url.toString();
    else if (methodName.equals("toString") && params.length == 0)
      return "[BurlapProxy " + _url + "]";

    InputStream is = null;

    URLConnection conn = null;
    HttpURLConnection httpConn = null;
    try {
      conn = _factory.openConnection(_url);
      conn.setRequestProperty("Content-Type", "text/xml");

      OutputStream os;

      try {
        os = conn.getOutputStream();
      } catch (Exception e) {
        throw new BurlapRuntimeException(e);
      }

      BurlapOutput out = _factory.getBurlapOutput(os);

      if (!_factory.isOverloadEnabled()) {
      } else if (args != null) methodName = methodName + "__" + args.length;
      else methodName = methodName + "__0";

      if (log.isLoggable(Level.FINE))
        log.fine(this + " calling " + methodName + " (" + method + ")");

      out.call(methodName, args);

      try {
        os.flush();
      } catch (Exception e) {
        throw new BurlapRuntimeException(e);
      }

      if (conn instanceof HttpURLConnection) {
        httpConn = (HttpURLConnection) conn;
        int code = 500;

        try {
          code = httpConn.getResponseCode();
        } catch (Exception e) {
        }

        if (code != 200) {
          StringBuffer sb = new StringBuffer();
          int ch;

          try {
            is = httpConn.getInputStream();

            if (is != null) {
              while ((ch = is.read()) >= 0) sb.append((char) ch);

              is.close();
            }

            is = httpConn.getErrorStream();
            if (is != null) {
              while ((ch = is.read()) >= 0) sb.append((char) ch);
            }
          } catch (FileNotFoundException e) {
            throw new BurlapRuntimeException(code + ": " + String.valueOf(e));
          } catch (IOException e) {
          }

          if (is != null) is.close();

          throw new BurlapProtocolException(code + ": " + sb.toString());
        }
      }

      is = conn.getInputStream();

      AbstractBurlapInput in = _factory.getBurlapInput(is);

      return in.readReply(method.getReturnType());
    } catch (BurlapProtocolException e) {
      throw new BurlapRuntimeException(e);
    } finally {
      try {
        if (is != null) is.close();
      } catch (IOException e) {
      }

      if (httpConn != null) httpConn.disconnect();
    }
  }
  private static void doAddGlobalTransforms(
      ASTTransformationsContext context, boolean isFirstScan) {
    final CompilationUnit compilationUnit = context.getCompilationUnit();
    GroovyClassLoader transformLoader = compilationUnit.getTransformLoader();
    Map<String, URL> transformNames = new LinkedHashMap<String, URL>();
    try {
      Enumeration<URL> globalServices =
          transformLoader.getResources(
              "META-INF/services/org.codehaus.groovy.transform.ASTTransformation");
      while (globalServices.hasMoreElements()) {
        URL service = globalServices.nextElement();
        String className;
        BufferedReader svcIn = null;
        try {
          svcIn = new BufferedReader(new InputStreamReader(service.openStream()));
          try {
            className = svcIn.readLine();
          } catch (IOException ioe) {
            compilationUnit
                .getErrorCollector()
                .addError(
                    new SimpleMessage(
                        "IOException reading the service definition at "
                            + service.toExternalForm()
                            + " because of exception "
                            + ioe.toString(),
                        null));
            continue;
          }
          Set<String> disabledGlobalTransforms =
              compilationUnit.getConfiguration().getDisabledGlobalASTTransformations();
          if (disabledGlobalTransforms == null) disabledGlobalTransforms = Collections.emptySet();
          while (className != null) {
            if (!className.startsWith("#") && className.length() > 0) {
              if (!disabledGlobalTransforms.contains(className)) {
                if (transformNames.containsKey(className)) {
                  if (!service.equals(transformNames.get(className))) {
                    compilationUnit
                        .getErrorCollector()
                        .addWarning(
                            WarningMessage.POSSIBLE_ERRORS,
                            "The global transform for class "
                                + className
                                + " is defined in both "
                                + transformNames.get(className).toExternalForm()
                                + " and "
                                + service.toExternalForm()
                                + " - the former definition will be used and the latter ignored.",
                            null,
                            null);
                  }

                } else {
                  transformNames.put(className, service);
                }
              }
            }
            try {
              className = svcIn.readLine();
            } catch (IOException ioe) {
              compilationUnit
                  .getErrorCollector()
                  .addError(
                      new SimpleMessage(
                          "IOException reading the service definition at "
                              + service.toExternalForm()
                              + " because of exception "
                              + ioe.toString(),
                          null));
              //noinspection UnnecessaryContinue
              continue;
            }
          }
        } finally {
          if (svcIn != null) svcIn.close();
        }
      }
    } catch (IOException e) {
      // FIXME the warning message will NPE with what I have :(
      compilationUnit
          .getErrorCollector()
          .addError(
              new SimpleMessage(
                  "IO Exception attempting to load global transforms:" + e.getMessage(), null));
    }
    try {
      Class.forName("java.lang.annotation.Annotation"); // test for 1.5 JVM
    } catch (Exception e) {
      // we failed, notify the user
      StringBuffer sb = new StringBuffer();
      sb.append("Global ASTTransformations are not enabled in retro builds of groovy.\n");
      sb.append("The following transformations will be ignored:");
      for (Map.Entry<String, URL> entry : transformNames.entrySet()) {
        sb.append('\t');
        sb.append(entry.getKey());
        sb.append('\n');
      }
      compilationUnit
          .getErrorCollector()
          .addWarning(
              new WarningMessage(WarningMessage.POSSIBLE_ERRORS, sb.toString(), null, null));
      return;
    }

    // record the transforms found in the first scan, so that in the 2nd scan, phase operations
    // can be added for only for new transforms that have come in
    if (isFirstScan) {
      for (Map.Entry<String, URL> entry : transformNames.entrySet()) {
        context.getGlobalTransformNames().add(entry.getKey());
      }
      addPhaseOperationsForGlobalTransforms(
          context.getCompilationUnit(), transformNames, isFirstScan);
    } else {
      Iterator<Map.Entry<String, URL>> it = transformNames.entrySet().iterator();
      while (it.hasNext()) {
        Map.Entry<String, URL> entry = it.next();
        if (!context.getGlobalTransformNames().add(entry.getKey())) {
          // phase operations for this transform class have already been added before, so remove
          // from current scan cycle
          it.remove();
        }
      }
      addPhaseOperationsForGlobalTransforms(
          context.getCompilationUnit(), transformNames, isFirstScan);
    }
  }
Exemplo n.º 27
0
  /** Initializes the Location objects for the LocationManager. */
  public static void initializeLocations() {
    // do install location initialization first since others may depend on it
    // assumes that the property is already set
    installLocation = buildLocation(PROP_INSTALL_AREA, null, "", true, false, null); // $NON-NLS-1$

    // TODO not sure what the data area prefix should be here for the user area
    Location temp =
        buildLocation(PROP_USER_AREA_DEFAULT, null, "", false, false, null); // $NON-NLS-1$
    URL defaultLocation = temp == null ? null : temp.getURL();
    if (defaultLocation == null)
      defaultLocation =
          buildURL(
              new File(FrameworkProperties.getProperty(PROP_USER_HOME), "user").getAbsolutePath(),
              true); //$NON-NLS-1$
    userLocation =
        buildLocation(PROP_USER_AREA, defaultLocation, "", false, false, null); // $NON-NLS-1$

    temp =
        buildLocation(
            PROP_INSTANCE_AREA_DEFAULT,
            null,
            "",
            false,
            false,
            INSTANCE_DATA_AREA_PREFIX); //$NON-NLS-1$
    defaultLocation = temp == null ? null : temp.getURL();
    if (defaultLocation == null)
      defaultLocation =
          buildURL(
              new File(FrameworkProperties.getProperty(PROP_USER_DIR), "workspace")
                  .getAbsolutePath(),
              true); //$NON-NLS-1$
    instanceLocation =
        buildLocation(
            PROP_INSTANCE_AREA,
            defaultLocation,
            "",
            false,
            false,
            INSTANCE_DATA_AREA_PREFIX); //$NON-NLS-1$

    mungeConfigurationLocation();
    // compute a default but it is very unlikely to be used since main will have computed everything
    temp = buildLocation(PROP_CONFIG_AREA_DEFAULT, null, "", false, false, null); // $NON-NLS-1$
    defaultLocation = temp == null ? null : temp.getURL();
    if (defaultLocation == null && FrameworkProperties.getProperty(PROP_CONFIG_AREA) == null)
      // only compute the default if the configuration area property is not set
      defaultLocation = buildURL(computeDefaultConfigurationLocation(), true);
    configurationLocation =
        buildLocation(PROP_CONFIG_AREA, defaultLocation, "", false, false, null); // $NON-NLS-1$
    // get the parent location based on the system property. This will have been set on the
    // way in either by the caller/user or by main.  There will be no parent location if we are not
    // cascaded.
    URL parentLocation = computeSharedConfigurationLocation();
    if (parentLocation != null && !parentLocation.equals(configurationLocation.getURL())) {
      Location parent = new BasicLocation(null, parentLocation, true, null);
      ((BasicLocation) configurationLocation).setParent(parent);
    }
    initializeDerivedConfigurationLocations();

    if (FrameworkProperties.getProperty(PROP_HOME_LOCATION_AREA) == null) {
      String eclipseLauncher = FrameworkProperties.getProperty(PROP_LAUNCHER);
      String eclipseHomeLocationPath = getEclipseHomeLocation(eclipseLauncher);
      if (eclipseHomeLocationPath != null)
        FrameworkProperties.setProperty(PROP_HOME_LOCATION_AREA, eclipseHomeLocationPath);
    }
    // if eclipse.home.location is not set then default to osgi.install.area
    if (FrameworkProperties.getProperty(PROP_HOME_LOCATION_AREA) == null
        && FrameworkProperties.getProperty(PROP_INSTALL_AREA) != null)
      FrameworkProperties.setProperty(
          PROP_HOME_LOCATION_AREA, FrameworkProperties.getProperty(PROP_INSTALL_AREA));
    eclipseHomeLocation =
        buildLocation(PROP_HOME_LOCATION_AREA, null, "", true, true, null); // $NON-NLS-1$
  }
Exemplo n.º 28
0
 /**
  * Returns true if this package is sealed with respect to the specified code source url.
  *
  * @param url the code source url
  * @return true if this package is sealed with respect to url
  */
 public boolean isSealed(URL url) {
   return url.equals(sealBase);
 }
Exemplo n.º 29
0
  /**
   * Displays the specified URL in the HTML component.
   *
   * @param url The URL
   * @param addToHistory Should the URL be added to the back/forward history?
   * @param scrollPosition The vertical scrollPosition
   */
  public void gotoURL(String url, boolean addToHistory, final int scrollPosition) {
    // the TOC pane looks up user's guide URLs relative to the
    // doc directory...
    String shortURL;
    if (MiscUtilities.isURL(url)) {
      if (url.startsWith(baseURL)) {
        shortURL = url.substring(baseURL.length());
        if (shortURL.startsWith("/")) {
          shortURL = shortURL.substring(1);
        }
      } else {
        shortURL = url;
      }
    } else {
      shortURL = url;
      if (baseURL.endsWith("/")) {
        url = baseURL + url;
      } else {
        url = baseURL + '/' + url;
      }
    }

    // reset default cursor so that the hand cursor doesn't
    // stick around
    viewer.setCursor(Cursor.getDefaultCursor());

    try {
      URL _url = new URL(url);

      if (!_url.equals(viewer.getPage())) {
        title.setText(jEdit.getProperty("helpviewer.loading"));
      } else {
        /* don't show loading msg because we won't
        receive a propertyChanged */
      }

      historyModel.setCurrentScrollPosition(viewer.getPage(), getCurrentScrollPosition());
      viewer.setPage(_url);
      if (0 != scrollPosition) {
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                viewerScrollPane.getVerticalScrollBar().setValue(scrollPosition);
              }
            });
      }
      if (addToHistory) {
        historyModel.addToHistory(url);
      }
    } catch (MalformedURLException mf) {
      Log.log(Log.ERROR, this, mf);
      String[] args = {url, mf.getMessage()};
      GUIUtilities.error(this, "badurl", args);
      return;
    } catch (IOException io) {
      Log.log(Log.ERROR, this, io);
      String[] args = {url, io.toString()};
      GUIUtilities.error(this, "read-error", args);
      return;
    }

    this.shortURL = shortURL;

    // select the appropriate tree node.
    if (shortURL != null) {
      toc.selectNode(shortURL);
    }

    viewer.requestFocus();
  } // }}}
Exemplo n.º 30
0
  private void updateUI() {
    if (!isAdded()) {
      return;
    }
    if (isSessionOpen()) {
      connectedStateLabel.setTextColor(
          getResources()
              .getColor(
                  AirFacebookExtension.context.getResourceId(
                      "color.com_facebook_usersettingsfragment_connected_text_color")));
      connectedStateLabel.setShadowLayer(
          1f,
          0f,
          -1f,
          getResources()
              .getColor(
                  AirFacebookExtension.context.getResourceId(
                      "color.com_facebook_usersettingsfragment_connected_shadow_color")));

      if (user != null) {
        ImageRequest request = getImageRequest();
        if (request != null) {
          URL requestUrl = request.getImageUrl();
          // Do we already have the right picture? If so, leave it alone.
          if (!requestUrl.equals(connectedStateLabel.getTag())) {
            if (user.getId().equals(userProfilePicID)) {
              connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
              connectedStateLabel.setTag(requestUrl);
            } else {
              ImageDownloader.downloadAsync(request);
            }
          }
        }
        connectedStateLabel.setText(user.getName());
      } else {
        connectedStateLabel.setText(
            getResources()
                .getString(
                    AirFacebookExtension.context.getResourceId(
                        "string.com_facebook_usersettingsfragment_logged_in")));
        Drawable noProfilePic =
            getResources()
                .getDrawable(
                    AirFacebookExtension.context.getResourceId(
                        "drawable.com_facebook_profile_default_icon"));
        noProfilePic.setBounds(
            0,
            0,
            getResources()
                .getDimensionPixelSize(
                    AirFacebookExtension.context.getResourceId(
                        "dimen.com_facebook_usersettingsfragment_profile_picture_width")),
            getResources()
                .getDimensionPixelSize(
                    AirFacebookExtension.context.getResourceId(
                        "dimen.com_facebook_usersettingsfragment_profile_picture_height")));
        connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
      }
    } else {
      int textColor =
          getResources()
              .getColor(
                  AirFacebookExtension.context.getResourceId(
                      "color.com_facebook_usersettingsfragment_not_connected_text_color"));
      connectedStateLabel.setTextColor(textColor);
      connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
      connectedStateLabel.setText(
          getResources()
              .getString(
                  AirFacebookExtension.context.getResourceId(
                      "string.com_facebook_usersettingsfragment_not_logged_in")));
      connectedStateLabel.setCompoundDrawables(null, null, null, null);
      connectedStateLabel.setTag(null);
    }
  }