コード例 #1
0
  protected void layOutPropertyPanel(int deviceTypes, SWTList rowRenderer) {
    Composite propertiesComposite = editor.getSWTPropertiesComposite();

    addHandOnKeyboardToStart(deviceTypes, propertiesComposite);

    frameList = rowRenderer;
    frameList.setTable(
        new Table(propertiesComposite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION));

    demonstrateScriptButton = new Button(propertiesComposite, SWT.NONE);
    demonstrateScriptButton.setText(startDemonstratingLabel);
    shell.setDefaultButton(demonstrateScriptButton);
    demonstrateScriptButton.addSelectionListener(
        new SWTWidgetChangeHandler(SEFrameChooserLID.OpenScriptEditor));

    lIDMap.addWidget(
        SEFrameChooserLID.OpenScriptEditor, demonstrateScriptButton, ListenerIdentifierMap.NORMAL);

    closeButton = new Button(propertiesComposite, SWT.NONE);
    closeButton.setText(L10N.get("SE.Close", "Close"));
    closeButton.addSelectionListener(new SWTWidgetChangeHandler(CogToolLID.CloseWindow));

    propertiesComposite.setLayout(new FormLayout());

    // First thing resides at the top
    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 5);
    data.right = new FormAttachment(100, 0);

    positionStartLocParms(data);

    frameList.getTable().setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 5);
    demonstrateScriptButton.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(demonstrateScriptButton, 0, SWT.TOP);
    data.left = new FormAttachment(demonstrateScriptButton, 5, SWT.RIGHT);
    data.bottom = new FormAttachment(100, 0);
    closeButton.setLayoutData(data);

    SashUtility.createVerticalSash(
        editor.bodyComposite,
        FRAME_LIST_WIDTH,
        250,
        SWT.RIGHT,
        propertiesComposite,
        editor.getPropFormData(),
        editor.scrollComposite,
        editor.getScrollFormData());
  }
コード例 #2
0
ファイル: EditActionCmd.java プロジェクト: RimiChen/cogtool
  /**
   * Check that the given action is not the same as that of another transition from the given
   * source, where the other transition is different from the given transition. Thus, if checking
   * when creating a new transition, the given currentTransition will be <code>null</code>.
   * Otherwise, when modifying the action of an existing transition, currentTransition should be
   * that transition.
   *
   * @param source the transition source widget/device in which the new action must be unique
   * @param action the initial action value to test
   * @param propertiess the default values for the interaction dialog box for specifying action
   *     property changes
   * @param deviceTypes the device types currently available to allow for different action
   *     possibilities when not unique
   * @param limitMode the limit on which device types can actually be used for selecting different
   *     action possibilities when not unique
   * @param currentTransition the transition that the new action value should be attached to; use
   *     <code>null</code> when creating a new transition
   * @param interaction the way to interact with the user
   * @return the created action that is not in conflict, or <code>null</code> if the user requests a
   *     cancel of the current operation
   * @author mlh
   */
  public static AAction ensureActionIsUnique(
      TransitionSource source,
      AAction action,
      ActionProperties properties,
      int deviceTypes,
      int limitMode,
      Transition currentTransition,
      ActionInteraction interaction) {
    // Check if given action has a transition on the given source
    Transition actionTransition = source.getTransition(action);

    // If not unique on this source, complain and try to get new parms.
    // To be unique, the found transition either must not exist (be null)
    // or must be the (existing) transition for the given action.
    while ((actionTransition != null) && (actionTransition != currentTransition)) {
      if (!interaction.determineNewAction(
          properties,
          deviceTypes,
          limitMode,
          action,
          source,
          currentTransition,
          L10N.get("DE.ChangeActionType", "Change Action Type"))) {
        return null; // user canceled operation
      }

      // Not canceled; build the action specified
      action = buildActionFromProperties(properties, deviceTypes, limitMode, interaction);

      // Building the action may also interact with the user
      // (such as when text is improperly specified as empty);
      // the user may have requested a cancel; if so, propagate.
      if (action == null) {
        return null;
      }

      // A "legal" Action successfully created;
      // check for uniqueness again!
      actionTransition = source.getTransition(action);
    }

    // A "legal" and non-conflicting action was created; return!
    return action;
  } // ensureActionIsUnique
コード例 #3
0
  protected void layOutView(Shell parent) {
    title = new Label(parent, SWT.CENTER);
    title.setText(L10N.get("SE.PickStartFrame", "Select the Start Frame for this Script"));
    // Increase the size of the instruction line.
    // TODO:mlh fix this (use FontUtils?)!
    FontData font = new FontData("Lucida Grande", 18, 0);
    title.setFont(new Font(null, font));

    // Set up the layouts

    FormData data = new FormData();
    data.top = new FormAttachment(title, 0, SWT.CENTER);
    data.right = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 0);
    title.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(title, 5, SWT.BOTTOM);
    data.bottom = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 5);
    data.right = new FormAttachment(100, 0);
    editor.setLayoutData(data);
  }
コード例 #4
0
public class SEFrameChooserView extends ScriptView {
  protected Composite structureView;

  protected SWTList frameList;

  protected Button demonstrateScriptButton;
  protected Button closeButton;
  protected Label title;

  public static final int MIN_WIDTH = 500;
  public static final int MIN_HEIGHT = 300;
  public static final int FRAME_LIST_WIDTH = 250;

  protected static final String startDemonstratingLabel =
      L10N.get("SE.DemonstrateScript", "Start Demonstrating");

  public static final SimpleMenuItemDefinition START_DEMONSTRATION =
      new SimpleMenuItemDefinition(startDemonstratingLabel, SEFrameChooserLID.OpenScriptEditor);

  /**
   * Return the list of needed menus This is to handle macos which is only supposed to show a
   * limited set of specific menus.
   */
  @Override
  protected MenuType[] neededMenus() {
    return new MenuFactory.MenuType[] {
      MenuFactory.MenuType.FileMenu,
      MenuFactory.MenuType.EditMenu,
      MenuFactory.MenuType.ZoomModifyMenu,
      // TODO: script menu?
      MenuFactory.MenuType.WindowMenu,
      MenuFactory.MenuType.HelpMenu
    };
  }

  /**
   * @param windowShell
   * @param listenerIDMap
   * @param transformer
   */
  public SEFrameChooserView(
      int deviceTypes,
      ListenerIdentifierMap listenerIDMap,
      ILIDTransmuter transformer,
      MenuFactory.IWindowMenuData<Project> menuData,
      CogToolScalableFigure contents,
      IFlatDraw2DMouseMotionListener motionL,
      Draw2DContextMenuUtil.MenuListener clickL,
      SWTList rowRenderer,
      Zoomable zoomer,
      Rectangle loc) {
    super(listenerIDMap, transformer, menuData, loc, DEFAULT_WIDTH, DEFAULT_HEIGHT);

    shell.setMinimumSize(MIN_WIDTH, MIN_HEIGHT);

    FormLayout propertiesLayout = new FormLayout();
    shell.setLayout(propertiesLayout);

    editor =
        new InteractionDrawingEditor(
            contents,
            motionL,
            clickL,
            getShell(),
            zoomer,
            FRAME_LIST_WIDTH,
            SWT.LEFT,
            0,
            WindowUtil.getCursor(WindowUtil.SELECT_CURSOR));

    layOutView(shell);
    layOutPropertyPanel(deviceTypes, rowRenderer);

    editor.getSWTEditorSubstrate().addListener(SWT.MenuDetect, clickL);

    frameList.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent evt) {
            TableItem i = (TableItem) evt.item;
            performAction(CogToolLID.SetStartFrame, i.getData(), true);
            //                    selection.setSelectedFrame((Frame) i.getData());
          }

          public void widgetDefaultSelected(SelectionEvent evt) {
            performAction(SEFrameChooserLID.OpenScriptEditor);
          }
        });

    // Listen to Menu events on the History table.
    // Used to detect context click on the selected row.
    frameList.addListener(
        SWT.MenuDetect,
        new Listener() {
          public void handleEvent(Event arg0) {
            // xyzzy TODO: must select/deselect by pos! for Mac (unless selection occurs before
            // menudetect!
            showFrameListMenu();
          }
        });
  }

  protected void positionStartLocParms(FormData data) {
    if (mouseHandStartLoc != null) {
      FormData handLayoutData = new FormData();
      handLayoutData.bottom = new FormAttachment(demonstrateScriptButton, -5, SWT.TOP);
      handLayoutData.left = new FormAttachment(userMouseHand, 0, SWT.LEFT);
      handLayoutData.right = new FormAttachment(100, 0);

      mouseHandStartLoc.setLayoutData(handLayoutData);

      data.bottom = new FormAttachment(userMouseHand, -5, SWT.TOP);
    } else {
      data.bottom = new FormAttachment(demonstrateScriptButton, -5, SWT.TOP);
    }
  }

  public void resetDeviceTypes(int newDeviceTypes) {
    Composite propertiesComposite = editor.getSWTPropertiesComposite();

    addHandOnKeyboardToStart(newDeviceTypes, propertiesComposite);
    positionStartLocParms((FormData) frameList.getTable().getLayoutData());
    propertiesComposite.layout();
  }

  protected void layOutPropertyPanel(int deviceTypes, SWTList rowRenderer) {
    Composite propertiesComposite = editor.getSWTPropertiesComposite();

    addHandOnKeyboardToStart(deviceTypes, propertiesComposite);

    frameList = rowRenderer;
    frameList.setTable(
        new Table(propertiesComposite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION));

    demonstrateScriptButton = new Button(propertiesComposite, SWT.NONE);
    demonstrateScriptButton.setText(startDemonstratingLabel);
    shell.setDefaultButton(demonstrateScriptButton);
    demonstrateScriptButton.addSelectionListener(
        new SWTWidgetChangeHandler(SEFrameChooserLID.OpenScriptEditor));

    lIDMap.addWidget(
        SEFrameChooserLID.OpenScriptEditor, demonstrateScriptButton, ListenerIdentifierMap.NORMAL);

    closeButton = new Button(propertiesComposite, SWT.NONE);
    closeButton.setText(L10N.get("SE.Close", "Close"));
    closeButton.addSelectionListener(new SWTWidgetChangeHandler(CogToolLID.CloseWindow));

    propertiesComposite.setLayout(new FormLayout());

    // First thing resides at the top
    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 5);
    data.right = new FormAttachment(100, 0);

    positionStartLocParms(data);

    frameList.getTable().setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 5);
    demonstrateScriptButton.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(demonstrateScriptButton, 0, SWT.TOP);
    data.left = new FormAttachment(demonstrateScriptButton, 5, SWT.RIGHT);
    data.bottom = new FormAttachment(100, 0);
    closeButton.setLayoutData(data);

    SashUtility.createVerticalSash(
        editor.bodyComposite,
        FRAME_LIST_WIDTH,
        250,
        SWT.RIGHT,
        propertiesComposite,
        editor.getPropFormData(),
        editor.scrollComposite,
        editor.getScrollFormData());
  }

  protected void layOutView(Shell parent) {
    title = new Label(parent, SWT.CENTER);
    title.setText(L10N.get("SE.PickStartFrame", "Select the Start Frame for this Script"));
    // Increase the size of the instruction line.
    // TODO:mlh fix this (use FontUtils?)!
    FontData font = new FontData("Lucida Grande", 18, 0);
    title.setFont(new Font(null, font));

    // Set up the layouts

    FormData data = new FormData();
    data.top = new FormAttachment(title, 0, SWT.CENTER);
    data.right = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 0);
    title.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(title, 5, SWT.BOTTOM);
    data.bottom = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 5);
    data.right = new FormAttachment(100, 0);
    editor.setLayoutData(data);
  }

  protected static final int STANDARD_MENU = 0;
  protected static final int POSITIONAL_MENU = 1;
  protected static final int FRAME_LIST_MENU = 2;

  protected static final MenuItemDefinition[] STANDARD_ITEMS =
      new MenuItemDefinition[] {
        MenuFactory.ZOOM_IN, MenuFactory.ZOOM_OUT, MenuFactory.ZOOM_NORMAL, MenuFactory.ZOOM_FIT
      };

  protected static final MenuItemDefinition[] POSITIONAL_ITEMS =
      new MenuItemDefinition[] {
        START_DEMONSTRATION,
        MenuUtil.SEPARATOR,
        MenuFactory.ZOOM_IN,
        MenuFactory.ZOOM_OUT,
        MenuFactory.ZOOM_NORMAL,
        MenuFactory.ZOOM_FIT
      };

  protected static final MenuItemDefinition[] FRAME_LIST_ITEMS =
      new MenuItemDefinition[] {START_DEMONSTRATION};

  /**
   * Returns the set of context menus used by the view
   *
   * @return the context menus
   */
  @Override
  public MenuItemDefinition[][] getContextMenuDefinitions() {
    return new MenuItemDefinition[][] {STANDARD_ITEMS, POSITIONAL_ITEMS, FRAME_LIST_ITEMS};
  }

  public void showStandardMenu() {
    contextMenus.getMenu(STANDARD_MENU).setVisible(true);
  }

  public void showPositionalMenu() {
    contextMenus.getMenu(POSITIONAL_MENU).setVisible(true);
  }

  public void showFrameListMenu() {
    contextMenus.getMenu(FRAME_LIST_MENU).setVisible(true);
  }

  /**
   * Make FrameList available to other objects for adding listeners
   *
   * @return
   */
  public SWTList getFrameList() {
    return frameList;
  }

  @Override
  public void dispose() {
    frameList.dispose();

    super.dispose();
  }

  public void setStartDemonstrationButtonSelected(boolean selected) {
    demonstrateScriptButton.setEnabled(selected);
  }
}