Search in sources :

Example 11 with NotifyChange

use of org.zkoss.bind.annotation.NotifyChange in project collect by openforis.

the class EditableListOfNodesVM method setLayout.

@Command
@NotifyChange({ "nodesPerTab" })
public void setLayout(@BindingParam("type") String type, @BindingParam("node") EntityDefinition node) {
    UIOptions uiOpts = getUIOptions();
    Layout layout = Layout.valueOf(type);
    uiOpts.setLayout(node, layout);
}
Also used : Layout(org.openforis.collect.metamodel.ui.UIOptions.Layout) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 12 with NotifyChange

use of org.zkoss.bind.annotation.NotifyChange in project collect by openforis.

the class TabsGroupVM method removeTab.

@Command
@NotifyChange({ "tabs" })
public void removeTab(@BindingParam("tab") UITab tab) {
    if (tab.getTabs().isEmpty()) {
        SessionStatus sessionStatus = getSessionStatus();
        CollectSurvey survey = sessionStatus.getSurvey();
        UIOptions uiOpts = survey.getUIOptions();
        List<NodeDefinition> nodesPerTab = uiOpts.getNodesPerTab(tab, false);
        if (nodesPerTab.isEmpty()) {
            UITabSet parent = tab.getParent();
            parent.removeTab(tab);
            postTabChangedCommand(parent);
        } else {
            MessageUtil.showWarning("survey.layout.tab.remove.error.associated_nodes_present");
        }
    } else {
        MessageUtil.showWarning("survey.layout.tab.remove.error.nested_tabs_present");
    }
}
Also used : SessionStatus(org.openforis.collect.designer.session.SessionStatus) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 13 with NotifyChange

use of org.zkoss.bind.annotation.NotifyChange in project collect by openforis.

the class TabsGroupVM method addTab.

@Command
@NotifyChange({ "tabs" })
public void addTab() {
    UIOptions uiOptions = tabSet.getUIOptions();
    UITab tab = uiOptions.createTab();
    String tabName = generateNewTabName(tabSet);
    tab.setName(tabName);
    tabSet.addTab(tab);
    postTabChangedCommand(tabSet);
    openTabLabelEditPopUp(tab);
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 14 with NotifyChange

use of org.zkoss.bind.annotation.NotifyChange in project compss by bsc-wdc.

the class CurrentGraphViewModel method update.

@Command
@NotifyChange("graph")
void update(Application monitoredApp) {
    logger.debug("Updating Graph...");
    String monitorLocation = monitoredApp.getPath() + Constants.MONITOR_CURRENT_DOT_FILE;
    File monitorFile = new File(monitorLocation);
    if (monitorFile.exists()) {
        if (monitorFile.length() > 45) {
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            String modifiedTime = sdf.format(monitorFile.lastModified());
            if (!modifiedTime.equals(graphLastUpdateTime)) {
                try {
                    String graphSVG = File.separator + "svg" + File.separator + monitoredApp.getName() + "_" + Constants.GRAPH_FILE_NAME;
                    graph = loadGraph(monitorLocation, graphSVG);
                    graphLastUpdateTime = modifiedTime;
                } catch (Exception e) {
                    graph = Constants.GRAPH_NOT_FOUND_PATH;
                    graphLastUpdateTime = "";
                    logger.error("Graph generation error");
                }
            } else {
                logger.debug("Graph is already loaded");
            }
        } else {
            // The empty graph has length = 45
            graph = Constants.GRAPH_EXECUTION_DONE_PATH;
            graphLastUpdateTime = "";
        }
    } else {
        graph = Constants.GRAPH_NOT_FOUND_PATH;
        graphLastUpdateTime = "";
        logger.debug("Graph file not found");
    }
}
Also used : File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) IOException(java.io.IOException) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command)

Example 15 with NotifyChange

use of org.zkoss.bind.annotation.NotifyChange in project compss by bsc-wdc.

the class RuntimeLogViewModel method update.

@Command
@NotifyChange({ "runtimeLog", "filter" })
public void update() {
    if (!Properties.getBasePath().equals("")) {
        // Check if applicaction has changed
        String newPath = Properties.getBasePath() + File.separator + Constants.RUNTIME_LOG;
        if (!this.runtimeLogPath.equals(newPath)) {
            // Load new application
            this.runtimeLogPath = newPath;
            this.lastParsedLine = 0;
            this.content = "";
            this.filter = "";
        }
        // Parse
        logger.debug("Parsing runtime.log file...");
        try (BufferedReader br = new BufferedReader(new FileReader(this.runtimeLogPath))) {
            StringBuilder sb = new StringBuilder("");
            String line = br.readLine();
            int i = 0;
            while (line != null) {
                if (i > this.lastParsedLine) {
                    if (line.contains(filter)) {
                        sb.append(line).append("\n");
                    }
                }
                i = i + 1;
                line = br.readLine();
            }
            this.content += sb.toString();
            this.lastParsedLine = i - 1;
        } catch (IOException ioe) {
            logger.error("Cannot parse runtime.log file: " + this.runtimeLogPath, ioe);
        }
    } else {
        // Load default value
        this.clear();
    }
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command)

Aggregations

Command (org.zkoss.bind.annotation.Command)26 NotifyChange (org.zkoss.bind.annotation.NotifyChange)26 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)17 UserCredential (es.bsc.compss.ui.auth.UserCredential)4 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)4 File (java.io.File)3 IOException (java.io.IOException)3 MessageUtil (org.openforis.collect.designer.util.MessageUtil)3 UITab (org.openforis.collect.metamodel.ui.UITab)3 CollectSurvey (org.openforis.collect.model.CollectSurvey)3 UITab (org.openforis.collect.model.ui.UITab)3 Session (org.zkoss.zk.ui.Session)3 SimpleDateFormat (java.text.SimpleDateFormat)2 SessionStatus (org.openforis.collect.designer.session.SessionStatus)2 ConfirmParams (org.openforis.collect.designer.util.MessageUtil.ConfirmParams)2 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)2 UITabDefinition (org.openforis.collect.model.ui.UITabDefinition)2 EmptyCompleteGraphException (es.bsc.compss.exceptions.EmptyCompleteGraphException)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1