use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class MapObjectFilter method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
final String filter = filterSource.getText();
if (initialFilter.equals(filter) && (checkboxEnableFilter.getSelection() == initialEnable))
// Nothing to apply
return;
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setFilter(filter);
md.setObjectFlags(checkboxEnableFilter.getSelection() ? NetworkMap.MF_FILTER_OBJECTS : 0, NetworkMap.MF_FILTER_OBJECTS);
new ConsoleJob(Messages.get().MapObjectFilter_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
initialFilter = filter;
initialEnable = checkboxEnableFilter.getSelection();
MapObjectFilter.this.setValid(true);
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().MapObjectFilter_JobError;
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class AbstractNetworkMapView method openLinkDci.
/**
* Handler for opening network map dci on double click
*/
private void openLinkDci() {
final NetworkMapLink link = (NetworkMapLink) currentSelection.getFirstElement();
if (!link.hasDciData())
return;
new ConsoleJob("Open link dci job", this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#runInternal(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
DciValue[] values = session.getLastValues(link.getDciAsList());
final StringBuilder sb = new StringBuilder();
for (DciValue v : values) {
sb.append("&");
sb.append(Integer.toString(v instanceof SimpleDciValue ? ChartDciConfig.ITEM : ChartDciConfig.TABLE));
sb.append("@");
sb.append(Long.toString(v.getNodeId()));
sb.append("@");
sb.append(Long.toString(v.getId()));
sb.append("@");
sb.append(URLEncoder.encode(v.getDescription(), "UTF-8"));
sb.append("@");
sb.append(URLEncoder.encode(v.getName(), "UTF-8"));
}
runInUIThread(new Runnable() {
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
try {
getSite().getPage().showView(HistoricalGraphView.ID, sb.toString(), IWorkbenchPage.VIEW_ACTIVATE);
} catch (PartInitException e) {
MessageDialogHelper.openError(getSite().getShell(), "Error", String.format("Error opening view: %s", e.getLocalizedMessage()));
}
}
});
}
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#getErrorMessage()
*/
@Override
protected String getErrorMessage() {
return "Cannot open dci link historical graph view";
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class PredefinedMap method init.
/*
* (non-Javadoc)
*
* @see
* org.netxms.ui.eclipse.networkmaps.views.NetworkMap#init(org.eclipse.ui
* .IViewSite)
*/
@Override
public void init(IViewSite site) throws PartInitException {
super.init(site);
mapObject = (NetworkMap) rootObject;
setPartName(rootObject.getObjectName());
ConsoleJob job = new ConsoleJob("Get map effective rights", this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
readOnly = ((mapObject.getEffectiveRights() & UserAccessRights.OBJECT_ACCESS_MODIFY) == 0);
}
@Override
protected String getErrorMessage() {
return "Cannot get effective rights for map";
}
};
job.start();
// FIXME: rewrite waiting
try {
job.join();
} catch (InterruptedException e) {
}
allowManualLayout = !readOnly;
if (mapObject.getLayout() == MapLayoutAlgorithm.MANUAL) {
automaticLayoutEnabled = false;
} else {
automaticLayoutEnabled = true;
layoutAlgorithm = mapObject.getLayout();
}
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class SelectScriptDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
dialogArea.setLayout(layout);
new Label(dialogArea, SWT.NONE).setText(Messages.get().SelectScriptDialog_AvailableScripts);
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | (multiSelection ? SWT.MULTI : 0));
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((Script) element).getName();
}
});
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
Script s1 = (Script) e1;
Script s2 = (Script) e2;
return s1.getName().compareToIgnoreCase(s2.getName());
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
SelectScriptDialog.this.okPressed();
}
});
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 300;
gd.widthHint = 400;
viewer.getControl().setLayoutData(gd);
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SelectScriptDialog_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<Script> scripts = session.getScriptLibrary();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(scripts.toArray());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().SelectScriptDialog_JobError;
}
}.start();
return dialogArea;
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ScriptExecutor method intermediateSave.
/**
* Update script
*/
public void intermediateSave(boolean saveOnSelectionChange) {
final Script s = library.get(saveOnSelectionChange ? previousSelection : scriptCombo.getSelectionIndex());
final String scriptSource = scriptEditor.getText();
new ConsoleJob(Messages.get().ScriptExecutor_JobName_Update, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyScript(s.getId(), s.getName(), scriptSource);
runInUIThread(new Runnable() {
@Override
public void run() {
clearDirtyFlags();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ScriptExecutor_JobError_Update;
}
}.start();
}
Aggregations