<commit_before>/*
 * Copyright 2017, <NAME> (Fraunhofer IOSB) Licensed under the Apache
 * License, Version 2.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
 * or agreed to in writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

package nato.ivct.gui.client.sut;

import org.eclipse.scout.rt.client.context.ClientRunContexts;
import org.eclipse.scout.rt.client.job.ModelJobs;
import org.eclipse.scout.rt.client.ui.desktop.outline.IOutline;
import org.eclipse.scout.rt.platform.util.concurrent.IRunnable;
import org.eclipse.scout.rt.shared.notification.INotificationHandler;
import org.slf4j.LoggerFactory;

import nato.ivct.gui.client.Desktop;
import nato.ivct.gui.client.outlines.SuTOutline;
import nato.ivct.gui.shared.sut.TcStatusNotification;


public class TcStatusNotificationHandler implements INotificationHandler<TcStatusNotification> {

    org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());


    @Override
    public void handleNotification(TcStatusNotification notification) {
        // inform client about test case progress
        ModelJobs.schedule(new IRunnable() {
            @Override
            public void run() throws Exception {
                logger.trace("Test Case Status Notification " + notification.getTcId() + " is at " + notification.getPercent() + "%");
                for (final IOutline outline: Desktop.CURRENT.get().getAvailableOutlines()) {
                    if (outline instanceof SuTOutline) {
                        Desktop.CURRENT.get().findForms(SuTTcExecutionForm.class).forEach(form -> {
                            if (form.getSutId().equalsIgnoreCase(notification.getSutId()) && form.getTestCaseId().equalsIgnoreCase(notification.getTcId())) {
                                //                                // set TC execution status in detail form
                                //                                final ITable tbl = form.getTestCaseExecutionStatusTableField().getTable();
                                //                                tbl.discardAllRows();
                                //                                final ITableRow row = tbl.addRow();
                                //                                // set verdict
                                //                                ((Table) tbl).getTcStatusColumn().setValue(row, notification.getStatus());
                                //
                                //                                // set execution progress
                                //                                ((Table) tbl).getProgressColumn().setValue(row, notification.getPercent());
                                //
                                //                                //record status and progress in the form
                                //                                form.setTestCaseStatus(notification.getStatus());
                                //                                form.setTestCaseProgress(Integer.toString(notification.getPercent()));
                                //
                                //                                // set TC execution status in table
                                //                                final SuTTcNodePage tcNP = (SuTTcNodePage) outline.findNode(form.getBadgeId() + "." + form.getTestsuiteId());
                                //                                final SuTCbTablePage cbNode = (SuTCbTablePage) tcNP.getParentNode();
                                //                                for (final ITableRow tr: cbNode.getTable().getRows()) {
                                //                                    // find row with test case name
                                //                                    if (cbNode.getTable().getAbstractTCColumn().getValue(tr).equals(notification.getTcId())) {
                                //                                        cbNode.getTable().getTCresultColumn().setValue(tr, notification.getStatus() + ": " + notification.getPercent() + "%");
                                //                                    }
                                //                                }
                            }
                        });
                    }
                }
            }
        }, ModelJobs.newInput(ClientRunContexts.copyCurrent()));
    }
}<commit_msg>Set TC execution status in form<commit_after>/*
 * Copyright 2017, <NAME> (Fraunhofer IOSB) Licensed under the Apache
 * License, Version 2.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
 * or agreed to in writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

package nato.ivct.gui.client.sut;

import org.eclipse.scout.rt.client.context.ClientRunContexts;
import org.eclipse.scout.rt.client.job.ModelJobs;
import org.eclipse.scout.rt.client.ui.desktop.outline.IOutline;
import org.eclipse.scout.rt.platform.util.concurrent.IRunnable;
import org.eclipse.scout.rt.shared.notification.INotificationHandler;
import org.slf4j.LoggerFactory;

import nato.ivct.gui.client.Desktop;
import nato.ivct.gui.client.outlines.SuTOutline;
import nato.ivct.gui.shared.sut.TcStatusNotification;


public class TcStatusNotificationHandler implements INotificationHandler<TcStatusNotification> {

    org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());


    @Override
    public void handleNotification(TcStatusNotification notification) {
        // inform client about test case progress
        ModelJobs.schedule(new IRunnable() {
            @Override
            public void run() throws Exception {
                logger.trace("Test Case Status Notification " + notification.getTcId() + " is at " + notification.getPercent() + "%");
                for (final IOutline outline: Desktop.CURRENT.get().getAvailableOutlines()) {
                    if (outline instanceof SuTOutline) {
                        Desktop.CURRENT.get().findForms(SuTTcExecutionForm.class).forEach(form -> {
                            if (form.getSutId().equalsIgnoreCase(notification.getSutId()) && form.getTestCaseId().equalsIgnoreCase(notification.getTcId())) {
                                // set TC execution status attribute in detail form
                                form.setTestCaseStatus(notification.getStatus());
                                // set TC execution status field in detail form
                                form.getTcExecutionStatus().setValue(notification.getStatus());

                                // set execution progress
                                //                                ((Table) tbl).getProgressColumn().setValue(row, notification.getPercent());
                            }
                        });
                    }
                }
            }
        }, ModelJobs.newInput(ClientRunContexts.copyCurrent()));
    }
}
{'fraction_non_alphanumeric': 0.09068241469816272, 'fraction_numerical': 0.0026246719160104987, 'mean_word_length': 1.5505354752342704, 'pattern_counts': {'":': 1, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 52, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1094678', 'n_tokens_mistral': 1816, 'n_tokens_neox': 1701, 'n_words': 404}