IEditorPart editorPart = getSite().getWorkbenchWindow().getActivePage().getActiveEditor(); if(editorPart != null) { IFileEditorInput input = (IFileEditorInput)editorPart.getEditorInput() ; IFile file = input.getFile(); IProject activeProject = file.getProject(); String activeProjectName = activeProject.getName(); //... use activeProjectName }
private IPath getDiffPath(IFile file) { DiffProject project = getDiffProject(file.getProject()); if (project != null) { return file.getProjectRelativePath(); } return file.getFullPath().removeFirstSegments(getTarget().getFullPath().segmentCount()); }
public IProject getProject() { if (file != null) { return file.getProject(); } return null; } }
/** * Gets the java project. * * @return the java project */ public IJavaProject getJavaProject() { if (null == javaProject && null != file) { javaProject = JavaCore.create(file.getProject()); } return javaProject; }
private IProject getCurrentProject(IEditorInput input) { IProject curProject = null; IFile inputFile = null; if (input instanceof IFileEditorInput) { inputFile = ((IFileEditorInput) input).getFile(); curProject = inputFile.getProject(); } return curProject; }
public IProject getCommonProject() { for (Enumeration<Object> contexts = inputContexts.elements(); contexts.hasMoreElements();) { InputContext context = (InputContext) contexts.nextElement(); IEditorInput input = context.getInput(); if (input instanceof IFileEditorInput) return ((IFileEditorInput) input).getFile().getProject(); } return null; }
public static IJavaProject getJavaProject(IFile appJar) { if (appJar == null) { throw new IllegalArgumentException("appJar is null"); } String projectName = appJar.getProject().getName(); return getJavaProject(projectName); }
public static boolean hasAngularNature(IDOMNode element) { IFile file = DOMUtils.getFile(element); if (file == null) { return false; } return AngularProject.hasAngularNature(file.getProject()); }
protected IProject getCurrentProject() { if (fEditor != null) { IEditorInput ei= fEditor.getEditorInput(); if (ei instanceof IFileEditorInput) { return ((IFileEditorInput) ei).getFile().getProject(); } } return null; }
public static URLClassLoader getProjectClassLoader(IFile file) { IProject project = file.getProject(); IJavaProject javaProject = JavaCore.create(project); return getProjectClassLoader(javaProject); }
/** * Creates and returns a default launch configuration for the given file. * * @param file * @return default launch configuration */ public static ILaunchConfiguration createDefaultLaunchConfiguration(IFile file) { return createDefaultLaunchConfiguration(file.getFullPath(), file.getProject()); }
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { IJavaProject project= JavaCore.create(files[0].getProject()); List result= addLibraryEntries(files, project, monitor); selectAndReveal(new StructuredSelection(result)); } catch (CoreException e) { throw new InvocationTargetException(e); } } };
public void updateConfiguration(TextDocumentIdentifier param) { IFile file = JDTUtils.findFile(param.getUri()); if (file == null) { return; } // most likely the handler is invoked intentionally by the user, that's why // we force the update despite no changes of in build descriptor being made projectManager.updateProject(file.getProject(), true); } }
/** * @param editorRef * @return true if the editor is editing the JSP content type and * the owning project is a JSF project */ boolean isValidJSPEditor(IEditorReference editorRef) { final IFile file = getIFile(editorRef); return file != null && JSFAppConfigUtils.isValidJSFProject(file.getProject()) && isJSPEditor(editorRef); }
@Override protected void structureChanged(IFile file, boolean added) { // If a plugin.xml file has been added to the project the editor should update if (added && ICoreConstants.PLUGIN_FILENAME_DESCRIPTOR.equalsIgnoreCase(file.getName())) { IProject project = getCommonProject(); if (project == null || project.equals(file.getProject())) { monitorFile(file); } } super.structureChanged(file, added); }
@Override public IStatus validateSave(IFile file) { RepositoryProvider provider = RepositoryProvider.getProvider(file.getProject()); FileModificationValidator validator = getDefaultValidator(); //if no provider or no validator use the default validator if (provider != null) { FileModificationValidator v = provider.getFileModificationValidator2(); if (v != null) validator = v; } return validator.validateSave(file); }
private IProject getProject(IEditorInput input) { IAdapterManager adapterManager = Platform.getAdapterManager(); Object o; if ((o = input.getAdapter(IResource.class)) != null || (o = adapterManager.getAdapter(input, IResource.class)) != null) { return ((IFile) o).getProject(); } if ((o = input.getAdapter(IProject.class)) != null || (o = adapterManager.getAdapter(input, IProject.class)) != null) { return (IProject) o; } return null; } }
public IJpaRootContentNode buildRootContent(IFile resourceFile) { OrmArtifactEdit oae = OrmArtifactEdit.getArtifactEditForRead(resourceFile.getProject()); OrmResource resource = oae.getOrmResource(resourceFile); oae.addListener(buildReloadListener(resource)); XmlRootContentNode root = OrmFactory.eINSTANCE.createXmlRootContentNode(); root.setArtifactEdit(oae); root.setEntityMappings(resource.getEntityMappings()); resource.eAdapters().add(buildRootNodeListener(resourceFile, root)); return root; }
public void setInput(IEditorInput iei ) { super.setInput(iei); setPartName( iei.getName()); setContentDescription(iei.getToolTipText()); if ( iei instanceof IFileEditorInput ) { IFileEditorInput in = (IFileEditorInput) iei; IProject project = in.getFile().getProject(); setPartName(project.getName()); } }
private void handleNew() { IFile file = ((IFileEditorInput) getPage().getPDEEditor().getEditorInput()).getFile(); final IProject project = file.getProject(); BusyIndicator.showWhile(pointTable.getTable().getDisplay(), () -> { NewExtensionPointWizard wizard = new NewExtensionPointWizard(project, (IPluginModelBase) getPage().getModel(), (ManifestEditor) getPage().getPDEEditor()); WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard); dialog.create(); SWTUtil.setDialogSize(dialog, 400, 450); dialog.open(); }); }