use of org.eclipse.core.resources.IStorage in project erlide_eclipse by erlang.
the class ErlModelUtils method getPathForInput.
private static String getPathForInput(final IEditorInput editorInput) {
if (editorInput instanceof IStorageEditorInput) {
final IStorageEditorInput sei = (IStorageEditorInput) editorInput;
try {
final IStorage storage = sei.getStorage();
final IPath p = storage.getFullPath();
return p.toPortableString();
} catch (final CoreException e) {
}
}
if (editorInput instanceof IURIEditorInput) {
final IURIEditorInput ue = (IURIEditorInput) editorInput;
return ue.getURI().getPath();
}
return null;
}
use of org.eclipse.core.resources.IStorage in project webtools.sourceediting by eclipse.
the class StorageModelProvider method calculateID.
String calculateID(IStorageEditorInput input) {
/**
* Typically CVS will return a path of "filename.ext" and the input's
* name will be "filename.ext version". The path must be used to load
* the model so that the suffix will be available to compute the
* contentType properly. The editor input name can then be set as the
* base location for display on the editor title bar.
*/
String path = null;
if (input instanceof ILocationProvider) {
IPath ipath = ((ILocationProvider) input).getPath(input);
if (ipath != null) {
path = ipath.toString();
}
}
if (path == null) {
try {
IStorage storage = input.getStorage();
if (storage != null) {
IPath storagePath = storage.getFullPath();
String name = storage.getName();
if (storagePath != null) {
// Favor the name.
if (!storagePath.lastSegment().equals(name)) {
IPath workingPath = storagePath.addTrailingSeparator();
path = workingPath.append(name).toString();
} else {
path = storagePath.makeAbsolute().toString();
}
}
if (path == null)
path = name;
}
} catch (CoreException e) {
Logger.logException(e);
} finally {
if (path == null)
// $NON-NLS-1$
path = input.getName();
}
}
/*
* Prepend the hash to the path value so that we have a 1:1:1 match
* between editor inputs, element info, and models. The editor manager
* should help prevent needlessly duplicated models as long as two
* editor inputs from the same storage indicate they're equals().
*/
// $NON-NLS-1$
path = input.hashCode() + "#" + path;
return path;
}
use of org.eclipse.core.resources.IStorage in project n4js by eclipse.
the class BuildInstruction method shouldGenerate.
private boolean shouldGenerate(Resource resource, IProject aProject) {
try {
Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(resource.getURI());
for (Pair<IStorage, IProject> pair : storages) {
if (pair.getFirst() instanceof IFile && pair.getSecond().equals(aProject)) {
IFile file = (IFile) pair.getFirst();
int findMaxProblemSeverity = file.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
// Easiest way here is to remove that error marker-type and look for other severe errors once more:
if (findMaxProblemSeverity == IMarker.SEVERITY_ERROR) {
// clean
GeneratorMarkerSupport generatorMarkerSupport = injector.getInstance(GeneratorMarkerSupport.class);
generatorMarkerSupport.deleteMarker(resource);
// and recompute:
findMaxProblemSeverity = file.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
}
// the final decision to build:
return findMaxProblemSeverity != IMarker.SEVERITY_ERROR;
}
}
return false;
} catch (CoreException exc) {
throw new WrappedException(exc);
}
}
use of org.eclipse.core.resources.IStorage in project mdw-designer by CenturyLinkCloud.
the class ProcessInstanceListView method createContextMenu.
private Menu createContextMenu(Shell shell) {
Menu menu = new Menu(shell, SWT.POP_UP);
final StructuredSelection selection = (StructuredSelection) getTableViewer().getSelection();
if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) {
final ProcessInstanceVO processInstanceInfo = (ProcessInstanceVO) selection.getFirstElement();
// open instance
MenuItem openItem = new MenuItem(menu, SWT.PUSH);
openItem.setText("Open");
ImageDescriptor openImageDesc = MdwPlugin.getImageDescriptor("icons/process.gif");
openItem.setImage(openImageDesc.createImage());
openItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleOpen(processInstanceInfo);
}
});
// owning document
if (OwnerType.DOCUMENT.equals(processInstanceInfo.getOwner()) || OwnerType.TESTER.equals(processInstanceInfo.getOwner())) {
MenuItem docItem = new MenuItem(menu, SWT.PUSH);
docItem.setText("View Owning Document");
ImageDescriptor docImageDesc = MdwPlugin.getImageDescriptor("icons/doc.gif");
docItem.setImage(docImageDesc.createImage());
docItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IStorage storage = new DocumentStorage(workflowProject, new DocumentReference(processInstanceInfo.getOwnerId(), null));
final IStorageEditorInput input = new StorageEditorInput(storage);
final IWorkbenchPage page = MdwPlugin.getActivePage();
if (page != null) {
BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {
public void run() {
try {
page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
} catch (PartInitException ex) {
PluginMessages.uiError(ex, "View Document", workflowProject);
}
}
});
}
}
});
}
// instance hierarchy
MenuItem hierarchyItem = new MenuItem(menu, SWT.PUSH);
hierarchyItem.setText("Instance Hierarchy");
ImageDescriptor hierarchyImageDesc = MdwPlugin.getImageDescriptor("icons/hierarchy.gif");
hierarchyItem.setImage(hierarchyImageDesc.createImage());
hierarchyItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
WorkflowProcess pv = new WorkflowProcess(processVersion);
pv.setProcessVO(processVersion.getProcessVO());
pv.setProcessInstance(processInstanceInfo);
new WorkflowElementActionHandler().showHierarchy(pv);
}
});
}
// delete
if (!selection.isEmpty() && !processVersion.getProject().isProduction() && processVersion.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION)) {
MenuItem deleteItem = new MenuItem(menu, SWT.PUSH);
deleteItem.setText("Delete...");
ImageDescriptor deleteImageDesc = MdwPlugin.getImageDescriptor("icons/delete.gif");
deleteItem.setImage(deleteImageDesc.createImage());
deleteItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) {
ProcessInstanceVO pii = (ProcessInstanceVO) selection.getFirstElement();
if (MessageDialog.openConfirm(getSite().getShell(), "Confirm Delete", "Delete process instance ID: " + pii.getId() + " for workflow project '" + processVersion.getProject().getName() + "'?")) {
List<ProcessInstanceVO> instances = new ArrayList<>();
instances.add((ProcessInstanceVO) selection.getFirstElement());
handleDelete(instances);
}
} else {
if (MessageDialog.openConfirm(getSite().getShell(), "Confirm Delete", "Delete selected process instances for workflow project '" + processVersion.getProject().getName() + "'?")) {
List<ProcessInstanceVO> instances = new ArrayList<>();
for (Object instance : selection.toArray()) {
if (instance instanceof ProcessInstanceVO)
instances.add((ProcessInstanceVO) instance);
}
handleDelete(instances);
}
}
}
});
}
return menu;
}
use of org.eclipse.core.resources.IStorage in project xtext-xtend by eclipse.
the class XtendNatureAddingEditorCallback method canBuild.
private boolean canBuild(XtextEditor editor) {
IResource resource = editor.getResource();
if (!(resource instanceof IStorage)) {
return false;
}
IStorage storage = (IStorage) resource;
URI uri = mapper.getUri(storage);
return uriValidator.canBuild(uri, storage);
}
Aggregations