/** * Private constructor to enforce singleton usage. */ private PerformanceStatsProcessor() { super("Performance Stats"); //$NON-NLS-1$ setSystem(true); setPriority(DECORATE); BundleContext context = PlatformActivator.getContext(); String filter = '(' + FrameworkLog.SERVICE_PERFORMANCE + '=' + Boolean.TRUE.toString() + ')'; Collection<ServiceReference<FrameworkLog>> references; FrameworkLog perfLog = null; try { references = context.getServiceReferences(FrameworkLog.class, filter); if (references != null && !references.isEmpty()) { //just take the first matching service perfLog = context.getService(references.iterator().next()); //make sure correct location is set IPath logLocation = Platform.getLogFileLocation(); logLocation = logLocation.removeLastSegments(1).append("performance.log"); //$NON-NLS-1$ perfLog.setFile(logLocation.toFile(), false); } } catch (Exception e) { IStatus error = new Status(IStatus.ERROR, Platform.PI_RUNTIME, 1, "Error loading performance log", e); //$NON-NLS-1$ InternalPlatform.getDefault().log(error); } //use the platform log if we couldn't create the performance log if (perfLog == null) perfLog = InternalPlatform.getDefault().getFrameworkLog(); log = perfLog; }
public static File fromOSGiJarToOSGiInstallArea(String path) { IPath parentFolder = new Path(path).removeLastSegments(1); if ("plugins".equalsIgnoreCase(parentFolder.lastSegment())) //$NON-NLS-1$ return parentFolder.removeLastSegments(1).toFile(); return parentFolder.toFile(); }
public static File fromOSGiJarToOSGiInstallArea(String path) { IPath parentFolder = new Path(path).removeLastSegments(1); if ("plugins".equalsIgnoreCase(parentFolder.lastSegment())) //$NON-NLS-1$ return parentFolder.removeLastSegments(1).toFile(); return parentFolder.toFile(); }
private IPath getRejectFilePath(IPath path) { IPath pp= null; if (path.segmentCount() > 1) { pp= path.removeLastSegments(1); pp= pp.append(path.lastSegment() + REJECT_FILE_EXTENSION); } else pp= new Path(path.lastSegment() + REJECT_FILE_EXTENSION); return pp; }
private boolean isDirectChildOfWorkspaceRootFolder(File location) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IPath rootLocationPath = workspace.getRoot().getLocation(); IPath locationPath = Path.fromOSString(location.getPath()); return rootLocationPath.equals(locationPath) || rootLocationPath.equals(locationPath.removeLastSegments(1)); }
/** * Notification before a compile that a unit is about to be compiled. */ public void aboutToCompile(SourceFile unit) { String message = Messages.bind(Messages.build_compiling, unit.resource.getFullPath().removeLastSegments(1).makeRelative().toString()); subTask(message); }
@Override public Object getNewElement() { IPath newPath= fProject.getPath().removeLastSegments(1).append(getNewElementName()); return JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().findMember(newPath)); }
/** * Notification while within a compile that a unit has finished being compiled. */ public void compiled(SourceFile unit) { String message = Messages.bind(Messages.build_compiling, unit.resource.getFullPath().removeLastSegments(1).makeRelative().toString()); subTask(message); updateProgressDelta(this.progressPerCompilationUnit); checkCancelWithinCompiler(); }
/** * Replaces the node at the specified key with the given node */ protected void replaceNode(IPath key, DataTreeNode node) { DataTreeNode found; if (key.isRoot()) { this.setRootNode(node); } else { found = this.findNodeAt(key.removeLastSegments(1)); found.replaceChild(key.lastSegment(), node); } }
public UnpackJarBuilder(JarPackageData jarPackage) { fSubfolder= jarPackage.getAbsoluteJarLocation().removeFileExtension().lastSegment() + SUBFOLDER_SUFFIX; fSubfolderPath= jarPackage.getAbsoluteJarLocation().removeLastSegments(1).append(fSubfolder); fJarPackage= jarPackage; }
protected void mkdirs(IPath path, IWorkspaceRoot root) throws CoreException { if (path.segmentCount() <= 1) return; IFolder folder = root.getFolder(path); if (!folder.exists()) { mkdirs(path.removeLastSegments(1), root); folder.create(true, true, null); } }
protected IContainer createFolder(IPath packagePath, IContainer outputFolder) throws CoreException { if (packagePath.isEmpty()) return outputFolder; IFolder folder = outputFolder.getFolder(packagePath); if (!folder.exists()) { createFolder(packagePath.removeLastSegments(1), outputFolder); folder.create(IResource.FORCE | IResource.DERIVED, true, null); } return folder; }
/** * Replaces the node at the specified key with the given node */ protected void replaceNode(IPath key, DataTreeNode node) { DataTreeNode found; if (key.isRoot()) { this.setRootNode(node); } else { found = this.findNodeAt(key.removeLastSegments(1)); found.replaceChild(key.lastSegment(), node); } }
private static void convertCUResourceChange(WorkspaceEdit edit, RenameCompilationUnitChange cuChange) { ICompilationUnit modifiedCU = (ICompilationUnit) cuChange.getModifiedElement(); RenameFile rf = new RenameFile(); String newCUName = cuChange.getNewName(); IPath currentPath = modifiedCU.getResource().getLocation(); rf.setOldUri(ResourceUtils.fixURI(modifiedCU.getResource().getRawLocationURI())); IPath newPath = currentPath.removeLastSegments(1).append(newCUName); rf.setNewUri(ResourceUtils.fixURI(newPath.toFile().toURI())); edit.getDocumentChanges().add(Either.forRight(rf)); }
private String getPathString(IPath path, boolean isExternal) { if (ArchiveFileFilter.isArchivePath(path, true)) { String appended= BasicElementLabels.getPathLabel(path.removeLastSegments(1), isExternal); String lastSegment= BasicElementLabels.getResourceName(path.lastSegment()); return Messages.format(NewWizardMessages.CPListLabelProvider_twopart, new String[] { lastSegment, appended }); } else { return BasicElementLabels.getPathLabel(path, isExternal); } }
private String getPathString(IPath path, boolean isExternal) { if (ArchiveFileFilter.isArchivePath(path, true)) { String appended= BasicElementLabels.getPathLabel(path.removeLastSegments(1), isExternal); String lastSegment= BasicElementLabels.getResourceName(path.lastSegment()); return Messages.format(NewWizardMessages.CPListLabelProvider_twopart, new String[] { lastSegment, appended }); } else { return BasicElementLabels.getPathLabel(path, isExternal); } }
@Override public String getDefaultCharset(boolean checkImplicit) { // non-existing resources default to parent's charset if (!exists()) return checkImplicit ? workspace.getCharsetManager().getCharsetFor(getFullPath().removeLastSegments(1), true) : null; return workspace.getCharsetManager().getCharsetFor(getFullPath(), checkImplicit); }
@Override public String getDefaultCharset(boolean checkImplicit) { // non-existing resources default to parent's charset if (!exists()) return checkImplicit ? workspace.getCharsetManager().getCharsetFor(getFullPath().removeLastSegments(1), true) : null; return workspace.getCharsetManager().getCharsetFor(getFullPath(), checkImplicit); }
protected IPath createNewPath(IPackageFragment oldPackage) { IPath oldPackagePath= createPath(oldPackage.getElementName()); IPath newPackagePath= createPath(getNewName(oldPackage)); return oldPackage.getPath().removeLastSegments(oldPackagePath.segmentCount()).append(newPackagePath); }
@Override protected IPath createNewPath() { IPackageFragment oldPackage= getPackage(); IPath oldPackageName= createPath(oldPackage.getElementName()); IPath newPackageName= createPath(getNewName()); return getResourcePath().removeLastSegments(oldPackageName.segmentCount()).append(newPackageName); }