use of org.eclipse.core.resources.IContainer in project knime-core by knime.
the class DeleteAction method deleteWorkflows.
private void deleteWorkflows(final List<IContainer> toDelWFs) {
for (IContainer wf : toDelWFs) {
assert VMFileLocker.isLockedForVM(new File(wf.getLocationURI()));
assert KnimeResourceUtil.isWorkflow(wf);
try {
// delete the workflow file first
IResource wfFile = wf.findMember(WorkflowPersistor.WORKFLOW_FILE);
wfFile.delete(true, null);
for (IResource child : wf.members()) {
if (VMFileLocker.LOCK_FILE.equals(child.getName())) {
// delete the lock file last
continue;
}
child.delete(true, null);
}
// release lock in order to delete lock file
VMFileLocker.unlockForVM(new File(wf.getLocationURI()));
// lock file resource may not exist
File lockFile = new File(new File(wf.getLocationURI()), VMFileLocker.LOCK_FILE);
lockFile.delete();
// delete the workflow directory itself
wf.delete(true, null);
} catch (CoreException e) {
LOGGER.error("Error while deleting workflow " + wf.getFullPath() + ": " + e.getMessage(), e);
// continue with next workflow...
}
}
}
use of org.eclipse.core.resources.IContainer in project knime-core by knime.
the class ImportKnimeWorkflowAction method run.
/**
* Invoke the Import wizards selection Wizard.
*/
@Override
public void run() {
WorkflowImportWizard wizard = new WorkflowImportWizard();
WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
IStructuredSelection selectionToPass;
// get the current workbench selection
ISelection workbenchSelection = m_workbenchWindow.getSelectionService().getSelection();
if (workbenchSelection instanceof IStructuredSelection) {
selectionToPass = (IStructuredSelection) workbenchSelection;
if (selectionToPass.size() == 1) {
Object o = selectionToPass.getFirstElement();
if (o instanceof IContainer) {
wizard.setInitialDestination((IContainer) o);
}
}
}
dialog.open();
}
use of org.eclipse.core.resources.IContainer in project knime-core by knime.
the class KnimeResourceUtil method getResourceForURI.
/**
* Returns the resource denoted by the specified URI - or null, if no such
* resource exists within the workspace.
*
* @param location if inside the workspace and existing the corresponding
* resource is returned - otherwise null
*
* @return the resource denoted by the specified URI - or null, if no such
* resource exists within the workspace.
*/
public static IResource getResourceForURI(final URI location) {
if (location == null) {
return null;
}
IWorkspaceRoot rootPath = ResourcesPlugin.getWorkspace().getRoot();
IContainer[] conts = rootPath.findContainersForLocationURI(location);
if (conts.length >= 1) {
return conts[0];
}
return null;
}
use of org.eclipse.core.resources.IContainer in project knime-core by knime.
the class KnimeResourceUtil method isWorkflow.
/**
* @param resource the resource to test
* @return true if the resource contains a workflow
*/
public static boolean isWorkflow(final IResource resource) {
if (resource == null) {
return false;
}
if (resource instanceof IFile) {
return false;
}
if (!(resource instanceof IContainer)) {
return false;
}
IContainer container = (IContainer) resource;
// if container contains a workflow file but not its parent
IContainer parent = container.getParent();
if ((parent != null) && parent.exists(WORKFLOW_FILE)) {
return false;
}
return container.exists(WORKFLOW_FILE);
}
use of org.eclipse.core.resources.IContainer in project knime-core by knime.
the class WorkflowExportWizard method findLeadOffset.
private int findLeadOffset() {
// go up until root is reached
int offset = 0;
IContainer p = m_container;
if (ResourcesPlugin.getWorkspace().getRoot().equals(m_container.getParent())) {
// nothing to strip -> use common export operation
return -1;
}
while (p != null && !p.equals(ResourcesPlugin.getWorkspace().getRoot())) {
offset++;
p = p.getParent();
}
return offset;
}
Aggregations