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();
}
}
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;
}
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;
}
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);
}
}
}
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;
}
Aggregations