use of org.netxms.client.objecttools.ObjectToolDetails in project netxms by netxms.
the class ObjectToolsEditor method createActions.
/**
* Create actions
*/
private void createActions() {
final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
actionShowFilter = new Action("Show filter", Action.AS_CHECK_BOX) {
@Override
public void run() {
enableFilter(!initShowFilter);
actionShowFilter.setChecked(initShowFilter);
}
};
actionShowFilter.setChecked(initShowFilter);
// $NON-NLS-1$
actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.objecttools.commands.showFilter");
handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), new ActionHandler(actionShowFilter));
actionRefresh = new RefreshAction() {
@Override
public void run() {
refreshToolList();
}
};
actionNew = new Action(Messages.get().ObjectToolsEditor_New) {
@Override
public void run() {
createTool();
}
};
actionNew.setImageDescriptor(SharedIcons.ADD_OBJECT);
actionEdit = new PropertyDialogAction(getSite(), viewer) {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final long toolId = ((ObjectTool) selection.getFirstElement()).getId();
// If there will be error, adapter factory will show error message to user
if (Platform.getAdapterManager().getAdapter(selection.getFirstElement(), ObjectToolDetails.class) == null)
return;
super.run();
ObjectToolDetails details = ObjectToolsAdapterFactory.getDetailsFromCache(toolId);
if ((details != null) && details.isModified()) {
saveObjectTool(details);
}
}
};
actionEdit.setImageDescriptor(SharedIcons.EDIT);
actionDelete = new Action(Messages.get().ObjectToolsEditor_Delete) {
@Override
public void run() {
deleteTools();
}
};
actionDelete.setImageDescriptor(SharedIcons.DELETE_OBJECT);
actionDisable = new Action(Messages.get().ObjectToolsEditor_Disable) {
@Override
public void run() {
setSelectedDisabled();
}
};
actionEnable = new Action(Messages.get().ObjectToolsEditor_Enable) {
@Override
public void run() {
setSelectedEnabled();
}
};
actionClone = new Action(Messages.get().ObjectToolsEditor_Clone) {
@Override
public void run() {
cloneTool();
}
};
}
use of org.netxms.client.objecttools.ObjectToolDetails in project netxms by netxms.
the class ObjectToolsEditor method createTool.
/**
* Create new tool
*/
private void createTool() {
final CreateNewToolDialog dlg = new CreateNewToolDialog(getSite().getShell());
if (dlg.open() == Window.OK) {
new ConsoleJob(Messages.get().ObjectToolsEditor_JobNewId, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final long toolId = session.generateObjectToolId();
final ObjectToolDetails details = new ObjectToolDetails(toolId, dlg.getType(), dlg.getName());
session.modifyObjectTool(details);
runInUIThread(new Runnable() {
@Override
public void run() {
PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, details);
dlg.open();
if (details.isModified())
saveObjectTool(details);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get(getDisplay()).ObjectToolsEditor_JobNewIdError;
}
}.start();
}
}
use of org.netxms.client.objecttools.ObjectToolDetails 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