2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2015 Victor Kirhenshtein
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 package org
.netxms
.ui
.eclipse
.jobs
;
21 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
22 import org
.eclipse
.core
.runtime
.IStatus
;
23 import org
.eclipse
.core
.runtime
.Status
;
24 import org
.eclipse
.ui
.IWorkbenchPart
;
25 import org
.netxms
.client
.NXCSession
;
26 import org
.netxms
.client
.server
.ServerJobIdUpdater
;
27 import org
.netxms
.ui
.eclipse
.console
.Activator
;
28 import org
.netxms
.ui
.eclipse
.shared
.ConsoleSharedData
;
31 * Tailored Job class for NetXMS console. Callers must call start() instead of schedule() for correct execution.
33 public abstract class ConsoleJobCallingServerJob
extends ConsoleJob
implements ServerJobIdUpdater
35 private NXCSession session
= null
;
36 private int serverJobId
= 0;
37 private boolean jobCanceled
= false
;
39 public ConsoleJobCallingServerJob(String name
, IWorkbenchPart wbPart
, String pluginId
, Object jobFamily
)
41 super(name
, wbPart
, pluginId
, jobFamily
);
42 session
= (NXCSession
)ConsoleSharedData
.getSession();
48 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
51 protected IStatus
run(IProgressMonitor monitor
)
57 status
= Status
.OK_STATUS
;
63 status
= Status
.CANCEL_STATUS
;
67 Activator
.logError("Exception in ConsoleJob", e
); //$NON-NLS-1$
69 status
= createFailureStatus(e
);
80 * @see org.eclipse.core.runtime.jobs.Job#canceling()
83 protected void canceling()
88 session
.cancelServerJob(serverJobId
);
92 Activator
.logError("Failed to cancel job", e
); //$NON-NLS-1$
97 public void setJobIdCallback(int id
)