Java 类org.eclipse.core.runtime.Status 实例源码

项目:n4js    文件:EclipseGracefulUIShutdownEnabler.java   
/**
 * Called to eagerly configure the logging-mechanism.
 */
public static void enableOnce() {
    if (logged)
        return;
    // workaround for shutdown-stack-traces due to non-initialized loggers.
    // @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=460863
    ResourcesPlugin.getPlugin().getLog()
            .log(new Status(IStatus.OK, ResourcesPlugin.PI_RESOURCES,
                    "Place holder to init log-system. Loaded by " + EclipseGracefulUIShutdownEnabler.class.getName()
                            + " @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=460863 "));

    // without actual logging the following line is enough (but restricted):
    // StatusHandlerRegistry.getDefault().getDefaultHandlerDescriptor();

    logged = true;
}
项目:scanning    文件:StatusQueueLaunchView.java   
private void openQueueMonitor() throws UnsupportedEncodingException {

        final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        String bundle = store.getString(BUNDLE);
        String bean   = store.getString(BEAN);
        String sqn    = store.getString(STATUS_QUEUE);
        String stn    = store.getString(STATUS_TOPIC);
        String submit = store.getString(SUBMIT_QUEUE);
        String part   = store.getString(PART_NAME);

        String queueViewId = QueueViews.createSecondaryId(bundle,bean, sqn, stn, submit);
        queueViewId = queueViewId+"partName="+part;
        try {
            Util.getPage().showView(StatusQueueView.ID, queueViewId, IWorkbenchPage.VIEW_VISIBLE);
        } catch (PartInitException e) {
            ErrorDialog.openError(Display.getDefault().getActiveShell(), "Cannot open view", "Cannot open view "+queueViewId,
                    new Status(Status.ERROR, "org.eclipse.scanning.event.ui", e.getMessage()));
            logger.error("Cannot open view", e);
        }
    }
项目:n4js    文件:ErrorDialogWithStackTraceUtil.java   
/**
 * Shows JFace ErrorDialog but improved by constructing full stack trace in detail area.
 *
 * @return true if OK was pressed
 */
public static boolean showErrorDialogWithStackTrace(String msg, Throwable throwable) {

    // Temporary holder of child statuses
    List<Status> childStatuses = new ArrayList<>();

    for (StackTraceElement stackTraceElement : throwable.getStackTrace()) {
        childStatuses.add(new Status(IStatus.ERROR, "N4js-plugin-id", stackTraceElement.toString()));
    }

    MultiStatus ms = new MultiStatus("N4js-plugin-id", IStatus.ERROR,
            childStatuses.toArray(new Status[] {}), // convert to array of statuses
            throwable.getLocalizedMessage(), throwable);

    final AtomicBoolean result = new AtomicBoolean(true);
    Display.getDefault()
            .syncExec(
                    () -> result.set(
                            ErrorDialog.openError(null, "Error occurred while organizing ", msg, ms) == Window.OK));

    return result.get();
}
项目:n4js    文件:BuildInstruction.java   
private void handleChangedContents(Delta delta, IProject aProject, ResourceSet resourceSet) throws CoreException {
    // TODO: we will run out of memory here if the number of deltas is large enough
    Resource resource = resourceSet.getResource(delta.getUri(), true);
    if (shouldGenerate(resource, aProject)) {
        try {
            compositeGenerator.doGenerate(resource, access);
        } catch (RuntimeException e) {
            if (e instanceof GeneratorException) {
                N4JSActivator
                        .getInstance()
                        .getLog()
                        .log(new Status(IStatus.ERROR, N4JSActivator.getInstance().getBundle().getSymbolicName(), e
                                .getMessage(), e.getCause()));
            }
            if (e.getCause() instanceof CoreException) {
                throw (CoreException) e.getCause();
            }
            throw e;
        }
    }
}
项目:scanning    文件:ControlValueJob.java   
@Override
protected IStatus run(IProgressMonitor monitor) {
    try {
        if (editor!=null) editor.setSafeEnabled(false);
        scannable.setPosition(value); // Blocking call
        if (editor!=null && value instanceof Number) {
        editor.setSafeValue(((Number)value).doubleValue());
        }
        return Status.OK_STATUS;

    } catch (Exception e) {
        editor.setSafeText(e.getMessage());
        logger.error("Cannot set position!", e);
        return Status.CANCEL_STATUS;

    } finally {
        editor.setSafeEnabled(true);
    }
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @param folder
 * @param filetorefresh
 * @return
 * @throws CoreException
 * @throws InterruptedException
 */
public static IResource resfreshFileInContainer(IContainer folder, String filetorefresh)
        throws CoreException, InterruptedException {
    final IResource buildfile = find(folder, filetorefresh);
    Job job = new WorkspaceJob("Refresh folders") {
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            if (buildfile != null && buildfile.exists()) {
                try {
                    buildfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                } catch (CoreException e) {
                    ResourceManager.logException(e);
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.setUser(true);
    job.schedule();

    return buildfile;
}
项目:n4js    文件:RunConfigurationConverter.java   
/**
 * Converts an {@link ILaunchConfiguration} to a {@link RunConfiguration}. Will throw a {@link WrappedException} in
 * case of error.
 *
 * @see RunConfiguration#writePersistentValues(Map)
 */
public RunConfiguration toRunConfiguration(ILaunchConfiguration launchConfig) throws CoreException {
    try {
        final Map<String, Object> properties = launchConfig.getAttributes();
        // special treatment of name required:
        // name is already included in 'properties', but we have to make sure that the name is up-to-date
        // in case the name of the launch configuration has been changed after the launch configuration
        // was created via method #toLaunchConfiguration()
        properties.put(RunConfiguration.NAME, launchConfig.getName());
        return runnerFrontEnd.createConfiguration(properties);
    } catch (Exception e) {
        String msg = "Error occurred while trying to launch module.";
        if (null != e.getMessage()) {
            msg += "\nReason: " + e.getMessage();
        }
        throw new CoreException(new Status(ERROR, PLUGIN_ID, msg, e));
    }
}
项目:scanning    文件:Stashing.java   
/**
 * Stash using appropriate messages to the user.
 * @param models
 * @param shell
 */
@Override
public void save(Object object) {
    try {

        if (file.exists()) {
            boolean ok = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Confirm Overwrite", "Are you sure that you would like to overwrite '"+file.getName()+"'?");
            if (!ok) return;
        }

        stash(object);

    } catch (Exception e) {
        ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Error Saving Information", "An exception occurred while writing the "+getStashName()+" to file.",
                              new Status(IStatus.ERROR, "org.eclipse.scanning.device.ui", e.getMessage()));
        logger.error("Error Saving Information", e);
    }
}
项目:gemoc-studio    文件:EclipseMessagingSystem.java   
/**
 * This method dispatches the messages between the console and error log view
 * DevError and DevWarning go in both
 * UserError and UserWarning go only in the colsole
 */
@Override
public void log(Kind msgKind, String message, String messageGroup) {

    // some error message should go to the eclipse error view
    switch (msgKind) {
    case DevWARNING:
        if(messageGroup ==  null || !messageGroup.isEmpty())
            Activator.getDefault().getLog().log(new Status(IStatus.WARNING, messageGroup, IStatus.WARNING, message != null ? message : "<null>",null));
        break;
    case DevERROR:
        if(messageGroup ==  null || !messageGroup.isEmpty())
            Activator.getDefault().getLog().log(new Status(IStatus.ERROR, messageGroup, IStatus.ERROR, message != null ? message : "<null>",null));
        break;
    default:
        break;
    }

    if(ConsoleLogLevel.isLevelEnoughToLog(ConsoleLogLevel.kind2Level(msgKind), getConsoleLogLevel())){
        getConsoleIO().print(getConsoleMessageFor(msgKind,message));
    }
}
项目:neoscada    文件:PortValidator.java   
@Override
public IStatus validate ( final Object value )
{
    if ( ! ( value instanceof Number ) )
    {
        return new Status ( IStatus.ERROR, Activator.PLUGIN_ID, "Value must be a number" );
    }

    final int port = ( (Number)value ).intValue ();

    if ( port < MIN || port > MAX )
    {
        return new Status ( IStatus.ERROR, Activator.PLUGIN_ID, String.format ( "Port number must be between %s and %s (inclusive)", MIN, MAX ) );
    }

    if ( port < 1024 && isUnix () )
    {
        return new Status ( IStatus.WARNING, Activator.PLUGIN_ID, String.format ( "Port numbers below 1024 are reserved for privileged users (root) and may not be available for use." ) );
    }

    return Status.OK_STATUS;
}
项目:EclipseMinifyBuilder    文件:PrefsAccess.java   
/**
 * Remove a resource (i.e. all its properties) from the builder's preferences.
 * 
 * @param prefs the preferences
 * @param resource the resource
 * @throws BackingStoreException
 */
public static void removeResource(Preferences prefs, IResource resource) 
        throws CoreException {
    try {
        String[] keys = prefs.keys();
        for (String key: keys) {
            if (key.endsWith("//" + resource.getProjectRelativePath().toPortableString())) {
                prefs.remove(key);
            }
        }
        prefs.flush();
    } catch (BackingStoreException e) {
        throw new CoreException(new Status(
                IStatus.ERROR, MinifyBuilder.BUILDER_ID, e.getMessage(), e));
    }
}
项目:gemoc-studio-modeldebugging    文件:AbstractDebugAsAction.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.sirius.tools.api.ui.IExternalJavaAction#execute(java.util.Collection, java.util.Map)
 */
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
    final ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager()
            .getLaunchConfigurationType(getLaunchConfigurationTypeID());
    Set<String> modes = new HashSet<String>();
    modes.add("debug");
    try {
        ILaunchDelegate[] delegates = launchConfigType.getDelegates(modes);
        if (delegates.length != 0
                && delegates[0].getDelegate() instanceof AbstractDSLLaunchConfigurationDelegateUI) {
            AbstractDSLLaunchConfigurationDelegateUI delegate = (AbstractDSLLaunchConfigurationDelegateUI)delegates[0]
                    .getDelegate();
            delegate.launch(delegate.getLaunchableResource(PlatformUI.getWorkbench()
                    .getActiveWorkbenchWindow().getActivePage().getActiveEditor()),
                    getFirstInstruction(selections), "debug");
        }
    } catch (CoreException e) {
        DebugSiriusIdeUiPlugin.getPlugin().getLog().log(
                new Status(IStatus.ERROR, DebugSiriusIdeUiPlugin.ID, e.getLocalizedMessage(), e));
    }
}
项目:gw4e.project    文件:TestConvertor.java   
public void apply() throws CoreException {
    Job job = new WorkspaceJob("GW4E Conversion Job") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            try {
                _apply(monitor);
            } catch (Exception e) {
                DialogManager.displayErrorMessage(MessageUtil.getString("project_conversion"), MessageUtil.getString("an_error_has_occured_while_configuring_the_project"), e);
                ResourceManager.logException(e);
            }
            return Status.OK_STATUS;
        }
    };
    job.setRule(testInterface.getJavaProject().getProject());
    job.setUser(true);
    job.schedule();
}
项目:camel-language-server    文件:CamelLSPStreamConnectionProvider.java   
private static String computeCamelLanguageServerJarPath() {
    String camelLanguageServerJarPath = "";
    Bundle bundle = Platform.getBundle(ActivatorCamelLspClient.ID);
    URL fileURL = bundle.findEntries("/libs", "camel-lsp-server-*.jar", false).nextElement();
    try {
        File file = new File(FileLocator.resolve(fileURL).toURI());
        if(Platform.OS_WIN32.equals(Platform.getOS())) {
            camelLanguageServerJarPath = "\"" + file.getAbsolutePath() + "\"";
        } else {
            camelLanguageServerJarPath = file.getAbsolutePath();
        }
    } catch (URISyntaxException | IOException exception) {
        ActivatorCamelLspClient.getInstance().getLog().log(new Status(IStatus.ERROR, ActivatorCamelLspClient.ID, "Cannot get the Camel LSP Server jar.", exception)); //$NON-NLS-1$
    }
    return camelLanguageServerJarPath;
}
项目:gemoc-studio-modeldebugging    文件:AbstractGemocAnimatorServices.java   
/**Refreshes given {@link DRepresentation} in the given {@link TransactionalEditingDomain}.
 * @param transactionalEditingDomain the {@link TransactionalEditingDomain}
 * @param representations the {@link List} of {@link DRepresentation} to refresh
 */
public void refreshRepresentations(
        final TransactionalEditingDomain transactionalEditingDomain,
        final List<DRepresentation> representations) {
    // TODO prevent the editors from getting dirty
    if (representations.size() != 0) {
        final RefreshRepresentationsCommand refresh = new RefreshRepresentationsCommand(
                transactionalEditingDomain,
                new NullProgressMonitor(),
                representations);
        try {
            CommandExecution.execute(transactionalEditingDomain, refresh);
        } catch (Exception e){
            String repString = representations.stream().map(r -> r.getName()).collect(Collectors.joining(", "));
            Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Failed to refresh Sirius representation(s)["+repString+"], we hope to be able to do it later", e));
        }

    }
}
项目:scanning    文件:StatusQueueView.java   
private void rerun(StatusBean bean) {

        try {
            final DateFormat format = DateFormat.getDateTimeInstance();
            boolean ok = MessageDialog.openQuestion(getViewSite().getShell(), "Confirm resubmission "+bean.getName(),
                      "Are you sure you want to rerun "+bean.getName()+" submitted on "+format.format(new Date(bean.getSubmissionTime()))+"?");

            if (!ok) return;

            final StatusBean copy = bean.getClass().newInstance();
            copy.merge(bean);
            copy.setUniqueId(UUID.randomUUID().toString());
            copy.setMessage("Rerun of "+bean.getName());
            copy.setStatus(org.eclipse.scanning.api.event.status.Status.SUBMITTED);
            copy.setPercentComplete(0.0);
            copy.setSubmissionTime(System.currentTimeMillis());

            queueConnection.submit(copy, true);

            reconnect();

        } catch (Exception e) {
            ErrorDialog.openError(getViewSite().getShell(), "Cannot rerun "+bean.getName(), "Cannot rerun "+bean.getName()+"\n\nPlease contact your support representative.",
                    new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()));
        }
    }
项目:gemoc-studio    文件:AbstractExampleWizard.java   
public boolean performFinish() {
    final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();

    WorkspaceJob job = new WorkspaceJob("Unzipping Projects") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            monitor.beginTask("Unzipping Projects", projectDescriptors.size());
            //System.out.println("Unzipping projects...");
            for ( ProjectDescriptor desc : projectDescriptors ) {
                unzipProject(desc, monitor);
                monitor.worked(1);
            }
            //System.out.println("Projects unzipped");
            return Status.OK_STATUS;
        }
    };
    job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.schedule();
    return true;
}
项目:Hydrograph    文件:DataViewerListeners.java   
private void executeJumpPageJob(String statusMessage, final Long pageNumberToJump) {
    Job job = new Job(statusMessage) {
        @Override
        protected IStatus run(IProgressMonitor monitor) {

            final StatusMessage status = dataViewerAdapter.jumpToPage(pageNumberToJump);
            dataViewLoader.updateDataViewLists();

            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    refreshDataViewerWindow(status);
                    DataViewerUtility.INSTANCE.resetSort(debugDataViewer);
                    debugDataViewer.redrawTableCursor();
                }
            });
            return Status.OK_STATUS;
        }

    };
    job.schedule();
}
项目:java-debug    文件:ResolveClasspathsHandler.java   
/**
 * Accord to the project name and the main class, compute runtime classpath.
 *
 * @param mainClass
 *            fully qualified class name
 * @param projectName
 *            project name
 * @return class path
 * @throws CoreException
 *             CoreException
 */
private static String[][] computeClassPath(String mainClass, String projectName) throws CoreException {
    IJavaProject project = null;
    // if type exists in multiple projects, debug configuration need provide
    // project name.
    if (projectName != null) {
        project = getJavaProjectFromName(projectName);
    } else {
        List<IJavaProject> projects = getJavaProjectFromType(mainClass);
        if (projects.size() == 0) {
            throw new CoreException(new Status(IStatus.ERROR, JavaDebuggerServerPlugin.PLUGIN_ID,
                    String.format("Main class '%s' doesn't exist in the workspace.", mainClass)));
        }
        if (projects.size() > 1) {
            throw new CoreException(new Status(IStatus.ERROR, JavaDebuggerServerPlugin.PLUGIN_ID,
                    String.format(
                            "Main class '%s' isn't unique in the workspace, please pass in specified projectname.",
                            mainClass)));
        }
        project = projects.get(0);
    }
    return computeClassPath(project);
}
项目:gw4e.project    文件:UITask.java   
/**
 * @param jobname
 * @param tasks
 * @return
 */
public static Job createJob(String jobname, List<UITask.Task> tasks) {
    Job job = new Job(jobname) {
        @Override
        protected IStatus run(IProgressMonitor monitor) {
            SubMonitor subMonitor = SubMonitor.convert(monitor, tasks.size());
            for (UITask.Task task : tasks) {
                try {
                    subMonitor.setTaskName(task.getSummary());
                    workOnTask(task, subMonitor.split(1));
                } catch (Exception e) {
                    return Status.CANCEL_STATUS;
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.setUser(true);
    return job;
}
项目:Hydrograph    文件:DebugDataViewer.java   
public void submitRecordCountJob() {
    Job job = new Job(Messages.FETCHING_TOTAL_NUMBER_OF_RECORDS) {
        @Override
        protected IStatus run(IProgressMonitor monitor) {

            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    statusManager.getStatusLineManager().getProgressMonitor().beginTask(Messages.FETCHING_TOTAL_NUMBER_OF_RECORDS, IProgressMonitor.UNKNOWN);
                }
            });

            final StatusMessage status = dataViewerAdapter.fetchRowCount();

            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    statusManager.getStatusLineManager().getProgressMonitor().done();
                    statusManager.setStatus(status);
                    statusManager.enableJumpPagePanel(true);
                    actionFactory.getAction(ResetSortAction.class.getName()).setEnabled(false);
                    actionFactory.getAction(ClearFilterAction.class.getName()).setEnabled(false);
                }
            });
            return Status.OK_STATUS;
        }
    };

    job.schedule();
}
项目:pgcodekeeper    文件:UsageReporter.java   
@Override
protected IStatus run(IProgressMonitor monitor) {
    if (monitor.isCanceled()) {
        return Status.CANCEL_STATUS;
    }
    monitor.beginTask(Messages.UsageReport_Querying_Enablement, 2);

    if (monitor.isCanceled()) {
        return Status.CANCEL_STATUS;
    }
    monitor.worked(1);
    try {
        lockToAskUser.lock();

        if (mainPrefs.getBoolean(USAGE_REPORT_PREF.ASK_USER_USAGEREPORT_ID)) {
            if (monitor.isCanceled()) {
                return Status.CANCEL_STATUS;
            }
            askUser();
        }
    } finally {
        lockToAskUser.unlock();
    }
    report();
    monitor.worked(2);
    monitor.done();

    return Status.OK_STATUS;
}
项目:n4js    文件:N4ExecutableExtensionFactory.java   
@Override
public final Object create() throws CoreException {
    try {
        final Class<?> clazz = getClassLoader().loadClass(clazzName);
        final Injector injector = getInjector();
        final Object result = injector.getInstance(clazz);
        if (result instanceof IExecutableExtension) {
            ((IExecutableExtension) result).setInitializationData(config, null, null);
        }
        return result;
    } catch (final Exception e) {
        throw new CoreException(new Status(ERROR, getBunleId(),
                nullToEmpty(e.getMessage()) + " ExtensionFactory: " + getClass().getName(), e));
    }
}
项目:n4js    文件:CustomElementSelectionDialog.java   
/**
 * Update the error state of the dialog.
 *
 * @param errorMessage
 *            The error message or null for no error
 */
protected void updateError(String errorMessage) {
    if (errorMessage != null) {
        updateStatus(new Status(IStatus.ERROR, N4JSActivator.ORG_ECLIPSE_N4JS_N4JS, errorMessage));
    } else {
        // Explicitly set empty message ok status here
        updateStatus(new Status(IStatus.OK, N4JSActivator.ORG_ECLIPSE_N4JS_N4JS, ""));
    }
}
项目:scanning    文件:DefaultResultsHandler.java   
@Override
public boolean open(StatusBean bean) throws Exception {
    try {
        final IWorkbenchPage page = Util.getPage();

        final File fdir = new File(Util.getSanitizedPath(bean.getRunDirectory()));
        if (!fdir.exists()){
            MessageDialog.openConfirm(getShell(), "Directory Not Found", "The directory '"+bean.getRunDirectory()+"' has been moved or deleted.\n\nPlease contact your support representative.");
            return false;
        }

        if (Util.isWindowsOS()) { // Open inside DAWN
            final String         dir  = fdir.getAbsolutePath();
            IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(dir+"/fred.html");
            final IEditorInput edInput = Util.getExternalFileStoreEditorInput(dir);
            page.openEditor(edInput, desc.getId());

        } else { // Linux cannot be relied on to open the browser on a directory.
            Util.browse(fdir);
        }
        return true;
    } catch (Exception e1) {
        ErrorDialog.openError(getShell(), "Internal Error", "Cannot open "+bean.getRunDirectory()+".\n\nPlease contact your support representative.",
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, e1.getMessage()));
        return false;
    }
}
项目:scanning    文件:PlottingController.java   
/**
 * Actions in addition to the standard plotting actions which
 * should be shown on the plot.
 *
 * @param site
 */
private void createActions(IViewSite site) {

    IActionBars bars = site.getActionBars();
    final List<IContributionManager> mans = Arrays.asList(bars.getToolBarManager(), bars.getMenuManager());

    final IAction configureAxes = new Action("Configure...", Activator.getImageDescriptor("icons/home-for-sale-sign-blue.png")) {

        @Override
        public void run() {

        try {
            IModelDialog<AxisConfiguration>  dialog = ServiceHolder.getInterfaceService().createModelDialog(site.getShell());
            dialog.setPreamble("Please define the axes and their ranges we will map within.");
            dialog.create();
            dialog.setSize(550,450); // As needed
            dialog.setText("Scan Area");
            dialog.setModel(getAxisConfiguration());
            int ok = dialog.open();
            if (ok==IModelDialog.OK) {
                AxisConfiguration conf = dialog.getModel();
                setAxisConfiguration(conf);
            }
        } catch (Exception ne) {
            ErrorDialog.openError(site.getShell(), "Error Showing Plot Configuration", "Please contact your support representative.", new Status(IStatus.ERROR, "org.eclipse.scanning.device.ui", ne.getMessage(), ne));
            logger.error("Cannot configure plot!", ne);
        }
    }
    };
    ViewUtil.addGroups("configure", mans, configureAxes);
}
项目:Hydrograph    文件:DataViewerListeners.java   
/**
 * 
 * Attach next page listener
 * 
 * @param button
 */
public void attachNextPageButtonListener(Button button) {
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            statusManager.setStatus(new StatusMessage(StatusConstants.PROGRESS, Messages.FETCHING_NEXT_PAGE));
            statusManager.setAllWindowControlsEnabled(false);

            Job job = new Job(Messages.FETCHING_NEXT_PAGE) {
                @Override
                protected IStatus run(IProgressMonitor monitor) {
                    final StatusMessage status = dataViewerAdapter.next();
                    dataViewLoader.updateDataViewLists();
                    Display.getDefault().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                            refreshDataViewerWindow(status);
                            statusManager.clearJumpToPageText();
                            DataViewerUtility.INSTANCE.resetSort(debugDataViewer);
                            debugDataViewer.redrawTableCursor();
                        }
                    });
                    return Status.OK_STATUS;
                }
            };

            job.schedule();
        }
    });
}
项目:n4js    文件:N4SchemeURIBasedStorage.java   
@Override
public InputStream getContents() throws CoreException {
    URIHandler handler = schemeHelper.createURIHandler(URIConverter.INSTANCE);
    try {
        return handler.createInputStream(getURI(), Collections.emptyMap());
    } catch (IOException e) {
        throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.n4js.ts.ui", "Cannot load "
                + getFullPath(), e));
    }
}
项目:OCCI-Studio    文件:OCCIDocumentProvider.java   
@Override
protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite)
        throws CoreException {
    try {
        //System.out.println("doSaveDocument ");
        ResourceSet resourceSet = createResourceSet();
        XtextResource xtextResource = (XtextResource) resourceSet.createResource(URI.createURI("temp.occi"));
        InputStream is = new ByteArrayInputStream(document.get().getBytes());
        xtextResource.load(is, Collections.EMPTY_MAP);
        is.close();
        URI uri = URI.createPlatformResourceURI(
                ((org.eclipse.ui.part.FileEditorInput) element).getFile().getFullPath().toString(), true);
        //resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
        //System.out.println("uriii "+uri);
        Resource xmiResource = resourceSet.getResource(uri, true);
        ((XMLResource) xmiResource).getDefaultSaveOptions().put(XMLResource.OPTION_URI_HANDLER,
                new URIHandlerImpl.PlatformSchemeAware());
        xmiResource.getContents().clear();
        xmiResource.getContents().addAll(xtextResource.getContents());
        // SUPER IMPORTANT to avoid to have references to temp.occi
        EcoreUtil.resolveAll(xmiResource);          
        xmiResource.save(Collections.EMPTY_MAP);
    } catch (IOException e) {
        throw new CoreException(
                new Status(IStatus.ERROR, "org.occiware.clouddesigner.occi.xtext.ui", "Failed to save", e));
    }
}
项目:incubator-netbeans    文件:SubmitTaskCommand.java   
@Override
public void execute() throws CoreException, IOException, MalformedURLException {

    LogUtils.logBugtrackingUsage(repositoryConnector.getConnectorKind(), "ISSUE_EDIT");

    MylynSubmitTaskJob job = new MylynSubmitTaskJob(taskDataManager, repositoryConnector, taskRepository,
            task, taskData, changedOldAttributes);
    if (submitJobListener != null) {
        job.addSubmitJobListener(submitJobListener);
    }

    Logger log = Logger.getLogger(this.getClass().getName());
    if(log.isLoggable(Level.FINE)) {
        log.log(
            Level.FINE, 
            "executing SubmitJobCommand for task with id {0}:{1} ", //NOI18N
            new Object[] { task.getTaskId(), taskRepository.getUrl() });
    }

    job.startJob(monitor);
    IStatus status = job.getStatus();
    rr = job.getResponse();
    submittedTask = Accessor.getInstance().toNbTask(job.getTask());
    if (status != null && status != Status.OK_STATUS) {
        log.log(Level.INFO, "Command failed with status: {0}", status); //NOI18N
        if (status.getException() instanceof CoreException) {
            throw (CoreException) status.getException();
        } else {
            throw new CoreException(status);
        }
    }
}
项目:AgentWorkbench    文件:P2OperationsHandler.java   
/**
 * Installs available updates from all repositories.
 *
 * @return the result status
 */
public IStatus installAvailableUpdates() {
    ProvisioningJob provisioningJob = this.getUpdateOperation().getProvisioningJob(this.getProgressMonitor());
    if (provisioningJob == null) {
        System.err.println("Trying to update from the Eclipse IDE? This won't work!");
        return Status.CANCEL_STATUS;
    }

    return provisioningJob.runModal(this.getProgressMonitor());
}
项目:gw4e.project    文件:SetNoCheckPoliciesForFileMarkerResolution.java   
@Override
public void run(IMarker marker) {
    Job job = new WorkspaceJob("GW4E Fix Job") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            fix(marker, monitor);
            return Status.OK_STATUS;
        }
    };
    job.setRule(marker.getResource().getProject());
    job.setUser(true);
    job.schedule();
}
项目:com.onpositive.prefeditor    文件:ViewerRefreshJob.java   
@Override
protected IStatus execute() {
    Display.getDefault().asyncExec(() -> {
        if (!viewer.getControl().isDisposed()) {
            viewer.refresh();
        }
    });
    return Status.OK_STATUS;
}
项目:OCCI-Studio    文件:ExamplesRegistry.java   
private static Image resolveImage(String pluginName, String path) {
    Bundle bundle = Platform.getBundle(pluginName);
    URL fileURL = bundle.getEntry(path);
    try {
        URL resolvedFileURL = FileLocator.toFileURL(fileURL);
        return ImageDescriptor.createFromURL(resolvedFileURL).createImage();
    } catch (IOException e) {
        Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
    }
    return null;
}
项目:Hydrograph    文件:DataViewerListeners.java   
/**
 * 
 * Attach Previous page listener.
 * 
 * @param button
 */
public void attachPreviousPageButtonListener(Button button) {
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {

            statusManager.setStatus(new StatusMessage(StatusConstants.PROGRESS, Messages.FETCHING_PREVIOUS_PAGE));
            statusManager.setAllWindowControlsEnabled(false);

            Job job = new Job(Messages.FETCHING_PREVIOUS_PAGE) {
                @Override
                protected IStatus run(IProgressMonitor monitor) {
                    final StatusMessage status = dataViewerAdapter.previous();

                    dataViewLoader.updateDataViewLists();

                    Display.getDefault().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                            refreshDataViewerWindow(status);
                            statusManager.clearJumpToPageText();
                            DataViewerUtility.INSTANCE.resetSort(debugDataViewer);
                            debugDataViewer.redrawTableCursor();
                        }                           
                    });
                    return Status.OK_STATUS;
                }
            };
            job.schedule();
        }
    });
}
项目:neoscada    文件:RealTimeListViewer.java   
public void loadFrom ( final IMemento memento )
{
    if ( memento == null )
    {
        return;
    }

    try
    {
        {
            this.initialColWidth = new LinkedList<Integer> ();
            final IMemento tableMemento = memento.getChild ( "tableCols" ); //$NON-NLS-1$
            if ( tableMemento != null )
            {
                int i = 0;
                Integer w;
                while ( ( w = tableMemento.getInteger ( "col_" + i ) ) != null ) //$NON-NLS-1$
                {
                    this.initialColWidth.add ( w );
                    i++;
                }
            }
        }

        for ( final IMemento child : memento.getChildren ( "item" ) ) //$NON-NLS-1$
        {
            final Item item = Item.loadFrom ( child );
            if ( item != null )
            {
                this.list.add ( item );
            }
        }
    }
    catch ( final Exception e )
    {
        Activator.getDefault ().getLog ().log ( new Status ( IStatus.ERROR, Activator.PLUGIN_ID, Messages.RealTimeListViewer_ErrorLoadingData, e ) );
    }
}
项目:scanning    文件:StatusQueueView.java   
protected void pauseJob() {

        for(StatusBean bean : getSelection()) {

            if (bean.getStatus().isFinal()) {
                MessageDialog.openInformation(getViewSite().getShell(), "Run '"+bean.getName()+"' inactive", "Run '"+bean.getName()+"' is inactive and cannot be paused.");
                continue;
            }

            try {
                if (bean.getStatus().isPaused()) {
                    bean.setStatus(org.eclipse.scanning.api.event.status.Status.REQUEST_RESUME);
                    bean.setMessage("Resume of "+bean.getName());
                } else {
                    bean.setStatus(org.eclipse.scanning.api.event.status.Status.REQUEST_PAUSE);
                    bean.setMessage("Pause of "+bean.getName());
                }

                IPublisher<StatusBean> terminate = service.createPublisher(getUri(), getTopicName());
                terminate.broadcast(bean);

            } catch (Exception e) {
                ErrorDialog.openError(getViewSite().getShell(), "Cannot pause "+bean.getName(), "Cannot pause "+bean.getName()+"\n\nPlease contact your support representative.",
                        new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()));
            }
        }
    }
项目:Equella    文件:ConvertJPFProjects.java   
protected void run()
{
    new Job("Convert JPF projects")
    {
        @Override
        protected IStatus run(IProgressMonitor monitor)
        {
            IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
            for( IProject project : projects )
            {
                if( project.isOpen() && !JPFProjectNature.hasNature(project)
                    && JPFProject.getManifest(project).exists() )
                {
                    IProjectDescription description;
                    try
                    {
                        description = project.getDescription();
                        JPFProjectNature.addNature(description);
                        project.setDescription(description, monitor);
                    }
                    catch( CoreException e )
                    {
                        JPFClasspathLog.logError(e);
                    }
                }
            }
            return Status.OK_STATUS;
        }
    }.schedule();
}
项目:vertigo-chroma-kspplugin    文件:PropertyUtils.java   
private void setValue(IProject project, String propertyValue) {
    /*
     * On fait l'action dans un job asynchrone pour éviter une ResourceException: The resource tree is locked for modifications
     */

    Job job = new Job("KspPreferenceSaving") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            IEclipsePreferences node = getProjectPluginNode(project);
            if (node == null) {
                LogUtils.info("Set " + propertyName + " : node null !");
                return Status.OK_STATUS;
            }
            if (VertigoStringUtils.isEmpty(propertyValue)) {
                node.remove(propertyName);
            } else {
                node.put(propertyName, propertyValue);
            }

            try {
                node.flush();
            } catch (BackingStoreException e) {
                ErrorUtils.handle(e);
            }
            return Status.OK_STATUS;
        }
    };

    job.setPriority(Job.SHORT);
    job.schedule();
}
项目:gemoc-studio-modeldebugging    文件:Activator.java   
public void start(BundleContext context) throws Exception {
    try {
        Class.forName("javafx.embed.swt.FXCanvas");
        super.start(context);
        plugin = this;
    } catch (ClassNotFoundException e) {
        ErrorDialog.openError(null,"State Graph Unavailable", "Please install JavaFX or use the Oracle JRE",
                new Status(IStatus.ERROR,PLUGIN_ID,"JavaFX is needed for the timeline to work"));
    }
}