Search in sources :

Example 1 with ConfigListElement

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SaveStoredConfigDialog(org.netxms.ui.eclipse.agentmanager.dialogs.SaveStoredConfigDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConfigListElement(org.netxms.client.agent.config.ConfigListElement) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with ConfigListElement

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConfigListElement(org.netxms.client.agent.config.ConfigListElement) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException)

Example 3 with ConfigListElement

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConfigListElement(org.netxms.client.agent.config.ConfigListElement) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException)

Example 4 with ConfigListElement

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConfigListElement(org.netxms.client.agent.config.ConfigListElement) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException)

Example 5 with ConfigListElement

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;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) ConfigListElement(org.netxms.client.agent.config.ConfigListElement) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Aggregations

ConfigListElement (org.netxms.client.agent.config.ConfigListElement)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 PartInitException (org.eclipse.ui.PartInitException)5 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 ArrayList (java.util.ArrayList)1 NXCPMessage (org.netxms.base.NXCPMessage)1 ConfigContent (org.netxms.client.agent.config.ConfigContent)1 AccessPoint (org.netxms.client.objects.AccessPoint)1 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)1 SaveStoredConfigDialog (org.netxms.ui.eclipse.agentmanager.dialogs.SaveStoredConfigDialog)1