Example usage for org.eclipse.jface.action IAction HANDLED

List of usage examples for org.eclipse.jface.action IAction HANDLED

Introduction

In this page you can find the example usage for org.eclipse.jface.action IAction HANDLED.

Prototype

String HANDLED

To view the source code for org.eclipse.jface.action IAction HANDLED.

Click Source Link

Document

Property name of an action's handler.

Usage

From source file:org.eclipse.ocl.xtext.base.ui.commands.ValidateHandler.java

License:Open Source License

/**
 * When a listener is attached to this handler, then this registers a
 * listener with the underlying action./*from   w  w w  . j a v  a 2s.c  o m*/
 */
private final void attachListener() {
    if (propertyChangeListener == null) {
        propertyChangeListener = new IPropertyChangeListener() {
            //            @Override
            @Override
            public final void propertyChange(final PropertyChangeEvent propertyChangeEvent) {
                final String property = propertyChangeEvent.getProperty();
                fireHandlerChanged(new HandlerEvent(ValidateHandler.this, IAction.ENABLED.equals(property),
                        IAction.HANDLED.equals(property)));
            }
        };
    }

    this.action.addPropertyChangeListener(propertyChangeListener);
}

From source file:org.eclipse.ui.internal.handlers.CommandLegacyActionWrapper.java

License:Open Source License

public final void setActionDefinitionId(final String id) {
    // Get the old values.
    final boolean oldChecked = isChecked();
    final String oldDescription = getDescription();
    final boolean oldEnabled = isEnabled();
    final boolean oldHandled = isHandled();
    final ImageDescriptor oldDefaultImage = getImageDescriptor();
    final ImageDescriptor oldDisabledImage = getDisabledImageDescriptor();
    final ImageDescriptor oldHoverImage = getHoverImageDescriptor();
    final String oldText = getText();

    // Update the command.
    final Command oldBaseCommand = command.getCommand();
    oldBaseCommand.removeCommandListener(commandListener);
    final ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class);
    final Command newBaseCommand = commandService.getCommand(id);
    command = new ParameterizedCommand(newBaseCommand, null);
    newBaseCommand.addCommandListener(commandListener);

    // Get the new values.
    final boolean newChecked = isChecked();
    final String newDescription = getDescription();
    final boolean newEnabled = isEnabled();
    final boolean newHandled = isHandled();
    final ImageDescriptor newDefaultImage = getImageDescriptor();
    final ImageDescriptor newDisabledImage = getDisabledImageDescriptor();
    final ImageDescriptor newHoverImage = getHoverImageDescriptor();
    final String newText = getText();

    // Fire property change events, as necessary.
    if (newChecked != oldChecked) {
        if (oldChecked) {
            firePropertyChange(IAction.CHECKED, Boolean.TRUE, Boolean.FALSE);
        } else {/*ww w.j  a  v  a2s  . c om*/
            firePropertyChange(IAction.CHECKED, Boolean.FALSE, Boolean.TRUE);
        }
    }

    if (!Util.equals(oldDescription, newDescription)) {
        firePropertyChange(IAction.DESCRIPTION, oldDescription, newDescription);
        firePropertyChange(IAction.TOOL_TIP_TEXT, oldDescription, newDescription);
    }

    if (newEnabled != oldEnabled) {
        if (oldEnabled) {
            firePropertyChange(IAction.ENABLED, Boolean.TRUE, Boolean.FALSE);
        } else {
            firePropertyChange(IAction.ENABLED, Boolean.FALSE, Boolean.TRUE);
        }
    }

    if (newHandled != oldHandled) {
        if (oldHandled) {
            firePropertyChange(IAction.HANDLED, Boolean.TRUE, Boolean.FALSE);
        } else {
            firePropertyChange(IAction.HANDLED, Boolean.FALSE, Boolean.TRUE);
        }
    }

    if (!Util.equals(oldDefaultImage, newDefaultImage)) {
        firePropertyChange(IAction.IMAGE, oldDefaultImage, newDefaultImage);
    }

    if (!Util.equals(oldDisabledImage, newDisabledImage)) {
        firePropertyChange(IAction.IMAGE, oldDisabledImage, newDisabledImage);
    }

    if (!Util.equals(oldHoverImage, newHoverImage)) {
        firePropertyChange(IAction.IMAGE, oldHoverImage, newHoverImage);
    }

    if (!Util.equals(oldText, newText)) {
        firePropertyChange(IAction.TEXT, oldText, newText);
    }
}

From source file:org.xmind.ui.internal.actions.AddMarkerHandler.java

License:Open Source License

private void hookAction() {
    if (action == null)
        return;/*from ww  w .j a va 2  s .c  o m*/

    if (propertyChangeListener == null) {
        propertyChangeListener = new IPropertyChangeListener() {
            public final void propertyChange(final PropertyChangeEvent propertyChangeEvent) {
                final String property = propertyChangeEvent.getProperty();
                fireHandlerChanged(new HandlerEvent(AddMarkerHandler.this, IAction.ENABLED.equals(property),
                        IAction.HANDLED.equals(property)));
            }
        };
    }
    action.addPropertyChangeListener(propertyChangeListener);
}