public void configureJavaProject(String newProjectCompliance, IProgressMonitor monitor) throws CoreException, OperationCanceledException { flush(fClassPathList.getElements(), getOutputLocation(), getJavaProject(), newProjectCompliance, monitor); initializeTimeStamps(); updateUI(); }
public void applyData(Object data) { if (data instanceof Map) { Map map= (Map) data; Object selectedLibrary= map.get(DATA_REVEAL_ENTRY); if (selectedLibrary instanceof IClasspathEntry) { IClasspathEntry entry= (IClasspathEntry) selectedLibrary; Object attr= map.get(DATA_REVEAL_ATTRIBUTE_KEY); String attributeKey= attr instanceof String ? (String) attr : null; if (fBuildPathsBlock != null) { fBuildPathsBlock.setElementToReveal(entry, attributeKey); } } Object entryToAdd= map.get(DATA_ADD_ENTRY); if (entryToAdd instanceof IClasspathEntry) { if (fBuildPathsBlock != null) { fBuildPathsBlock.addElement((IClasspathEntry) entryToAdd); } } fBlockOnApply= Boolean.TRUE.equals(map.get(DATA_BLOCK)); } }
private void createJavaProject(IProject project) throws CoreException { if (!project.exists()) { BuildPathsBlock.createProject(project, null, new NullProgressMonitor()); BuildPathsBlock.addJavaNature(project, new NullProgressMonitor()); } }
protected Control createDialogArea(Composite parent) { IStatusChangeListener listener = new IStatusChangeListener() { public void statusChanged(IStatus status) { updateStatus(status); } }; Composite result= (Composite)super.createDialogArea(parent); fBlock= new BuildPathsBlock(new BusyIndicatorRunnableContext(), listener, 0, false, null); fBlock.init(fProject, null, null); fBlock.createControl(result).setLayoutData(new GridData(GridData.FILL_BOTH)); applyDialogFont(result); return result; }
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (monitor == null) { monitor= new NullProgressMonitor(); } monitor.beginTask(NewWizardMessages.NewJavaProjectWizardPage_op_desc, 10); // initialize if needed if (fProjectModified || isNewProjectHandle()) { initBuildPaths(); } // create the project try { IPath locationPath= getLocationPath(); BuildPathsBlock.createProject(getProjectHandle(), locationPath != null ? URIUtil.toURI(locationPath) : null, new SubProgressMonitor(monitor, 2)); BuildPathsBlock.addJavaNature(getProjectHandle(), new SubProgressMonitor(monitor, 2)); fBuildPathsBlock.configureJavaProject(new SubProgressMonitor(monitor, 6)); } catch (CoreException e) { throw new InvocationTargetException(e); } catch (OperationCanceledException e) { throw new InterruptedException(); } finally { monitor.done(); } } };
} while (project.exists()); BuildPathsBlock.createProject(project, null, new SubProgressMonitor(pm, 3)); BuildPathsBlock.addJavaNature(project, new SubProgressMonitor(pm, 1)); IJavaProject javaProject= JavaCore.create(project); IPath outputLocation= BuildPathsBlock.getDefaultOutputLocation(javaProject); IClasspathEntry[] cpes= new IClasspathEntry[] { srcEntry, jreEntry }; javaProject.setRawClasspath(cpes, outputLocation, new SubProgressMonitor(pm, 1));
/** * Adds the Java nature to the project (if not set yet) and configures the build classpath. * * @param newProjectCompliance compliance to set for a new project, can be <code>null</code> * @param monitor a progress monitor to report progress or <code>null</code> if * progress reporting is not desired * @throws CoreException Thrown when the configuring the Java project failed. * @throws InterruptedException Thrown when the operation has been canceled. * @since 3.5 */ public void configureJavaProject(String newProjectCompliance, IProgressMonitor monitor) throws CoreException, InterruptedException { if (monitor == null) { monitor= new NullProgressMonitor(); } int nSteps= 6; monitor.beginTask(NewWizardMessages.JavaCapabilityConfigurationPage_op_desc_java, nSteps); try { IProject project= getJavaProject().getProject(); BuildPathsBlock.addJavaNature(project, new SubProgressMonitor(monitor, 1)); getBuildPathsBlock().configureJavaProject(newProjectCompliance, new SubProgressMonitor(monitor, 5)); } catch (OperationCanceledException e) { throw new InterruptedException(); } finally { monitor.done(); } }
@Override protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException { if (fDoFlushChange) { IJavaProject javaProject= getEntryToEdit().getJavaProject(); BuildPathsBlock.flush(getExistingEntries(), getOutputLocation(), javaProject, null, monitor); IProject project= javaProject.getProject(); IPath path= getEntryToEdit().getPath(); IResource folder= project.getWorkspace().getRoot().findMember(path); fPackageFragmentRoot= javaProject.getPackageFragmentRoot(folder); } }
@Override public void dispose() { try { super.dispose(); } finally { if (fBuildPathsBlock != null) { fBuildPathsBlock.dispose(); fBuildPathsBlock= null; } } }
@Override public void createControl(Composite parent) { Composite composite= new Composite(parent, SWT.NONE); composite.setFont(parent.getFont()); composite.setLayout(new GridLayout(1, false)); Control control= fBuildPathsBlock.createControl(composite); control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Dialog.applyDialogFont(composite); PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.NEW_JAVAPROJECT_WIZARD_PAGE); setControl(composite); }
@Override public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { fBuildPathsBlock.configureJavaProject(monitor); } };
BuildPathsBlock getBuildPathsBlock() { if (fBuildPathsBlock == null) { IStatusChangeListener listener= new IStatusChangeListener() { @Override public void statusChanged(IStatus status) { updateStatus(status); } }; fBuildPathsBlock= new BuildPathsBlock(new BusyIndicatorRunnableContext(), listener, 0, useNewSourcePage(), null); } return fBuildPathsBlock; }
private void buildPathChangeControlPressed(DialogField field) { if (field == fBuildPathDialogField) { IContainer container= chooseContainer(); if (container != null) { fBuildPathDialogField.setText(container.getFullPath().makeRelative().toString()); } } }
@Override public void customButtonPressed(ListDialogField<CPListElement> field, int index) { buildPathCustomButtonPressed(field, index); }
/** * Helper method to create and open a IProject. The project location * is configured. No natures are added. * * @param project The handle of the project to create. * @param locationURI The location of the project or <code>null</code> to create the project in the workspace * @param monitor a progress monitor to report progress or <code>null</code> if * progress reporting is not desired * @throws CoreException if the project couldn't be created * @see org.eclipse.core.resources.IProjectDescription#setLocationURI(java.net.URI) * @since 3.2 */ public static void createProject(IProject project, URI locationURI, IProgressMonitor monitor) throws CoreException { BuildPathsBlock.createProject(project, locationURI, monitor); }
private Control createWithJava(Composite parent, IProject project) { IWorkbenchPreferenceContainer pageContainer= null; IPreferencePageContainer container= getContainer(); if (container instanceof IWorkbenchPreferenceContainer) { pageContainer= (IWorkbenchPreferenceContainer) container; } fBuildPathsBlock= new BuildPathsBlock(new BusyIndicatorRunnableContext(), this, getSettings().getInt(INDEX), false, pageContainer); fBuildPathsBlock.init(JavaCore.create(project), null, null); return fBuildPathsBlock.createControl(parent); }
@Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (monitor == null) { monitor= new NullProgressMonitor(); } monitor.beginTask(NewWizardMessages.NewJavaProjectWizardPage_op_desc, 10); // initialize if needed if (fProjectModified || isNewProjectHandle()) { initBuildPaths(); } // create the project try { IPath locationPath= getLocationPath(); BuildPathsBlock.createProject(getProjectHandle(), locationPath != null ? URIUtil.toURI(locationPath) : null, new SubProgressMonitor(monitor, 2)); BuildPathsBlock.addJavaNature(getProjectHandle(), new SubProgressMonitor(monitor, 2)); fBuildPathsBlock.configureJavaProject(new SubProgressMonitor(monitor, 6)); } catch (CoreException e) { throw new InvocationTargetException(e); } catch (OperationCanceledException e) { throw new InterruptedException(); } finally { monitor.done(); } } };
} while (project.exists()); BuildPathsBlock.createProject(project, null, new SubProgressMonitor(pm, 3)); BuildPathsBlock.addJavaNature(project, new SubProgressMonitor(pm, 1)); IJavaProject javaProject= JavaCore.create(project); IPath outputLocation= BuildPathsBlock.getDefaultOutputLocation(javaProject); IClasspathEntry[] cpes= new IClasspathEntry[] { srcEntry, jreEntry }; javaProject.setRawClasspath(cpes, outputLocation, new SubProgressMonitor(pm, 1));
/** * Adds the Java nature to the project (if not set yet) and configures the build classpath. * * @param monitor a progress monitor to report progress or <code>null</code> if * progress reporting is not desired * @throws CoreException Thrown when the configuring the Java project failed. * @throws InterruptedException Thrown when the operation has been canceled. */ public void configureJavaProject(IProgressMonitor monitor) throws CoreException, InterruptedException { if (monitor == null) { monitor= new NullProgressMonitor(); } int nSteps= 6; monitor.beginTask(NewWizardMessages.JavaCapabilityConfigurationPage_op_desc_java, nSteps); try { IProject project= getJavaProject().getProject(); BuildPathsBlock.addJavaNature(project, new SubProgressMonitor(monitor, 1)); getBuildPathsBlock().configureJavaProject(new SubProgressMonitor(monitor, 5)); } catch (OperationCanceledException e) { throw new InterruptedException(); } finally { monitor.done(); } }
@Override protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException { if (fDoFlushChange) { IJavaProject javaProject= getEntryToEdit().getJavaProject(); BuildPathsBlock.flush(getExistingEntries(), getOutputLocation(), javaProject, null, monitor); IProject project= javaProject.getProject(); IPath path= getEntryToEdit().getPath(); IResource folder= project.getWorkspace().getRoot().findMember(path); fPackageFragmentRoot= javaProject.getPackageFragmentRoot(folder); } }