Search in sources :

Example 71 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project tdi-studio-se by Talend.

the class CodeGenInit method saveWorkspace.

private void saveWorkspace() throws CoreException {
    //$NON-NLS-1$
    info(Messages.getString("CodeGenInit.saveWorkspace"));
    ResourcesPlugin.getWorkspace().save(true, new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor)

Example 72 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project tdi-studio-se by Talend.

the class CodeGenInit method createAndLogonProject.

private void createAndLogonProject(ECodeLanguage language) throws Exception {
    Project project = getProject(language);
    if (project == null) {
        Project projectInfor = //$NON-NLS-1$
        ProjectHelper.createProject(//$NON-NLS-1$
        getProjectName(language), //$NON-NLS-1$
        "", language.getName(), createUser());
        project = repositoryFactory.createProject(projectInfor);
    }
    repositoryFactory.logOnProject(project, new NullProgressMonitor());
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor)

Example 73 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project tdi-studio-se by Talend.

the class ComponentProjectManager method initializeClasspath.

/**
     * DOC ycbai Initialize classpath of project.
     * 
     * @param project
     * @param monitor
     * @throws OperationCanceledException
     * @throws CoreException
     */
private void initializeClasspath(IJavaProject project, IProgressMonitor monitor) throws OperationCanceledException, CoreException {
    if (monitor != null && monitor.isCanceled()) {
        throw new OperationCanceledException();
    }
    if (project == null)
        return;
    IClasspathEntry[] entries = null;
    List<IClasspathEntry> cpEntries = new ArrayList<IClasspathEntry>();
    cpEntries.addAll(Arrays.asList(getDefaultJREClasspathEntries()));
    cpEntries.addAll(getDefaultUtilClasspathEntries());
    entries = (IClasspathEntry[]) cpEntries.toArray(new IClasspathEntry[cpEntries.size()]);
    if (monitor != null)
        monitor.worked(1);
    IPath output = getOutputLocation();
    IProgressMonitor subProgressMonitor = monitor == null ? new NullProgressMonitor() : new SubProgressMonitor(monitor, 2);
    project.setRawClasspath(entries, output, subProgressMonitor);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ArrayList(java.util.ArrayList) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 74 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project tdi-studio-se by Talend.

the class BusinessNewDiagramFileWizard method performFinish.

/**
     * @generated
     */
public boolean performFinish() {
    IFile diagramFile = myFileCreationPage.createNewFile();
    try {
        //$NON-NLS-1$
        diagramFile.setCharset("UTF-8", new NullProgressMonitor());
    } catch (CoreException e) {
        //$NON-NLS-1$
        BusinessDiagramEditorPlugin.getInstance().logError("Unable to set charset for diagram file", e);
    }
    ResourceSet resourceSet = myEditingDomain.getResourceSet();
    final Resource diagramResource = resourceSet.createResource(URI.createPlatformResourceURI(diagramFile.getFullPath().toString()));
    List affectedFiles = new LinkedList();
    affectedFiles.add(mySelectedModelFile);
    affectedFiles.add(diagramFile);
    AbstractTransactionalCommand command = new AbstractTransactionalCommand(myEditingDomain, //$NON-NLS-1$
    "Initializing diagram contents", //$NON-NLS-1$
    affectedFiles) {

        protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
            int diagramVID = BusinessVisualIDRegistry.getDiagramVisualID(myDiagramRoot);
            if (diagramVID != BusinessProcessEditPart.VISUAL_ID) {
                //$NON-NLS-1$
                return CommandResult.newErrorCommandResult("Incorrect model object stored as a root resource object");
            }
            Diagram diagram = ViewService.createDiagram(myDiagramRoot, BusinessProcessEditPart.MODEL_ID, BusinessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
            diagramResource.getContents().add(diagram);
            diagramResource.getContents().add(diagram.getElement());
            return CommandResult.newOKCommandResult();
        }
    };
    try {
        OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null);
        diagramResource.save(Collections.EMPTY_MAP);
        IDE.openEditor(myWorkbenchPage, diagramFile);
    } catch (ExecutionException e) {
        //$NON-NLS-1$
        BusinessDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e);
    } catch (IOException ex) {
        BusinessDiagramEditorPlugin.getInstance().logError("Save operation failed for: " + diagramFile.getFullPath().toString(), //$NON-NLS-1$
        ex);
    } catch (PartInitException ex) {
        //$NON-NLS-1$
        BusinessDiagramEditorPlugin.getInstance().logError("Unable to open editor", ex);
    }
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IAdaptable(org.eclipse.core.runtime.IAdaptable) IFile(org.eclipse.core.resources.IFile) Resource(org.eclipse.emf.ecore.resource.Resource) AbstractTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IOException(java.io.IOException) LinkedList(java.util.LinkedList) Diagram(org.eclipse.gmf.runtime.notation.Diagram) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) LinkedList(java.util.LinkedList) List(java.util.List) PartInitException(org.eclipse.ui.PartInitException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 75 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project tdi-studio-se by Talend.

the class EmfEmittersPersistenceFactory method getJetProject.

/**
     * DOC mhirt Comment method "getJetProject".
     * 
     * @return
     * @throws CoreException
     */
private static IProject getJetProject() {
    IProject project = null;
    try {
        IProgressMonitor monitor = new NullProgressMonitor();
        IProgressMonitor progressMonitor = new SubProgressMonitor(monitor, 1);
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        //$NON-NLS-1$
        project = workspace.getRoot().getProject(".JETEmitters");
        if (!project.exists()) {
            project.create(new SubProgressMonitor(progressMonitor, 1));
            progressMonitor.subTask(//$NON-NLS-1$
            CodeGenPlugin.getPlugin().getString(//$NON-NLS-1$
            "_UI_JETCreatingProject_message", new Object[] { project.getName() }));
            project.open(new SubProgressMonitor(progressMonitor, 1));
        }
    } catch (CoreException e) {
        log.error(e.getMessage(), e);
        project = null;
    }
    return project;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) IProject(org.eclipse.core.resources.IProject) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Aggregations

NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1614 CoreException (org.eclipse.core.runtime.CoreException)416 Test (org.junit.Test)382 IFile (org.eclipse.core.resources.IFile)342 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)267 IProject (org.eclipse.core.resources.IProject)258 File (java.io.File)205 IPath (org.eclipse.core.runtime.IPath)182 IOException (java.io.IOException)153 Path (org.eclipse.core.runtime.Path)132 ArrayList (java.util.ArrayList)122 IStatus (org.eclipse.core.runtime.IStatus)113 IFolder (org.eclipse.core.resources.IFolder)87 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)69 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)63 InvocationTargetException (java.lang.reflect.InvocationTargetException)60 List (java.util.List)59 IProjectDescription (org.eclipse.core.resources.IProjectDescription)57 IType (org.eclipse.jdt.core.IType)57 Status (org.eclipse.core.runtime.Status)55