/** * The contents of this file are subject to the OpenMRS Public License * Version 1.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://license.openmrs.org * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Copyright (C) OpenMRS, LLC. All Rights Reserved. */ package org.eclipse.datatools.connectivity.oda.openmrs.ui.impl; import java.util.logging.Logger; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button; // TODO: Auto-generated Javadoc /** * This class represents an individual check box that indicates whether or not * to "split" a certain token. The check box is thus tied to a specific token * and a specifice "splitter". For now, there are four supported "splitters": * Observation Date, Observation Location, Encounter Date, and Encounter Type. */ public class SplitTokenCheckBox { private static Logger log = Logger.getLogger(SplitTokenCheckBox.class .getName()); /** The "split" that the check box is associated with. */ private String split; /** The token that the check box is associated with. */ private String token; /** The check box. */ private Button check; /** * Instantiates a new check box for a given splitter and token combination. * * @param check the check box from the caller * @param split the dimension to "split" the token on * @param translateSplit the text version of the splitter that is displayed * to the user * @param token the token associated with the check box */ public SplitTokenCheckBox(final Button check, final String split, final String translateSplit, final String token) { this.check = check; this.split = split; this.token = token; check.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Determines if the checkBox is checked or not boolean selected = check.getSelection(); // If checked then execute this code if (selected == true) { log.info("Before check: " + InformationHolder.getPropertyValue("TOKENS")); // add this split to this token InformationHolder.setPropertyValue("TOKENS", Utils .addSplitForToken(token, translateSplit, InformationHolder .getPropertyValue("TOKENS"))); log.info("After check: " + InformationHolder.getPropertyValue("TOKENS")); } // If not checked, then execute this one else { log.info("Before uncheck: " + InformationHolder.getPropertyValue("TOKENS")); InformationHolder.setPropertyValue("TOKENS", Utils .removeSplitForToken(token, translateSplit, InformationHolder .getPropertyValue("TOKENS"))); log.info("After uncheck: " + InformationHolder.getPropertyValue("TOKENS")); } } }); } /** * Gets the split associated with the check box. * * @return the split */ public String getSplit() { return split; } /** * Gets the token associated with the check box. * * @return the token */ public String getToken() { return token; } /** * Gets the check box. * * @return the check */ public Button getCheck() { return check; } }