Search in sources :

Example 1 with CreateNewToolDialog

use of org.netxms.ui.eclipse.objecttools.dialogs.CreateNewToolDialog in project netxms by netxms.

the class ObjectToolsEditor method createTool.

/**
 * Create new tool
 */
private void createTool() {
    final CreateNewToolDialog dlg = new CreateNewToolDialog(getSite().getShell());
    if (dlg.open() == Window.OK) {
        new ConsoleJob(Messages.get().ObjectToolsEditor_JobNewId, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                final long toolId = session.generateObjectToolId();
                final ObjectToolDetails details = new ObjectToolDetails(toolId, dlg.getType(), dlg.getName());
                session.modifyObjectTool(details);
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, details);
                        dlg.open();
                        if (details.isModified())
                            saveObjectTool(details);
                    }
                });
            }

            @Override
            protected String getErrorMessage() {
                return Messages.get(getDisplay()).ObjectToolsEditor_JobNewIdError;
            }
        }.start();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) PropertyDialog(org.eclipse.ui.internal.dialogs.PropertyDialog) CreateNewToolDialog(org.netxms.ui.eclipse.objecttools.dialogs.CreateNewToolDialog) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) ObjectToolDetails(org.netxms.client.objecttools.ObjectToolDetails) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 PartInitException (org.eclipse.ui.PartInitException)1 PropertyDialog (org.eclipse.ui.internal.dialogs.PropertyDialog)1 ObjectToolDetails (org.netxms.client.objecttools.ObjectToolDetails)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 CreateNewToolDialog (org.netxms.ui.eclipse.objecttools.dialogs.CreateNewToolDialog)1