Search in sources :

Example 6 with ServerVariable

use of org.netxms.client.server.ServerVariable in project netxms by netxms.

the class ServerConfigurationEditor method setDefaultValue.

/**
 * Reset variable values to default
 */
@SuppressWarnings("unchecked")
private void setDefaultValue() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    final List<ServerVariable> list = selection.toList();
    new ConsoleJob("Set default server config values", this, Activator.PLUGIN_ID, ServerConfigurationEditor.JOB_FAMILY) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.setDefaultServerValues(list);
            varList = session.getServerVariables();
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    synchronized (varList) {
                        viewer.setInput(varList.values().toArray());
                    }
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return "Error setting default server config values";
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) ServerVariable(org.netxms.client.server.ServerVariable) PartInitException(org.eclipse.ui.PartInitException)

Example 7 with ServerVariable

use of org.netxms.client.server.ServerVariable in project netxms by netxms.

the class ServerConfigurationEditor method editVariable.

/**
 * Edit currently selected variable
 * @param var
 */
private void editVariable() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if ((selection == null) || (selection.size() != 1))
        return;
    final ServerVariable var = (ServerVariable) selection.getFirstElement();
    final VariableEditDialog dlg = new VariableEditDialog(getSite().getShell(), var);
    if (dlg.open() == Window.OK) {
        new ConsoleJob(Messages.get().ServerConfigurationEditor_ModifyJobName, this, Activator.PLUGIN_ID, JOB_FAMILY) {

            @Override
            protected String getErrorMessage() {
                return Messages.get().ServerConfigurationEditor_ModifyJobError;
            }

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                session.setServerVariable(dlg.getVarName(), dlg.getVarValue());
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        refresh();
                    }
                });
            }
        }.start();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) VariableEditDialog(org.netxms.ui.eclipse.serverconfig.dialogs.VariableEditDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) ServerVariable(org.netxms.client.server.ServerVariable) PartInitException(org.eclipse.ui.PartInitException)

Example 8 with ServerVariable

use of org.netxms.client.server.ServerVariable in project netxms by netxms.

the class ServerConfigurationEditor method deleteVariables.

/**
 * Delete selected variables
 */
private void deleteVariables() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if ((selection == null) || (selection.size() == 0))
        return;
    if (!MessageDialogHelper.openQuestion(getSite().getShell(), Messages.get().ServerConfigurationEditor_DeleteConfirmation, Messages.get().ServerConfigurationEditor_DeleteConfirmationText))
        return;
    final List<String> names = new ArrayList<String>(selection.size());
    for (Object o : selection.toList()) {
        if (o instanceof ServerVariable)
            names.add(((ServerVariable) o).getName());
    }
    new ConsoleJob(Messages.get().ServerConfigurationEditor_DeleteJobName, this, Activator.PLUGIN_ID, ServerConfigurationEditor.JOB_FAMILY) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (String n : names) {
                session.deleteServerVariable(n);
            }
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    refresh();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().ServerConfigurationEditor_DeleteJobError;
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) ServerVariable(org.netxms.client.server.ServerVariable) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

ServerVariable (org.netxms.client.server.ServerVariable)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 PartInitException (org.eclipse.ui.PartInitException)3 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 NXCPMessage (org.netxms.base.NXCPMessage)2 List (java.util.List)1 NXCSession (org.netxms.client.NXCSession)1 AccessPoint (org.netxms.client.objects.AccessPoint)1 Zone (org.netxms.client.objects.Zone)1 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)1 VariableEditDialog (org.netxms.ui.eclipse.serverconfig.dialogs.VariableEditDialog)1