use of org.netxms.client.NXCException in project netxms by netxms.
the class TableColumns method updateColumnsFromAgent.
/**
* Update columns from real table
*/
private void updateColumnsFromAgent(final String name, final boolean interactive, final AbstractObject queryObject) {
final NXCSession session = ConsoleSharedData.getSession();
ConsoleJob job = new ConsoleJob(Messages.get().TableColumns_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
try {
final org.netxms.client.Table table;
if (editor.getSourceNode() != 0) {
table = session.queryAgentTable(editor.getSourceNode(), name);
} else {
table = session.queryAgentTable((queryObject != null) ? queryObject.getObjectId() : dci.getNodeId(), name);
}
runInUIThread(new Runnable() {
@Override
public void run() {
columns.clear();
for (int i = 0; i < table.getColumnCount(); i++) {
ColumnDefinition c = new ColumnDefinition(table.getColumnName(i), table.getColumnDisplayName(i));
c.setDataType(table.getColumnDefinition(i).getDataType());
c.setInstanceColumn(table.getColumnDefinition(i).isInstanceColumn());
columns.add(c);
}
columnList.setInput(columns.toArray());
}
});
} catch (Exception e) {
Activator.logError("Cannot read table column definition from agent", e);
if (interactive) {
final String msg = (e instanceof NXCException) ? e.getLocalizedMessage() : "Internal error";
runInUIThread(new Runnable() {
@Override
public void run() {
MessageDialogHelper.openError(getShell(), "Error", String.format("Cannot read table column definition from agent (%s)", msg));
}
});
}
}
}
@Override
protected String getErrorMessage() {
return null;
}
};
job.setUser(false);
job.start();
}
use of org.netxms.client.NXCException in project netxms by netxms.
the class PackageManager method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
final String[] names = { Messages.get().PackageManager_ColumnID, Messages.get().PackageManager_ColumnName, Messages.get().PackageManager_ColumnVersion, Messages.get().PackageManager_ColumnPlatform, Messages.get().PackageManager_ColumnFile, Messages.get().PackageManager_ColumnDescription };
final int[] widths = { 70, 120, 90, 120, 150, 400 };
viewer = new SortableTableViewer(parent, names, widths, COLUMN_ID, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new PackageLabelProvider());
viewer.setComparator(new PackageComparator());
createActions();
contributeToActionBars();
createPopupMenu();
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
actionDeploy.setEnabled(selection.size() == 1);
actionRemove.setEnabled(selection.size() > 0);
}
});
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().PackageManager_OpenDatabase, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
try {
session.lockPackageDatabase();
} catch (NXCException e) {
// New versions may not require package DB lock
if (e.getErrorCode() != RCC.NOT_IMPLEMENTED)
throw e;
}
runInUIThread(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().PackageManager_OpenError;
}
}.start();
}
use of org.netxms.client.NXCException in project netxms by netxms.
the class AlarmLogViewer method fillContextMenu.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.logviewer.views.LogViewer#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
protected void fillContextMenu(final IMenuManager mgr) {
super.fillContextMenu(mgr);
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (// selection.size() == 0 && session.isHelpdeskLinkActive())
true) {
try {
Alarm alarm = session.getAlarm(Long.parseLong(((TableRow) selection.getFirstElement()).get(0).getValue()));
if (alarm.getHelpdeskState() == Alarm.HELPDESK_STATE_IGNORED)
mgr.add(actionCreateIssue);
else {
mgr.add(actionShowIssue);
if ((session.getUserSystemRights() & UserAccessRights.SYSTEM_ACCESS_UNLINK_ISSUES) != 0)
mgr.add(actionUnlinkIssue);
}
} catch (NumberFormatException | ArrayIndexOutOfBoundsException | IOException | NXCException e) {
Activator.logError("Error finding alarm", e);
}
}
}
use of org.netxms.client.NXCException in project netxms by netxms.
the class AgentFileManager method moveFile.
/**
* Move selected file
*/
private void moveFile(final AgentFile target, final AgentFile object) {
new ConsoleJob(Messages.get().AgentFileManager_MoveFile, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected String getErrorMessage() {
return Messages.get().AgentFileManager_MoveError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NestedVerifyOverwrite verify = new NestedVerifyOverwrite(object.getType(), object.getName(), true, true, false) {
@Override
public void executeAction() throws NXCException, IOException {
// $NON-NLS-1$
session.renameAgentFile(objectId, object.getFullName(), target.getFullName() + "/" + object.getName(), false);
}
@Override
public void executeSameFunctionWithOverwrite() throws IOException, NXCException {
// $NON-NLS-1$
session.renameAgentFile(objectId, object.getFullName(), target.getFullName() + "/" + object.getName(), true);
}
};
verify.run(viewer.getControl().getDisplay());
if (verify.isOkPressed()) {
target.setChildren(session.listAgentFiles(target, target.getFullName(), objectId));
object.getParent().setChildren(session.listAgentFiles(object.getParent(), object.getParent().getFullName(), objectId));
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.refresh(object.getParent(), true);
object.setParent(target);
viewer.refresh(object.getParent(), true);
}
});
}
}
}.start();
}
use of org.netxms.client.NXCException in project netxms by netxms.
the class AgentFileManager method createFolder.
/**
* Create new folder
*/
private void createFolder() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
final Object[] objects = selection.toArray();
final AgentFile parentFolder = ((AgentFile) objects[0]).isDirectory() ? ((AgentFile) objects[0]) : ((AgentFile) objects[0]).getParent();
final CreateFolderDialog dlg = new CreateFolderDialog(getSite().getShell());
if (dlg.open() != Window.OK)
return;
final String newFolder = dlg.getNewName();
new ConsoleJob(Messages.get().AgentFileManager_CreatingFolder, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected String getErrorMessage() {
return Messages.get().AgentFileManager_FolderCreationError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NestedVerifyOverwrite verify = new NestedVerifyOverwrite(AgentFile.DIRECTORY, newFolder, true, true, false) {
@Override
public void executeAction() throws NXCException, IOException {
// $NON-NLS-1$
session.createFolderOnAgent(objectId, parentFolder.getFullName() + "/" + newFolder);
}
@Override
public void executeSameFunctionWithOverwrite() throws IOException, NXCException {
// do nothing
}
};
verify.run(viewer.getControl().getDisplay());
parentFolder.setChildren(session.listAgentFiles(parentFolder, parentFolder.getFullName(), objectId));
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.refresh(parentFolder, true);
}
});
}
}.start();
}
Aggregations