Search in sources :

Example 6 with ConfigListElement

use of org.netxms.client.agent.config.ConfigListElement in project netxms by netxms.

the class ServerStoredAgentConfigEditorView method createNewConfig.

/**
 * Creates new config that is sent to server on save
 */
private void createNewConfig() {
    modified = true;
    firePropertyChange(PROP_DIRTY);
    actionSave.setEnabled(true);
    ConfigListElement newElement = new ConfigListElement();
    elements.add(newElement);
    configList.setInput(elements.toArray(new ConfigListElement[elements.size()]));
    reselection = true;
    StructuredSelection selection = new StructuredSelection(newElement);
    previousSelection = selection;
    configList.setSelection(selection);
    content = new ConfigContent();
    updateContent();
}
Also used : ConfigContent(org.netxms.client.agent.config.ConfigContent) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConfigListElement(org.netxms.client.agent.config.ConfigListElement)

Example 7 with ConfigListElement

use of org.netxms.client.agent.config.ConfigListElement in project netxms by netxms.

the class ServerStoredAgentConfigEditorView method getConfigList.

/**
 * Gets config list from server and sets editable fields to nothing
 */
public void getConfigList() {
    IStructuredSelection selection = (IStructuredSelection) configList.getSelection();
    final ConfigListElement element = selection == null ? null : (ConfigListElement) selection.getFirstElement();
    new ConsoleJob(Messages.get().PackageManager_OpenDatabase, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            elements = session.getConfigList();
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    configList.setInput(elements.toArray(new ConfigListElement[elements.size()]));
                    if (element == null && elements.size() > 0) {
                        StructuredSelection selection = new StructuredSelection(elements.get(0));
                        configList.setSelection(selection);
                    }
                    if (element != null) {
                        long id = element.getId();
                        if (id == 0)
                            id = elements.get(elements.size() - 1).getId();
                        for (int i = 0; i < elements.size(); i++) {
                            if (elements.get(i).getId() == id) {
                                StructuredSelection selection = new StructuredSelection(elements.get(i));
                                configList.setSelection(selection);
                            }
                        }
                    }
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().ServerStoredAgentConfigEditorView_JobError_GetList;
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) 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)

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