use of org.freeplane.features.map.AMapChangeListenerAdapter in project freeplane by freeplane.
the class NodeTooltipManager method getSharedInstance.
public static NodeTooltipManager getSharedInstance(ModeController modeController) {
{
final NodeTooltipManager instance = modeController.getExtension(NodeTooltipManager.class);
if (instance != null) {
return instance;
}
}
final NodeTooltipManager instance = new NodeTooltipManager();
setTooltipDelays(instance);
UIManager.put("PopupMenu.consumeEventOnClose", Boolean.FALSE);
ResourceController.getResourceController().addPropertyChangeListener(new IFreeplanePropertyListener() {
public void propertyChanged(final String propertyName, final String newValue, final String oldValue) {
if (propertyName.startsWith(TOOL_TIP_MANAGER)) {
setTooltipDelays(instance);
}
}
});
IMapChangeListener mapChangeListener = new AMapChangeListenerAdapter() {
@Override
public void onNodeDeleted(NodeDeletionEvent nodeDeletionEvent) {
instance.hideTipWindow();
}
@Override
public void onNodeInserted(NodeModel parent, NodeModel child, int newIndex) {
instance.hideTipWindow();
}
@Override
public void onNodeMoved(NodeMoveEvent nodeMoveEvent) {
instance.hideTipWindow();
}
};
MapController mapController = modeController.getMapController();
mapController.addMapChangeListener(mapChangeListener);
INodeSelectionListener nodeSelectionListener = new INodeSelectionListener() {
public void onSelect(NodeModel node) {
NodeView view = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, instance.insideComponent);
if (view != null && node.equals(view.getModel()))
return;
instance.hideTipWindow();
}
public void onDeselect(NodeModel node) {
}
};
mapController.addNodeSelectionListener(nodeSelectionListener);
modeController.addExtension(NodeTooltipManager.class, instance);
return instance;
}
use of org.freeplane.features.map.AMapChangeListenerAdapter in project freeplane by freeplane.
the class StyleEditorPanel method addListeners.
private void addListeners() {
final Controller controller = Controller.getCurrentController();
final ModeController modeController = Controller.getCurrentModeController();
final MapController mapController = modeController.getMapController();
mapController.addNodeSelectionListener(new INodeSelectionListener() {
public void onSelect(final NodeModel node) {
final IMapSelection selection = controller.getSelection();
if (selection == null) {
return;
}
if (selection.size() == 1) {
setComponentsEnabled(true);
setStyle(node);
}
}
public void setComponentsEnabled(boolean enabled) {
final Container panel = (Container) getComponent(0);
for (int i = 0; i < panel.getComponentCount(); i++) {
panel.getComponent(i).setEnabled(enabled);
}
}
public void onDeselect(final NodeModel node) {
setComponentsEnabled(false);
}
});
mapController.addNodeChangeListener(new INodeChangeListener() {
public void nodeChanged(final NodeChangeEvent event) {
final IMapSelection selection = controller.getSelection();
if (selection == null) {
return;
}
final NodeModel node = event.getNode();
if (selection.getSelected().equals(node)) {
setStyle(node);
}
}
});
mapController.addMapChangeListener(new AMapChangeListenerAdapter() {
@Override
public void mapChanged(MapChangeEvent event) {
if (!MapStyle.MAP_STYLES.equals(event.getProperty()))
return;
final IMapSelection selection = controller.getSelection();
if (selection == null) {
return;
}
final NodeModel node = selection.getSelected();
setStyle(node);
}
});
}
Aggregations