org.eclipse.ui.keys.Key Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of workbench Show documentation
Show all versions of workbench Show documentation
This plug-in contains the bulk of the Workbench implementation, and depends on JFace, SWT, and Core Runtime. It cannot be used independently from org.eclipse.ui. Workbench client plug-ins should not depend directly on this plug-in.
The newest version!
/*******************************************************************************
* Copyright (c) 2000, 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.ui.keys;
import org.eclipse.jface.bindings.keys.IKeyLookup;
import org.eclipse.jface.bindings.keys.KeyLookupFactory;
import org.eclipse.ui.internal.util.Util;
/**
*
* Key
is the abstract base class for all objects representing
* keys on the keyboard.
*
*
* All Key
objects have a formal string representation, called
* the 'name' of the key, available via the toString()
method.
*
*
* All Key
objects, via the format()
method,
* provide a version of their formal string representation translated by
* platform and locale, suitable for display to a user.
*
*
* Key
objects are immutable. Clients are not permitted to extend
* this class.
*
*
* @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke and
* org.eclipse.jface.bindings.keys.KeyLookupFactory
* @since 3.0
*/
public abstract class Key implements Comparable {
/**
* The key from which this key was constructed. This value is defined by
* KeyLookupFactory.getDefault()
.
*/
protected final int key;
/**
* Constructs an instance of Key
given its formal string
* representation.
*
* @param key
* the integer representation of this key, as defined by
* KeyLookupFactory.getDefault()
.
*/
Key(final int key) {
this.key = key;
}
/**
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public final int compareTo(final Object object) {
return Util.compare(key, ((Key) object).key);
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
public final boolean equals(final Object object) {
if (!(object instanceof Key)) {
return false;
}
return key == ((Key) object).key;
}
/**
* @see java.lang.Object#hashCode()
*/
public final int hashCode() {
return Util.hashCode(key);
}
/**
* Returns the formal string representation for this key.
*
* @return The formal string representation for this key. Guaranteed not to
* be null
.
* @see java.lang.Object#toString()
*/
public final String toString() {
final IKeyLookup lookup = KeyLookupFactory.getDefault();
return lookup.formalNameLookup(key);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy