use of org.freeplane.core.resources.IFreeplanePropertyListener in project freeplane by freeplane.
the class MapView method createPropertyChangeListener.
private static void createPropertyChangeListener() {
MapView.propertyChangeListener = new IFreeplanePropertyListener() {
public void propertyChanged(final String propertyName, final String newValue, final String oldValue) {
final Component c = Controller.getCurrentController().getMapViewManager().getMapViewComponent();
if (!(c instanceof MapView)) {
return;
}
final MapView mapView = (MapView) c;
if (propertyName.equals(RESOURCES_SELECTED_NODE_COLOR)) {
MapView.standardSelectColor = ColorUtils.stringToColor(newValue);
mapView.repaintSelecteds();
return;
}
if (propertyName.equals(RESOURCES_SELECTED_NODE_RECTANGLE_COLOR)) {
MapView.standardSelectRectangleColor = ColorUtils.stringToColor(newValue);
mapView.repaintSelecteds();
return;
}
if (propertyName.equals(ResourceController.RESOURCE_DRAW_RECTANGLE_FOR_SELECTION)) {
MapView.standardDrawRectangleForSelection = TreeXmlReader.xmlToBoolean(newValue);
mapView.repaintSelecteds();
return;
}
if (propertyName.equals("printonwhitebackground")) {
MapView.printOnWhiteBackground = TreeXmlReader.xmlToBoolean(newValue);
return;
}
if (propertyName.equals(SPOTLIGHT_BACKGROUND_COLOR)) {
MapView.spotlightBackgroundColor = ColorUtils.stringToColor(newValue);
mapView.repaint();
return;
}
if (propertyName.equals(HIDE_SINGLE_END_CONNECTORS)) {
MapView.hideSingleEndConnectors = ResourceController.getResourceController().getBooleanProperty(HIDE_SINGLE_END_CONNECTORS);
mapView.repaint();
return;
}
if (propertyName.equals(SHOW_CONNECTORS_PROPERTY)) {
MapView.showConnectors = ResourceController.getResourceController().getProperty(SHOW_CONNECTORS_PROPERTY).intern();
mapView.repaint();
return;
}
if (propertyName.equals(SHOW_ICONS_PROPERTY)) {
MapView.showIcons = ResourceController.getResourceController().getBooleanProperty(SHOW_ICONS_PROPERTY);
mapView.updateIconsRecursively(mapView.getRoot());
mapView.repaint();
return;
}
if (propertyName.equals(OUTLINE_HGAP_PROPERTY)) {
MapView.outlineHGap = ResourceController.getResourceController().getLengthProperty(OUTLINE_HGAP_PROPERTY);
if (mapView.isOutlineLayoutSet()) {
mapView.getRoot().updateAll();
mapView.repaint();
}
return;
}
if (propertyName.equals(OUTLINE_VIEW_FITS_WINDOW_WIDTH)) {
outlineViewFitsWindowWidth = ResourceController.getResourceController().getBooleanProperty(OUTLINE_VIEW_FITS_WINDOW_WIDTH);
if (mapView.isOutlineLayoutSet()) {
mapView.getRoot().updateAll();
mapView.repaint();
}
return;
}
}
};
ResourceController.getResourceController().addPropertyChangeListener(MapView.propertyChangeListener);
}
use of org.freeplane.core.resources.IFreeplanePropertyListener 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.core.resources.IFreeplanePropertyListener in project freeplane by freeplane.
the class SpellCheckerController method init.
private void init() {
if (spellCheckerInitialized == true) {
return;
}
spellCheckerInitialized = true;
final ResourceController resourceController = ResourceController.getResourceController();
final File orthoDir = new File(resourceController.getResourceBaseDir(), "ortho");
registerDictionaries(orthoDir);
final File userOrthoDir = new File(resourceController.getFreeplaneUserDirectory(), "ortho");
registerDictionaries(userOrthoDir);
if (!spellCheckerEnabled) {
return;
}
setSpellCheckOptions(resourceController);
resourceController.addPropertyChangeListener(new IFreeplanePropertyListener() {
public void propertyChanged(final String propertyName, final String newValue, final String oldValue) {
if (propertyName.startsWith("spelling_opt")) {
setSpellCheckOptions(resourceController);
}
}
});
String spellingLanguage = resourceController.getProperty(SPELLING_LANGUAGE, null);
if (spellingLanguage == null) {
spellingLanguage = resourceController.getLanguageCode();
}
if (!spellingLanguage.equals("disabled")) {
SpellChecker.setLanguage(spellingLanguage);
}
languageChangeListener = new LanguageChangeListener() {
public void languageChanged(final LanguageChangeEvent ev) {
EventQueue.invokeLater(new Runnable() {
public void run() {
final Locale currentLocale = ev.getCurrentLocale();
if (currentLocale == null) {
resourceController.setProperty(SPELLING_LANGUAGE, "disabled");
return;
}
resourceController.setProperty(SPELLING_LANGUAGE, currentLocale.getLanguage());
}
});
}
};
SpellChecker.addLanguageChangeLister(languageChangeListener);
}
Aggregations