use of org.netxms.ui.eclipse.networkmaps.algorithms.ManualLayout in project netxms by netxms.
the class AbstractNetworkMapView method createPartControl.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.ViewPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public final void createPartControl(Composite parent) {
FillLayout layout = new FillLayout();
parent.setLayout(layout);
viewer = new ExtendedGraphViewer(parent, SWT.NONE);
viewer.setContentProvider(new MapContentProvider(viewer));
labelProvider = new MapLabelProvider(viewer);
viewer.setLabelProvider(labelProvider);
viewer.setBackgroundColor(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB());
IDialogSettings settings = Activator.getDefault().getDialogSettings();
try {
// $NON-NLS-1$
alwaysFitLayout = settings.getBoolean(viewId + ".alwaysFitLayout");
} catch (Exception e) {
}
// Zoom level restore and save
try {
// $NON-NLS-1$
viewer.zoomTo(settings.getDouble(viewId + ".zoom"));
} catch (NumberFormatException e) {
}
viewer.getGraphControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
IDialogSettings settings = Activator.getDefault().getDialogSettings();
// $NON-NLS-1$
settings.put(viewId + ".zoom", viewer.getZoom());
}
});
getSite().setSelectionProvider(this);
ISelectionChangedListener listener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent e) {
if (bendpointEditor != null) {
bendpointEditor.stop();
bendpointEditor = null;
}
currentSelection = transformSelection(e.getSelection());
if (currentSelection.size() == 1) {
int selectionType = analyzeSelection(currentSelection);
if (selectionType == SELECTION_OBJECTS) {
AbstractObject object = (AbstractObject) currentSelection.getFirstElement();
actionOpenDrillDownObject.setEnabled(object.getDrillDownObjectId() != 0);
} else {
actionOpenDrillDownObject.setEnabled(false);
if (selectionType == SELECTION_LINKS) {
NetworkMapLink link = (NetworkMapLink) currentSelection.getFirstElement();
actionLockLink.setChecked(link.isLocked());
if (!link.isLocked() && link.getRouting() == NetworkMapLink.ROUTING_BENDPOINTS) {
bendpointEditor = new BendpointEditor(link, (GraphConnection) viewer.getGraphControl().getSelection().get(0), viewer);
}
}
}
} else {
actionOpenDrillDownObject.setEnabled(false);
}
if (selectionListeners.isEmpty())
return;
SelectionChangedEvent event = new SelectionChangedEvent(AbstractNetworkMapView.this, currentSelection);
for (ISelectionChangedListener l : selectionListeners) {
l.selectionChanged(event);
}
}
};
viewer.addPostSelectionChangedListener(listener);
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
int selectionType = analyzeSelection(currentSelection);
if (selectionType == SELECTION_EMPTY)
return;
if (selectionType == SELECTION_OBJECTS) {
AbstractObject object = (AbstractObject) currentSelection.getFirstElement();
if (object instanceof Rack) {
openRackView(Long.toString(object.getObjectId()));
return;
}
for (DoubleClickHandlerData h : doubleClickHandlers) {
if ((h.enabledFor == null) || (h.enabledFor.isInstance(object))) {
if (h.handler.onDoubleClick(object)) {
return;
}
}
}
} else if (((NetworkMapLink) currentSelection.getFirstElement()).isLocked() && selectionType == SELECTION_LINKS) {
openLinkDci();
}
// Default behavior
actionOpenDrillDownObject.run();
}
});
sessionListener = new SessionListener() {
@Override
public void notificationHandler(final SessionNotification n) {
if (n.getCode() == SessionNotification.OBJECT_CHANGED) {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
onObjectChange((AbstractObject) n.getObject());
}
});
}
}
};
session.addListener(sessionListener);
createActions();
contributeToActionBars();
createPopupMenu();
if (automaticLayoutEnabled) {
setLayoutAlgorithm(layoutAlgorithm, true);
} else {
viewer.setLayoutAlgorithm(new ManualLayout());
}
activateContext();
registerDoubleClickHandlers();
setupMapControl();
refreshMap();
}
use of org.netxms.ui.eclipse.networkmaps.algorithms.ManualLayout in project netxms by netxms.
the class AbstractNetworkMapView method setManualLayout.
/**
* Set manual layout mode
*/
protected void setManualLayout() {
updateObjectPositions();
automaticLayoutEnabled = false;
viewer.setLayoutAlgorithm(new ManualLayout(), true);
for (int i = 0; i < actionSetAlgorithm.length; i++) actionSetAlgorithm[i].setEnabled(false);
actionSaveLayout.setEnabled(true);
}
Aggregations