Skip to content
Commits on Source (2)
target/
bin/
.project
.classpath
.settings/
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.core.commands</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile
formatter_settings_version=12
internal.default.compliance=user
org.eclipse.jdt.ui.exception.name=e
org.eclipse.jdt.ui.gettersetter.use.is=true
org.eclipse.jdt.ui.javadoc=true
org.eclipse.jdt.ui.overrideannotation=true
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return Returns the ${bare_field_name}.\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} The ${bare_field_name} to set.\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment"/><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @since 3.5\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template></templates>
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=false
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_functional_interfaces=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=true
sp_cleanup.insert_inferred_type_arguments=false
sp_cleanup.make_local_variable_final=true
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=false
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=true
sp_cleanup.organize_imports=true
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_redundant_type_arguments=false
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=true
sp_cleanup.remove_unused_imports=true
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.use_anonymous_class_creation=false
sp_cleanup.use_blocks=true
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_lambda=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
sp_cleanup.use_type_arguments=false
#Tue Nov 16 14:10:21 EST 2004
compilers.p.unused-element-or-attribute=1
compilers.p.unresolved-ex-points=0
compilers.p.deprecated=0
compilers.p.unknown-element=1
compilers.p.unknown-resource=1
compilers.p.unknown-class=1
compilers.p.unknown-attribute=0
compilers.p.no-required-att=0
eclipse.preferences.version=1
compilers.p.unresolved-import=0
compilers.p.not-externalized-att=0
compilers.p.illegal-att-value=0
compilers.use-project=true
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.commands
Bundle-Version: 3.8.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.core.commands,
org.eclipse.core.commands.common,
org.eclipse.core.commands.contexts,
org.eclipse.core.commands.operations,
org.eclipse.core.commands.util,
org.eclipse.core.internal.commands.operations;x-internal:=true,
org.eclipse.core.internal.commands.util;x-internal:=true
Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.2.0,4.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>June 2, 2006</p>
<h3>License</h3>
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
</body>
</html>
\ No newline at end of file
###############################################################################
# Copyright (c) 2004, 2015 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
###############################################################################
source.. = src/
output.. = bin/
src.includes = about.html
bin.includes = about.html,\
plugin.properties,\
.,\
META-INF/
jre.compilation.profile = JavaSE-1.7
\ No newline at end of file
# To force a version qualifier update add the bug here
Bug 403352 - Update all parent versions to match our build stream
###############################################################################
# Copyright (c) 2004,2005 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
###############################################################################
pluginName = Commands
providerName = Eclipse.org
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012 Eclipse Foundation.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/org/documents/edl-v10.php
Contributors:
Igor Fedorenko - initial implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>eclipse.platform.ui</artifactId>
<groupId>eclipse.platform.ui</groupId>
<version>4.6.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.commands</artifactId>
<version>3.8.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
/*******************************************************************************
* Copyright (c) 2004, 2015 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.core.commands;
import org.eclipse.core.commands.common.EventManager;
/**
* <p>
* This class is a partial implementation of <code>IHandler</code>. This
* abstract implementation provides support for handler listeners. You should
* subclass from this method unless you want to implement your own listener
* support. Subclasses should call
* {@link AbstractHandler#fireHandlerChanged(HandlerEvent)}when the handler
* changes. Subclasses can also override {@link AbstractHandler#isEnabled()} and
* {@link AbstractHandler#isHandled()}.
* </p>
*
* @since 3.1
*/
public abstract class AbstractHandler extends EventManager implements IHandler2 {
/**
* Track this base class enabled state.
*
* @since 3.4
*/
private boolean baseEnabled = true;
/**
* @see IHandler#addHandlerListener(IHandlerListener)
*/
@Override
public void addHandlerListener(final IHandlerListener handlerListener) {
addListenerObject(handlerListener);
}
/**
* The default implementation does nothing. Subclasses who attach listeners
* to other objects are encouraged to detach them in this method.
*
* @see org.eclipse.core.commands.IHandler#dispose()
*/
@Override
public void dispose() {
// Do nothing.
}
/**
* Fires an event to all registered listeners describing changes to this
* instance.
* <p>
* Subclasses may extend the definition of this method (i.e., if a different
* type of listener can be attached to a subclass). This is used primarily
* for support of <code>AbstractHandler</code> in
* <code>org.eclipse.ui.workbench</code>, and clients should be wary of
* overriding this behaviour. If this method is overridden, then the first
* line of the method should be "<code>super.fireHandlerChanged(handlerEvent);</code>".
* </p>
*
* @param handlerEvent
* the event describing changes to this instance. Must not be
* <code>null</code>.
*/
protected void fireHandlerChanged(final HandlerEvent handlerEvent) {
if (handlerEvent == null) {
throw new NullPointerException();
}
final Object[] listeners = getListeners();
for (int i = 0; i < listeners.length; i++) {
final IHandlerListener listener = (IHandlerListener) listeners[i];
listener.handlerChanged(handlerEvent);
}
}
/**
* Whether this handler is capable of executing at this time. Subclasses may
* override this method. If clients override this method they should also
* consider overriding {@link #setEnabled(Object)} so they can be notified
* about framework execution contexts.
*
* @return <code>true</code>
* @see #setEnabled(Object)
* @see #setBaseEnabled(boolean)
*/
@Override
public boolean isEnabled() {
return baseEnabled;
}
/**
* Allow the default {@link #isEnabled()} to answer our enabled state. It
* will fire a HandlerEvent if necessary. If clients use this method they
* should also consider overriding {@link #setEnabled(Object)} so they can
* be notified about framework execution contexts.
*
* @param state
* the enabled state
* @since 3.4
*/
protected void setBaseEnabled(boolean state) {
if (baseEnabled == state) {
return;
}
baseEnabled = state;
fireHandlerChanged(new HandlerEvent(this, true, false));
}
/**
* Called by the framework to allow the handler to update its enabled state
* by extracting the same information available at execution time. Clients
* may override if they need to extract information from the application
* context.
*
* @param evaluationContext
* the application context. May be <code>null</code>
* @since 3.4
* @see #setBaseEnabled(boolean)
*/
@Override
public void setEnabled(Object evaluationContext) {
}
/**
* Whether this handler is capable of handling delegated responsibilities at
* this time. Subclasses may override this method.
*
* @return <code>true</code>
*/
@Override
public boolean isHandled() {
return true;
}
/**
* <p>
* Returns true iff there is one or more IHandlerListeners attached to this
* AbstractHandler.
* </p>
* <p>
* Subclasses may extend the definition of this method (i.e., if a different
* type of listener can be attached to a subclass). This is used primarily
* for support of <code>AbstractHandler</code> in
* <code>org.eclipse.ui.workbench</code>, and clients should be wary of
* overriding this behaviour. If this method is overridden, then the return
* value should include "<code>super.hasListeners() ||</code>".
* </p>
*
* @return true iff there is one or more IHandlerListeners attached to this
* AbstractHandler
*/
protected boolean hasListeners() {
return isListenerAttached();
}
/**
* @see IHandler#removeHandlerListener(IHandlerListener)
*/
@Override
public void removeHandlerListener(final IHandlerListener handlerListener) {
removeListenerObject(handlerListener);
}
}
/*******************************************************************************
* Copyright (c) 2005, 2015 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.core.commands;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* <p>
* An abstract implementation of {@link IObjectWithState}. This provides basic
* handling for adding and remove state. When state is added, the handler
* attaches itself as a listener and fire a handleStateChange event to notify
* this handler. When state is removed, the handler removes itself as a
* listener.
* </p>
* <p>
* Clients may extend this class.
* </p>
*
* @since 3.2
*/
public abstract class AbstractHandlerWithState extends AbstractHandler implements IObjectWithState, IStateListener {
/**
* The map of states currently held by this handler. If this handler has no
* state (generally, when inactive), then this will be <code>null</code>.
*/
private Map<String, State> states;
private static final String[] EMPTY = new String[0];
/**
* <p>
* Adds a state to this handler. This will add this handler as a listener to
* the state, and then fire a handleStateChange so that the handler can
* respond to the incoming state.
* </p>
* <p>
* Clients may extend this method, but they should call this super method
* first before doing anything else.
* </p>
*
* @param stateId
* The identifier indicating the type of state being added; must
* not be <code>null</code>.
* @param state
* The state to add; must not be <code>null</code>.
*/
@Override
public void addState(final String stateId, final State state) {
if (state == null) {
throw new NullPointerException("Cannot add a null state"); //$NON-NLS-1$
}
if (states == null) {
states = new HashMap<>(3);
}
states.put(stateId, state);
state.addListener(this);
handleStateChange(state, null);
}
@Override
public final State getState(final String stateId) {
if ((states == null) || (states.isEmpty())) {
return null;
}
return states.get(stateId);
}
@Override
public final String[] getStateIds() {
if ((states == null) || (states.isEmpty())) {
return EMPTY;
}
final Set<String> stateIds = states.keySet();
return stateIds.toArray(new String[stateIds.size()]);
}
/**
* <p>
* Removes a state from this handler. This will remove this handler as a
* listener to the state. No event is fired to notify the handler of this
* change.
* </p>
* <p>
* Clients may extend this method, but they should call this super method
* first before doing anything else.
* </p>
*
* @param stateId
* The identifier of the state to remove; must not be
* <code>null</code>.
*/
@Override
public void removeState(final String stateId) {
if (stateId == null) {
throw new NullPointerException("Cannot remove a null state"); //$NON-NLS-1$
}
if (states == null) {
return;
}
final State state = states.get(stateId);
if (state != null) {
state.removeListener(this);
if (states != null) {
states.remove(stateId);
if (states.isEmpty()) {
states = null;
}
}
}
}
}
/*******************************************************************************
* Copyright (c) 2005, 2015 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.core.commands;
/**
* <p>
* Supports conversion between objects and strings for command parameter values.
* Extenders must produce strings that identify objects (of a specific command
* parameter type) as well as consume the strings to locate and return the
* objects they identify.
* </p>
* <p>
* This class offers multiple handlers of a command a consistent way of
* converting string parameter values into the objects that the handlers would
* prefer to deal with. This class also gives clients a way to serialize
* object parameters as strings so that entire parameterized commands can be
* serialized, stored and later deserialized and executed.
* </p>
* <p>
* This class will typically be extended so the subclass can be referenced from
* the <code>converter</code> attribute of the
* <code>commandParameterType</code> elemement of the
* <code>org.eclipse.ui.commands</code> extension-point. Objects implementing
* this interface may also be passed directly to
* {@link ParameterType#define(String, AbstractParameterValueConverter)} by
* clients.
* </p>
*
* @see ParameterType#define(String, AbstractParameterValueConverter)
* @see ParameterizedCommand#serialize()
* @since 3.2
*/
public abstract class AbstractParameterValueConverter {
/**
* Converts a string encoded command parameter value into the parameter
* value object.
*
* @param parameterValue
* a command parameter value string describing an object; may be
* <code>null</code>
* @return the object described by the command parameter value string; may
* be <code>null</code>
* @throws ParameterValueConversionException
* if an object cannot be produced from the
* <code>parameterValue</code> string
*/
public abstract Object convertToObject(final String parameterValue)
throws ParameterValueConversionException;
/**
* Converts a command parameter value object into a string that encodes a
* reference to the object or serialization of the object.
*
* @param parameterValue
* an object to convert into an identifying string; may be
* <code>null</code>
* @return a string describing the provided object; may be <code>null</code>
* @throws ParameterValueConversionException
* if a string reference or serialization cannot be provided for
* the <code>parameterValue</code>
*/
public abstract String convertToString(final Object parameterValue)
throws ParameterValueConversionException;
}
/*******************************************************************************
* Copyright (c) 2005, 2015 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.core.commands;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import org.eclipse.core.commands.common.NamedHandleObject;
import org.eclipse.core.internal.commands.util.Util;
/**
* <p>
* A logical group for a set of commands. A command belongs to exactly one
* category. The category has no functional effect, but may be used in graphical
* tools that want to group the set of commands somehow.
* </p>
*
* @since 3.1
*/
public final class Category extends NamedHandleObject {
/**
* A collection of objects listening to changes to this category. This
* collection is <code>null</code> if there are no listeners.
*/
private Collection<ICategoryListener> categoryListeners;
/**
* Constructs a new instance of <code>Category</code> based on the given
* identifier. When a category is first constructed, it is undefined.
* Category should only be constructed by the <code>CommandManager</code>
* to ensure that identifier remain unique.
*
* @param id
* The identifier for the category. This value must not be
* <code>null</code>, and must be unique amongst all
* categories.
*/
Category(final String id) {
super(id);
}
/**
* Adds a listener to this category that will be notified when this
* category's state changes.
*
* @param categoryListener
* The listener to be added; must not be <code>null</code>.
*/
public final void addCategoryListener(
final ICategoryListener categoryListener) {
if (categoryListener == null) {
throw new NullPointerException();
}
if (categoryListeners == null) {
categoryListeners = new ArrayList<>();
}
if (!categoryListeners.contains(categoryListener)) {
categoryListeners.add(categoryListener);
}
}
/**
* <p>
* Defines this category by giving it a name, and possibly a description as
* well. The defined property automatically becomes <code>true</code>.
* </p>
* <p>
* Notification is sent to all listeners that something has changed.
* </p>
*
* @param name
* The name of this command; must not be <code>null</code>.
* @param description
* The description for this command; may be <code>null</code>.
*/
public final void define(final String name, final String description) {
if (name == null) {
throw new NullPointerException("The name of a command cannot be null"); //$NON-NLS-1$
}
final boolean definedChanged = !this.defined;
this.defined = true;
final boolean nameChanged = !Util.equals(this.name, name);
this.name = name;
final boolean descriptionChanged = !Util.equals(this.description, description);
this.description = description;
fireCategoryChanged(new CategoryEvent(this, definedChanged, descriptionChanged, nameChanged));
}
/**
* Notifies the listeners for this category that it has changed in some way.
*
* @param categoryEvent
* The event to send to all of the listener; must not be
* <code>null</code>.
*/
private final void fireCategoryChanged(final CategoryEvent categoryEvent) {
if (categoryEvent == null) {
throw new NullPointerException();
}
if (categoryListeners != null) {
final Iterator<ICategoryListener> listenerItr = categoryListeners.iterator();
while (listenerItr.hasNext()) {
final ICategoryListener listener = listenerItr.next();
listener.categoryChanged(categoryEvent);
}
}
}
/**
* Removes a listener from this category.
*
* @param categoryListener
* The listener to be removed; must not be <code>null</code>.
*
*/
public final void removeCategoryListener(
final ICategoryListener categoryListener) {
if (categoryListener == null) {
throw new NullPointerException();
}
if (categoryListeners != null) {
categoryListeners.remove(categoryListener);
}
}
@Override
public String toString() {
if (string == null) {
final StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("Category("); //$NON-NLS-1$
stringBuffer.append(id);
stringBuffer.append(',');
stringBuffer.append(name);
stringBuffer.append(',');
stringBuffer.append(description);
stringBuffer.append(',');
stringBuffer.append(defined);
stringBuffer.append(')');
string = stringBuffer.toString();
}
return string;
}
@Override
public void undefine() {
string = null;
final boolean definedChanged = defined;
defined = false;
final boolean nameChanged = name != null;
name = null;
final boolean descriptionChanged = description != null;
description = null;
fireCategoryChanged(new CategoryEvent(this, definedChanged, descriptionChanged, nameChanged));
}
}
/*******************************************************************************
* Copyright (c) 2004, 2015 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.core.commands;
import org.eclipse.core.commands.common.AbstractNamedHandleEvent;
/**
* An instance of this class describes changes to an instance of
* <code>Category</code>.
* <p>
* This class is not intended to be extended by clients.
* </p>
*
* @since 3.1
* @see ICategoryListener#categoryChanged(CategoryEvent)
*/
public final class CategoryEvent extends AbstractNamedHandleEvent {
/**
* The category that has changed; this value is never <code>null</code>.
*/
private final Category category;
/**
* Creates a new instance of this class.
*
* @param category
* the instance of the interface that changed.
* @param definedChanged
* true, iff the defined property changed.
* @param descriptionChanged
* true, iff the description property changed.
* @param nameChanged
* true, iff the name property changed.
*/
public CategoryEvent(final Category category, final boolean definedChanged,
final boolean descriptionChanged, final boolean nameChanged) {
super(definedChanged, descriptionChanged, nameChanged);
if (category == null) {
throw new NullPointerException();
}
this.category = category;
}
/**
* Returns the instance of the interface that changed.
*
* @return the instance of the interface that changed. Guaranteed not to be
* <code>null</code>.
*/
public final Category getCategory() {
return category;
}
}
/*******************************************************************************
* Copyright (c) 2004, 2015 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.core.commands;
import org.eclipse.core.commands.common.AbstractNamedHandleEvent;
/**
* An instance of this class describes changes to an instance of
* <code>Command</code>.
* <p>
* This class is not intended to be extended by clients.
* </p>
*
* @since 3.1
* @see ICommandListener#commandChanged(CommandEvent)
*/
public final class CommandEvent extends AbstractNamedHandleEvent {
/**
* The bit used to represent whether the command has changed its category.
*/
private static final int CHANGED_CATEGORY = LAST_USED_BIT << 1;
/**
* The bit used to represent whether the command has changed its handler.
*/
private static final int CHANGED_HANDLED = LAST_USED_BIT << 2;
/**
* The bit used to represent whether the command has changed its parameters.
*/
private static final int CHANGED_PARAMETERS = LAST_USED_BIT << 3;
/**
* The bit used to represent whether the command has changed its return
* type.
*
* @since 3.2
*/
private static final int CHANGED_RETURN_TYPE = LAST_USED_BIT << 4;
/**
* The bit used to represent whether the command has changed its help
* context identifier.
*
* @since 3.2
*/
private static final int CHANGED_HELP_CONTEXT_ID = LAST_USED_BIT << 5;
/**
* The bit used to represent whether this commands active handler has
* changed its enablement state.
*
* @since 3.3
*/
private static final int CHANGED_ENABLED = LAST_USED_BIT << 6;
/**
* The command that has changed; this value is never <code>null</code>.
*/
private final Command command;
/**
* Creates a new instance of this class.
*
* @param command
* the instance of the interface that changed.
* @param categoryChanged
* <code>true</code>, iff the category property changed.
* @param definedChanged
* <code>true</code>, iff the defined property changed.
* @param descriptionChanged
* <code>true</code>, iff the description property changed.
* @param handledChanged
* <code>true</code>, iff the handled property changed.
* @param nameChanged
* <code>true</code>, iff the name property changed.
* @param parametersChanged
* <code>true</code> if the parameters have changed;
* <code>false</code> otherwise.
*/
public CommandEvent(final Command command, final boolean categoryChanged,
final boolean definedChanged, final boolean descriptionChanged,
final boolean handledChanged, final boolean nameChanged,
final boolean parametersChanged) {
this(command, categoryChanged, definedChanged, descriptionChanged,
handledChanged, nameChanged, parametersChanged, false);
}
/**
* Creates a new instance of this class.
*
* @param command
* the instance of the interface that changed.
* @param categoryChanged
* <code>true</code>, iff the category property changed.
* @param definedChanged
* <code>true</code>, iff the defined property changed.
* @param descriptionChanged
* <code>true</code>, iff the description property changed.
* @param handledChanged
* <code>true</code>, iff the handled property changed.
* @param nameChanged
* <code>true</code>, iff the name property changed.
* @param parametersChanged
* <code>true</code> if the parameters have changed;
* <code>false</code> otherwise.
* @param returnTypeChanged
* <code>true</code> iff the return type property changed;
* <code>false</code> otherwise.
* @since 3.2
*/
public CommandEvent(final Command command, final boolean categoryChanged,
final boolean definedChanged, final boolean descriptionChanged,
final boolean handledChanged, final boolean nameChanged,
final boolean parametersChanged, final boolean returnTypeChanged) {
this(command, categoryChanged, definedChanged, descriptionChanged,
handledChanged, nameChanged, parametersChanged,
returnTypeChanged, false);
}
/**
* Creates a new instance of this class.
*
* @param command
* the instance of the interface that changed.
* @param categoryChanged
* <code>true</code>, iff the category property changed.
* @param definedChanged
* <code>true</code>, iff the defined property changed.
* @param descriptionChanged
* <code>true</code>, iff the description property changed.
* @param handledChanged
* <code>true</code>, iff the handled property changed.
* @param nameChanged
* <code>true</code>, iff the name property changed.
* @param parametersChanged
* <code>true</code> if the parameters have changed;
* <code>false</code> otherwise.
* @param returnTypeChanged
* <code>true</code> iff the return type property changed;
* <code>false</code> otherwise.
* @param helpContextIdChanged
* <code>true</code> iff the help context identifier changed;
* <code>false</code> otherwise.
* @since 3.2
*/
public CommandEvent(final Command command, final boolean categoryChanged,
final boolean definedChanged, final boolean descriptionChanged,
final boolean handledChanged, final boolean nameChanged,
final boolean parametersChanged, final boolean returnTypeChanged,
final boolean helpContextIdChanged) {
this(command, categoryChanged, definedChanged, descriptionChanged,
handledChanged, nameChanged, parametersChanged,
returnTypeChanged, helpContextIdChanged, false);
}
/**
* Creates a new instance of this class.
*
* @param command
* the instance of the interface that changed.
* @param categoryChanged
* <code>true</code>, iff the category property changed.
* @param definedChanged
* <code>true</code>, iff the defined property changed.
* @param descriptionChanged
* <code>true</code>, iff the description property changed.
* @param handledChanged
* <code>true</code>, iff the handled property changed.
* @param nameChanged
* <code>true</code>, iff the name property changed.
* @param parametersChanged
* <code>true</code> if the parameters have changed;
* <code>false</code> otherwise.
* @param returnTypeChanged
* <code>true</code> iff the return type property changed;
* <code>false</code> otherwise.
* @param helpContextIdChanged
* <code>true</code> iff the help context identifier changed;
* <code>false</code> otherwise.
* @param enabledChanged
* <code>true</code> iff the comand enablement changed;
* <code>false</code> otherwise.
* @since 3.3
*/
public CommandEvent(final Command command, final boolean categoryChanged,
final boolean definedChanged, final boolean descriptionChanged,
final boolean handledChanged, final boolean nameChanged,
final boolean parametersChanged, final boolean returnTypeChanged,
final boolean helpContextIdChanged, final boolean enabledChanged) {
super(definedChanged, descriptionChanged, nameChanged);
if (command == null) {
throw new NullPointerException();
}
this.command = command;
if (categoryChanged) {
changedValues |= CHANGED_CATEGORY;
}
if (handledChanged) {
changedValues |= CHANGED_HANDLED;
}
if (parametersChanged) {
changedValues |= CHANGED_PARAMETERS;
}
if (returnTypeChanged) {
changedValues |= CHANGED_RETURN_TYPE;
}
if (helpContextIdChanged) {
changedValues |= CHANGED_HELP_CONTEXT_ID;
}
if (enabledChanged) {
changedValues |= CHANGED_ENABLED;
}
}
/**
* Returns the instance of the interface that changed.
*
* @return the instance of the interface that changed. Guaranteed not to be
* <code>null</code>.
*/
public final Command getCommand() {
return command;
}
/**
* Returns whether or not the category property changed.
*
* @return <code>true</code>, iff the category property changed.
*/
public final boolean isCategoryChanged() {
return ((changedValues & CHANGED_CATEGORY) != 0);
}
/**
* Returns whether or not the handled property changed.
*
* @return <code>true</code>, iff the handled property changed.
*/
public final boolean isHandledChanged() {
return ((changedValues & CHANGED_HANDLED) != 0);
}
/**
* Returns whether or not the help context identifier changed.
*
* @return <code>true</code>, iff the help context identifier changed.
* @since 3.2
*/
public final boolean isHelpContextIdChanged() {
return ((changedValues & CHANGED_HELP_CONTEXT_ID) != 0);
}
/**
* Returns whether or not the parameters have changed.
*
* @return <code>true</code>, iff the parameters property changed.
*/
public final boolean isParametersChanged() {
return ((changedValues & CHANGED_PARAMETERS) != 0);
}
/**
* Returns whether or not the return type property changed.
*
* @return <code>true</code>, iff the return type property changed.
* @since 3.2
*/
public final boolean isReturnTypeChanged() {
return ((changedValues & CHANGED_RETURN_TYPE) != 0);
}
/**
* Return whether the enable property changed.
*
* @return <code>true</code> iff the comand enablement changed
* @since 3.3
*/
public final boolean isEnabledChanged() {
return ((changedValues & CHANGED_ENABLED) != 0);
}
}