use of org.eclipse.ui.progress.IProgressService in project webtools.sourceediting by eclipse.
the class XSDModelAdapter method createSchema.
public XSDSchema createSchema(Document document) {
try {
// (cs) note that we always want to ensure that a
// schema model object get's returned
schema = XSDFactory.eINSTANCE.createXSDSchema();
resourceSet = XSDSchemaImpl.createResourceSet();
resourceSet.getAdapterFactories().add(new XSDSchemaLocationResolverAdapterFactory());
IDOMNode domNode = (IDOMNode) document;
String baseLocation = domNode.getModel().getBaseLocation();
// TODO... gotta pester SSE folks to provide 'useful' baseLocations
//
URI uri = getURI(baseLocation);
Resource resource = new XSDResourceImpl();
resource.setURI(uri);
schema = XSDFactory.eINSTANCE.createXSDSchema();
resource.getContents().add(schema);
resourceSet.getResources().add(resource);
schema.setDocument(document);
final Element element = document.getDocumentElement();
if (element != null) {
// Force the loading of the "meta" schema for schema instance instance.
//
String schemaForSchemaNamespace = element.getNamespaceURI();
XSDSchemaImpl.getSchemaForSchema(schemaForSchemaNamespace);
}
IRunnableWithProgress setElementOperation = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// Use the animated flavour as we don't know beforehand how many ticks we need.
// The task name will be displayed by the code in XSDResourceImpl.
// $NON-NLS-1$
monitor.beginTask("", IProgressMonitor.UNKNOWN);
Map loadOptions = resourceSet.getLoadOptions();
loadOptions.put(XSDResourceImpl.XSD_PROGRESS_MONITOR, monitor);
schema.setElement(element);
loadOptions.remove(XSDResourceImpl.XSD_PROGRESS_MONITOR);
}
};
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
try {
progressService.busyCursorWhile(setElementOperation);
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
// attach an adapter to keep the XSD model and DOM in sync
//
modelReconcileAdapter = new XSDModelReconcileAdapter(document, schema);
domNode.getModel().addModelStateListener(modelReconcileAdapter);
} catch (Exception ex) {
ex.printStackTrace();
}
return schema;
}
use of org.eclipse.ui.progress.IProgressService in project netxms by netxms.
the class Activator method start.
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
// Register icon for our jobs
IProgressService service = PlatformUI.getWorkbench().getProgressService();
// $NON-NLS-1$
service.registerIconForFamily(getImageDescriptor("icons/alarm_browser.png"), AlarmList.JOB_FAMILY);
}
use of org.eclipse.ui.progress.IProgressService in project netxms by netxms.
the class Activator method start.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
* )
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
IProgressService service = PlatformUI.getWorkbench().getProgressService();
// $NON-NLS-1$
service.registerIconForFamily(getImageDescriptor("icons/actionmgr.png"), PLUGIN_ID);
}
use of org.eclipse.ui.progress.IProgressService in project erlide_eclipse by erlang.
the class SearchUtil method runQuery.
public static void runQuery(final ErlangSearchPattern pattern, final ErlSearchScope scope, final String scopeDescription, final Shell shell) {
final ErlSearchQuery query = new ErlSearchQuery(pattern, scope, scopeDescription);
if (query.canRunInBackground()) {
/*
* This indirection with Object as parameter is needed to prevent the loading
* of the Search plug-in: the VM verifies the method call and hence loads the
* types used in the method signature, eventually triggering the loading of a
* plug-in (in this case ISearchQuery results in Search plug-in being loaded).
*/
NewSearchUI.runQueryInBackground(query);
} else {
final IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
/*
* This indirection with Object as parameter is needed to prevent the loading
* of the Search plug-in: the VM verifies the method call and hence loads the
* types used in the method signature, eventually triggering the loading of a
* plug-in (in this case it would be ISearchQuery).
*/
final IStatus status = NewSearchUI.runQueryInForeground(progressService, query);
if (status.matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) {
ErrorDialog.openError(shell, "Search", "Problems occurred while searching. " + "The affected files will be skipped.", status);
}
}
}
use of org.eclipse.ui.progress.IProgressService in project jbosstools-openshift by jbosstools.
the class OpenShiftResourceDocumentProvider method doSaveDocument.
@Override
protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
OpenShiftResourceInput input = getInput(element);
if (input == null) {
return;
}
IResource resource = input.getResource();
IClient client = ResourceUtils.getClient(resource);
IProgressService service = PlatformUI.getWorkbench().getProgressService();
Connection connection = input.getConnection();
String resourceName = input.getName();
IResource newResource = connection.getResourceFactory().create(document.get());
final Exception[] exceptions = new Exception[1];
Job updateResourceJob = new Job("Update " + resourceName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
client.update(newResource);
} catch (Exception e) {
exceptions[0] = e;
Display.getDefault().asyncExec(() -> setDirty(element));
String problem = e.getMessage();
if (e instanceof OpenShiftException) {
OpenShiftException oe = (OpenShiftException) e;
if (oe.getStatus() != null) {
problem = oe.getStatus().getMessage();
}
}
IStatus error = OpenShiftUIActivator.statusFactory().errorStatus(NLS.bind("Could not update \"{0}\" for project \"{1}\" : {2}", new String[] { resourceName, resource.getNamespaceName(), problem }), e);
return error;
}
return Status.OK_STATUS;
}
};
updateResourceJob.schedule();
Shell shell = Display.getCurrent().getActiveShell();
service.showInDialog(shell, updateResourceJob);
// we need to ensure the dirty flag stays set to true
if (exceptions[0] != null) {
throw new CoreException(OpenShiftUIActivator.statusFactory().errorStatus(exceptions[0]));
}
}
Aggregations