Пример #1
0
  private void initView() {
    // create widgets
    name =
        new TextAdapter(new JTextField()) {

          @Override
          protected void updateModel(String text) {
            setQueryName(text);
          }
        };

    queryRoot = Application.getWidgetFactory().createComboBox();
    AutoCompletion.enable(queryRoot);
    queryRoot.setRenderer(CellRenderers.listRendererWithIcons());

    qualifier =
        new ValidatorTextAdapter(new JTextField()) {

          @Override
          protected void updateModel(String text) {
            setQueryQualifier(text);
          }

          @Override
          protected void validate(String text) throws ValidationException {
            createQualifier(text);
          }
        };

    distinct = new JCheckBox();

    properties = new ObjectQueryPropertiesPanel(mediator);

    // assemble
    CellConstraints cc = new CellConstraints();
    FormLayout layout =
        new FormLayout(
            "right:max(80dlu;pref), 3dlu, fill:200dlu", "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();

    builder.addSeparator("SelectQuery Settings", cc.xywh(1, 1, 3, 1));
    builder.addLabel("Query Name:", cc.xy(1, 3));
    builder.add(name.getComponent(), cc.xy(3, 3));
    builder.addLabel("Query Root:", cc.xy(1, 5));
    builder.add(queryRoot, cc.xy(3, 5));
    builder.addLabel("Qualifier:", cc.xy(1, 7));
    builder.add(qualifier.getComponent(), cc.xy(3, 7));
    builder.addLabel("Distinct:", cc.xy(1, 9));
    builder.add(distinct, cc.xy(3, 9));

    this.setLayout(new BorderLayout());
    this.add(builder.getPanel(), BorderLayout.NORTH);
    this.add(properties, BorderLayout.CENTER);
  }
Пример #2
0
  private void initView() {
    this.setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar();
    ActionManager actionManager = Application.getInstance().getActionManager();
    toolBar.add(actionManager.getAction(CreateAttributeAction.class).buildButton());

    add(toolBar, BorderLayout.NORTH);

    className =
        new TextAdapter(new JTextField()) {

          @Override
          protected void updateModel(String text) {
            setClassName(text);
          }
        };

    FormLayout layout = new FormLayout("right:50dlu, 3dlu, fill:150dlu, 3dlu, fill:100", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    builder.append("Class Name:", className.getComponent(), 3);

    add(builder.getPanel(), BorderLayout.CENTER);
  }
Пример #3
0
  /**
   * Updates the view from the current model state. Invoked when a currently displayed query is
   * changed.
   */
  void initFromModel() {
    Query query = mediator.getCurrentQuery();

    if (!(query instanceof SelectQuery)) {
      setVisible(false);
      return;
    }

    SelectQuery selectQuery = (SelectQuery) query;

    name.setText(query.getName());
    distinct.setSelected(selectQuery.isDistinct());
    qualifier.setText(
        selectQuery.getQualifier() != null ? selectQuery.getQualifier().toString() : null);

    // init root choices and title label..

    // - SelectQuery supports ObjEntity roots

    // TODO: now we only allow roots from the current map,
    // since query root is fully resolved during map loading,
    // making it impossible to reference other DataMaps.

    DataMap map = mediator.getCurrentDataMap();
    Object[] roots = map.getObjEntities().toArray();

    if (roots.length > 1) {
      Arrays.sort(roots, Comparators.getDataMapChildrenComparator());
    }

    DefaultComboBoxModel model = new DefaultComboBoxModel(roots);
    model.setSelectedItem(selectQuery.getRoot());
    queryRoot.setModel(model);

    properties.initFromModel(selectQuery);

    setVisible(true);
  }
Пример #4
0
  public void undo() throws CannotUndoException {
    restoreSelections();

    listener.finishCurrentEdit();

    if (canUndo()) {
      super.undo();
    } else {
      die();
    }

    if (adapter != null) {
      adapter.updateModel();
    }

    editor.requestFocusInWindow();
    editor.selectAll();
  }
Пример #5
0
 private void initFromModel(Embeddable embeddable) {
   className.setText(embeddable.getClassName());
 }
Пример #6
0
 public TextCompoundEdit(TextAdapter adapter, JTextFieldUndoListener listener) {
   this(adapter.getComponent(), listener);
   this.adapter = adapter;
 }