Search in sources :

Example 1 with Command

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");
}
Also used : UserCredential(es.bsc.compss.ui.auth.UserCredential) File(java.io.File) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command)

Example 2 with Command

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");
    }
}
Also used : File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) EmptyCompleteGraphException(es.bsc.compss.exceptions.EmptyCompleteGraphException) EmptyCompleteGraphException(es.bsc.compss.exceptions.EmptyCompleteGraphException) IOException(java.io.IOException) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command)

Example 3 with Command

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);
    }
}
Also used : Window(org.zkoss.zul.Window) AttributeType(org.openforis.collect.designer.metamodel.AttributeType) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) Command(org.zkoss.bind.annotation.Command)

Example 4 with Command

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());
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) AttributeDefinitionFormObject(org.openforis.collect.designer.form.AttributeDefinitionFormObject) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 5 with Command

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);
            }
        });
    }
}
Also used : Window(org.zkoss.zul.Window) CodeAttributeDefinitionFormObject(org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject) NodeSelectedEvent(org.openforis.collect.designer.viewmodel.SchemaTreePopUpVM.NodeSelectedEvent) Predicate(org.openforis.collect.designer.util.Predicate) UITab(org.openforis.collect.metamodel.ui.UITab) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) SurveyObject(org.openforis.idm.metamodel.SurveyObject) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Aggregations

Command (org.zkoss.bind.annotation.Command)62 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)44 NotifyChange (org.zkoss.bind.annotation.NotifyChange)26 File (java.io.File)12 CollectSurvey (org.openforis.collect.model.CollectSurvey)10 MessageUtil (org.openforis.collect.designer.util.MessageUtil)9 UITab (org.openforis.collect.metamodel.ui.UITab)6 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)6 FileInputStream (java.io.FileInputStream)5 ConfirmParams (org.openforis.collect.designer.util.MessageUtil.ConfirmParams)5 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)5 SurveyObject (org.openforis.idm.metamodel.SurveyObject)5 Media (org.zkoss.util.media.Media)5 Window (org.zkoss.zul.Window)5 UserCredential (es.bsc.compss.ui.auth.UserCredential)4 IOException (java.io.IOException)4 Date (java.util.Date)4 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)4 SessionStatus (org.openforis.collect.designer.session.SessionStatus)3 ConfirmHandler (org.openforis.collect.designer.util.MessageUtil.ConfirmHandler)3