use of org.netxms.client.agent.config.ConfigListElement in project netxms by netxms.
the class ServerStoredAgentConfigEditorView method onSelectionChange.
/**
* @param event
*/
private void onSelectionChange(SelectionChangedEvent event) {
if (reselection) {
reselection = false;
return;
}
if (modified) {
SaveStoredConfigDialog dlg = new SaveStoredConfigDialog(getSite().getShell());
int rc = dlg.open();
if (rc == SaveStoredConfigDialog.SAVE_ID) {
intermediateSave();
modified = false;
firePropertyChange(PROP_DIRTY);
actionSave.setEnabled(false);
return;
}
if (rc == SaveStoredConfigDialog.CANCEL) {
reselection = true;
configList.setSelection(previousSelection);
return;
}
}
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
previousSelection = selection;
if (selection == null)
return;
final ConfigListElement element = (ConfigListElement) selection.getFirstElement();
new ConsoleJob(Messages.get().ServerStoredAgentConfigEditorView_JobTitle_GetContent, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
if (element != null) {
content = session.getConfigContent(element.getId());
runInUIThread(new Runnable() {
@Override
public void run() {
updateContent();
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().ServerStoredAgentConfigEditorView_JobError_GetContent;
}
}.start();
}
use of org.netxms.client.agent.config.ConfigListElement in project netxms by netxms.
the class ServerStoredAgentConfigEditorView method moveDown.
/**
* Move selected item down
*/
private void moveDown() {
IStructuredSelection selection = (IStructuredSelection) configList.getSelection();
if (selection == null)
return;
final ConfigListElement element1 = (ConfigListElement) selection.getFirstElement();
int index = elements.indexOf(element1);
if (index >= (elements.size() - 1))
return;
final ConfigListElement elemen2 = elements.get(index + 1);
new ConsoleJob(Messages.get().ServerStoredAgentConfigEditorView_JobMoveDown, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.swapAgentConfigs(element1.getId(), elemen2.getId());
runInUIThread(new Runnable() {
@Override
public void run() {
getConfigList();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ServerStoredAgentConfigEditorView_JobError_MoveDown;
}
}.start();
}
use of org.netxms.client.agent.config.ConfigListElement in project netxms by netxms.
the class ServerStoredAgentConfigEditorView method moveUp.
/**
* Move selected item up
*/
private void moveUp() {
IStructuredSelection selection = (IStructuredSelection) configList.getSelection();
if (selection == null)
return;
final ConfigListElement element1 = (ConfigListElement) selection.getFirstElement();
int index = elements.indexOf(element1);
if (index <= 0)
return;
final ConfigListElement element2 = elements.get(index - 1);
new ConsoleJob(Messages.get().ServerStoredAgentConfigEditorView_JobMoveUp, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.swapAgentConfigs(element1.getId(), element2.getId());
runInUIThread(new Runnable() {
@Override
public void run() {
getConfigList();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ServerStoredAgentConfigEditorView_JobError_MoveUp;
}
}.start();
}
use of org.netxms.client.agent.config.ConfigListElement in project netxms by netxms.
the class ServerStoredAgentConfigEditorView method deleteConfig.
/**
* Delete selected configuration
*/
private void deleteConfig() {
IStructuredSelection selection = (IStructuredSelection) configList.getSelection();
if (selection == null)
return;
final ConfigListElement element = (ConfigListElement) selection.getFirstElement();
new ConsoleJob(Messages.get().ServerStoredAgentConfigEditorView_JobDelete, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.deleteAgentConfig(element.getId());
runInUIThread(new Runnable() {
@Override
public void run() {
elements.remove(element);
configList.setInput(elements.toArray(new ConfigListElement[elements.size()]));
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ServerStoredAgentConfigEditorView_JobError_Delete;
}
}.start();
}
use of org.netxms.client.agent.config.ConfigListElement in project netxms by netxms.
the class NXCSession method getConfigList.
/**
* Gets the list of configuration files.(Config id, name and sequence number)
*
* @return the list of configuration files in correct sequence
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<ConfigListElement> getConfigList() throws NXCException, IOException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_AGENT_CFG_LIST);
sendMessage(msg);
NXCPMessage response = waitForRCC(msg.getMessageId());
int size = response.getFieldAsInt32(NXCPCodes.VID_NUM_RECORDS);
List<ConfigListElement> elements = new ArrayList<ConfigListElement>(size);
long i, base;
for (i = 0, base = NXCPCodes.VID_AGENT_CFG_LIST_BASE; i < size; i++, base += 10) {
elements.add(new ConfigListElement(base, response));
}
Collections.sort(elements);
return elements;
}
Aggregations