use of org.eclipse.ui.IViewReference in project netxms by netxms.
the class OpenAgentConfig method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
IViewReference vr = window.getActivePage().findViewReference(AgentConfigEditorView.ID, Long.toString(nodeId));
if (vr != null) {
AgentConfigEditorView view = (AgentConfigEditorView) vr.getView(true);
if (view != null) {
window.getActivePage().activate(view);
}
} else {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().OpenAgentConfig_GetConfig, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final String config = session.getAgentConfig(nodeId);
runInUIThread(new Runnable() {
@Override
public void run() {
try {
AgentConfigEditorView view = (AgentConfigEditorView) window.getActivePage().showView(AgentConfigEditorView.ID, Long.toString(nodeId), IWorkbenchPage.VIEW_ACTIVATE);
view.setConfig(config);
} catch (PartInitException e) {
MessageDialogHelper.openError(window.getShell(), Messages.get().OpenAgentConfig_Error, Messages.get().OpenAgentConfig_OpenErrorPrefix + e.getLocalizedMessage());
}
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().OpenAgentConfig_OpenError;
}
}.start();
}
}
use of org.eclipse.ui.IViewReference in project netxms by netxms.
the class CreateInterfraceDci method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
final CreateInterfaceDciDialog dlg = new CreateInterfaceDciDialog(shell, (objects.size() == 1) ? objects.get(0) : null);
if (dlg.open() == Window.OK) {
final List<Interface> ifaces = new ArrayList<Interface>(objects);
// Get set of nodes
final Set<AbstractNode> nodes = new HashSet<AbstractNode>();
for (Interface iface : ifaces) {
AbstractNode node = iface.getParentNode();
if (node != null) {
nodes.add(node);
}
}
// Check what nodes requires DCI list lock
final Map<Long, Boolean> lockRequired = new HashMap<Long, Boolean>(nodes.size());
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (AbstractNode n : nodes) {
IViewReference ref = page.findViewReference(DataCollectionEditor.ID, Long.toString(n.getObjectId()));
lockRequired.put(n.getObjectId(), !((ref != null) && (ref.getView(false) != null)));
}
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CreateInterfraceDci_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().CreateInterfraceDci_JobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
InterfaceDciInfo[] dciInfo = dlg.getDciInfo();
monitor.beginTask(Messages.get(getDisplay()).CreateInterfraceDci_TaskName, ifaces.size() * dciInfo.length);
for (int i = 0; i < ifaces.size(); i++) {
for (int j = 0; j < dciInfo.length; j++) {
if (dciInfo[j].enabled) {
createInterfaceDci(session, ifaces.get(i), j, dciInfo[j], dlg.getPollingInterval(), dlg.getRetentionTime(), ifaces.size() > 1, lockRequired);
}
monitor.worked(1);
}
}
monitor.done();
}
}.start();
}
}
use of org.eclipse.ui.IViewReference in project netxms by netxms.
the class CreateSnmpDci method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
if (objects.size() == 0)
return;
MibObject mibObject = MibCache.findObject(objects.get(0).getName(), false);
String description = (mibObject != null) ? mibObject.getName() : objects.get(0).getName();
if (objects.size() > 1)
// $NON-NLS-1$
description += " @@instance@@";
final CreateSnmpDciDialog dlg = new CreateSnmpDciDialog(shell, description);
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final List<SnmpValue> values = new ArrayList<SnmpValue>(objects);
// Get set of nodes
final Set<AbstractNode> nodes = new HashSet<AbstractNode>();
for (SnmpValue v : values) {
AbstractNode node = (AbstractNode) session.findObjectById(v.getNodeId(), AbstractNode.class);
if (node != null) {
nodes.add(node);
}
}
// Check what nodes requires DCI list lock
final Map<Long, Boolean> lockRequired = new HashMap<Long, Boolean>(nodes.size());
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (AbstractNode n : nodes) {
IViewReference ref = page.findViewReference(DataCollectionEditor.ID, Long.toString(n.getObjectId()));
lockRequired.put(n.getObjectId(), !((ref != null) && (ref.getView(false) != null)));
}
new ConsoleJob(Messages.get().CreateSnmpDci_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().CreateSnmpDci_ErrorMessage;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
monitor.beginTask(Messages.get(getDisplay()).CreateSnmpDci_TaskTitle, values.size());
for (SnmpValue v : values) {
// $NON-NLS-1$
final String description = dlg.getDescription().replaceAll("@@instance@@", Long.toString(v.getObjectId().getIdFromPos(v.getObjectId().getLength() - 1)));
createDci(session, v, description, dlg.getPollingInterval(), dlg.getRetentionTime(), dlg.getDeltaCalculation(), lockRequired);
monitor.worked(1);
}
monitor.done();
}
}.start();
}
use of org.eclipse.ui.IViewReference in project netxms by netxms.
the class ShowVlans method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
IViewReference vr = window.getActivePage().findViewReference(VlanView.ID, Long.toString(objectId));
if (vr != null) {
VlanView view = (VlanView) vr.getView(true);
if (view != null) {
window.getActivePage().activate(view);
}
} else {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().ShowVlans_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<VlanInfo> vlans = session.getVlans(objectId);
runInUIThread(new Runnable() {
@Override
public void run() {
try {
VlanView view = (VlanView) window.getActivePage().showView(VlanView.ID, Long.toString(objectId), IWorkbenchPage.VIEW_ACTIVATE);
view.setVlans(vlans);
} catch (PartInitException e) {
MessageDialogHelper.openError(window.getShell(), Messages.get().ShowVlans_Error, Messages.get().ShowVlans_CannotOpenView + e.getLocalizedMessage());
}
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ShowVlans_JobError;
}
}.start();
}
}
use of org.eclipse.ui.IViewReference in project hale by halestudio.
the class TransformationReportPage method onDoubleClick.
@Override
protected void onDoubleClick(Message m) {
if (m instanceof TransformationMessage) {
TransformationMessage tm = (TransformationMessage) m;
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
if (as != null && as.getAlignment().getCell(tm.getCellId()) != null) {
IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
// pin the property sheet if possible
IViewReference ref = activeWindow.getActivePage().findViewReference(IPageLayout.ID_PROP_SHEET);
if (ref != null) {
IViewPart part = ref.getView(false);
if (part instanceof PropertySheet) {
PropertySheet sheet = (PropertySheet) part;
if (!sheet.isPinned()) {
sheet.setPinned(true);
}
}
}
// show cell in mapping view
try {
IViewPart part = activeWindow.getActivePage().showView(MappingView.ID);
if (part instanceof MappingView) {
((MappingView) part).selectCell(tm.getCellId());
}
} catch (PartInitException e) {
// ignore
}
}
}
super.onDoubleClick(m);
}
Aggregations