Ejemplo n.º 1
0
  private void setDataObject(DataObject dataObject) {
    this.dataObject = dataObject;
    refreshObjectSelector(dataObject);

    // We create a new selection model due to a bug found in GWT when we change e.g. from one data
    // object with 9 rows
    // to one with 3 rows and the table was sorted.
    // Several tests has been done and the final workaround (not too bad) we found is to
    // 1) sort the table again
    // 2) create a new selection model
    // 3) populate the table with new items
    // 3) select the first row
    SingleSelectionModel selectionModel2 = new SingleSelectionModel<ObjectProperty>();
    dataObjectPropertiesTable.setSelectionModel(selectionModel2);

    selectionModel2.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {

          @Override
          public void onSelectionChange(SelectionChangeEvent event) {
            ObjectProperty selectedProperty =
                ((SingleSelectionModel<ObjectProperty>)
                        dataObjectPropertiesTable.getSelectionModel())
                    .getSelectedObject();
            notifyFieldSelected(selectedProperty);
          }
        });

    List<ObjectProperty> dataObjectProperties =
        (dataObject != null)
            ? DataModelerUtils.getManagedProperties(dataObject)
            : Collections.<ObjectProperty>emptyList();

    ArrayList<ObjectProperty> sortBuffer = new ArrayList<ObjectProperty>();
    if (dataObject != null) {
      sortBuffer.addAll(dataObjectProperties);
    }
    Collections.sort(sortBuffer, new ObjectPropertyComparator("name"));

    dataObjectPropertiesProvider.getList().clear();
    dataObjectPropertiesProvider.getList().addAll(sortBuffer);
    dataObjectPropertiesProvider.flush();
    dataObjectPropertiesProvider.refresh();

    dataObjectPropertiesTable
        .getColumnSortList()
        .push(new ColumnSortList.ColumnSortInfo(dataObjectPropertiesTable.getColumn(2), true));

    if (dataObjectProperties.size() > 0) {
      dataObjectPropertiesTable.setKeyboardSelectedRow(0);
      selectionModel2.setSelected(sortBuffer.get(0), true);
    }

    // set the first row selected again. Sounds crazy, but's part of the workaround, don't remove
    // this line.
    if (dataObjectProperties.size() > 0) {
      dataObjectPropertiesTable.setKeyboardSelectedRow(0);
    }
  }
Ejemplo n.º 2
0
 public void select(String key) {
   for (Property property : dataProvider.getList()) {
     if (property.getName().equals(key)) {
       selectionModel.setSelected(property, true);
       break;
     }
   }
 }
Ejemplo n.º 3
0
    public SingletonDialog(Set<String> singletonTypes, final SimpleCallback callback) {
      super(Console.CONSTANTS.selectResourceType());

      // Create a CellList that uses the cell.
      cellList =
          new CellList<String>(
              new TextCell() {
                @Override
                public void render(Context context, String data, SafeHtmlBuilder sb) {
                  String cssName =
                      (context.getIndex() % 2 > 0)
                          ? "combobox-item combobox-item-odd"
                          : "combobox-item";

                  if (data.equals(selectionModel.getSelectedObject()))
                    cssName += " combobox-item-selected";

                  sb.append(TEMPLATE.item(cssName, data));
                }
              });

      cellList.setStyleName("fill-layout-width");
      selectionModel = new SingleSelectionModel<String>();

      cellList.setSelectionModel(selectionModel);
      cellList.setRowCount(singletonTypes.size(), true);
      ArrayList<String> values = new ArrayList<String>(singletonTypes);
      cellList.setRowData(0, values);

      selectionModel.setSelected(values.get(0), true);

      VerticalPanel panel = new VerticalPanel();
      panel.setStyleName("fill-layout-width");
      panel.add(cellList.asWidget());
      Widget widget =
          new WindowContentBuilder(
                  panel,
                  new DialogueOptions(
                      Console.CONSTANTS.common_label_continue(),
                      new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {

                          SingletonDialog.this.hide();
                          callback.onSuccess(selectionModel.getSelectedObject());
                        }
                      },
                      Console.CONSTANTS.common_label_cancel(),
                      new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                          SingletonDialog.this.hide();
                        }
                      }))
              .build();

      setWidget(widget);
    }
 /* (non-Javadoc)
  * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#removeNode()
  */
 @Override
 public void removeNode() {
   if (selectedNode != null) {
     CellTreeNode parent = selectedNode.getParent();
     parent.removeChild(selectedNode);
     closeParentOpenNodes(cellTree.getRootTreeNode());
     selectionModel.setSelected(parent, true);
   }
 }
 /* (non-Javadoc)
  * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#paste()
  */
 @Override
 public void paste() {
   if (selectedNode != null) {
     CellTreeNode pasteNode = copiedNode.cloneNode();
     selectedNode.appendChild(pasteNode);
     closeSelectedOpenNodes(cellTree.getRootTreeNode());
     selectionModel.setSelected(selectedNode, true);
     copiedNode = pasteNode;
   }
 }
 /* (non-Javadoc)
  * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#addNode(java.lang.String, java.lang.String, short)
  */
 @Override
 public CellTreeNode addNode(String value, String label, short nodeType) {
   CellTreeNode childNode = null;
   if ((selectedNode != null)
       && (value != null)
       && (value.trim().length() > 0)) { // if nodeTex textbox is not empty
     childNode = selectedNode.createChild(value, label, nodeType);
     closeSelectedOpenNodes(cellTree.getRootTreeNode());
     selectionModel.setSelected(selectedNode, true);
   }
   return childNode;
 }
 /**
  * On right click.
  *
  * @param value the value
  * @param event the event
  * @param element the element
  */
 public void onRightClick(CellTreeNode value, Event event, Element element) {
   clearMessages();
   selectedNode = value;
   selectionModel.setSelected(selectedNode, true);
   int x = element.getAbsoluteRight() - 10;
   int y = element.getAbsoluteBottom() + 5;
   popupPanel.setPopupPosition(x, y);
   popupPanel.setAnimationEnabled(true);
   //		popupPanel.setSize("175px", "75px");
   popupPanel.show();
   popupPanel.setStyleName("popup");
   clauseWorkspaceContextMenu.displayMenuItems(popupPanel);
 }
Ejemplo n.º 8
0
  private void onProblemSelected(Problem selectedProblem) {
    ProblemAndSubmissionReceipt[] data = page.getSession().get(ProblemAndSubmissionReceipt[].class);
    SingleSelectionModel<? super ProblemAndSubmissionReceipt> sm =
        (SingleSelectionModel<? super ProblemAndSubmissionReceipt>) cellTable.getSelectionModel();
    for (ProblemAndSubmissionReceipt p : data) {
      if (p.getProblem().getProblemId().equals(selectedProblem.getProblemId())) {
        // Found the selected problem, so change the selected row
        sm.clear();
        sm.setSelected(p, true);
        return;
      }
    }

    // The selected problem isn't being viewed currently,
    // so just clear the selection
    sm.clear();
  }
Ejemplo n.º 9
0
 @Override
 public void setValue(E value) {
   selectionModel.setSelected(value, true);
 }
 /* (non-Javadoc)
  * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#refreshCellTreeAfterAdding(mat.client.clause.clauseworkspace.model.CellTreeNode)
  */
 @Override
 public void refreshCellTreeAfterAdding(CellTreeNode selectedNode) {
   closeSelectedOpenNodes(cellTree.getRootTreeNode());
   selectionModel.setSelected(selectedNode, true);
 }