Example #1
0
  @Override
  public Action getPreferredAction() {
    FormEditor formEditor = FormEditor.getFormEditor(component.getFormModel());
    if (formEditor == null) {
      return null;
    }

    for (Action action : formEditor.getDefaultComponentActions()) {
      if (action.isEnabled()) {
        return action;
      }
    }

    return null;
  }
    /**
     * Create the object.
     *
     * @exception IOException if something fails
     */
    public void create() throws IOException {
      RADMenuItemComponent newMenuComp;

      if ((RADMenuItemComponent.recognizeType(item) & MASK_CONTAINER) == 0) {
        newMenuComp = new RADMenuItemComponent();
      } else {
        newMenuComp = new RADMenuComponent();
      }

      newMenuComp.initialize(RADMenuComponent.this.getFormManager());
      newMenuComp.setComponent(item);
      if (newMenuComp instanceof RADMenuComponent) {
        ((RADMenuComponent) newMenuComp).initSubComponents(new RADComponent[0]);
      }
      RADMenuComponent.this
          .getFormManager()
          .addNonVisualComponent(newMenuComp, RADMenuComponent.this);

      // for some components, we initialize their properties with some non-default values
      // e.g. a label on buttons, checkboxes
      FormEditor.defaultMenuInit(newMenuComp);
      addVisualMenu(newMenuComp);

      RADMenuComponent.this.getFormManager().selectComponent(newMenuComp, false);
    }
 /**
  * Display name for the creation action. This should be presented as an item in a menu.
  *
  * @return the name of the action
  */
 public String getName() {
   String s = item.getName();
   if (FormEditor.getFormSettings().getShortBeanNames()) {
     int index = s.lastIndexOf('.');
     if (index != -1) return s.substring(index + 1);
   }
   return s;
 }
    public void mouseReleased(MouseEvent e) {
      if (m_dragging && m_gc != null) {
        if (m_comp_size > 0) {
          int col = m_gc.getColumn() + m_gc.getColumnSpan() - 1;
          GridView view = m_gc.getParentView();
          ColumnSpec oldspec = view.getColumnSpec(col);
          FormEditor editor = FormEditor.getEditor(view);

          if (editor != null) {
            NewSizeAdapter adapter = new NewSizeAdapter(oldspec, m_comp_size, m_units);
            if (!adapter.isResizeGrow() && !adapter.isBoundedSize()) {
              String newspec = FormUtils.toEncodedString(adapter);
              EditColumnSpecCommand cmd =
                  new EditColumnSpecCommand(
                      view.getParentForm(), col, new ColumnSpec(newspec), oldspec);
              CommandUtils.invoke(cmd, editor);
            } else {
              String msg = null;
              if (adapter.isBoundedSize()) {
                msg =
                    I18N.getLocalizedMessage(
                        "The column size is set to bounded.\nYou must manually set the size in the column specification window.");
              } else if (adapter.isResizeGrow()) {
                msg =
                    I18N.getLocalizedMessage(
                        "The column resize behavior is set to grow.\nYou must manually set the size in the column specification window.");
              } else {
                msg =
                    I18N.getLocalizedMessage(
                        "You must manually set the size in the column specification window.");
              }

              String title = I18N.getLocalizedMessage("Error");
              JOptionPane.showMessageDialog(m_view, msg, title, JOptionPane.ERROR_MESSAGE);
            }
          } else {
            assert (false);
          }
        }

        javax.swing.SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                m_overlay.setResizeIndicator(null);
                m_overlay.repaint();
                m_dragging = false;
                update(m_gc);
              }
            });
      }
    }
 private static FormDesigner getDesigner(RADComponent comp) {
   return FormEditor.getFormDesigner(comp.getFormModel());
 }
 /**
  * Display name for the creation action. This should be presented as an item in a menu.
  *
  * @return the name of the action
  */
 public String getName() {
   return FormEditor.getFormBundle().getString("CTL_separator");
 }
Example #7
0
  @Override
  public Action[] getActions(boolean context) {
    if (actions == null) {
      List<Action> actions = new ArrayList<Action>(20);
      RADComponent topComp = component.getFormModel().getTopRADComponent();

      if (component.isReadOnly()) {
        if (component == topComp) {
          actions.add(SystemAction.get(TestAction.class));
          actions.add(null);
        }
        Event[] events = component.getKnownEvents();
        for (int i = 0; i < events.length; i++) {
          if (events[i].hasEventHandlers()) {
            actions.add(SystemAction.get(EventsAction.class));
            actions.add(null);
            break;
          }
        }

        actions.add(SystemAction.get(CopyAction.class));
      } else {
        if (InPlaceEditLayer.supportsEditingFor(component.getBeanClass(), false)) {
          actions.add(SystemAction.get(InPlaceEditAction.class));
        }
        if (javax.swing.JTable.class.isAssignableFrom(component.getBeanClass())) {
          actions.add(SystemAction.get(CustomizeTableAction.class));
        }
        if (component != topComp) {
          actions.add(SystemAction.get(ChangeVariableNameAction.class));
        } else {
          actions.add(SystemAction.get(TestAction.class));
        }
        if (FormEditor.getBindingSupport(component.getFormModel()) != null) {
          // zxb:删除掉绑定菜单项。
          // actions.add(SystemAction.get(BindAction.class));
        }
        actions.add(SystemAction.get(EventsAction.class));
        actions.add(null);

        java.util.List actionProps = component.getActionProperties();
        Iterator iter = actionProps.iterator();
        while (iter.hasNext()) {
          final RADProperty prop = (RADProperty) iter.next();
          Action action = PropertyAction.createIfEditable(prop);
          if (action != null) {
            actions.add(action);
          }
        }
        addSeparator(actions);

        if (component instanceof ComponentContainer) {
          addContainerActions(actions);
          addLayoutActions(actions);
        } else {
          addLayoutActions(actions);
          addContainerActions(actions);
        }
        if (component != topComp) {
          actions.add(SystemAction.get(MoveUpAction.class));
          actions.add(SystemAction.get(MoveDownAction.class));
        }
        if (component instanceof ComponentContainer) {
          actions.add(SystemAction.get(ReorderAction.class));
        }
        addSeparator(actions);

        if (component != topComp) {
          actions.add(SystemAction.get(CutAction.class));
        }
        actions.add(SystemAction.get(CopyAction.class));
        if (component instanceof ComponentContainer) {
          actions.add(SystemAction.get(PasteAction.class));
        }
        if (component != topComp) {
          actions.add(SystemAction.get(DuplicateAction.class));
          actions.add(SystemAction.get(DeleteAction.class));
        }

        actions.add(null);
        // zxb:删除掉自定义代码菜单项。
        // actions.add(SystemAction.get(CustomCodeAction.class));
      }
      actions.add(null);

      javax.swing.Action[] superActions = super.getActions(context);
      for (int i = 0; i < superActions.length; i++) actions.add(superActions[i]);

      this.actions = new Action[actions.size()];
      actions.toArray(this.actions);
    }
    return actions;
  }
 /**
  * @see FormEditor#setAsText(String)
  * @verifies set using uuid
  */
 @Test
 public void setAsText_shouldSetUsingUuid() throws Exception {
   FormEditor editor = new FormEditor();
   editor.setAsText("d9218f76-6c39-45f4-8efa-4c5c6c199f50");
   Assert.assertNotNull(editor.getValue());
 }
 /**
  * @see FormEditor#setAsText(String)
  * @verifies set using id
  */
 @Test
 public void setAsText_shouldSetUsingId() throws Exception {
   FormEditor editor = new FormEditor();
   editor.setAsText("1");
   Assert.assertNotNull(editor.getValue());
 }