<commit_before>package ch.elexis.core.ui.tasks.parts.controls;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;

public class RunContextTextWithDefaultValue extends Text {

	public RunContextTextWithDefaultValue(Composite compAssisted, AbstractTaskDescriptorConfigurationComposite atdcc,
			String key, String defaultValue, String configuredValue) {
		super(compAssisted, SWT.BORDER);

		setMessage(defaultValue != null ? defaultValue : StringUtils.EMPTY);
		setText(configuredValue != null ? configuredValue : StringUtils.EMPTY);

		addModifyListener(new ModifyListener() {

			@Override
			public void modifyText(ModifyEvent e) {
				if (StringUtils.isNotBlank(getText())) {
					atdcc.taskDescriptor.setRunContextParameter(key, getText().trim());
				} else {
					atdcc.taskDescriptor.setRunContextParameter(key, null);
				}
				atdcc.saveTaskDescriptor();
			}
		});
	}

	@Override
	protected void checkSubclass() {
	}

}<commit_msg>[24409] Provide URL Test in TaskConfiguration<commit_after>package ch.elexis.core.ui.tasks.parts.controls;

import java.io.IOException;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Text;

import ch.elexis.core.services.IVirtualFilesystemService;
import ch.elexis.core.services.IVirtualFilesystemService.IVirtualFilesystemHandle;
import ch.elexis.core.utils.OsgiServiceUtil;

public class RunContextTextWithDefaultValue extends Text {

	/**
	 * @wbp.parser.entryPoint
	 */
	public RunContextTextWithDefaultValue(Composite compAssisted, AbstractTaskDescriptorConfigurationComposite atdcc,
			String key, String defaultValue, String configuredValue) {
		super(compAssisted, SWT.BORDER);

		setMessage(defaultValue != null ? defaultValue : StringUtils.EMPTY);
		setText(configuredValue != null ? configuredValue : StringUtils.EMPTY);

		addModifyListener(event -> {
			if (StringUtils.isNotBlank(getText())) {
				atdcc.taskDescriptor.setRunContextParameter(key, getText().trim());
			} else {
				atdcc.taskDescriptor.setRunContextParameter(key, null);
			}
			atdcc.saveTaskDescriptor();
		});

		addMenuDetectListener(evmdl -> {
			IVirtualFilesystemService vfsService = OsgiServiceUtil.getService(IVirtualFilesystemService.class)
					.orElse(null);
			try {
				final IVirtualFilesystemHandle vfsHandle = vfsService.of(getText());
				evmdl.doit = false; // prevent system to handle this event
				Menu menu = new Menu(evmdl.display.getActiveShell(), SWT.POP_UP);
				MenuItem exit = new MenuItem(menu, SWT.NONE);
				exit.setText("Test URL");
				exit.addListener(SWT.Selection, event -> {

					boolean canRead = false;
					boolean isDirectory = false;
					try {
						canRead = vfsHandle.canRead();
						isDirectory = vfsHandle.isDirectory();

					} catch (IOException e) {
						MessageDialog.openError(getShell(), "VFS Test", e.getLocalizedMessage());
						return;
					}

					MessageDialog.openInformation(getShell(), "VFS Test",
							"canRead: " + canRead + ", isDirectory: " + isDirectory);
				});
				menu.setVisible(true);

			} catch (IOException ex) {
				return;
			}

		});
	}

	@Override
	protected void checkSubclass() {
	}

}
{'fraction_non_alphanumeric': 0.11190205011389522, 'fraction_numerical': 0.0019931662870159455, 'mean_word_length': 4.63884430176565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2684759', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1073, 'n_words': 191}