/**
   * Return the IResource instance that matches the specified path. The path is the relative path in
   * the workspace. If no IResource instance is found that match this path a null is returned.
   *
   * @param name the path to the IResource
   * @return the IResource
   */
  public static IResource findIResourceByPath(final IPath workspacePath) {
    if (workspacePath == null || workspacePath.isEmpty() || getWorkspace() == null) return null;

    // Collect all IResources within all IProjects
    final FileResourceCollectorVisitor visitor = new FileResourceCollectorVisitor();
    if (getWorkspace() != null && getWorkspace().getRoot() != null) {
      final IProject[] projects = getWorkspace().getRoot().getProjects();
      for (final IProject project : projects)
        try {
          project.accept(visitor);
        } catch (final CoreException e) {
          // do nothing
        }
    }

    final IFile[] fileResources = visitor.getFileResources();
    for (final IFile fileResource : fileResources)
      if (fileResource != null) {
        final IPath path = fileResource.getFullPath();
        // Do not process file names staring with '.' since these
        // are considered reserved for Eclipse specific files
        if (path.lastSegment().charAt(0) == '.') continue;
        if (path.equals(workspacePath)) return fileResource;
      }

    return null;
  }
Пример #2
0
  /**
   * Set the boolean symbol on and off image path. If the path is relative, then build absolute
   * path.
   *
   * <p><b>Rules:</b> <br>
   * If the image selected is on, then search off image. <br>
   * If the image selected is off, then search on image. <br>
   * If one or both is not found, the image path selected is the same for both.
   *
   * @param model
   * @param imagePath The path to the selected image (on or off or other)
   */
  public synchronized void setSymbolImagePath(ControlBoolSymbolModel model, IPath imagePath) {
    if (imagePath == null || imagePath.isEmpty()) {
      return;
    }
    if (!imagePath.isAbsolute()) {
      imagePath = org.csstudio.opibuilder.util.ResourceUtil.buildAbsolutePath(model, imagePath);
    }
    // Default
    this.onImagePath = imagePath;
    this.offImagePath = imagePath;

    // Search on or off equivalent
    if (ImageUtils.isOnImage(imagePath)) {
      IPath offImagePath = ImageUtils.searchOffImage(imagePath);
      if (offImagePath != null) {
        this.offImagePath = offImagePath;
      }
    } else if (ImageUtils.isOffImage(imagePath)) {
      IPath onImagePath = ImageUtils.searchOnImage(imagePath);
      if (onImagePath != null) {
        this.onImagePath = onImagePath;
      }
    }
    if (imagePath.getFileExtension() != null
        && "svg".compareToIgnoreCase(imagePath.getFileExtension()) == 0) {
      workingWithSVG = true;
    } else {
      workingWithSVG = false;
    }
    loadOffImage();
    loadOnImage();
  }
Пример #3
0
  private synchronized void updateIndexState(IPath indexLocation, Integer indexState) {
    if (indexLocation.isEmpty()) throw new IllegalArgumentException();

    getIndexStates(); // ensure the states are initialized
    if (indexState != null) {
      if (indexState.equals(indexStates.get(indexLocation))) return; // not changed
      indexStates.put(indexLocation, indexState);
    } else {
      if (!indexStates.containsKey(indexLocation)) return; // did not exist anyway
      indexStates.removeKey(indexLocation);
    }

    writeSavedIndexNamesFile();

    if (VERBOSE) {
      String state = "?"; // $NON-NLS-1$
      if (indexState == SAVED_STATE) state = "SAVED"; // $NON-NLS-1$
      else if (indexState == UPDATING_STATE) state = "UPDATING"; // $NON-NLS-1$
      else if (indexState == UNKNOWN_STATE) state = "UNKNOWN"; // $NON-NLS-1$
      else if (indexState == REBUILDING_STATE) state = "REBUILDING"; // $NON-NLS-1$
      Util.verbose(
          "-> index state updated to: "
              + state
              + " for: "
              + indexLocation); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }
Пример #4
0
 private void writeSavedIndexNamesFile() {
   BufferedWriter writer = null;
   try {
     writer = new BufferedWriter(new FileWriter(savedIndexNamesFile));
     writer.write(DiskIndex.SIGNATURE);
     writer.write('+');
     writer.write(getRubyPluginWorkingLocation().toOSString());
     writer.write('\n');
     Object[] keys = indexStates.keyTable;
     Object[] states = indexStates.valueTable;
     for (int i = 0, l = states.length; i < l; i++) {
       IPath key = (IPath) keys[i];
       if (key != null && !key.isEmpty() && states[i] == SAVED_STATE) {
         writer.write(key.lastSegment());
         writer.write('\n');
       }
     }
   } catch (IOException ignored) {
     if (VERBOSE)
       Util.verbose("Failed to write saved index file names", System.err); // $NON-NLS-1$
   } finally {
     if (writer != null) {
       try {
         writer.close();
       } catch (IOException e) {
         // ignore
       }
     }
   }
 }
Пример #5
0
  /**
   * Determines whether or not this is a valid {@link IRuntime} of a Karaf installation.
   *
   * @return a {@link IStatus} object indicating whether or not this is a valid Karaf runtime. A
   *     valid Karaf Runtime will return {@link Status#OK_STATUS} otherwise a status based on {@link
   *     IStatus#ERROR}
   */
  @Override
  public IStatus validate() {
    final IPath location = getRuntime().getLocation();

    if (location == null || location.isEmpty()) {
      return new Status(IStatus.ERROR, KarafWtpPluginActivator.PLUGIN_ID, 0, "", null);
    }

    final IStatus status = super.validate();
    if (!status.isOK()) {
      return status;
    }

    KarafPlatformModel karafTargetPlatform;
    try {
      karafTargetPlatform = KarafPlatformModelRegistry.findPlatformModel(location);
      if (karafTargetPlatform != null) {
        return Status.OK_STATUS;
      } else {
        return new Status(
            IStatus.ERROR,
            KarafWtpPluginActivator.PLUGIN_ID,
            0,
            "Unable to validate Karaf installation",
            null);
      }
    } catch (final CoreException e) {
      return new Status(
          IStatus.ERROR,
          KarafWtpPluginActivator.PLUGIN_ID,
          0,
          "Unable to locate Karaf platform",
          e);
    }
  }
Пример #6
0
  public String getVersion() {
    if (version == null) {
      IPath sdkLocation = getLocation().makeAbsolute();

      if (!sdkLocation.isEmpty()) {
        try {
          version = SDKUtil.readSDKVersion(sdkLocation.toOSString());

          if (version.equals(ILiferayConstants.V611.toString())) {
            Properties buildProperties =
                getProperties(sdkLocation.append("build.properties").toFile()); // $NON-NLS-1$

            if (hasAppServerSpecificProps(buildProperties)) {
              version = ILiferayConstants.V612.toString();
            }
          }

          if (version.equals(ILiferayConstants.V6120.toString())) {
            Properties buildProperties =
                getProperties(sdkLocation.append("build.properties").toFile()); // $NON-NLS-1$

            if (hasAppServerSpecificProps(buildProperties)) {
              version = ILiferayConstants.V6130.toString();
            }
          }
        } catch (Exception e) {
          SDKCorePlugin.logError("Could not detect the sdk version.", e); // $NON-NLS-1$
        }
      }
    }

    return version;
  }
Пример #7
0
 /**
  * The main drawing routine.
  *
  * @param gfx The {@link Graphics} to use
  */
 @Override
 public synchronized void paintFigure(final Graphics gfx) {
   if (isLoadingImage()) return;
   Rectangle bounds = getBounds().getCopy();
   ImageUtils.crop(bounds, this.getInsets());
   IPath imagePath = booleanValue ? onImagePath : offImagePath;
   if (loadingError) {
     if (!imagePath.isEmpty()) {
       gfx.setBackgroundColor(getBackgroundColor());
       gfx.setForegroundColor(getForegroundColor());
       gfx.fillRectangle(bounds);
       gfx.translate(bounds.getLocation());
       TextPainter.drawText(
           gfx,
           "ERROR in loading image\n" + imagePath,
           bounds.width / 2,
           bounds.height / 2,
           TextPainter.CENTER);
     }
     return;
   }
   Color currentcolor = null;
   if (useForegroundColor) currentcolor = getForegroundColor();
   else currentcolor = booleanValue ? onColor : offColor;
   getCurrentImage().setCurrentColor(currentcolor);
   getCurrentImage().setBounds(bounds);
   getCurrentImage().setBorder(getBorder());
   getCurrentImage().setAbsoluteScale(gfx.getAbsoluteScale());
   getCurrentImage().paintFigure(gfx);
   if (!isEnabled()) {
     gfx.setAlpha(DISABLED_ALPHA);
     gfx.setBackgroundColor(DISABLE_COLOR);
     gfx.fillRectangle(bounds);
   }
 }
Пример #8
0
  public BundleModuleRegistry(String bundleSymbolicName, Collection<IPath> paths) {
    if (bundleSymbolicName == null || bundleSymbolicName.length() == 0) {
      throw new IllegalArgumentException("Invalid bundle symbolic name"); // $NON-NLS-1$
    }

    for (IPath nextPath : paths) {
      if (nextPath == null || nextPath.isEmpty() || !nextPath.isValidPath(nextPath.toString())) {
        throw new IllegalArgumentException("Invalid resource path:" + nextPath); // $NON-NLS-1$
      }
    }

    this.bundleID = bundleSymbolicName;
    this.defaultFolderItems = Collections.emptySet();
    this.filePaths = new HashSet<IPath>();
    this.folderPaths = new HashSet<IPath>();

    for (IPath filePath : paths) {
      if (filePath.segmentCount() > 1) {
        extractFolderPaths(folderPaths, filePath);
        filePaths.add(filePath);
      } else {
        if (defaultFolderItems.isEmpty()) {
          defaultFolderItems = new HashSet<IPath>();
        }
        defaultFolderItems.add(filePath);
      }
    }
  }
 /**
  * Checks if all source files are existing. If not, create them.
  *
  * @param javaProj
  */
 private void checkSourceFolders(final IJavaProject javaProj) {
   if (javaProj == null) return;
   if (javaProj.exists()) {
     try {
       if (!javaProj.isOpen()) {
         javaProj.open(new NullProgressMonitor());
       }
       IClasspathEntry[] entries = javaProj.getRawClasspath();
       for (IClasspathEntry entry : entries) {
         if (IClasspathEntry.CPE_SOURCE == entry.getEntryKind()) {
           IPath path = entry.getPath();
           final IPath folderPath = path.removeFirstSegments(1);
           if (!folderPath.isEmpty()) {
             Display.getDefault()
                 .asyncExec(
                     new Runnable() {
                       public void run() {
                         try {
                           ImportUtils.createFolders(
                               javaProj.getProject(), folderPath, IResource.FORCE);
                         } catch (CoreException e) {
                           _log.error(e.getMessage());
                         }
                       }
                     });
           }
         }
       }
     } catch (JavaModelException e) {
       _log.error("findProjectSources: Could not retrieve project sources:", e); // $NON-NLS-1$
     }
   }
 }
Пример #10
0
 /**
  * Returns a status for this library describing any error states
  *
  * @return
  */
 IStatus validate() {
   if (!getSystemLibraryPath().toFile().exists()) {
     return new Status(
         IStatus.ERROR,
         IJavaDebugUIConstants.PLUGIN_ID,
         IJavaDebugUIConstants.INTERNAL_ERROR,
         "System library does not exist: " + getSystemLibraryPath().toOSString(),
         null); //$NON-NLS-1$
   }
   IPath path = getSystemLibrarySourcePath();
   if (!path.isEmpty()) {
     if (!path.toFile().exists()) {
       // check for workspace resource
       IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
       if (resource == null || !resource.exists()) {
         return new Status(
             IStatus.ERROR,
             IJavaDebugUIConstants.PLUGIN_ID,
             IJavaDebugUIConstants.INTERNAL_ERROR,
             "Source attachment does not exist: " + path.toOSString(),
             null); //$NON-NLS-1$
       }
     }
   }
   return Status.OK_STATUS;
 }
Пример #11
0
  /* (non-Javadoc)
   * @see org.eclipse.sequoyah.tfm.sign.core.extension.security.ISecurityManagement#isKeyStoreSelected()
   */
  public boolean isKeyStoreSelected() throws SignException {

    if ((ksLocation == null) || (ksLocation.isEmpty())) {
      return false;
    }

    return true;
  }
 private static String encodePath(IPath path) {
   if (path == null) {
     return "#"; //$NON-NLS-1$
   } else if (path.isEmpty()) {
     return "&"; //$NON-NLS-1$
   } else {
     return encode(path.toPortableString());
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.cdt.utils.CygwinToolsProvider#getCygPath()
  */
 public CygPath getCygPath() {
   IPath cygPathPath = getCygPathPath();
   CygPath cygpath = null;
   if (cygPathPath != null && !cygPathPath.isEmpty()) {
     try {
       cygpath = new CygPath(cygPathPath.toOSString());
     } catch (IOException e1) {
     }
   }
   return cygpath;
 }
 private boolean isAndroidRepo(IPath repoPath) {
   if (repoPath == null || repoPath.isEmpty()) {
     return false;
   }
   final File root = repoPath.toFile();
   if (new File(root, ".repo").isDirectory()) {
     return true;
   }
   setErrorMessage(repoPath + " does not point to a valid android repo ");
   return false;
 }
Пример #15
0
 /**
  * Create a folder relative to the project based on aProjectRelativePathString.
  *
  * @param aProjectRelativePath
  * @return
  * @throws CoreException
  * @since 1.0.0
  */
 public IFolder createFolder(IPath aProjectRelativePath) throws CoreException {
   if (aProjectRelativePath != null && !aProjectRelativePath.isEmpty()) {
     IFolder folder =
         getWorkspace().getRoot().getFolder(getProjectPath().append(aProjectRelativePath));
     if (!folder.exists()) {
       ProjectUtilities.ensureContainerNotReadOnly(folder);
       folder.create(true, true, null);
     }
     return folder;
   }
   return null;
 }
Пример #16
0
 private static void buildPaths(
     final IWorkspaceRoot root, final IProject project, final Collection<IPath> list)
     throws CoreException {
   final IPath projectPath = project.getFullPath();
   for (final IPath pp : list) {
     // only create in-project paths
     if (!pp.isAbsolute() && !pp.toString().equals(".") && !pp.isEmpty()) {
       final IPath path = projectPath.append(pp);
       final IFolder folder = root.getFolder(path);
       createFolderHelper(folder);
     }
   }
 }
Пример #17
0
  @Override
  public IFileStore getStore(URI uri) {
    CDOURIData data = new CDOURIData(uri.toString());
    // String authority = uri.getAuthority();
    // IPath path = new Path(uri.getPath());
    // String repositoryName = path.segment(0);
    // path = path.removeFirstSegments(1);
    //
    // IPath branchPath = Path.EMPTY;
    // long timeStamp = CDOBranchPoint.UNSPECIFIED_DATE;
    //
    // while (path.segmentCount() != 0)
    // {
    // String segment = path.segment(0);
    // path = path.removeFirstSegments(1);
    //
    // if (segment.startsWith("@"))
    // {
    // if (segment.length() != 1)
    // {
    // if (!segment.equals("@HEAD"))
    // {
    // timeStamp = Long.parseLong(segment.substring(1));
    // }
    // }
    //
    // break;
    // }
    //
    // branchPath = branchPath.append(segment);
    // }
    //
    // int segments = branchPath.segmentCount();
    // if (segments == 0 || segments == 1 &&
    // !branchPath.segment(0).equals(CDOBranch.MAIN_BRANCH_NAME))
    // {
    // branchPath = new Path(CDOBranch.MAIN_BRANCH_NAME).append(branchPath);
    // }

    String authority = data.getAuthority();
    String repositoryName = data.getRepositoryName();
    IPath path = data.getResourcePath();
    IPath branchPath = data.getBranchPath();
    long timeStamp = data.getTimeStamp();
    CDOFileRoot root = new CDOFileRoot(this, authority, repositoryName, branchPath, timeStamp);
    if (path.isEmpty()) {
      return root;
    }

    return root.getFileStore(path);
  }
 private void addBaseString(IPath endPath, CPElement cpentry, StringBuffer str) {
   IPath baseRef = (IPath) cpentry.getAttribute(CPElement.BASE_REF);
   if (!baseRef.isEmpty()) {
     if (baseRef.isAbsolute()) {
       //				str.append("From project ");
       IPath path = baseRef;
       if (endPath != null) {
         path = path.append(endPath);
       }
       str.append(path.makeRelative().toPortableString());
     } else {
       //				str.append("From contribution ");
       IPathEntryContainer container;
       if (endPath != null) {
         str.append(endPath.toPortableString());
       }
       str.append(" - ("); // $NON-NLS-1$
       try {
         container = CoreModel.getPathEntryContainer(baseRef, cpentry.getCProject());
         if (container != null) {
           str.append(container.getDescription());
         }
       } catch (CModelException e1) {
       }
       str.append(')');
     }
   } else {
     IPath path = (IPath) cpentry.getAttribute(CPElement.BASE);
     if (!path.isEmpty()) {
       if (endPath != null) {
         path = path.append(endPath);
       }
       str.insert(0, path.toPortableString());
     } else if (endPath != null) {
       str.insert(0, endPath.toPortableString());
     }
   }
 }
 public String getCPElementAttributeText(CPElementAttribute attrib) {
   String notAvailable = CPathEntryMessages.CPElementLabelProvider_none;
   StringBuffer buf = new StringBuffer();
   String key = attrib.getKey();
   if (key.equals(CPElement.SOURCEATTACHMENT)) {
     buf.append(CPathEntryMessages.CPElementLabelProvider_source_attachment_label);
     IPath path = (IPath) attrib.getValue();
     if (path != null && !path.isEmpty()) {
       buf.append(getPathString(path, path.getDevice() != null));
     } else {
       buf.append(notAvailable);
     }
   } else if (key.equals(CPElement.SOURCEATTACHMENTROOT)) {
     buf.append(CPathEntryMessages.CPElementLabelProvider_source_attachment_root_label);
     IPath path = (IPath) attrib.getValue();
     if (path != null && !path.isEmpty()) {
       buf.append(path.toString());
     } else {
       buf.append(notAvailable);
     }
   }
   if (key.equals(CPElement.EXCLUSION)) {
     buf.append(CPathEntryMessages.CPElementLabelProvider_exclusion_filter_label);
     IPath[] patterns = (IPath[]) attrib.getValue();
     if (patterns != null && patterns.length > 0) {
       for (int i = 0; i < patterns.length; i++) {
         if (i > 0) {
           buf.append(CPathEntryMessages.CPElementLabelProvider_exclusion_filter_separator);
         }
         buf.append(patterns[i].toString());
       }
     } else {
       buf.append(notAvailable);
     }
   }
   return buf.toString();
 }
Пример #20
0
 private synchronized void loadBoolImageFromFile(boolean boolOnImage) {
   final IPath imagePath = boolOnImage ? onImagePath : offImagePath;
   if (imagePath != null && !imagePath.isEmpty()) {
     loadingImage = true;
     loadBoolImage(
         boolOnImage,
         new IJobErrorHandler() {
           public void handleError(Exception exception) {
             loadingError = true;
             loadingImage = false;
             Activator.getLogger()
                 .log(Level.WARNING, "ERROR in loading image " + imagePath, exception);
           }
         });
   }
 }
Пример #21
0
 private static IPackageFragmentRoot findPackageFragmentRoot(
     IJavaProject javaProject, IPath filePath) throws JavaModelException {
   if (filePath.isEmpty() || filePath.isRoot()) {
     return null;
   } else {
     IResource possibleFragmentResource =
         ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(filePath);
     if (possibleFragmentResource != null) {
       filePath = possibleFragmentResource.getFullPath();
     }
     IPackageFragmentRoot fragment = javaProject.findPackageFragmentRoot(filePath);
     if (fragment != null) {
       return fragment;
     } else {
       return findPackageFragmentRoot(javaProject, filePath.removeLastSegments(1));
     }
   }
 }
Пример #22
0
 private void fillTreeItemWithGitDirectory(
     RepositoryMapping m, TreeItem treeItem, boolean isAlternative) {
   if (m.getGitDir() == null)
     treeItem.setText(2, UIText.ExistingOrNewPage_SymbolicValueEmptyMapping);
   else {
     IPath relativePath = new Path(m.getGitDir());
     if (isAlternative) {
       IPath withoutLastSegment = relativePath.removeLastSegments(1);
       IPath path;
       if (withoutLastSegment.isEmpty()) path = Path.fromPortableString("."); // $NON-NLS-1$
       else path = withoutLastSegment;
       treeItem.setText(0, path.toString());
     }
     treeItem.setText(2, relativePath.toOSString());
     try {
       IProject project = m.getContainer().getProject();
       Repository repo =
           new RepositoryBuilder().setGitDir(m.getGitDirAbsolutePath().toFile()).build();
       File workTree = repo.getWorkTree();
       IPath workTreePath = Path.fromOSString(workTree.getAbsolutePath());
       if (workTreePath.isPrefixOf(project.getLocation())) {
         IPath makeRelativeTo = project.getLocation().makeRelativeTo(workTreePath);
         String repoRelativePath =
             makeRelativeTo.append("/.project").toPortableString(); // $NON-NLS-1$
         ObjectId headCommitId = repo.resolve(Constants.HEAD);
         if (headCommitId != null) {
           // Not an empty repo
           RevWalk revWalk = new RevWalk(repo);
           RevCommit headCommit = revWalk.parseCommit(headCommitId);
           RevTree headTree = headCommit.getTree();
           TreeWalk projectInRepo = TreeWalk.forPath(repo, repoRelativePath, headTree);
           if (projectInRepo != null) {
             // the .project file is tracked by this repo
             treeItem.setChecked(true);
           }
           revWalk.dispose();
         }
       }
       repo.close();
     } catch (IOException e1) {
       Activator.logError(UIText.ExistingOrNewPage_FailedToDetectRepositoryMessage, e1);
     }
   }
 }
Пример #23
0
  public NewSourceFolderDialog(
      Shell parent,
      String title,
      IProject project,
      List existingFolders,
      BPListElement entryToEdit) {
    super(parent);
    setTitle(title);

    fContainerFieldStatus = new StatusInfo();

    SourceContainerAdapter adapter = new SourceContainerAdapter();

    fUseProjectButton = new SelectionButtonDialogField(SWT.RADIO);
    fUseProjectButton.setLabelText(NewWizardMessages.NewSourceFolderDialog_useproject_button);
    fUseProjectButton.setDialogFieldListener(adapter);

    fUseFolderButton = new SelectionButtonDialogField(SWT.RADIO);
    fUseFolderButton.setLabelText(NewWizardMessages.NewSourceFolderDialog_usefolder_button);
    fUseFolderButton.setDialogFieldListener(adapter);

    fContainerDialogField = new StringDialogField();
    fContainerDialogField.setDialogFieldListener(adapter);
    fContainerDialogField.setLabelText(NewWizardMessages.NewSourceFolderDialog_sourcefolder_label);

    fUseFolderButton.attachDialogField(fContainerDialogField);

    fFolder = null;
    fExistingFolders = existingFolders;
    fCurrProject = project;

    boolean useFolders = true;
    if (entryToEdit == null) {
      fContainerDialogField.setText(""); // $NON-NLS-1$
    } else {
      IPath editPath = entryToEdit.getPath().removeFirstSegments(1);
      fContainerDialogField.setText(editPath.toString());
      useFolders = !editPath.isEmpty();
    }
    fUseFolderButton.setSelection(useFolders);
    fUseProjectButton.setSelection(!useFolders);
  }
  protected void addDependentsOf(
      IPath path,
      boolean isStructuralChange,
      StringSet qualifiedNames,
      StringSet simpleNames,
      StringSet rootNames) {
    path = path.setDevice(null);
    if (isStructuralChange) {
      String last = path.lastSegment();
      if (last.length() == TypeConstants.PACKAGE_INFO_NAME.length)
        if (CharOperation.equals(last.toCharArray(), TypeConstants.PACKAGE_INFO_NAME)) {
          path =
              path.removeLastSegments(
                  1); // the package-info file has changed so blame the package itself
          /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=323785, in the case of default package,
            there is no need to blame the package itself as there can be no annotations or documentation
            comment tags in the package-info file that can influence the rest of the package. Just bail out
            so we don't touch null objects below.
          */
          if (path.isEmpty()) return;
        }
    }

    if (isStructuralChange && !this.hasStructuralChanges) {
      this.newState.tagAsStructurallyChanged();
      this.hasStructuralChanges = true;
    }
    // the qualifiedStrings are of the form 'p1/p2' & the simpleStrings are just 'X'
    rootNames.add(path.segment(0));
    String packageName = path.removeLastSegments(1).toString();
    boolean wasNew = qualifiedNames.add(packageName);
    String typeName = path.lastSegment();
    int memberIndex = typeName.indexOf('$');
    if (memberIndex > 0) typeName = typeName.substring(0, memberIndex);
    wasNew = simpleNames.add(typeName) | wasNew;
    if (wasNew && JavaBuilder.DEBUG)
      System.out.println(
          "  will look for dependents of " //$NON-NLS-1$
              + typeName
              + " in "
              + packageName); //$NON-NLS-1$
  }
Пример #25
0
  /**
   * Get the Security Management tool from preference store location (@link
   * #securityProviderPrefStore}).
   *
   * @return the path to the keystore tool.
   * @throws SignException when the JRE home directory is not configured correctly.
   */
  private final IPath getSecurityManagementTool() throws SignException {
    IPath securityToolLocation = getToolLocation(null);

    if ((securityToolLocation == null) || (securityToolLocation.isEmpty())) {
      String message =
          MessageFormat.format(
              Messages.SunSecurityManagement_defaultErrorMessage2,
              new Object[] {
                getId(),
                Messages.SunSecurityManagement_Security_tool_not_configured_correctly,
                Messages.SunSecurityManagement_Security_tool_using_features
              });
      throw new SignException(
          SignErrors.getErrorMessage(SignErrors.SECURITY_MANAGER_NOT_CONFIGURED)
              + "\n"
              + //$NON-NLS-1$
              message);
    }
    securityToolLocation = securityToolLocation.append("bin" + File.separator + "keytool");
    return securityToolLocation;
  }
    public IStatus run(final IProgressMonitor progressMonitor) {
      IStatus status = Status.OK_STATUS;

      if ((_path != null) && !_path.isEmpty()) {
        // display a temporary message + cancel button while the display
        // is loading

        if (!progressMonitor.isCanceled()) {
          // showMessage(progressMonitor, "Loading " + _path.toString());

          if (!progressMonitor.isCanceled()) {
            load(progressMonitor);
          } else {
            status = Status.CANCEL_STATUS;
          }
        } else {
          status = Status.CANCEL_STATUS;
        }
      }

      return status;
    }
Пример #27
0
  /**
   * Verify that program name of the configuration can be found as a file.
   *
   * @return Absolute path of the program location
   */
  public static IPath verifyProgramPath(ILaunchConfiguration configuration, ICProject cproject)
      throws CoreException {
    String programName =
        configuration.getAttribute(
            ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) null);
    if (programName == null) {
      abort(
          LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"),
          null, //$NON-NLS-1$
          ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
    }

    IPath programPath = new Path(programName);
    if (programPath.isEmpty()) {
      abort(
          LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"),
          null, //$NON-NLS-1$
          ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
    }

    if (!programPath.isAbsolute() && cproject != null) {
      // Find the specified program within the specified project
      IFile wsProgramPath = cproject.getProject().getFile(programPath);
      programPath = wsProgramPath.getLocation();
    }

    if (!programPath.toFile().exists()) {
      abort(
          LaunchMessages.getString(
              "AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$
          new FileNotFoundException(
              LaunchMessages.getFormattedString(
                  "AbstractCLaunchDelegate.PROGRAM_PATH_not_found", //$NON-NLS-1$
                  programPath.toOSString())),
          ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
    }

    return programPath;
  }
 private ImageDescriptor getCPElementBaseImage(CPElement cpentry) {
   switch (cpentry.getEntryKind()) {
     case IPathEntry.CDT_OUTPUT:
       if (cpentry.getPath().segmentCount() == 1) {
         return fProjectImage;
       }
       return fOutputImage;
     case IPathEntry.CDT_SOURCE:
       if (cpentry.getPath().segmentCount() == 1) {
         return fProjectImage;
       }
       return fFolderImage;
     case IPathEntry.CDT_LIBRARY:
       IPath path = (IPath) cpentry.getAttribute(CPElement.SOURCEATTACHMENT);
       if (path == null || path.isEmpty()) {
         return fLibIcon;
       }
       return fLibWSrcIcon;
     case IPathEntry.CDT_PROJECT:
       return fProjectImage;
     case IPathEntry.CDT_CONTAINER:
       return fContainerImage;
     case IPathEntry.CDT_INCLUDE:
       if (((Boolean) cpentry.getAttribute(CPElement.SYSTEM_INCLUDE)).booleanValue())
         return fIncludeIcon;
       return fQuoteIncludeIcon;
     case IPathEntry.CDT_INCLUDE_FILE:
       return fIncludeFileIcon;
     case IPathEntry.CDT_MACRO:
       return fMacroIcon;
     case IPathEntry.CDT_MACRO_FILE:
       return fMacrosFileIcon;
     default:
       return null;
   }
 }
Пример #29
0
  public void testRepoRelativePath() throws Throwable {
    IProject project = null;
    try {
      GitRepository repo = createRepo();
      IPath repoPath = repo.workingDirectory();

      String projectName = repoPath.lastSegment();

      IWorkspace workspace = ResourcesPlugin.getWorkspace();
      IProjectDescription description = workspace.newProjectDescription(projectName);
      description.setLocation(repoPath);

      project = workspace.getRoot().getProject(projectName);
      project.create(description, null);
      project.open(null);

      IPath relativePath = repo.relativePath(project);
      assertTrue("Expected relative path of root of repo to be empty", relativePath.isEmpty());
    } finally {
      if (project != null) {
        project.delete(true, null);
      }
    }
  }
Пример #30
0
  /**
   * Updates completions for the BibTeX -data
   *
   * @param bibNames Names of the BibTeX -files that the document uses
   * @param resource The resource of the document
   */
  private void updateBibs(String[] bibNames, boolean biblatexMode, IResource resource) {
    IProject project = getCurrentProject();
    if (project == null) return;

    if (!biblatexMode) {
      for (int i = 0; i < bibNames.length; i++) {
        if (!bibNames[i].endsWith(".bib")) {
          bibNames[i] += ".bib";
        }
      }
    }

    if (bibContainer.checkFreshness(bibNames)) {
      return;
    }

    TexlipseProperties.setSessionProperty(project, TexlipseProperties.BIBFILE_PROPERTY, bibNames);

    List<String> newBibs = bibContainer.updateBibHash(bibNames);

    IPath path = resource.getFullPath().removeFirstSegments(1).removeLastSegments(1);
    if (!path.isEmpty()) path = path.addTrailingSeparator();

    KpsewhichRunner filesearch = new KpsewhichRunner();

    for (Iterator<String> iter = newBibs.iterator(); iter.hasNext(); ) {
      String name = iter.next();
      try {
        String filepath = "";
        // First try local search
        IResource res = project.findMember(path + name);
        // Try searching relative to main file
        if (res == null) {
          IContainer sourceDir = TexlipseProperties.getProjectSourceDir(project);
          res = sourceDir.findMember(name);
        }

        if (res != null) {
          filepath = res.getLocation().toOSString();
        }
        if (res == null) {
          // Try Kpsewhich
          filepath = filesearch.getFile(resource, name, "bibtex");
          if (filepath.length() > 0 && !(new File(filepath).isAbsolute())) {
            // filepath is a local path
            res = project.findMember(path + filepath);
            if (res != null) {
              filepath = res.getLocation().toOSString();
            } else {
              filepath = "";
            }
          } else if (filepath.length() > 0) {
            // Create a link to resource
            IPath p = new Path(filepath);
            if (name.indexOf('/') >= 0) {
              // Remove path from name
              name = name.substring(name.lastIndexOf('/') + 1);
            }
            IFile f = project.getFile(path + name);
            if (f != null && !f.exists()) {
              f.createLink(p, IResource.NONE, null);
            }
          }
        }

        if (filepath.length() > 0) {
          BibParser parser = new BibParser(filepath);
          try {
            List<ReferenceEntry> bibEntriesList = parser.getEntries();
            if (bibEntriesList != null && bibEntriesList.size() > 0) {
              bibContainer.addRefSource(path + name, bibEntriesList);
            } else if (bibEntriesList == null) {
              MarkerHandler marker = MarkerHandler.getInstance();
              marker.addFatalError(
                  editor,
                  "The BibTeX file " + filepath + " contains fatal errors, parsing aborted.");
              continue;
            }
          } catch (IOException ioe) {
            TexlipsePlugin.log("Can't read BibTeX file " + filepath, ioe);
          }
        } else {
          MarkerHandler marker = MarkerHandler.getInstance();
          marker.addFatalError(editor, "The BibTeX file " + name + " not found.");
        }

      } catch (CoreException ce) {
        TexlipsePlugin.log("Can't run Kpathsea", ce);
      }
    }
    bibContainer.organize();
  }