use of org.netxms.client.NXCSession in project netxms by netxms.
the class ObjectBrowser method createContent.
/* (non-Javadoc)
* @see org.netxms.webui.mobile.pages.AbstractPage#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Composite createContent(Composite parent) {
viewer = new TableViewer(parent, SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ObjectListLabelProvider());
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return ((AbstractObject) e1).getObjectName().compareToIgnoreCase(((AbstractObject) e2).getObjectName());
}
});
viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
AbstractObject o = (AbstractObject) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
handleSelection(o);
}
});
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
viewer.setInput(session.findObjectById(rootObjectId).getChildsAsArray());
setTitle(session.getObjectName(rootObjectId));
return null;
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class Agent method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected boolean applyChanges(final boolean isApply) {
final NXCObjectModificationData md = new NXCObjectModificationData(node.getObjectId());
if (isApply)
setValid(false);
try {
md.setAgentPort(Integer.parseInt(agentPort.getText(), 10));
} catch (NumberFormatException e) {
MessageDialog.openWarning(getShell(), Messages.get().Communication_Warning, Messages.get().Communication_WarningInvalidAgentPort);
if (isApply)
setValid(true);
return false;
}
md.setAgentProxy(agentProxy.getObjectId());
md.setAgentAuthMethod(agentAuthMethod.getSelectionIndex());
md.setAgentSecret(agentSharedSecret.getText());
md.setAgentCompressionMode(collectAgentCompressionMode());
md.setObjectFlags(agentForceEncryption.getSelection() ? AbstractNode.NF_FORCE_ENCRYPTION : 0, AbstractNode.NF_FORCE_ENCRYPTION);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(String.format("Updating agent communication settings for node %s", node.getObjectName()), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return String.format("Cannot update communication settings for node %s", node.getObjectName());
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
Agent.this.setValid(true);
}
});
}
}
}.start();
return true;
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class ClusterNetworks method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if (!isModified)
// Nothing to apply
return;
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setNetworkList(networks);
new ConsoleJob(Messages.get().ClusterNetworks_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
isModified = false;
}
@Override
protected String getErrorMessage() {
return Messages.get().ClusterNetworks_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
ClusterNetworks.this.setValid(true);
}
});
}
}
}.start();
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class Location method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected boolean applyChanges(final boolean isApply) {
int type = GeoLocation.UNSET;
if (radioTypeManual.getSelection())
type = GeoLocation.MANUAL;
else if (radioTypeAuto.getSelection())
type = GeoLocation.GPS;
GeoLocation location;
if (type == GeoLocation.MANUAL) {
try {
location = GeoLocation.parseGeoLocation(latitude.getText(), longitude.getText());
} catch (GeoLocationFormatException e) {
MessageDialogHelper.openError(getShell(), Messages.get().Location_Error, Messages.get().Location_FormatError);
return false;
}
} else {
location = new GeoLocation(type == GeoLocation.GPS);
}
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setGeolocation(location);
md.setPostalAddress(new PostalAddress(country.getText().trim(), city.getText().trim(), streetAddress.getText().trim(), postcode.getText().trim()));
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(String.format(Messages.get().Location_JobName, object.getObjectName()), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return Messages.get().Location_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
Location.this.setValid(true);
}
});
}
}
}.start();
return true;
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class MapSeedNodes method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
if (object == null || !(object instanceof NetworkMap))
return dialogArea;
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
viewer = new TableViewer(dialogArea, SWT.BORDER);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new LabelProvider() {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(Object element) {
return ((AbstractObject) element).getObjectName();
}
});
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
seedNodes = new HashSet<AbstractObject>(session.findMultipleObjects(((NetworkMap) object).getSeedObjectIds(), false));
viewer.setInput(seedNodes);
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
buttons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gridData);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText("Add...");
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
addButton.addSelectionListener(new SelectionListener() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
dlg.enableMultiSelection(true);
if (dlg.open() == Window.OK) {
List<AbstractObject> selected = dlg.getSelectedObjects();
if (selected.size() > 0) {
seedNodes.addAll(selected);
viewer.setInput(seedNodes);
isModified = true;
}
}
}
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText("Delete");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
deleteButton.addSelectionListener(new SelectionListener() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() > 0) {
seedNodes.removeAll(selection.toList());
viewer.setInput(seedNodes);
isModified = true;
}
}
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
return dialogArea;
}
Aggregations