use of org.netxms.ui.eclipse.objects.ObjectWrapper in project netxms by netxms.
the class SummaryTableWidget method showObjectDetails.
/**
* Show details for selected object
*/
private void showObjectDetails() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
AbstractObject object = ((ObjectWrapper) selection.getFirstElement()).getObject();
if (object != null) {
try {
TabbedObjectView view = (TabbedObjectView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(TabbedObjectView.ID);
view.setObject(object);
} catch (PartInitException e) {
MessageDialogHelper.openError(getShell(), Messages.get().SummaryTableWidget_Error, String.format(Messages.get().SummaryTableWidget_CannotOpenObjectDetails, e.getLocalizedMessage()));
}
}
}
use of org.netxms.ui.eclipse.objects.ObjectWrapper in project netxms by netxms.
the class ObjectToolsDynamicMenu method buildNodeSet.
/**
* Build node set from selection
*
* @param selection
* @return
*/
private Set<ObjectContext> buildNodeSet(IStructuredSelection selection) {
final Set<ObjectContext> nodes = new HashSet<ObjectContext>();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
for (Object o : selection.toList()) {
if (o instanceof AbstractNode) {
nodes.add(new ObjectContext((AbstractNode) o, null));
} else if ((o instanceof Container) || (o instanceof ServiceRoot) || (o instanceof Subnet) || (o instanceof Cluster)) {
for (AbstractObject n : ((AbstractObject) o).getAllChilds(AbstractObject.OBJECT_NODE)) nodes.add(new ObjectContext((AbstractNode) n, null));
} else if (o instanceof Alarm) {
AbstractNode n = (AbstractNode) session.findObjectById(((Alarm) o).getSourceObjectId(), AbstractNode.class);
if (n != null)
nodes.add(new ObjectContext(n, (Alarm) o));
} else if (o instanceof ObjectWrapper) {
AbstractObject n = ((ObjectWrapper) o).getObject();
if ((n != null) && (n instanceof AbstractNode))
nodes.add(new ObjectContext((AbstractNode) n, null));
}
}
return nodes;
}
use of org.netxms.ui.eclipse.objects.ObjectWrapper 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.ui.eclipse.objects.ObjectWrapper 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;
}
Aggregations