Search in sources :

Example 46 with IContainer

use of org.eclipse.core.resources.IContainer in project sling by apache.

the class JcrContentContentProvider method resourceChanged.

@Override
public void resourceChanged(IResourceChangeEvent event) {
    if (viewer.getTree().isDisposed()) {
        return;
    }
    try {
        final Set<IProject> toBeRefreshed = new HashSet<>();
        event.getDelta().accept(new IResourceDeltaVisitor() {

            @Override
            public boolean visit(IResourceDelta delta) throws CoreException {
                if (delta.getResource() instanceof IContainer) {
                    return true;
                }
                IProject p = delta.getResource().getProject();
                IFolder syncDir = getSyncDir(p);
                if (syncDir == null) {
                    return false;
                }
                toBeRefreshed.add(syncDir.getProject());
                return true;
            }
        });
        for (final IProject project : toBeRefreshed) {
            viewer.getTree().getDisplay().asyncExec(new Runnable() {

                @Override
                public void run() {
                    if (viewer.getTree().isDisposed()) {
                        return;
                    }
                    long start = System.currentTimeMillis();
                    viewer.refresh(project, true);
                    long end = System.currentTimeMillis();
                    Activator.getDefault().getPluginLogger().tracePerformance("viewer.refresh({0},true)", (end - start), project);
                }
            });
        }
    } catch (CoreException e) {
        //TODO proper logging
        e.printStackTrace();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IResourceDeltaVisitor(org.eclipse.core.resources.IResourceDeltaVisitor) IContainer(org.eclipse.core.resources.IContainer) IProject(org.eclipse.core.resources.IProject) HashSet(java.util.HashSet) IResourceDelta(org.eclipse.core.resources.IResourceDelta) IFolder(org.eclipse.core.resources.IFolder)

Example 47 with IContainer

use of org.eclipse.core.resources.IContainer in project sling by apache.

the class JcrNode method canBePastedTo.

public boolean canBePastedTo(Clipboard clipboard) {
    Repository repository = ServerUtil.getDefaultRepository(getProject());
    NodeTypeRegistry ntManager = (repository == null) ? null : repository.getNodeTypeRegistry();
    IResource[] resourceData = (IResource[]) clipboard.getContents(ResourceTransfer.getInstance());
    if (resourceData != null) {
        IContainer container = getDropContainer();
        return container != null;
    }
    String[] fileData = (String[]) clipboard.getContents(FileTransfer.getInstance());
    if (fileData != null) {
        IContainer container = getDropContainer();
        return container != null;
    }
    String text = (String) clipboard.getContents(TextTransfer.getInstance());
    if (text != null) {
        return (domElement != null);
    }
    return false;
}
Also used : Repository(org.apache.sling.ide.transport.Repository) NodeTypeRegistry(org.apache.sling.ide.transport.NodeTypeRegistry) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 48 with IContainer

use of org.eclipse.core.resources.IContainer in project sling by apache.

the class ImportWizardPage method queryForLocation.

protected IPath queryForLocation(IProject initialSelection, String msg, String title) {
    ContainerSelectionDialog dialog = new ContainerSelectionDialog(getControl().getShell(), initialSelection, allowNewContainerName(), msg);
    if (title != null) {
        dialog.setTitle(title);
    }
    dialog.showClosedProjects(false);
    dialog.setValidator(new ISelectionValidator() {

        @Override
        public String isValid(Object selection) {
            if (!(selection instanceof IPath)) {
                return "Please select a valid import location";
            }
            IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
            IContainer container = (IContainer) root.findMember((IPath) selection);
            if (container instanceof IProject) {
                return "Please select a folder inside the project";
            }
            if (!ProjectHelper.isContentProject(container.getProject())) {
                return "Project " + container.getProject().getName() + " is not a content project";
            }
            if (!ProjectUtil.isInsideContentSyncRoot(container)) {
                return "Please select a folder inside the content sync root folder " + ProjectUtil.getSyncDirectory(container.getProject()).getProjectRelativePath();
            }
            return null;
        }
    });
    dialog.open();
    Object[] result = dialog.getResult();
    if (result != null && result.length == 1) {
        return (IPath) result[0];
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) ISelectionValidator(org.eclipse.ui.dialogs.ISelectionValidator) IContainer(org.eclipse.core.resources.IContainer) IProject(org.eclipse.core.resources.IProject)

Example 49 with IContainer

use of org.eclipse.core.resources.IContainer in project applause by applause.

the class ApplauseBuilderParticipant method cleanOutput.

protected void cleanOutput(IBuildContext ctx, OutputConfiguration config, IProgressMonitor monitor) throws CoreException {
    final IProject project = ctx.getBuiltProject();
    IContainer container = getContainer(project, config.getOutputDirectory());
    if (!container.exists()) {
        return;
    }
    if (config.isCanClearOutputDirectory()) {
        for (IResource resource : container.members()) {
            resource.delete(IResource.KEEP_HISTORY, monitor);
        }
    } else if (config.isCleanUpDerivedResources()) {
        List<IFile> resources = derivedResourceMarkers.findDerivedResources(container, null);
        for (IFile iFile : resources) {
            iFile.delete(IResource.KEEP_HISTORY, monitor);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) IContainer(org.eclipse.core.resources.IContainer) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource)

Example 50 with IContainer

use of org.eclipse.core.resources.IContainer in project applause by applause.

the class ApplauseBuilderParticipant method getGeneratorMarkers.

/**
	 * @since 2.4
	 */
protected Map<OutputConfiguration, Iterable<IMarker>> getGeneratorMarkers(IProject builtProject, Collection<OutputConfiguration> outputConfigurations) throws CoreException {
    Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = newHashMap();
    for (OutputConfiguration config : outputConfigurations) {
        if (config.isCleanUpDerivedResources()) {
            IContainer container = getContainer(builtProject, config.getOutputDirectory());
            final Iterable<IMarker> markers = derivedResourceMarkers.findDerivedResourceMarkers(container, generatorIdProvider.getGeneratorIdentifier());
            generatorMarkers.put(config, markers);
        }
    }
    return generatorMarkers;
}
Also used : OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) IMarker(org.eclipse.core.resources.IMarker) IContainer(org.eclipse.core.resources.IContainer)

Aggregations

IContainer (org.eclipse.core.resources.IContainer)199 IResource (org.eclipse.core.resources.IResource)89 IFile (org.eclipse.core.resources.IFile)71 IPath (org.eclipse.core.runtime.IPath)47 CoreException (org.eclipse.core.runtime.CoreException)46 IFolder (org.eclipse.core.resources.IFolder)45 Path (org.eclipse.core.runtime.Path)43 IProject (org.eclipse.core.resources.IProject)28 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)26 ArrayList (java.util.ArrayList)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)21 IOException (java.io.IOException)13 IStatus (org.eclipse.core.runtime.IStatus)13 ByteArrayInputStream (java.io.ByteArrayInputStream)12 File (java.io.File)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)12 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)12 Status (org.eclipse.core.runtime.Status)10 PartInitException (org.eclipse.ui.PartInitException)10 InputStream (java.io.InputStream)9