Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.togethersoft.openapi.ide.command
Class IdeCommandConstraints

    com.togethersoft.openapi.util.properties.DictionaryProperties
      |
      +--com.togethersoft.openapi.ide.command.IdeCommandConstraints

public class IdeCommandConstraints
extends DictionaryProperties

Defines the domain of applicability for the command item (`IdeCommandItem` or `IdeCommandGroup`).

`IdeCommandConstraints()` constructor creates an "empty" constraint object which doesn't define any constraints for the command item.

The string in `IdeCommandConstraints(String)` constructor contains the constraints separated with a comma. A constraint is a string "nameOfTheConstraint = value" pair. This class contains a set of constants with the possible names of constraints:

- For command item being inserted into popup menus and diagram toolbars `context` constraint (this name is defined by the CONTEXT constant) defines the kind of objects for which the command item will appear. Possible values for this constraint are:
  1. `element` (defined in the ELEMENT_CONTEXT constant) - the command item will appear for elements.
  2. `file` (defined in the FILE_CONTEXT constant) - the command item will appear for files.
  3. `textEditor` (defined in the TEXT_EDITOR_CONTEXT constant) - the command item will appear in text editor.
- For command items whose `context` constraint is `element`, the `shapeType` constraint (this name is defined by the SHAPE_TYPE constant) defines the shape type of element the command item will appear for. For diagram toolbar command item this constraint must contain the shape type of the diagram. Some of shape types values are defined in RwiShapeType interface.

  For example,

      new IdeCommandConstraints("context=element, shapeType="+RwiShapeType.CLASS)

  will create a constraint that makes command item appear only for elements with the shape types of CLASS.

- For command items whose `context` constraint is `file` (this value is defined by the FILE_CONTEXT constant) or `textEditor` (TEXT_EDITOR_CONTEXT constant), the `fileCategory` constraint (this name is defined by the FILE_CATEGORY constant) defines the category of file the command item will appear for. The values should be taken from the resource.config file (for example, `java_class, java_source, cpp_source, cpp_header, diagram, project, config, text_file` etc.)

  For example,

      new IdeCommandConstraints("context=file, fileCategory=java_source, fileCategory=text_file")

  will create a constraint that makes command item appear only for java sources and all supported kinds of text files.

      new IdeCommandConstraints("context=textEditor, fileCategory=java_source")

  will create a constraint that makes command item appear in the text editor only for java sources.

- `placeBefore` constraint (this name is defined by the PLACE_BEFORE constant) specifies before which command item this command item will be inserted. The value is the string ID of the anchor command item (the ID is assigned at the moment of creation in the method IdeCommandManager.createItem).

- `placeAfter` constraint (this name is defined by the PLACE_AFTER constant) specifies after which command item this command item will be inserted. The value is the string ID of the anchor command item.

- `parent` constraint (this name is defined by the PARENT constant) specifies the group this command item will be inserted into. The value is the string ID of the group.

  For example:

        IdeCommandManager cman=IdeCommandManagerAccess.getCommandManager();
        IdeCommandGroup myGroup=cman.createGroup("IDOfTheGroup",new IdeCommandConstraints("context = element, location=popupMenu"), new IdeCommandAdapter());
        IdeCommandItem myItem=cman.createItem("IDOfTheItem",new IdeCommandConstraints("context = element, parent=IDOfTheGroup, location=popupMenu"),new IdeCommandAdapter());

  (this code creates an item "My menu" with a submenu "Generate code" in a popup menu for elements.)

- `location` constraint (this name is defined by the LOCATION constant) specifies where the command item will be located. Possible values are defined in the constants MAIN_TOOLBAR_LOCATION (main toolbar), MAIN_MENU_LOCATION (main menu), POPUP_MENU_LOCATION (popup menu). For example:

       new IdeCommandConstraints("context=element, shapeType="+RwiShapeType.CLASS+", parent=IDOfTheParent, location=popupMenu")

In previous examples we directly used the values of constraints defined in this interface. Of course, it is possible to write it in the right style (the last example):

     IdeCommandContraints rightWayIsTough = new IdeCommandConstraints(IdeCommandConstraints.CONTEXT+"="+IdeCommandConstraints.ELEMENT+","+IdeCommandConstraints.SHAPE_TYPE+"="+RwiShapeType.CLASS+","+IdeCommandConstraints.PARENT+"=IDOfTheParent,"+IdeCommandConstraints.LOCATION+"="+IdeCommandConstraints.POPUP_MENU_LOCATION); // 8=)

Author:
  TogetherSoft
See Also: IdeCommandManager.createItem(java.lang.String,com.togethersoft.openapi.ide.command.IdeCommandConstraints,com.togethersoft.openapi.ide.command.IdeCommandListener), IdeCommandManager.createGroup(java.lang.String,com.togethersoft.openapi.ide.command.IdeCommandConstraints,com.togethersoft.openapi.ide.command.IdeCommandCheckListener), IdeCommandItem

Field Summary
`final static String` | `CONTEXT` The value is `"context"`.
`final static String` | `ELEMENT_CONTEXT` The value is `"element"`.
`final static String` | `EXTENSION`
`final static String` | `FILE_CATEGORY` The value is `"fileCategory"`.
`final static String` | `FILE_CONTEXT` The value is `"file"`.
`final static String` | `LOCATION` The value is `"location"`.
`final static String` | `MAIN_MENU_LOCATION` The value is `"mainMenu"`.
`final static String` | `MAIN_TOOLBAR_LOCATION` The value is `"mainToolbar"`.
`final static String` | `PARENT` The value is `"parent"`.
`final static String` | `PLACE_AFTER` The value is `"placeAfter"`.
`final static String` | `PLACE_BEFORE` The value is `"placeBefore"`.
`final static String` | `POPUP_MENU_LOCATION` The value is `"popupMenu"`.
`final static String` | `SHAPE_TYPE` The value is `"shapeType"`.
`final static String` | `TEXT_EDITOR_CONTEXT` The value is `"textEditor"`.

Constructor Summary
`IdeCommandConstraints()` `IdeCommandConstraints()` constructor creates an "empty" constraint object which doesn't define any constraints for the command item.
`IdeCommandConstraints(String values)` Creates a constraint object.

Methods inherited from class com.togethersoft.openapi.util.properties.DictionaryProperties
`addPropertyChangeListener, addVetoableChangeListener, clear, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getImplementation, getProperty, propertyNames, putProperty, removePropertyChangeListener, removeVetoableChangeListener`

Field Detail

### CONTEXT

    public final static String CONTEXT

  The value is `"context"`.

### ELEMENT_CONTEXT

    public final static String ELEMENT_CONTEXT

  The value is `"element"`.

### EXTENSION

    public final static String EXTENSION

### FILE_CATEGORY

    public final static String FILE_CATEGORY

  The value is `"fileCategory"`.

### FILE_CONTEXT

    public final static String FILE_CONTEXT

  The value is `"file"`.

### LOCATION

    public final static String LOCATION

  The value is `"location"`.

### MAIN_MENU_LOCATION

    public final static String MAIN_MENU_LOCATION

  The value is `"mainMenu"`.

### MAIN_TOOLBAR_LOCATION

    public final static String MAIN_TOOLBAR_LOCATION

  The value is `"mainToolbar"`.

### PARENT

    public final static String PARENT

  The value is `"parent"`.

### PLACE_AFTER

    public final static String PLACE_AFTER

  The value is `"placeAfter"`.

### PLACE_BEFORE

    public final static String PLACE_BEFORE

  The value is `"placeBefore"`.

### POPUP_MENU_LOCATION

    public final static String POPUP_MENU_LOCATION

  The value is `"popupMenu"`.

### SHAPE_TYPE

    public final static String SHAPE_TYPE

  The value is `"shapeType"`.

### TEXT_EDITOR_CONTEXT

    public final static String TEXT_EDITOR_CONTEXT

  The value is `"textEditor"`.

Constructor Detail

### IdeCommandConstraints

    public IdeCommandConstraints()

  `IdeCommandConstraints()` constructor creates an "empty" constraint object which doesn't define any constraints for the command item.

### IdeCommandConstraints

    public IdeCommandConstraints(String values)

  Creates a constraint object. See the description of this interface for details.
  Parameters:
    values - `String` of comma-delimited constraints

Association Links

to Class java.lang.String

  The value is `"location"`.

to Class java.lang.String

  The value is `"mainMenu"`.

to Class java.lang.String

  The value is `"mainToolbar"`.

to Class java.lang.String

  The value is `"popupMenu"`.

to Class java.lang.String

  The value is `"placeBefore"`.

to Class java.lang.String

  The value is `"placeAfter"`.

to Class java.lang.String

  The value is `"parent"`.

to Class java.lang.String

  The value is `"context"`.

to Class java.lang.String

  The value is `"element"`.

to Class java.lang.String

  The value is `"file"`.

to Class java.lang.String

  The value is `"textEditor"`.

to Class java.lang.String

  The value is `"shapeType"`.

to Class java.lang.String

to Class java.lang.String

  The value is `"fileCategory"`.

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD