Search in sources :

Example 6 with ModelData

use of com.extjs.gxt.ui.client.data.ModelData in project activityinfo by bedatadriven.

the class DbEditor method onNodeDropped.

private void onNodeDropped(List<TreeStoreModel> data) {
    if (data.isEmpty()) {
        return;
    }
    // update sortOrder and folder membership
    ModelData source = data.get(0).getModel();
    ModelData parent = treeStore.getParent(source);
    LOGGER.info("source = " + source);
    List<ModelData> children = parent == null ? treeStore.getRootItems() : treeStore.getChildren(parent);
    for (int i = 0; i != children.size(); ++i) {
        Record record = treeStore.getRecord(children.get(i));
        record.set("sortOrder", i);
    }
    if (source instanceof ActivityDTO) {
        Record record = treeStore.getRecord(source);
        if (parent instanceof FolderDTO) {
            record.set("folderId", ((FolderDTO) parent).getId());
        } else {
            record.set("folderId", null);
        }
    }
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) Record(com.extjs.gxt.ui.client.store.Record) ActivityDTO(org.activityinfo.legacy.shared.model.ActivityDTO)

Example 7 with ModelData

use of com.extjs.gxt.ui.client.data.ModelData in project activityinfo by bedatadriven.

the class DbEditor method onSelectionChanged.

private void onSelectionChanged(ModelData selectedItem) {
    toolBar.setActionEnabled(UIActions.EDIT, this.db.isDesignAllowed() && canEditWithFormDesigner(selectedItem));
    toolBar.setActionEnabled(UIActions.DELETE, this.db.isDesignAllowed() && selectedItem instanceof EntityDTO);
    // in case of activity enable only if reportingFrequency==once (monthly implementation with subforms is on the way...)
    boolean enableTable = selectedItem instanceof IsFormClass;
    Optional<IsActivityDTO> selectedActivity = getSelectedActivity(selectedItem);
    if (selectedActivity.isPresent()) {
        enableTable = selectedActivity.get().getReportingFrequency() == ActivityFormDTO.REPORT_ONCE;
    }
    toolBar.setActionEnabled(UIActions.OPEN_TABLE, enableTable);
    ModelData sel = tree.getSelectionModel().getSelectedItem();
    Optional<IsActivityDTO> activity = DbEditor.this.getSelectedActivity(sel);
    boolean classicActivitySelected = activity.map(IsActivityDTO::getClassicView).orElse(false);
    newMenu.setNewIndicatorEnabled(classicActivitySelected);
    newMenu.setNewAttributeGroupEnabled(classicActivitySelected);
    newMenu.setNewAttributeEnabled(classicActivitySelected && (sel instanceof AttributeGroupDTO || sel instanceof AttributeDTO));
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData)

Example 8 with ModelData

use of com.extjs.gxt.ui.client.data.ModelData in project activityinfo by bedatadriven.

the class DesignTreeDropTarget method showFeedback.

@Override
protected void showFeedback(DNDEvent event) {
    final TreePanel.TreeNode overItem = tree.findNode(event.getTarget());
    if (overItem == null) {
        clearStyles(event);
    }
    ModelData sourceModel = tree.getSelectionModel().getSelectedItem();
    ModelData overModel = null;
    if (overItem != null) {
        overModel = overItem.getModel();
        // Dropping a node onto itself? Abort.
        if (overModel == sourceModel) {
            clearStyles(event);
            return;
        }
        // Dropping a node into one of its children? Nope.
        List<ModelData> children = tree.getStore().getChildren(sourceModel, true);
        if (children.contains(overItem.getModel())) {
            clearStyles(event);
            return;
        }
    }
    // Now decide whether this move is legal
    // insert = insert after the overItem as a sibling
    // append = append to the overItem's children
    boolean insert = false;
    boolean append = false;
    // For most items, we will only allow inserting within the same parent
    if (overModel != null && tree.getStore().getParent(sourceModel) == tree.getStore().getParent(overModel)) {
        insert = true;
    }
    // Activities/Forms can be moved into other folders
    if (sourceModel instanceof ActivityDTO) {
        if (overModel == null || overModel instanceof FolderDTO) {
            insert = true;
            append = true;
        }
        if (overModel instanceof ActivityDTO) {
            insert = true;
        }
    }
    // which operation is allowed.
    if (append) {
        setFeedback(DND.Feedback.BOTH);
    } else {
        setFeedback(DND.Feedback.INSERT);
    }
    if (append && overItem == null) {
        handleAppend(event, overItem);
    } else if (insert) {
        handleInsert(event, overItem);
    } else if (append) {
        handleAppend(event, overItem);
    } else {
        if (activeItem != null) {
            tree.getView().onDropChange(activeItem, false);
        }
        status = -1;
        activeItem = null;
        appendItem = null;
        Insert.get().hide();
        event.getStatus().setStatus(false);
    }
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) FolderDTO(org.activityinfo.legacy.shared.model.FolderDTO) TreePanel(com.extjs.gxt.ui.client.widget.treepanel.TreePanel) ActivityDTO(org.activityinfo.legacy.shared.model.ActivityDTO)

Example 9 with ModelData

use of com.extjs.gxt.ui.client.data.ModelData in project activityinfo by bedatadriven.

the class BaseMapDialog method onButtonPressed.

@Override
protected void onButtonPressed(Button button) {
    if (button.getItemId().equals("cancel")) {
        hide();
    } else {
        ModelData thumb = listView.getSelectionModel().getSelectedItem();
        if (thumb != null) {
            callback.onSelect((String) thumb.get("id"), (String) thumb.get("name"));
            hide();
        }
    }
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) BaseModelData(com.extjs.gxt.ui.client.data.BaseModelData)

Example 10 with ModelData

use of com.extjs.gxt.ui.client.data.ModelData in project activityinfo by bedatadriven.

the class HighlightingGridView method onRowOver.

@Override
protected void onRowOver(Element row) {
    int index = findRowIndex(row);
    if (index != -1) {
        ModelData model = grid.getStore().getAt(index);
        if (isHighlightable(model)) {
            fly(row).addStyleName(IndicatorLinkResources.INSTANCE.style().highlight());
            GridEvent event = new GridEvent(grid);
            event.setModel(model);
            grid.fireEvent(HighlightingGridView.ROW_MOUSE_OVER, event);
        }
    }
    overRow = row;
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) GridEvent(com.extjs.gxt.ui.client.event.GridEvent)

Aggregations

ModelData (com.extjs.gxt.ui.client.data.ModelData)10 ActivityDTO (org.activityinfo.legacy.shared.model.ActivityDTO)3 BaseModelData (com.extjs.gxt.ui.client.data.BaseModelData)2 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 ArrayList (java.util.ArrayList)2 GridEvent (com.extjs.gxt.ui.client.event.GridEvent)1 ListStore (com.extjs.gxt.ui.client.store.ListStore)1 Record (com.extjs.gxt.ui.client.store.Record)1 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)1 BorderLayoutData (com.extjs.gxt.ui.client.widget.layout.BorderLayoutData)1 TreePanel (com.extjs.gxt.ui.client.widget.treepanel.TreePanel)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 AbstractImagePrototype (com.google.gwt.user.client.ui.AbstractImagePrototype)1 List (java.util.List)1 GetBaseMaps (org.activityinfo.legacy.shared.command.GetBaseMaps)1 BaseMapResult (org.activityinfo.legacy.shared.command.result.BaseMapResult)1 BaseMap (org.activityinfo.legacy.shared.model.BaseMap)1 FolderDTO (org.activityinfo.legacy.shared.model.FolderDTO)1 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)1 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)1