Search in sources :

Example 1 with SaveStoredConfigDialog

use of org.netxms.ui.eclipse.agentmanager.dialogs.SaveStoredConfigDialog 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 SaveStoredConfigDialog

use of org.netxms.ui.eclipse.agentmanager.dialogs.SaveStoredConfigDialog in project netxms by netxms.

the class ServerStoredAgentConfigEditorView method promptToSaveOnClose.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.ui.ISaveablePart2#promptToSaveOnClose()
    */
@Override
public int promptToSaveOnClose() {
    SaveStoredConfigDialog dlg = new SaveStoredConfigDialog(getSite().getShell());
    int rc = dlg.open();
    modified = (rc != SaveStoredConfigDialog.SAVE_ID);
    return (rc == IDialogConstants.CANCEL_ID) ? CANCEL : ((rc == SaveConfigDialog.DISCARD_ID) ? NO : YES);
}
Also used : SaveStoredConfigDialog(org.netxms.ui.eclipse.agentmanager.dialogs.SaveStoredConfigDialog)

Aggregations

SaveStoredConfigDialog (org.netxms.ui.eclipse.agentmanager.dialogs.SaveStoredConfigDialog)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 PartInitException (org.eclipse.ui.PartInitException)1 ConfigListElement (org.netxms.client.agent.config.ConfigListElement)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1