use of org.zkoss.bind.annotation.Command in project compss by bsc-wdc.
the class ApplicationsViewModel method update.
@Command
@NotifyChange("applications")
public void update() {
logger.debug("Updating Applications ViewModel...");
// Erase all current applications
applications.clear();
setSelectedApp("");
// Import new resources
String appsLocation = ((UserCredential) Sessions.getCurrent().getAttribute("userCredential")).getCOMPSs_BASE_LOG();
File COMPSs_LOG_DIR = new File(appsLocation);
if (COMPSs_LOG_DIR.exists()) {
for (File f : COMPSs_LOG_DIR.listFiles()) {
logger.debug("Adding application " + f.getName());
Application app = new Application(f.getName(), appsLocation + File.separator + f.getName());
applications.add(app);
}
}
if (Properties.isSortApplications()) {
Collections.sort(applications, new ApplicationComparator());
}
logger.debug("Applications ViewModel updated");
}
use of org.zkoss.bind.annotation.Command in project compss by bsc-wdc.
the class CompleteGraphViewModel method update.
@Command
@NotifyChange("completeGraph")
public void update(Application monitoredApp) {
logger.debug("Updating Complete Graph...");
String completeMonitorLocation = monitoredApp.getPath() + Constants.MONITOR_COMPLETE_DOT_FILE;
File completeMonitorFile = new File(completeMonitorLocation);
if (completeMonitorFile.exists()) {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
String modifiedTime = sdf.format(completeMonitorFile.lastModified());
if (!modifiedTime.equals(completeGraphLastUpdateTime)) {
// Update needed
try {
String completeGraphSVG = File.separator + "svg" + File.separator + monitoredApp.getName() + "_" + Constants.COMPLETE_GRAPH_FILE_NAME;
completeGraph = loadGraph(completeMonitorLocation, completeGraphSVG);
completeGraphLastUpdateTime = modifiedTime;
} catch (EmptyCompleteGraphException ecge) {
logger.debug("Empty complete graph");
completeGraph = Constants.EMPTY_GRAPH_PATH;
completeGraphLastUpdateTime = modifiedTime;
} catch (Exception e) {
completeGraph = Constants.GRAPH_NOT_FOUND_PATH;
completeGraphLastUpdateTime = "";
logger.error("Graph generation error", e);
}
} else {
logger.debug("Complete Graph is already loaded");
}
} else {
completeGraph = Constants.GRAPH_NOT_FOUND_PATH;
completeGraphLastUpdateTime = "";
logger.debug("Complete Graph file not found");
}
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class AttributeConversionVM method convert.
@Command
public void convert(@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) {
if (validateForm(ctx)) {
String typeLabel = form.get("type");
AttributeType type = AttributeType.fromLabel(typeLabel);
AttributeDefinition convertedAttribute = new AttributeConverter().convert(attributeDefinition, type);
dispatchNodeConvertedCommand(convertedAttribute);
Window popUp = ComponentUtil.getClosest(ctx.getComponent(), Window.class);
closePopUp(popUp);
}
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class AttributeVM method generateEntityAlias.
@Command
public void generateEntityAlias() {
AttributeDefinitionFormObject<?> fo = (AttributeDefinitionFormObject<?>) formObject;
String referencedAttributePath = fo.getReferencedAttributePath();
EntityDefinition sourceDef = editedItem.getParentEntityDefinition();
String aliasName = sourceDef + "_alias";
NodeDefinition referencedAttributeDef = editedItem.getDefinitionByPath(referencedAttributePath);
EntityDefinition parentDef = referencedAttributeDef.getNearestAncestorMultipleEntity();
if (parentDef.containsChildDefinition(aliasName)) {
MessageUtil.showError("survey.schema.attribute.generate_entity_alias.error.alias_already_existing", aliasName, parentDef.getName());
} else {
EntityDefinition aliasDef = schemaUpdater.generateAlias(sourceDef, editedItem.getName(), parentDef, referencedAttributeDef.getName());
((CollectSurvey) aliasDef.getSurvey()).getUIOptions().setLayout(aliasDef, Layout.TABLE);
aliasDef.rename(aliasName);
dispatchSchemaChangedCommand();
MessageUtil.showInfo("survey.schema.attribute.generate_entity_alias.generation_successfull", aliasName, parentDef.getName());
}
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class CodeAttributeVM method openParentAttributeSelector.
@Command
public void openParentAttributeSelector(@ContextParam(ContextType.BINDER) final Binder binder) {
String title = Labels.getLabel("survey.schema.attribute.code.select_parent_for_node", new String[] { editedItem.getName() });
final Collection<CodeAttributeDefinition> assignableParentAttributes = editedItem.getAssignableParentCodeAttributeDefinitions();
if (assignableParentAttributes.isEmpty()) {
MessageUtil.showWarning("survey.schema.attribute.code.no_assignable_parent_available");
} else {
CodeAttributeDefinition parentCodeAttributeDefinition = ((CodeAttributeDefinitionFormObject) formObject).getParentCodeAttributeDefinition();
Predicate<SurveyObject> includedNodePredicate = new Predicate<SurveyObject>() {
@Override
public boolean evaluate(SurveyObject item) {
return item instanceof UITab || item instanceof EntityDefinition || item instanceof CodeAttributeDefinition && assignableParentAttributes.contains(item);
}
};
Predicate<SurveyObject> disabledNodePredicate = new Predicate<SurveyObject>() {
@Override
public boolean evaluate(SurveyObject item) {
return !(item instanceof CodeAttributeDefinition);
}
};
final Window parentSelectorPopUp = SchemaTreePopUpVM.openPopup(title, editedItem.getRootEntity(), null, includedNodePredicate, false, false, disabledNodePredicate, null, parentCodeAttributeDefinition, true);
parentSelectorPopUp.addEventListener(SchemaTreePopUpVM.NODE_SELECTED_EVENT_NAME, new EventListener<NodeSelectedEvent>() {
public void onEvent(NodeSelectedEvent event) throws Exception {
CodeAttributeDefinition parentAttrDefn = (CodeAttributeDefinition) event.getSelectedItem();
CodeAttributeDefinitionFormObject fo = (CodeAttributeDefinitionFormObject) formObject;
fo.setParentCodeAttributeDefinition(parentAttrDefn);
String hierarchicalLevel = getHierarchicalLevelName(parentAttrDefn);
fo.setHierarchicalLevel(hierarchicalLevel);
notifyChange("formObject");
dispatchApplyChangesCommand(binder);
notifyChange("dependentCodePaths");
closePopUp(parentSelectorPopUp);
}
});
}
}
Aggregations