List of usage examples for org.eclipse.jdt.core IJavaProject getProject
IProject getProject();
IProject
on which this IJavaProject
was created. From source file:com.liferay.ide.server.util.ServerUtil.java
License:Open Source License
public static IPath getPortalDir(IJavaProject project) { return getPortalDir(project.getProject()); }
From source file:com.liferay.ide.theme.core.facet.ThemePluginFacetInstall.java
License:Open Source License
protected void removeUnneededClasspathEntries() { IFacetedProjectWorkingCopy facetedProject = getFacetedProject(); IJavaProject javaProject = JavaCore.create(facetedProject.getProject()); try {//from www . j av a2s . co m IClasspathEntry[] existingClasspath = javaProject.getRawClasspath(); List<IClasspathEntry> newClasspath = new ArrayList<IClasspathEntry>(); for (IClasspathEntry entry : existingClasspath) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { continue; } else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { String path = entry.getPath().toPortableString(); if (path.contains("org.eclipse.jdt.launching.JRE_CONTAINER") || //$NON-NLS-1$ path.contains("org.eclipse.jst.j2ee.internal.web.container") || //$NON-NLS-1$ path.contains("org.eclipse.jst.j2ee.internal.module.container")) //$NON-NLS-1$ { continue; } } newClasspath.add(entry); } javaProject.setRawClasspath(newClasspath.toArray(new IClasspathEntry[0]), null); IResource sourceFolder = javaProject.getProject() .findMember(IPluginFacetConstants.PORTLET_PLUGIN_SDK_SOURCE_FOLDER); if (sourceFolder.exists()) { sourceFolder.delete(true, null); } } catch (Exception e) { } }
From source file:com.mg.merp.wb.badi.library.BadiLibraryPlugin.java
License:Open Source License
/** * ? ?? .MBAi// www.ja v a 2 s .c o m * * @param project * @return ?? */ public static Set<String> initLibsFromPropFile(IJavaProject project) { Set<String> result = null; InputStream is = null; try { is = new FileInputStream(project.getProject().getLocation() + "/" + MBAI_PROPERTY_FILE_NAME); Properties properties = new Properties(); properties.load(is); String incl = properties.getProperty(INCLUDED_LIBS_PROPERTY_NAME); if (incl == null) result = new LinkedHashSet<String>(); else { String[] str = CoreUtils.stringToStringArray(incl, ","); result = new LinkedHashSet<String>(Arrays.asList(str)); } } catch (Exception e) { result = new LinkedHashSet<String>(); } finally { try { if (is != null) is.close(); } catch (IOException e) { } } return result; }
From source file:com.mg.merp.wb.badi.library.BadiLibraryPlugin.java
License:Open Source License
/** * ? , .MBAi/*from w ww .j av a 2s .c om*/ * * @param project * @param lst ?? */ public static void storeLibsInPropFile(IJavaProject project, List<String> lst) { OutputStream os = null; try { Properties properties = new Properties(); properties.setProperty(INCLUDED_LIBS_PROPERTY_NAME, CoreUtils.stringListToString(lst, ",")); IPath pth = project.getProject().getLocation(); os = new FileOutputStream(pth + "/" + MBAI_PROPERTY_FILE_NAME); properties.store(os, MBAI_PROPERTY_FILE_COMMENT); } catch (FileNotFoundException e) { } catch (IOException e) { } finally { try { os.close(); } catch (IOException e) { } } }
From source file:com.microsoft.applicationinsights.ui.config.AIProjConfigWizardDialog.java
License:Open Source License
private void createAIConfiguration(IJavaProject proj) throws Exception { handleWebXML(proj.getProject(), handler); handleAppInsightsXML(proj.getProject(), handler); handler.save();//from ww w. j a v a2 s. co m }
From source file:com.microsoft.applicationinsights.ui.config.AIProjConfigWizardDialog.java
License:Open Source License
private IProject getSelectedProject() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); ISelectionService service = window.getSelectionService(); ISelection selection = service.getSelection(); Object element = null;//from w w w.j a v a 2 s .c om IResource resource; IProject selProject = null; if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSel = (IStructuredSelection) selection; element = structuredSel.getFirstElement(); } if (element instanceof IProject) { resource = (IResource) element; selProject = resource.getProject(); } else if (element instanceof IJavaProject) { IJavaProject proj = ((IJavaElement) element).getJavaProject(); selProject = proj.getProject(); } return selProject; }
From source file:com.microsoft.applicationinsights.util.AILibraryUtil.java
License:Open Source License
/** * This method returns currently selected project in workspace. * /* www .j a v a 2s . co m*/ * @return IProject */ public static IProject getSelectedProject() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); ISelectionService service = window.getSelectionService(); ISelection selection = service.getSelection(); Object element = null; IResource resource; IProject selProject = null; if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSel = (IStructuredSelection) selection; element = structuredSel.getFirstElement(); } if (element instanceof IProject) { resource = (IResource) element; selProject = resource.getProject(); } else if (element instanceof IJavaProject) { IJavaProject proj = ((IJavaElement) element).getJavaProject(); selProject = proj.getProject(); } return selProject; }
From source file:com.microsoft.azuretools.core.utils.PluginUtil.java
License:Open Source License
/** * This method returns currently selected project in workspace. * @return IProject//from ww w . java 2s . c o m */ public static IProject getSelectedProject() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); ISelectionService service = window.getSelectionService(); ISelection selection = service.getSelection(); Object element = null; IResource resource; IProject selProject = null; if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSel = (IStructuredSelection) selection; element = structuredSel.getFirstElement(); } if (element instanceof IProject) { resource = (IResource) element; selProject = resource.getProject(); } else if (element instanceof IJavaProject) { IJavaProject proj = ((IJavaElement) element).getJavaProject(); selProject = proj.getProject(); } else if (element instanceof IResource) { resource = (IResource) element; selProject = resource.getProject(); } else { IWorkbenchPage page = window.getActivePage(); IEditorPart editorPart = page.getActiveEditor(); if (editorPart != null) { IFile file = (IFile) editorPart.getEditorInput().getAdapter(IFile.class); if (file != null) { selProject = file.getProject(); } } } return selProject; }
From source file:com.microsoft.azuretools.docker.utils.AzureDockerUIResources.java
License:Open Source License
public static IProject getCurrentSelectedProject() { IProject project = null;/* www . j a v a 2 s. c o m*/ ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getSelectionService(); ISelection selection = selectionService.getSelection(); if (selection instanceof IStructuredSelection) { Object element = ((IStructuredSelection) selection).getFirstElement(); if (element instanceof IResource) { project = ((IResource) element).getProject(); } else if (element instanceof PackageFragmentRoot) { IJavaProject jProject = ((PackageFragmentRoot) element).getJavaProject(); project = jProject.getProject(); } else if (element instanceof IJavaElement) { IJavaProject jProject = ((IJavaElement) element).getJavaProject(); project = jProject.getProject(); } } if (project == null) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace.getRoot() != null && workspace.getRoot().getProjects().length > 0) { IProject[] projects = workspace.getRoot().getProjects(); project = projects[projects.length - 1]; } else { PluginUtil.displayErrorDialog(Display.getDefault().getActiveShell(), "No Active Project", "Must have a project first"); } } return project; }
From source file:com.microsoft.azuretools.wasdkjava.ui.classpath.ClasspathContainerPage.java
License:Open Source License
/** * This method returns currently selected project in workspace. * @return IProject/*from w ww .j a v a2 s . c o m*/ */ private IProject getSelectedProject() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); ISelectionService service = window.getSelectionService(); ISelection selection = service.getSelection(); Object element = null; IResource resource; IProject selProject = null; if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSel = (IStructuredSelection) selection; element = structuredSel.getFirstElement(); } if (element instanceof IProject) { resource = (IResource) element; selProject = resource.getProject(); } else if (element instanceof IJavaProject) { IJavaProject proj = ((IJavaElement) element).getJavaProject(); selProject = proj.getProject(); } return selProject; }