use of org.eclipse.core.resources.IContainer in project knime-core by knime.
the class WorkflowExportWizard method canFinish.
/**
* {@inheritDoc}
*/
@Override
public boolean canFinish() {
Collection<IContainer> workflows = m_page.getWorkflows();
final List<IResource> resourceList = new ArrayList<IResource>();
for (IContainer c : workflows) {
addResourcesFor(resourceList, c, m_excludeData);
}
if (resourceList.isEmpty()) {
return false;
}
return m_page.isPageComplete();
}
use of org.eclipse.core.resources.IContainer in project knime-core by knime.
the class WorkflowExportPage method handleSingleSelection.
private IContainer handleSingleSelection(final IStructuredSelection selection) {
Object obj = selection.getFirstElement();
IContainer resultContainer = null;
// prepare default export file name
if (obj instanceof IContainer) {
resultContainer = (IContainer) obj;
} else if (obj instanceof IResource) {
resultContainer = ((IResource) obj).getParent();
}
if (obj instanceof NodeContainer) {
resultContainer = getContainerForWorkflow((NodeContainer) obj);
}
if (obj instanceof IContainer) {
IContainer container = (IContainer) obj;
// check whether it is a workflow group -> list all workflows
if (KnimeResourceUtil.isWorkflowGroup(container) || container instanceof IWorkspaceRoot) {
// get all contained containers and list them recursively
m_treeViewer.setInput(container);
m_treeViewer.getTree().setVisible(true);
m_treeViewer.expandAll();
// all
if (selection.size() <= 1) {
/*
* Since the tree is expanded before the deprecated method
* should work. Reason why it is deprecated:
* "this method only checks or unchecks visible items" but
* CheckboxTreeViewer#setSubtreeChecked(Object, boolean)
* does not work.
*/
m_treeViewer.setAllChecked(true);
}
} else if (KnimeResourceUtil.isWorkflow(container)) {
// or a workflow -> list nothing
m_treeViewer.getTree().setVisible(false);
}
}
return resultContainer;
}
use of org.eclipse.core.resources.IContainer in project knime-core by knime.
the class WorkflowExportPage method handleSelection.
private IContainer handleSelection(final IStructuredSelection selection) {
IContainer resultContainer = null;
// reset checked elements
m_treeViewer.expandAll();
m_treeViewer.setAllChecked(false);
if (selection.size() > 1) {
resultContainer = handleMultiSelection(selection);
} else if (selection.size() == 1) {
resultContainer = handleSingleSelection(selection);
}
if (resultContainer != null) {
String containerSelectionText = resultContainer.getFullPath().toString();
if (resultContainer instanceof IWorkspaceRoot) {
containerSelectionText = "/";
}
m_containerText.setText(containerSelectionText);
}
// also update the target file name
updateFileName(resultContainer);
return resultContainer;
}
use of org.eclipse.core.resources.IContainer in project knime-core by knime.
the class WorkflowExportPage method getWorkflows.
/**
* @return checked workflows and workflow groups
*/
public Collection<IContainer> getWorkflows() {
Object[] checkedObjs = m_treeViewer.getCheckedElements();
List<IContainer> workflows = new ArrayList<IContainer>();
// also add the root
IContainer rootContainer = getContainerForFullPath(new Path(m_containerText.getText()));
if (rootContainer != null) {
workflows.add(rootContainer);
}
for (Object o : checkedObjs) {
if (o instanceof IContainer) {
IContainer container = (IContainer) o;
if (KnimeResourceUtil.isWorkflowGroup(container) || KnimeResourceUtil.isWorkflow(container)) {
workflows.add(container);
}
}
}
return workflows;
}
use of org.eclipse.core.resources.IContainer in project knime-core by knime.
the class WorkflowExportPage method dialogChanged.
/**
* Ensures that both text fields are set.
*/
private void dialogChanged() {
Collection<IContainer> workflows = getWorkflows();
final List<IResource> list = new ArrayList<IResource>();
for (IContainer c : workflows) {
WorkflowExportWizard.addResourcesFor(list, c, excludeData());
}
if (list.isEmpty()) {
updateStatus("Select an element to export!");
return;
}
String fileName = getFileName();
if (fileName.length() == 0 || fileName.endsWith(File.separator)) {
updateStatus("File name must be specified");
return;
}
updateStatus(null);
}
Aggregations