| /***************************************************************************** |
| * Copyright (c) 2019 CEA LIST. |
| * |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Xavier Le Pallec (for CEA LIST) xlepallec@lilo.org - Bug 558456 |
| * |
| *****************************************************************************/ |
| |
| package org.eclipse.papyrus.uml.diagram.clazz.lf.associationlabellayout.preferences; |
| |
| import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
| import org.eclipse.core.runtime.preferences.InstanceScope; |
| import org.eclipse.papyrus.uml.diagram.clazz.lf.associationlabellayout.Activator; |
| import org.eclipse.papyrus.uml.diagram.clazz.lf.associationlabellayout.messages.Messages; |
| import org.osgi.service.prefs.BackingStoreException; |
| |
| /** |
| * This class helps at accessing to eclipse configuration options related to |
| * this plug-in. |
| * |
| */ |
| public class Settings { |
| |
| static Settings instance; |
| |
| /** |
| * The instance (singleton) that allows to access to the configuration options. |
| * |
| * @return |
| */ |
| public static Settings getInstance() { |
| if (instance == null) { |
| instance = new Settings(); |
| } |
| return instance; |
| } |
| |
| /** |
| * Option: is the plug-in is on ? |
| * |
| * @return true if it is on. |
| */ |
| public boolean isActivated() { |
| return InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).getBoolean(Messages.Settings_activated, true); |
| } |
| |
| /** |
| * set the Option: is the plug-in is on ? |
| * |
| * @param activated |
| * true to activate the plug-in. |
| */ |
| public void setActivated(boolean activated) { |
| IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID); |
| preferences.putBoolean(Messages.Settings_activated, activated); |
| try { |
| preferences.flush(); |
| } catch (BackingStoreException exception) { |
| Activator.getDefault().logError(exception.getMessage(), exception); |
| } |
| } |
| } |