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);
}
}
}
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));
}
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);
}
}
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();
}
}
}
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;
}
Aggregations