Search in sources :

Example 11 with IProgressService

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;
}
Also used : Element(org.w3c.dom.Element) Resource(org.eclipse.emf.ecore.resource.Resource) XSDResourceImpl(org.eclipse.xsd.util.XSDResourceImpl) XSDSchemaLocationResolverAdapterFactory(org.eclipse.wst.xsd.ui.internal.util.XSDSchemaLocationResolverAdapterFactory) URI(org.eclipse.emf.common.util.URI) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) IProgressService(org.eclipse.ui.progress.IProgressService) Map(java.util.Map)

Example 12 with IProgressService

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);
}
Also used : IProgressService(org.eclipse.ui.progress.IProgressService)

Example 13 with IProgressService

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);
}
Also used : IProgressService(org.eclipse.ui.progress.IProgressService)

Example 14 with IProgressService

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);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IProgressService(org.eclipse.ui.progress.IProgressService)

Example 15 with IProgressService

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]));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) OpenShiftException(com.openshift.restclient.OpenShiftException) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IClient(com.openshift.restclient.IClient) CoreException(org.eclipse.core.runtime.CoreException) OpenShiftException(com.openshift.restclient.OpenShiftException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Shell(org.eclipse.swt.widgets.Shell) CoreException(org.eclipse.core.runtime.CoreException) IProgressService(org.eclipse.ui.progress.IProgressService) Job(org.eclipse.core.runtime.jobs.Job) IResource(com.openshift.restclient.model.IResource)

Aggregations

IProgressService (org.eclipse.ui.progress.IProgressService)38 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)17 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)15 IStatus (org.eclipse.core.runtime.IStatus)11 IOException (java.io.IOException)7 Status (org.eclipse.core.runtime.Status)6 IWorkbench (org.eclipse.ui.IWorkbench)6 File (java.io.File)5 CoreException (org.eclipse.core.runtime.CoreException)5 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)4 IContext (org.talend.core.model.process.IContext)4 ProcessorException (org.talend.designer.runprocess.ProcessorException)4 MessageFormat (java.text.MessageFormat)3 Date (java.util.Date)3 IProject (org.eclipse.core.resources.IProject)3 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)3 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)3 IProcessor (org.talend.designer.runprocess.IProcessor)3 ClearPerformanceAction (org.talend.designer.runprocess.ui.actions.ClearPerformanceAction)3