<commit_before>/*******************************************************************************
 * Copyright (c) 2005-2008, <NAME> and Elexis
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    <NAME> - initial implementation
 *    
 *******************************************************************************/
package ch.elexis.core.ui.views;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

import javax.inject.Inject;
import javax.inject.Named;

import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.LocationAdapter;
import org.eclipse.swt.browser.LocationEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

import com.equo.chromium.swt.Browser;

import ch.elexis.core.constants.Preferences;
import ch.elexis.core.ui.util.CoreUiUtil;
import ch.rgw.tools.ExHandler;
import ch.rgw.tools.StringTool;

/**
 * Diese View reichtet einen Browser aufs Arzneimittel-Kompendium ein.
 */
public class ODDBView extends ViewPart {
	public static final String ID = "ch.elexis.ODDBView";
	Browser browser;
	
	@Override
	public void createPartControl(Composite parent){
		browser = new Browser(parent, SWT.NONE);
		browser.addLocationListener(new LocationAdapter() {
			
			@Override
			public void changed(LocationEvent arg0){
				String text = getText(arg0.location);
				System.out.println(text);
			}
			
		});
		// browser.setUrl("http://ch.oddb.org");
		browser.setUrl("http://santesuisse.oddb.org/");
		
	}
	
	@Override
	public void setFocus(){
		// TODO Auto-generated method stub
		
	}
	
	public String getText(String loc){
		try {
			if (StringTool.isNothing(loc)) {
				loc = browser.getUrl();
			}
			URLConnection url = new URL(loc).openConnection();
			url.setDoInput(true);
			BufferedReader in = new BufferedReader(new InputStreamReader(url.getInputStream()));
			StringBuilder ret = new StringBuilder();
			String line;
			;
			while ((line = in.readLine()) != null) {
				ret.append(line);
			}
			// Programm beenden
			in.close();
			return ret.toString();
		} catch (IOException e) {
			ExHandler.handle(e);
			return "";
		}
	}
	
	@Optional
	@Inject
	public void setFixLayout(MPart part, @Named(Preferences.USR_FIX_LAYOUT) boolean currentState){
		CoreUiUtil.updateFixLayout(part, currentState);
	}
}
<commit_msg>[23437] Fix URL for oddb.org<commit_after>/*******************************************************************************
 * Copyright (c) 2005-2008, <NAME> and Elexis
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    <NAME> - initial implementation
 *    
 *******************************************************************************/
package ch.elexis.core.ui.views;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

import javax.inject.Inject;
import javax.inject.Named;

import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.LocationAdapter;
import org.eclipse.swt.browser.LocationEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

import com.equo.chromium.swt.Browser;

import ch.elexis.core.constants.Preferences;
import ch.elexis.core.ui.util.CoreUiUtil;
import ch.rgw.tools.ExHandler;
import ch.rgw.tools.StringTool;

/**
 * Diese View reichtet einen Browser aufs Arzneimittel-Kompendium ein.
 */
public class ODDBView extends ViewPart {
	public static final String ID = "ch.elexis.ODDBView";
	Browser browser;
	
	@Override
	public void createPartControl(Composite parent){
		browser = new Browser(parent, SWT.NONE);
		browser.addLocationListener(new LocationAdapter() {
			
			@Override
			public void changed(LocationEvent arg0){
				String text = getText(arg0.location);
				System.out.println(text);
			}
			
		});
		// browser.setUrl("http://ch.oddb.org");
		browser.setUrl("https://just-medical.oddb.org/");
		
	}
	
	@Override
	public void setFocus(){
		// TODO Auto-generated method stub
		
	}
	
	public String getText(String loc){
		try {
			if (StringTool.isNothing(loc)) {
				loc = browser.getUrl();
			}
			URLConnection url = new URL(loc).openConnection();
			url.setDoInput(true);
			BufferedReader in = new BufferedReader(new InputStreamReader(url.getInputStream()));
			StringBuilder ret = new StringBuilder();
			String line;
			;
			while ((line = in.readLine()) != null) {
				ret.append(line);
			}
			// Programm beenden
			in.close();
			return ret.toString();
		} catch (IOException e) {
			ExHandler.handle(e);
			return "";
		}
	}
	
	@Optional
	@Inject
	public void setFixLayout(MPart part, @Named(Preferences.USR_FIX_LAYOUT) boolean currentState){
		CoreUiUtil.updateFixLayout(part, currentState);
	}
}

{'fraction_non_alphanumeric': 0.17273904198261514, 'fraction_numerical': 0.0068429813205104495, 'mean_word_length': 4.32807881773399, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, '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': '5831973', 'n_tokens_mistral': 1832, 'n_tokens_neox': 1650, 'n_words': 370}