Search in sources :

Example 1 with WadoNodeList

use of org.karnak.backend.model.dicom.WadoNodeList in project karnak by OsiriX-Foundation.

the class MonitorView method buildwadoNodeListSelector.

private void buildwadoNodeListSelector() {
    wadoNodeListSelector = new Select<>();
    wadoNodeListSelector.setEmptySelectionAllowed(false);
    WadoNodeList pacsProdWadoNodeList = Util.readWadoNodes(this.getClass().getResource("/config/pacs-wado-web.csv"), "Public web");
    wadoNodeListSelector.setItems(pacsProdWadoNodeList);
    wadoNodeListSelector.addValueChangeListener((ValueChangeListener<ValueChangeEvent<WadoNodeList>>) event -> logic.wadoNodeListSelected(event.getValue()));
    if (!pacsProdWadoNodeList.isEmpty()) {
        wadoNodeListSelector.setValue(pacsProdWadoNodeList);
    }
}
Also used : DicomNodeList(org.karnak.backend.model.dicom.DicomNodeList) Html(com.vaadin.flow.component.Html) Select(com.vaadin.flow.component.select.Select) Util(org.karnak.frontend.dicom.Util) ValueChangeEvent(com.vaadin.flow.component.HasValue.ValueChangeEvent) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Div(com.vaadin.flow.component.html.Div) AbstractView(org.karnak.frontend.dicom.AbstractView) H6(com.vaadin.flow.component.html.H6) ValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener) WadoNodeList(org.karnak.backend.model.dicom.WadoNodeList) Alignment(com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment) Button(com.vaadin.flow.component.button.Button) ValueChangeEvent(com.vaadin.flow.component.HasValue.ValueChangeEvent) WadoNodeList(org.karnak.backend.model.dicom.WadoNodeList)

Example 2 with WadoNodeList

use of org.karnak.backend.model.dicom.WadoNodeList in project karnak by OsiriX-Foundation.

the class Util method readWadoNodes.

public static WadoNodeList readWadoNodes(URL url, String name) {
    WadoNodeList list = new WadoNodeList(name);
    if (url != null) {
        Scanner scan = null;
        try {
            // $NON-NLS-1$
            scan = new Scanner(url.openStream(), StandardCharsets.UTF_8);
            while (scan.hasNext()) {
                String val = scan.nextLine();
                if (val.startsWith("#")) {
                    continue;
                }
                // $NON-NLS-1$
                String[] line = val.split(",(?=([^\"]*\"[^\"]*\")*+[^\"]*$)", -1);
                if (line.length >= 2) {
                    try {
                        WadoNode node = new WadoNode(trimSplit(line[0]), new URL(trimSplit(line[1])));
                        list.add(node);
                        for (int i = 2; i < line.length; i++) {
                            node.getTags().add(trimSplit(line[i]));
                        }
                    } catch (Exception e) {
                        System.out.println("Cannot read wado node:  " + line[2]);
                    }
                }
            }
        } catch (Exception e) {
            System.out.println("Cannot read wado nodes files:  " + url);
        } finally {
            if (scan != null) {
                scan.close();
            }
        }
    }
    return list;
}
Also used : Scanner(java.util.Scanner) URL(java.net.URL) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) WadoNodeList(org.karnak.backend.model.dicom.WadoNodeList) WadoNode(org.karnak.backend.model.dicom.WadoNode)

Aggregations

WadoNodeList (org.karnak.backend.model.dicom.WadoNodeList)2 ValueChangeEvent (com.vaadin.flow.component.HasValue.ValueChangeEvent)1 ValueChangeListener (com.vaadin.flow.component.HasValue.ValueChangeListener)1 Html (com.vaadin.flow.component.Html)1 Button (com.vaadin.flow.component.button.Button)1 Div (com.vaadin.flow.component.html.Div)1 H6 (com.vaadin.flow.component.html.H6)1 Alignment (com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 Select (com.vaadin.flow.component.select.Select)1 URL (java.net.URL)1 Scanner (java.util.Scanner)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 DicomNodeList (org.karnak.backend.model.dicom.DicomNodeList)1 WadoNode (org.karnak.backend.model.dicom.WadoNode)1 AbstractView (org.karnak.frontend.dicom.AbstractView)1 Util (org.karnak.frontend.dicom.Util)1