Java Code Examples for org.eclipse.jface.bindings.Binding#SYSTEM

The following examples show how to use org.eclipse.jface.bindings.Binding#SYSTEM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyBindings.java    From workspacemechanic with Eclipse Public License 1.0 6 votes vote down vote up
KeyBindings(MechanicLog log, Binding[] bindings) {
  this.log = log;
  List<Binding> ub = new ArrayList<Binding>();
  List<Binding> sb = new ArrayList<Binding>();

  for (Binding binding : bindings) {
    if (binding.getType() == Binding.USER) {
      ub.add(binding);
    } else if (binding.getType() == Binding.SYSTEM) {
      sb.add(binding);
    } else {
      throw new UnsupportedOperationException("Unexpected binding type: " + binding.getType());
    }
  }
  this.userBindings = ub;
  this.systemBindings = Collections.unmodifiableList(sb);
  this.userBindingsMap = buildQualifierToBindingMap(userBindings);
  this.systemBindingsMap = buildQualifierToBindingMap(systemBindings);
}
 
Example 2
Source File: KeyBindings.java    From workspacemechanic with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Bind a scheme / platform / context / trigger sequence to a command.
 */
public void addIfNotPresent(
    Scheme scheme,
    String platform,
    String contextId,
    KeySequence triggerSequence,
    ParameterizedCommand command) {
  Map<String,String> params = commandParamMap(command);
  Binding binding = find(scheme, platform, triggerSequence, command.getId(), params);
  // If no binding exists, create the user binding, add it and return true.
  if (binding == null) {
    Binding bindingToAdd = createBinding(scheme, platform, contextId, triggerSequence, command);
    addUserBinding(bindingToAdd);
    addedBindings.add(bindingToAdd);
    return;
  }

  /*
   * If a system binding exists for this scheme / sequence, find out if there's a
   * user binding hiding it, and if so remove it.
   */
  if ((binding.getType() == Binding.SYSTEM)) {
    // Finding a user binding to a null command.
    // ZORZELLA: do we even need to supply params?
    Binding userBinding = find(scheme, platform, triggerSequence, null, params, userBindings);
    if (userBinding != null) {
      userBindings.remove(userBinding);
      return;
    }
  }
  return;
}
 
Example 3
Source File: KeyBindingsManualFormatter.java    From workspacemechanic with Eclipse Public License 1.0 5 votes vote down vote up
static BindingType from(int eclipseBindingType) {
  if (eclipseBindingType == Binding.SYSTEM) {
    return SYSTEM;
  } else if (eclipseBindingType == Binding.USER) {
    return USER;
  } else {
    throw new UnsupportedOperationException("Binding type: " + eclipseBindingType);
  }
}
 
Example 4
Source File: BindingModel2.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Removes the <code>bindingElement</code> binding.
 * @param bindingElement
 */
public void remove(BindingElement bindingElement) {
	if (bindingElement == null || !(bindingElement.getModelObject() instanceof Binding)) {
		return;
	}
	KeyBinding keyBinding = (KeyBinding) bindingElement.getModelObject();
	if (keyBinding.getType() == Binding.USER) {
		bindingManager.removeBinding(keyBinding);
	} else {
		KeySequence keySequence = keyBinding.getKeySequence();

		// Add the delete binding
		bindingManager.addBinding(new KeyBinding(keySequence, null, keyBinding.getSchemeId(), keyBinding
				.getContextId(), null, null, null, Binding.USER));

		// Unbind any conflicts affected by the delete binding
		ConflictModel conflictModel = controller.getConflictModel();
		conflictModel.updateConflictsFor(bindingElement);
		Collection conflictsList = conflictModel.getConflicts();
		if (conflictsList != null) {
			Object[] conflicts = conflictsList.toArray();
			for (int i = 0; i < conflicts.length; i++) {
				BindingElement be = (BindingElement) conflicts[i];
				if (be == bindingElement) {
					continue;
				}
				Object modelObject = be.getModelObject();
				if (modelObject instanceof Binding) {
					Binding binding = (Binding) modelObject;
					if (binding.getType() != Binding.SYSTEM) {
						continue;
					}
					ParameterizedCommand pCommand = binding.getParameterizedCommand();
					be.fill(pCommand);
					commandToElement.put(pCommand, be);
				}
			}
		}
	}
	ParameterizedCommand parameterizedCommand = keyBinding.getParameterizedCommand();
	bindingElement.fill(parameterizedCommand);
	commandToElement.put(parameterizedCommand, bindingElement);
	controller.firePropertyChange(this, PROP_CONFLICT_ELEMENT_MAP, null, bindingElement);
}
 
Example 5
Source File: BindingModel2.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Removes the <code>bindingElement</code> binding.
 * @param bindingElement
 */
public void remove(BindingElement bindingElement) {
	if (bindingElement == null || !(bindingElement.getModelObject() instanceof Binding)) {
		return;
	}
	KeyBinding keyBinding = (KeyBinding) bindingElement.getModelObject();
	if (keyBinding.getType() == Binding.USER) {
		bindingManager.removeBinding(keyBinding);
	} else {
		KeySequence keySequence = keyBinding.getKeySequence();

		// Add the delete binding
		bindingManager.addBinding(new KeyBinding(keySequence, null, keyBinding.getSchemeId(), keyBinding
				.getContextId(), null, null, null, Binding.USER));

		// Unbind any conflicts affected by the delete binding
		ConflictModel conflictModel = controller.getConflictModel();
		conflictModel.updateConflictsFor(bindingElement);
		Collection conflictsList = conflictModel.getConflicts();
		if (conflictsList != null) {
			Object[] conflicts = conflictsList.toArray();
			for (int i = 0; i < conflicts.length; i++) {
				BindingElement be = (BindingElement) conflicts[i];
				if (be == bindingElement) {
					continue;
				}
				Object modelObject = be.getModelObject();
				if (modelObject instanceof Binding) {
					Binding binding = (Binding) modelObject;
					if (binding.getType() != Binding.SYSTEM) {
						continue;
					}
					ParameterizedCommand pCommand = binding.getParameterizedCommand();
					be.fill(pCommand);
					commandToElement.put(pCommand, be);
				}
			}
		}
	}
	ParameterizedCommand parameterizedCommand = keyBinding.getParameterizedCommand();
	bindingElement.fill(parameterizedCommand);
	commandToElement.put(parameterizedCommand, bindingElement);
	controller.firePropertyChange(this, PROP_CONFLICT_ELEMENT_MAP, null, bindingElement);
}
 
Example 6
Source File: BindingModel2.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Removes the <code>bindingElement</code> binding.
 * @param bindingElement
 */
public void remove(BindingElement bindingElement) {
	if (bindingElement == null || !(bindingElement.getModelObject() instanceof Binding)) {
		return;
	}
	KeyBinding keyBinding = (KeyBinding) bindingElement.getModelObject();
	if (keyBinding.getType() == Binding.USER) {
		bindingManager.removeBinding(keyBinding);
	} else {
		KeySequence keySequence = keyBinding.getKeySequence();

		// Add the delete binding
		bindingManager.addBinding(new KeyBinding(keySequence, null, keyBinding.getSchemeId(), keyBinding
				.getContextId(), null, null, null, Binding.USER));

		// Unbind any conflicts affected by the delete binding
		ConflictModel conflictModel = controller.getConflictModel();
		conflictModel.updateConflictsFor(bindingElement);
		Collection conflictsList = conflictModel.getConflicts();
		if (conflictsList != null) {
			Object[] conflicts = conflictsList.toArray();
			for (int i = 0; i < conflicts.length; i++) {
				BindingElement be = (BindingElement) conflicts[i];
				if (be == bindingElement) {
					continue;
				}
				Object modelObject = be.getModelObject();
				if (modelObject instanceof Binding) {
					Binding binding = (Binding) modelObject;
					if (binding.getType() != Binding.SYSTEM) {
						continue;
					}
					ParameterizedCommand pCommand = binding.getParameterizedCommand();
					be.fill(pCommand);
					commandToElement.put(pCommand, be);
				}
			}
		}
	}
	ParameterizedCommand parameterizedCommand = keyBinding.getParameterizedCommand();
	bindingElement.fill(parameterizedCommand);
	commandToElement.put(parameterizedCommand, bindingElement);
	controller.firePropertyChange(this, PROP_CONFLICT_ELEMENT_MAP, null, bindingElement);
}