use of org.netxms.client.NXCSession in project netxms by netxms.
the class ScheduleMaintenance method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = window.getActivePage().getSelection();
if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
return null;
final MaintanenceScheduleDialog dialog = new MaintanenceScheduleDialog(window.getShell());
if (dialog.open() != Window.OK)
return null;
final Object[] objects = ((IStructuredSelection) selection).toArray();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SetObjectManagementState_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object o : objects) {
if (o instanceof AbstractObject) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ScheduledTask taskStart = new ScheduledTask("Maintenance.Enter", "", "", "", dialog.getStartDate(), ScheduledTask.SYSTEM, ((AbstractObject) o).getObjectId());
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ScheduledTask taskEnd = new ScheduledTask("Maintenance.Leave", "", "", "", dialog.getEndDate(), ScheduledTask.SYSTEM, ((AbstractObject) o).getObjectId());
session.addSchedule(taskStart);
session.addSchedule(taskEnd);
}
}
}
@Override
protected String getErrorMessage() {
return Messages.get().SetObjectManagementState_JobError;
}
}.start();
return null;
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class SetObjectManagementState method execute.
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = window.getActivePage().getSelection();
if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
return null;
final Object[] objects = ((IStructuredSelection) selection).toArray();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SetObjectManagementState_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object o : objects) {
if (o instanceof AbstractObject)
session.setObjectManaged(((AbstractObject) o).getObjectId(), managed);
else if (o instanceof ObjectWrapper)
session.setObjectManaged(((ObjectWrapper) o).getObjectId(), managed);
}
}
@Override
protected String getErrorMessage() {
return Messages.get().SetObjectManagementState_JobError;
}
}.start();
return null;
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class MultipleObjectAction method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@SuppressWarnings("unchecked")
@Override
public final void run(IAction action) {
if (selection == null)
return;
if (!confirm())
return;
Iterator<AbstractObject> it = selection.iterator();
while (it.hasNext()) {
final AbstractObject object = it.next();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(formatJobDescription(object), part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
runObjectAction(session, object);
}
@Override
protected String getErrorMessage() {
return formatErrorMessage(object, getDisplay());
}
}.start();
}
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class SetObjectMaintenanceState method execute.
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = window.getActivePage().getSelection();
if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
return null;
final Object[] objects = ((IStructuredSelection) selection).toArray();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SetObjectManagementState_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object o : objects) {
if (o instanceof AbstractObject)
session.setObjectMaintenance(((AbstractObject) o).getObjectId(), maintained);
else if (o instanceof ObjectWrapper)
session.setObjectMaintenance(((ObjectWrapper) o).getObjectId(), maintained);
}
}
@Override
protected String getErrorMessage() {
return Messages.get().SetObjectManagementState_JobError;
}
}.start();
return null;
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class ComponentsTab method objectChanged.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#objectChanged(org.netxms.client.objects.AbstractObject)
*/
@Override
public void objectChanged(final AbstractObject object) {
viewer.setInput(new Object[0]);
if (object == null)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
ConsoleJob job = new ConsoleJob(Messages.get().ComponentsTab_JobName, getViewPart(), Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
try {
final PhysicalComponent root = session.getNodePhysicalComponents(object.getObjectId());
runInUIThread(new Runnable() {
@Override
public void run() {
if (viewer.getTree().isDisposed())
return;
if ((ComponentsTab.this.getObject() != null) && (ComponentsTab.this.getObject().getObjectId() == object.getObjectId())) {
viewer.setInput(new Object[] { root });
viewer.expandAll();
}
}
});
} catch (NXCException e) {
if (e.getErrorCode() != RCC.NO_COMPONENT_DATA)
throw e;
runInUIThread(new Runnable() {
@Override
public void run() {
if (viewer.getTree().isDisposed())
return;
if ((ComponentsTab.this.getObject() != null) && (ComponentsTab.this.getObject().getObjectId() == object.getObjectId())) {
viewer.setInput(new Object[0]);
}
}
});
}
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().ComponentsTab_JobError, object.getObjectName());
}
};
job.setUser(false);
job.start();
}
Aggregations