/** * Return the finished String for a job. * * @param job * the completed Job * @param withTime * @return String */ String getJobInfoFinishedString(Job job, boolean withTime) { String time = null; if (withTime) { time = getTimeString(); } if (time != null) { return NLS.bind(ProgressMessages.JobInfo_FinishedAt, job.getName(), time); } return NLS.bind(ProgressMessages.JobInfo_Finished, job.getName()); }
/** * Returns the progress for a monitor whose totalWork is * <code>IProgressMonitor.UNKNOWN</code>. * * @return String */ private String unknownProgress() { if (taskName == null) { return jobInfo.getJob().getName(); } String[] messageValues = new String[2]; messageValues[0] = jobInfo.getJob().getName(); messageValues[1] = taskName; return NLS.bind(ProgressMessages.JobInfo_UnknownProgress, messageValues); } }
/** * Print a debug message to the console. * Prepend the message with the current date, the name of the current thread and the current job if present. */ public static void debug(String message) { StringBuilder output = new StringBuilder(); output.append(new Date(System.currentTimeMillis())); output.append(" - ["); //$NON-NLS-1$ output.append(Thread.currentThread().getName()); output.append("] "); //$NON-NLS-1$ Job currentJob = Job.getJobManager().currentJob(); if (currentJob != null) { output.append(currentJob.getClass().getName()); output.append("("); //$NON-NLS-1$ output.append(currentJob.getName()); output.append("): "); //$NON-NLS-1$ } output.append(message); System.out.println(output.toString()); }
/** * Print a debug message to the console. * Prepend the message with the current date, the name of the current thread and the current job if present. */ public static void debug(String message) { StringBuilder output = new StringBuilder(); Job currentJob = Job.getJobManager().currentJob(); if (currentJob != null) { output.append(currentJob.getClass().getName()); output.append("("); //$NON-NLS-1$ output.append(currentJob.getName()); output.append("): "); //$NON-NLS-1$ } output.append(message); DEBUG_TRACE.trace(null, output.toString()); }
/** * Returns the display String without the task name. * * @param showProgress * Whether or not we are showing progress * * @return String */ String getDisplayStringWithoutTask(boolean showProgress) { if (!showProgress || totalWork == IProgressMonitor.UNKNOWN) { return jobInfo.getJob().getName(); } return NLS.bind(ProgressMessages.JobInfo_NoTaskNameDoneMessage, jobInfo.getJob().getName(), String.valueOf(getPercentDone())); }
/** * Print a debug message to the console. * Prepend the message with the current date, the name of the current thread and the current job if present. */ public static void debug(String message) { StringBuilder output = new StringBuilder(); output.append(new Date(System.currentTimeMillis())); output.append(" - ["); //$NON-NLS-1$ output.append(Thread.currentThread().getName()); output.append("] "); //$NON-NLS-1$ Job currentJob = Job.getJobManager().currentJob(); if (currentJob != null) { output.append(currentJob.getClass().getName()); output.append("("); //$NON-NLS-1$ output.append(currentJob.getName()); output.append("): "); //$NON-NLS-1$ } output.append(message); System.out.println(output.toString()); }
/** Waits for all the jobs to finish. */ public static void waitForJobsToFinish() { EclipseMisc.withService(IJobManager.class, jobManager -> { Job job; while ((job = jobManager.currentJob()) != null) { System.out.print(" waiting for " + job.getName() + " to finish... "); job.join(); System.out.println("complete."); } }); } }
@Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(job.getName()); shell.addTraverseListener(e -> { if (e.detail == SWT.TRAVERSE_ESCAPE) { cancelPressed(); e.detail = SWT.TRAVERSE_NONE; e.doit = true; } }); }
@Override String getDisplayString(boolean showProgress) { if (totalWork == IProgressMonitor.UNKNOWN) { return unknownProgress(); } if (taskName == null) { return getDisplayStringWithoutTask(showProgress); } if (showProgress) { String[] messageValues = new String[3]; messageValues[0] = String.valueOf(getPercentDone()); messageValues[1] = jobInfo.getJob().getName(); messageValues[2] = taskName; return NLS.bind(ProgressMessages.JobInfo_DoneMessage, messageValues); } String[] messageValues = new String[2]; messageValues[0] = jobInfo.getJob().getName(); messageValues[1] = taskName; return NLS.bind(ProgressMessages.JobInfo_DoneNoProgressMessage, messageValues); }
@Override String getCondensedDisplayString() { TaskInfo info = getTaskInfo(); if (info != null) { return info.getDisplayStringWithoutTask(true); } return getJob().getName(); }
String jobName = curJob.getName();
/** * Returns the display string based on the current status and the name of * the job. * * @param showProgress * a boolean to indicate if we should show progress or not. * * @return String */ private String getDisplayStringWithStatus(boolean showProgress) { if (isCanceled()) { return NLS.bind(ProgressMessages.JobInfo_Cancelled, (new Object[] { getJob().getName() })); } if (isBlocked()) { return NLS.bind(ProgressMessages.JobInfo_Blocked, (new Object[] { getJob().getName(), blockedStatus.getMessage() })); } if (getJob().getState() == Job.RUNNING) { TaskInfo info = getTaskInfo(); if (info == null) { return getJob().getName(); } return info.getDisplayString(showProgress); } if (getJob().getState() == Job.SLEEPING) { return NLS.bind(ProgressMessages.JobInfo_Sleeping, (new Object[] { getJob().getName() })); } return NLS.bind(ProgressMessages.JobInfo_Waiting, (new Object[] { getJob().getName() })); }
String name = job.getName();
protected void sendStatus() { if (client == null || preferenceManager == null || preferenceManager.getClientPreferences() == null || !preferenceManager.getClientPreferences().isProgressReportSupported()) { return; } ProgressReport progressReport = new ProgressReport(progressId); String task = StringUtils.defaultIfBlank(taskName, (job == null || StringUtils.isBlank(job.getName())) ? "Background task" : job.getName()); progressReport.setTask(task); progressReport.setSubTask(subTaskName); progressReport.setTotalWork(totalWork); progressReport.setWorkDone(progress); progressReport.setComplete(isDone()); progressReport.setStatus(formatMessage(task)); client.sendProgressReport(progressReport); }
@Override public String getColumnText(Object element, int columnIndex) { StatusAdapter statusAdapter = (StatusAdapter) element; String text = WorkbenchMessages.WorkbenchStatusDialog_ProblemOccurred; if (!isMulti()) { Job job = Adapters.adapt(statusAdapter, Job.class); if (job != null) { text = getPrimaryMessage(statusAdapter); } else { text = getSecondaryMessage(statusAdapter); } } else { Job job = Adapters.adapt(statusAdapter, Job.class); if (job != null) { text = job.getName(); } else { text = getPrimaryMessage(statusAdapter); } } Long timestamp = (Long) statusAdapter .getProperty(IStatusAdapterConstants.TIMESTAMP_PROPERTY); if (timestamp != null && isMulti()) { String date = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG) .format(new Date(timestamp.longValue())); return NLS.bind(ProgressMessages.JobInfo_Error, (new Object[] { text, date })); } return text; }
.bind( WorkbenchMessages.WorkbenchStatusDialog_ProblemOccurredInJob, job.getName());