Search in sources :

Example 11 with CreateObjectDialog

use of org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog in project netxms by netxms.

the class CreateAgentPolicyLogParser method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final CreateObjectDialog dlg = new CreateObjectDialog(targetPart.getSite().getShell(), Messages.get().CreateAgentPolicyConfig_AgentPolicy_Config);
    if (dlg.open() == Window.OK) {
        final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        new ConsoleJob(Messages.get().CreateAgentPolicyConfig_JobName, targetPart, Activator.PLUGIN_ID, null) {

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_AGENTPOLICY_LOGPARSER, dlg.getObjectName(), currentObject.getObjectId());
                session.createObject(cd);
            }

            @Override
            protected String getErrorMessage() {
                return Messages.get().CreateAgentPolicyConfig_JobError;
            }
        }.start();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateObjectDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 12 with CreateObjectDialog

use of org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog in project netxms by netxms.

the class CreateCondition method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CreateCondition_Condition);
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().CreateCondition_JobTitle, part, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_CONDITION, dlg.getObjectName(), parentId);
            session.createObject(cd);
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().CreateCondition_JobError, dlg.getObjectName());
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateObjectDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 13 with CreateObjectDialog

use of org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog in project netxms by netxms.

the class CreateTemplate method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CreateTemplate_Template);
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().CreateTemplate_JobTitle, part, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_TEMPLATE, dlg.getObjectName(), parentId);
            session.createObject(cd);
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().CreateTemplate_JobError, dlg.getObjectName());
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateObjectDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 14 with CreateObjectDialog

use of org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog in project netxms by netxms.

the class CreateContainer method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CreateContainer_Container);
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().CreateContainer_JobTitle, part, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_CONTAINER, dlg.getObjectName(), parentId);
            session.createObject(cd);
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().CreateContainer_JobError, dlg.getObjectName());
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateObjectDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 15 with CreateObjectDialog

use of org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog 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();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateObjectDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) ObjectToolDetails(org.netxms.client.objecttools.ObjectToolDetails) PartInitException(org.eclipse.ui.PartInitException) ObjectTool(org.netxms.client.objecttools.ObjectTool)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)16 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)16 CreateObjectDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog)16 NXCObjectCreationData (org.netxms.client.NXCObjectCreationData)15 NXCSession (org.netxms.client.NXCSession)15 NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 PartInitException (org.eclipse.ui.PartInitException)1 ObjectTool (org.netxms.client.objecttools.ObjectTool)1 ObjectToolDetails (org.netxms.client.objecttools.ObjectToolDetails)1