use of org.netxms.client.objecttools.ObjectTool in project netxms by netxms.
the class ObjectToolsAdapterFactory method getAdapter.
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject.getClass() != ObjectTool.class)
return null;
// Adapt to tool details
if (adapterType == ObjectToolDetails.class) {
final long toolId = ((ObjectTool) adaptableObject).getId();
ObjectToolDetails details = cache.get(toolId);
if (details == null) {
ToolDetailLoader job = new ToolDetailLoader(toolId, PlatformUI.getWorkbench().getDisplay());
IProgressService service = PlatformUI.getWorkbench().getProgressService();
try {
service.busyCursorWhile(job);
details = job.getResult();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return details;
}
// Adapt to IWorkbenchAdapter
if (adapterType == IWorkbenchAdapter.class) {
return new IWorkbenchAdapter() {
@Override
public Object getParent(Object o) {
return null;
}
@Override
public String getLabel(Object o) {
return ((ObjectTool) o).getDisplayName();
}
@Override
public ImageDescriptor getImageDescriptor(Object object) {
return null;
}
@Override
public Object[] getChildren(Object o) {
return null;
}
};
}
return null;
}
use of org.netxms.client.objecttools.ObjectTool in project netxms by netxms.
the class ObjectToolsEditor method setSelectedDisabled.
private void setSelectedDisabled() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
if (!MessageDialogHelper.openConfirm(getSite().getShell(), Messages.get().ObjectToolsEditor_Confirmation, Messages.get().ObjectToolsEditor_AckToDisableObjectTool))
return;
final Object[] objects = selection.toArray();
new ConsoleJob(Messages.get(viewer.getControl().getDisplay()).ObjectToolsEditor_DisableObjTool, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected String getErrorMessage() {
return Messages.get(getDisplay()).ObjectToolsEditor_ErrorDisablingObjectTools;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (int i = 0; i < objects.length; i++) {
if ((((ObjectTool) objects[i]).getFlags() & ObjectTool.DISABLED) == 0)
session.changeObjecToolDisableStatuss(((ObjectTool) objects[i]).getId(), false);
}
}
}.start();
}
use of org.netxms.client.objecttools.ObjectTool in project netxms by netxms.
the class ObjectToolsEditor method refreshToolList.
/**
* Refresh tool list
*/
private void refreshToolList() {
new ConsoleJob(Messages.get(viewer.getControl().getDisplay()).ObjectToolsEditor_JobGetConfig, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID, viewer.getControl().getDisplay()) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<ObjectTool> tl = session.getObjectTools();
runInUIThread(new Runnable() {
@Override
public void run() {
tools.clear();
for (ObjectTool t : tl) tools.put(t.getId(), t);
viewer.setInput(tools.values().toArray());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get(getDisplay()).ObjectToolsEditor_JobGetConfigError;
}
}.start();
}
use of org.netxms.client.objecttools.ObjectTool in project netxms by netxms.
the class ObjectToolsEditor method cloneTool.
/**
* Clone object tool
*/
private void cloneTool() {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
final CreateObjectDialog dlg = new CreateObjectDialog(getSite().getShell(), "Object tool");
if (dlg.open() == Window.OK) {
new ConsoleJob("Clone object tool", this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final long toolId = session.generateObjectToolId();
ObjectTool objTool = (ObjectTool) selection.toArray()[0];
ObjectToolDetails details = session.getObjectToolDetails(objTool.getId());
details.setId(toolId);
details.setName(dlg.getObjectName());
session.modifyObjectTool(details);
}
@Override
protected String getErrorMessage() {
return "Cannot clone object tool";
}
}.start();
}
}
Aggregations