All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.jface.menus.TextState Maven / Gradle / Ivy

Go to download

JFace is a UI toolkit with classes for handling many common UI programming tasks. JFace is window-system-independent in both its API and implementation, and is designed to work with SWT without hiding it. JFace includes the usual UI toolkit components of image and font registries, text, dialog, preference and wizard frameworks, and progress reporting for long running operations. Two of its more interesting features are actions and viewers. The action mechanism allows user commands to be defined independently from their exact whereabouts in the UI. Viewers are model based adapters for certain SWT widgets, simplifying the presentation of application data structured as lists, tables or trees.

The newest version!
/*******************************************************************************
 * Copyright (c) 2005, 2006 IBM Corporation and others.
 * 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.jface.menus;

import org.eclipse.core.commands.INamedHandleStateIds;
import org.eclipse.jface.commands.PersistentState;
import org.eclipse.jface.preference.IPreferenceStore;

/**
 * 

* A piece of state carrying a single {@link String}. *

*

* If this state is registered using {@link INamedHandleStateIds#NAME} or * {@link INamedHandleStateIds#DESCRIPTION}, then this allows the handler to * communicate a textual change for a given command. This is typically used by * graphical applications to allow more specific text to be displayed in the * menus. For example, "Undo" might become "Undo Typing" through the use of a * {@link TextState}. *

*

* Clients may instantiate this class, but must not extend. *

* * @since 3.2 * @see INamedHandleStateIds */ public class TextState extends PersistentState { public final void load(final IPreferenceStore store, final String preferenceKey) { final String value = store.getString(preferenceKey); setValue(value); } public final void save(final IPreferenceStore store, final String preferenceKey) { final Object value = getValue(); if (value instanceof String) { store.setValue(preferenceKey, ((String) value)); } } public void setValue(final Object value) { if (!(value instanceof String)) { throw new IllegalArgumentException( "TextState takes a String as a value"); //$NON-NLS-1$ } super.setValue(value); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy