X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FsymbolEditor%2FGridVisibleFunction.java;fp=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FsymbolEditor%2FGridVisibleFunction.java;h=225528ebf43ba976181b8e8cf8c026059033b3aa;hp=b708d57c87bec3421018a9a430ba0a0d7160d86f;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/symbolEditor/GridVisibleFunction.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/symbolEditor/GridVisibleFunction.java index b708d57c8..225528ebf 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/symbolEditor/GridVisibleFunction.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/symbolEditor/GridVisibleFunction.java @@ -1,50 +1,50 @@ -/******************************************************************************* - * Copyright (c) 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Semantum Oy - initial API and implementation - *******************************************************************************/ -package org.simantics.modeling.ui.symbolEditor; - -import org.simantics.g2d.canvas.ICanvasContext; -import org.simantics.g2d.participant.GridPainter; -import org.simantics.scl.runtime.function.Function1; -import org.simantics.utils.datastructures.hints.HintListenerAdapter; -import org.simantics.utils.datastructures.hints.IHintContext; -import org.simantics.utils.datastructures.hints.IHintObservable; -import org.simantics.utils.datastructures.hints.IHintContext.Key; - -/** - * A function and a listener for diagram grid visibility. The function - * returns the current grid visibility as a Boolean. - * - * @author Tuukka Lehtonen - */ -public class GridVisibleFunction extends HintListenerAdapter implements Function1 { - - Boolean enabled; - - public GridVisibleFunction(ICanvasContext ctx) { - IHintContext hctx = ctx.getDefaultHintContext(); - // Initialize state - hintChanged(hctx, GridPainter.KEY_GRID_ENABLED, null, hctx.getHint(GridPainter.KEY_GRID_ENABLED)); - // Start listening - hctx.addKeyHintListener(GridPainter.KEY_GRID_ENABLED, this); - } - - @Override - public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) { - enabled = Boolean.valueOf(Boolean.TRUE.equals(newValue)); - } - - @Override - public Boolean apply(Object p0) { - return enabled; - } - +/******************************************************************************* + * Copyright (c) 2013 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.modeling.ui.symbolEditor; + +import org.simantics.g2d.canvas.ICanvasContext; +import org.simantics.g2d.participant.GridPainter; +import org.simantics.scl.runtime.function.Function1; +import org.simantics.utils.datastructures.hints.HintListenerAdapter; +import org.simantics.utils.datastructures.hints.IHintContext; +import org.simantics.utils.datastructures.hints.IHintObservable; +import org.simantics.utils.datastructures.hints.IHintContext.Key; + +/** + * A function and a listener for diagram grid visibility. The function + * returns the current grid visibility as a Boolean. + * + * @author Tuukka Lehtonen + */ +public class GridVisibleFunction extends HintListenerAdapter implements Function1 { + + Boolean enabled; + + public GridVisibleFunction(ICanvasContext ctx) { + IHintContext hctx = ctx.getDefaultHintContext(); + // Initialize state + hintChanged(hctx, GridPainter.KEY_GRID_ENABLED, null, hctx.getHint(GridPainter.KEY_GRID_ENABLED)); + // Start listening + hctx.addKeyHintListener(GridPainter.KEY_GRID_ENABLED, this); + } + + @Override + public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) { + enabled = Boolean.valueOf(Boolean.TRUE.equals(newValue)); + } + + @Override + public Boolean apply(Object p0) { + return enabled; + } + } \ No newline at end of file