Example usage for java.awt Container setLayout

List of usage examples for java.awt Container setLayout

Introduction

In this page you can find the example usage for java.awt Container setLayout.

Prototype

public void setLayout(LayoutManager mgr) 

Source Link

Document

Sets the layout manager for this container.

Usage

From source file:ffx.ui.MainPanel.java

/**
 * <p>/*  ww  w .ja v  a2s.  c o m*/
 * initialize</p>
 */
public void initialize() {
    if (init) {
        return;
    }
    init = true;
    String dir = System.getProperty("user.dir",
            FileSystemView.getFileSystemView().getDefaultDirectory().getAbsolutePath());
    setCWD(new File(dir));
    locale = new FFXLocale("en", "US");
    JDialog splashScreen = null;
    ClassLoader loader = getClass().getClassLoader();
    if (!GraphicsEnvironment.isHeadless()) {
        // Splash Screen
        JFrame.setDefaultLookAndFeelDecorated(true);
        splashScreen = new JDialog(frame, false);
        ImageIcon logo = new ImageIcon(loader.getResource("ffx/ui/icons/splash.png"));
        JLabel ffxLabel = new JLabel(logo);
        ffxLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
        Container contentpane = splashScreen.getContentPane();
        contentpane.setLayout(new BorderLayout());
        contentpane.add(ffxLabel, BorderLayout.CENTER);
        splashScreen.setUndecorated(true);
        splashScreen.pack();
        Dimension screenDimension = getToolkit().getScreenSize();
        Dimension splashDimension = splashScreen.getSize();
        splashScreen.setLocation((screenDimension.width - splashDimension.width) / 2,
                (screenDimension.height - splashDimension.height) / 2);
        splashScreen.setResizable(false);
        splashScreen.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        splashScreen.setVisible(true);
        // Make all pop-up Menus Heavyweight so they play nicely with Java3D
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    }
    // Create the Root Node
    dataRoot = new MSRoot();
    Border bb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    statusLabel = new JLabel("  ");
    JLabel stepLabel = new JLabel("  ");
    stepLabel.setHorizontalAlignment(JLabel.RIGHT);
    JLabel energyLabel = new JLabel("  ");
    energyLabel.setHorizontalAlignment(JLabel.RIGHT);
    JPanel statusPanel = new JPanel(new GridLayout(1, 3));
    statusPanel.setBorder(bb);
    statusPanel.add(statusLabel);
    statusPanel.add(stepLabel);
    statusPanel.add(energyLabel);
    if (!GraphicsEnvironment.isHeadless()) {
        GraphicsConfigTemplate3D template3D = new GraphicsConfigTemplate3D();
        template3D.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED);
        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getBestConfiguration(template3D);
        graphicsCanvas = new GraphicsCanvas(gc, this);
        graphicsPanel = new GraphicsPanel(graphicsCanvas, statusPanel);
    }
    // Initialize various Panels
    hierarchy = new Hierarchy(this);
    hierarchy.setStatus(statusLabel, stepLabel, energyLabel);
    keywordPanel = new KeywordPanel(this);
    modelingPanel = new ModelingPanel(this);
    JPanel treePane = new JPanel(new BorderLayout());
    JScrollPane scrollPane = new JScrollPane(hierarchy, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    treePane.add(scrollPane, BorderLayout.CENTER);
    tabbedPane = new JTabbedPane();

    ImageIcon graphicsIcon = new ImageIcon(loader.getResource("ffx/ui/icons/monitor.png"));
    ImageIcon keywordIcon = new ImageIcon(loader.getResource("ffx/ui/icons/key.png"));
    ImageIcon modelingIcon = new ImageIcon(loader.getResource("ffx/ui/icons/cog.png"));
    tabbedPane.addTab(locale.getValue("Graphics"), graphicsIcon, graphicsPanel);
    tabbedPane.addTab(locale.getValue("KeywordEditor"), keywordIcon, keywordPanel);
    tabbedPane.addTab(locale.getValue("ModelingCommands"), modelingIcon, modelingPanel);
    tabbedPane.addChangeListener(this);
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, tabbedPane);

    /* splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false,
     treePane, graphicsPanel); */
    splitPane.setResizeWeight(0.25);
    splitPane.setOneTouchExpandable(true);
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    if (!GraphicsEnvironment.isHeadless()) {
        mainMenu = new MainMenu(this);
        add(mainMenu.getToolBar(), BorderLayout.NORTH);
        getModelingShell();
        loadPrefs();
        SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this));
        splashScreen.dispose();
    }
}

From source file:net.sf.nmedit.nomad.core.Nomad.java

void setupUI() {
    this.clipBoard = new Clipboard("nomad clipboard");
    ApplicationClipboard.setApplicationClipboard(clipBoard);

    mainWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    mainWindow.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            Nomad.sharedInstance().handleExit();
        }/*from w  w  w  . j a  va2  s . c o  m*/
    });
    pageContainer = new DefaultDocumentManager();

    Container contentPane = mainWindow.getContentPane();

    explorerTree = new FileExplorerTree();
    explorerTree.setFont(new Font("Arial", Font.PLAIN, 11));

    explorerTree.createPopup(menuBuilder);

    JScrollPane explorerTreeScroller = new JScrollPane(explorerTree);
    toolPane = new JTabbedPane2();
    toolPane.setCloseActionEnabled(false);

    toolPane.addTab("Explorer", getImage("/icons/eview16/filenav_nav.gif"), explorerTreeScroller);

    new DropTarget(contentPane, new URIListDropHandler() {
        public void uriListDropped(URI[] uriList) {
            for (URI uri : uriList) {
                try {
                    File f = new File(uri);
                    openOrSelect(f);
                } catch (IllegalArgumentException e) {
                    // ignore
                }
            }
        }
    });

    synthPane = new JTabbedPane2();
    synthPane.setCloseActionEnabled(true);

    JSplitPane sidebarSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false);
    sidebarSplit.setTopComponent(toolPane);
    sidebarSplit.setBottomComponent(synthPane);
    sidebarSplit.setResizeWeight(0.8);
    sidebarSplit.setOneTouchExpandable(true);
    /*
    JComponent sidebar = new JPanel(new BorderLayout());
    sidebar.setBorder(null);
    sidebar.add(sidebarSplit, BorderLayout.CENTER);
    */
    if (!Platform.isFlavor(OS.MacOSFlavor)) {
        /*
        JToolBar tb = createQuickActionToolbar();
        sidebar.add(tb, BorderLayout.NORTH);*/

    } else {
        registerForMacOSXEvents();
    }
    JSplitPane splitLR = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitLR.setResizeWeight(0);
    splitLR.setDividerLocation(200);
    splitLR.setRightComponent(pageContainer);
    splitLR.setLeftComponent(sidebarSplit);

    contentPane.setLayout(new BorderLayout());
    contentPane.add(splitLR, BorderLayout.CENTER);
    if (contentPane instanceof JComponent)
        ((JComponent) contentPane).revalidate();
}

From source file:processing.app.Editor.java

public Editor(Base ibase, File file, int[] location, Platform platform) throws Exception {
    super("Arduino");
    this.base = ibase;
    this.platform = platform;

    Base.setIcon(this);

    // Install default actions for Run, Present, etc.
    resetHandlers();/*from  w w w  .  j  a  v a  2  s.  co m*/

    // add listener to handle window close box hit event
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            base.handleClose(Editor.this);
        }
    });
    // don't close the window when clicked, the app will take care
    // of that via the handleQuitInternal() methods
    // http://dev.processing.org/bugs/show_bug.cgi?id=440
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    // When bringing a window to front, let the Base know
    addWindowListener(new WindowAdapter() {
        public void windowActivated(WindowEvent e) {
            base.handleActivated(Editor.this);
        }

        // added for 1.0.5
        // http://dev.processing.org/bugs/show_bug.cgi?id=1260
        public void windowDeactivated(WindowEvent e) {
            fileMenu.remove(sketchbookMenu);
            fileMenu.remove(examplesMenu);
            List<Component> toolsMenuItemsToRemove = new LinkedList<Component>();
            for (Component menuItem : toolsMenu.getMenuComponents()) {
                if (menuItem instanceof JComponent) {
                    Object removeOnWindowDeactivation = ((JComponent) menuItem)
                            .getClientProperty("removeOnWindowDeactivation");
                    if (removeOnWindowDeactivation != null
                            && Boolean.valueOf(removeOnWindowDeactivation.toString())) {
                        toolsMenuItemsToRemove.add(menuItem);
                    }
                }
            }
            for (Component menuItem : toolsMenuItemsToRemove) {
                toolsMenu.remove(menuItem);
            }
            toolsMenu.remove(serialMenu);
        }
    });

    //PdeKeywords keywords = new PdeKeywords();
    //sketchbook = new Sketchbook(this);

    buildMenuBar();

    // For rev 0120, placing things inside a JPanel
    Container contentPain = getContentPane();
    contentPain.setLayout(new BorderLayout());
    JPanel pain = new JPanel();
    pain.setLayout(new BorderLayout());
    contentPain.add(pain, BorderLayout.CENTER);

    Box box = Box.createVerticalBox();
    Box upper = Box.createVerticalBox();

    if (toolbarMenu == null) {
        toolbarMenu = new JMenu();
        base.rebuildToolbarMenu(toolbarMenu);
    }
    toolbar = new EditorToolbar(this, toolbarMenu);
    upper.add(toolbar);

    header = new EditorHeader(this);
    upper.add(header);

    textarea = createTextArea();
    textarea.setName("editor");

    // assemble console panel, consisting of status area and the console itself
    consolePanel = new JPanel();
    consolePanel.setLayout(new BorderLayout());

    status = new EditorStatus(this);
    consolePanel.add(status, BorderLayout.NORTH);

    console = new EditorConsole(this);
    console.setName("console");
    // windows puts an ugly border on this guy
    console.setBorder(null);
    consolePanel.add(console, BorderLayout.CENTER);

    lineStatus = new EditorLineStatus();
    consolePanel.add(lineStatus, BorderLayout.SOUTH);

    // RTextScrollPane
    scrollPane = new RTextScrollPane(textarea, true);
    scrollPane.setBorder(new MatteBorder(0, 6, 0, 0, Theme.getColor("editor.bgcolor")));
    scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    scrollPane.setLineNumbersEnabled(PreferencesData.getBoolean("editor.linenumbers"));
    scrollPane.setIconRowHeaderEnabled(false);

    Gutter gutter = scrollPane.getGutter();
    gutter.setBookmarkingEnabled(false);
    //gutter.setBookmarkIcon(CompletionsRenderer.getIcon(CompletionType.TEMPLATE));
    gutter.setIconRowHeaderInheritsGutterBackground(true);

    upper.add(scrollPane);
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upper, consolePanel);

    splitPane.setOneTouchExpandable(true);
    // repaint child panes while resizing
    splitPane.setContinuousLayout(true);
    // if window increases in size, give all of increase to
    // the textarea in the uppper pane
    splitPane.setResizeWeight(1D);

    // to fix ugliness.. normally macosx java 1.3 puts an
    // ugly white border around this object, so turn it off.
    splitPane.setBorder(null);

    // the default size on windows is too small and kinda ugly
    int dividerSize = PreferencesData.getInteger("editor.divider.size");
    if (dividerSize != 0) {
        splitPane.setDividerSize(dividerSize);
    }

    // the following changed from 600, 400 for netbooks
    // http://code.google.com/p/arduino/issues/detail?id=52
    splitPane.setMinimumSize(new Dimension(600, 100));
    box.add(splitPane);

    // hopefully these are no longer needed w/ swing
    // (har har har.. that was wishful thinking)
    // listener = new EditorListener(this, textarea);
    pain.add(box);

    // get shift down/up events so we can show the alt version of toolbar buttons
    textarea.addKeyListener(toolbar);

    pain.setTransferHandler(new FileDropHandler());

    //    System.out.println("t1");

    // Finish preparing Editor (formerly found in Base)
    pack();

    //    System.out.println("t2");

    // Set the window bounds and the divider location before setting it visible
    setPlacement(location);

    // Set the minimum size for the editor window
    setMinimumSize(new Dimension(PreferencesData.getInteger("editor.window.width.min"),
            PreferencesData.getInteger("editor.window.height.min")));
    //    System.out.println("t3");

    // Bring back the general options for the editor
    applyPreferences();

    //    System.out.println("t4");

    // Open the document that was passed in
    boolean loaded = handleOpenInternal(file);
    if (!loaded)
        sketch = null;

    //    System.out.println("t5");

    // All set, now show the window
    //setVisible(true);
}

From source file:com.egangotri.transliteratorAsSwing.TransliteratorJFrame.java

public TransliteratorJFrame() {
    super("eGangotri Indic Transliterator");

    PrintWriter pw = new PrintWriter(System.out, true);
    setSize(650, 650);//  w  ww . j  a  va 2  s . c o m

    // menubar
    menubar = new JMenuBar();

    // menus
    file = new JMenu("File");
    help = new JMenu("Help");

    // JMenuItem
    save_1 = new JMenuItem("Save Input");
    save_1.setActionCommand("save_1");
    save_1.addActionListener(this);

    save_2 = new JMenuItem("Save Output-1");
    save_2.setActionCommand("save_2");
    save_2.addActionListener(this);

    save_3 = new JMenuItem("Save Output-2");
    save_3.setActionCommand("save_3");
    save_3.addActionListener(this);

    open_1 = new JMenuItem("Open File for Input");
    open_1.setActionCommand("open_1");
    open_1.addActionListener(this);

    exitItem = new JMenuItem("Exit");
    exitItem.setActionCommand("Exit");
    exitItem.addActionListener(this);

    aboutItem = new JMenuItem("About");
    aboutItem.setActionCommand("about_item");
    aboutItem.addActionListener(this);

    itransItem = new JMenuItem("ITRANS " + Constants.ENCODING_SCHEME);
    itransItem.setActionCommand("itrans_encoding");
    itransItem.addActionListener(this);

    slpItem = new JMenuItem("SLP " + Constants.ENCODING_SCHEME);
    slpItem.setActionCommand("slp_encoding");
    slpItem.addActionListener(this);

    hkItem = new JMenuItem("Harvard Kyoto " + Constants.ENCODING_SCHEME);
    hkItem.setActionCommand("hk_encoding");
    hkItem.addActionListener(this);

    velthuisItem = new JMenuItem("Velthuis " + Constants.ENCODING_SCHEME);
    velthuisItem.setActionCommand("velthuis_encoding");
    velthuisItem.addActionListener(this);

    dvnItem = new JMenuItem("Devanagari " + Constants.ENCODING_SCHEME);
    dvnItem.setActionCommand("devanagari_encoding");
    dvnItem.addActionListener(this);

    iastItem = new JMenuItem("IAST " + Constants.ENCODING_SCHEME);
    iastItem.setActionCommand("iast_encoding");
    iastItem.addActionListener(this);

    // add menuitems to menu
    file.add(open_1);
    file.add(save_1);
    file.add(save_2);
    file.add(save_3);
    file.add(exitItem);

    help.add(aboutItem);
    help.add(itransItem);
    help.add(slpItem);
    help.add(hkItem);
    help.add(velthuisItem);
    help.add(dvnItem);
    help.add(iastItem);

    // add menus to menubar
    menubar.add(file);
    menubar.add(help);
    // menus end

    // JPanel Initilization
    p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    p1a = new JPanel(new BorderLayout());
    p2 = new JPanel();
    p3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    p3a = new JPanel(new BorderLayout());

    p4 = new JPanel();
    p5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    p5a = new JPanel(new BorderLayout());

    p6 = new JPanel();
    p6a = new JPanel();
    p7 = new JPanel();

    // JLabel Initialization
    label1 = new JLabel("Input:");
    label2 = new JLabel("Output-1");
    label3 = new JLabel("Output-2");

    capitalize = new JCheckBox("Capitalize Extended Latin");
    capitalize.setSelected(capitalizeIAST);
    capitalize.setActionCommand("capitalize");
    capitalize.addActionListener(this);

    // Buttons
    clearButton = new JButton("Clear");
    clearButton.setActionCommand("clear");
    clearButton.setToolTipText("Clear all Fields");

    refreshButton = new JButton("Refresh");
    refreshButton.setActionCommand("refresh");
    refreshButton.setToolTipText("Refesh the View");

    exitButton = new JButton("Exit");
    exitButton.setActionCommand("Exit");
    exitButton.setToolTipText("Quit the Application.");

    clipboardButton1 = new JButton("Clipboard");
    clipboardButton1.setActionCommand("clipboard-1");
    clipboardButton1.setToolTipText("Clipboard Input");

    clipboardButton2 = new JButton("Clipboard");
    clipboardButton2.setActionCommand("clipboard-2");
    clipboardButton2.setToolTipText("Clipboard Output-1");

    clipboardButton3 = new JButton("Clipboard");
    clipboardButton3.setActionCommand("clipboard-3");
    clipboardButton3.setToolTipText("Clipboard Output-2");

    clearButton.addActionListener(this);
    refreshButton.addActionListener(this);
    exitButton.addActionListener(this);

    clipboardButton1.addActionListener(this);
    clipboardButton2.addActionListener(this);
    clipboardButton3.addActionListener(this);

    Container contentPane = getContentPane();

    // JTextBox
    tb1 = new JTextArea(new PlainDocument(), null, 6, 45);
    tb1.setLineWrap(true);
    tb1.setWrapStyleWord(true);
    tb1.addKeyListener(this);

    tb2 = new JTextArea(new PlainDocument(), null, 6, 45);
    tb2.setLineWrap(true);
    tb2.setWrapStyleWord(true);
    tb2.addKeyListener(this);

    tb3 = new JTextArea(new PlainDocument(), null, 6, 45);
    tb3.setLineWrap(true);
    tb3.setWrapStyleWord(true);
    tb3.addKeyListener(this);

    // Setting Fonts
    Font unicodeFont = new Font(Constants.ARIAL_UNICODE_MS, Font.PLAIN, Constants.FONT_SIZE);
    tb1.setFont(unicodeFont);
    tb2.setFont(unicodeFont);
    tb3.setFont(unicodeFont);

    comboBox1 = new JComboBox(Constants.ENCODINGS.toArray());
    comboBox1.setActionCommand("comboBox1");
    comboBox1.setSelectedItem(Constants.ITRANS);
    comboBox1.addActionListener(this);

    comboBox2 = new JComboBox(Constants.ENCODINGS.toArray());
    comboBox2.setActionCommand("comboBox2");
    comboBox2.setSelectedItem(Constants.UNICODE_DVN);
    comboBox2.addActionListener(this);

    comboBox3 = new JComboBox(Constants.ENCODINGS.toArray());
    comboBox3.setActionCommand("comboBox3");
    comboBox3.setSelectedItem(Constants.IAST);
    comboBox3.addActionListener(this);

    /** *EXPERIMENT*** */
    textPane = new JTextPane();
    RTFEditorKit rtfkit = new RTFEditorKit();
    // HTMLEditorKit htmlkit = new HTMLEditorKit();
    textPane.setEditorKit(rtfkit); // set Kit which will read RTF Doc
    // textPane.setEditorKit(htmlkit);
    textPane.setEditable(false); // make uneditable
    textPane.setPreferredSize(new Dimension(200, 200));
    textPane.setText(""); // set

    p1.add(label1);
    p1a.add(comboBox1, BorderLayout.LINE_END);
    p1a.add(clipboardButton1, BorderLayout.LINE_START);

    p2.add(new JScrollPane(tb1));

    p3.add(label2);
    p3a.add(comboBox2, BorderLayout.LINE_END);
    p3a.add(clipboardButton2, BorderLayout.LINE_START);

    p4.add(new JScrollPane(tb2));

    p5.add(label3);
    p5a.add(comboBox3, BorderLayout.LINE_END);
    p5a.add(clipboardButton3, BorderLayout.LINE_START);

    p6.add(new JScrollPane(tb3));

    p6a.add(capitalize);
    p7.add(clearButton);
    p7.add(refreshButton);
    p7.add(exitButton);
    this.setJMenuBar(menubar);

    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));

    contentPane.add(p1);
    contentPane.add(p1a);
    contentPane.add(p2);
    contentPane.add(p3);
    contentPane.add(p3a);
    contentPane.add(p4);
    contentPane.add(p5);
    contentPane.add(p5a);
    contentPane.add(p6);
    contentPane.add(p6a);
    contentPane.add(p7);

}

From source file:AppearanceExplorer.java

public void init() {

    // initialize the code base
    try {//w  w w .  java 2 s  . c om
        java.net.URL codeBase = getCodeBase();
        codeBaseString = codeBase.toString();
    } catch (Exception e) {
        // probably running as an application, try the application
        // code base
        codeBaseString = "file:./";
    }

    // set up a NumFormat object to print out float with only 3 fraction
    // digits
    nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(3);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

    canvas = new Canvas3D(config);
    canvas.setSize(600, 600);

    u = new SimpleUniverse(canvas);

    if (isApplication) {
        offScreenCanvas = new OffScreenCanvas3D(config, true);
        // set the size of the off-screen canvas based on a scale
        // of the on-screen size
        Screen3D sOn = canvas.getScreen3D();
        Screen3D sOff = offScreenCanvas.getScreen3D();
        Dimension dim = sOn.getSize();
        dim.width *= offScreenScale;
        dim.height *= offScreenScale;
        sOff.setSize(dim);
        sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth() * offScreenScale);
        sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight() * offScreenScale);

        // attach the offscreen canvas to the view
        u.getViewer().getView().addCanvas3D(offScreenCanvas);
    }
    contentPane.add("Center", canvas);

    BackgroundTool bgTool = new BackgroundTool(codeBaseString);
    bgSwitch = bgTool.getSwitch();
    bgChooser = bgTool.getChooser();

    // Create a simple scene and attach it to the virtual universe
    BranchGroup scene = createSceneGraph();

    // set up sound
    u.getViewer().createAudioDevice();

    // get the view
    view = u.getViewer().getView();

    // Get the viewing platform
    ViewingPlatform viewingPlatform = u.getViewingPlatform();

    // Move the viewing platform back to enclose the -2 -> 2 range
    double viewRadius = 2.0; // want to be able to see circle
    // of viewRadius size around origin
    // get the field of view
    double fov = u.getViewer().getView().getFieldOfView();

    // calc view distance to make circle view in fov
    float viewDistance = (float) (viewRadius / Math.tan(fov / 2.0));
    tmpVector.set(0.0f, 0.0f, viewDistance);// setup offset
    tmpTrans.set(tmpVector); // set trans to translate
    // move the view platform
    viewingPlatform.getViewPlatformTransform().setTransform(tmpTrans);

    // add an orbit behavior to move the viewing platform
    OrbitBehavior orbit = new OrbitBehavior(canvas,
            OrbitBehavior.PROPORTIONAL_ZOOM | OrbitBehavior.REVERSE_ROTATE | OrbitBehavior.REVERSE_TRANSLATE);
    orbit.setZoomFactor(0.25);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
    orbit.setSchedulingBounds(bounds);
    viewingPlatform.setViewPlatformBehavior(orbit);

    u.addBranchGraph(scene);

    contentPane.add("East", guiPanel());
}

From source file:com.projity.pm.graphic.frames.GraphicManager.java

public void initView() {
    Container c = container;
    if (container != null && container instanceof RootPaneContainer) {
        c = ((RootPaneContainer) container).getContentPane();
    }//from w w w .j av  a 2  s.c  om
    if (!Environment.isRibbonUI())
        c.setLayout(new BorderLayout());
    JPanel panel = new JPanel();
    c.add(panel, "Center"); //$NON-NLS-1$
    setFrameManager(new DefaultFrameManager(container, panel, this));

    initLayout();

    if (!Environment.isPlugin())
        setToolBarAndMenus(c);

    setEnabledDocumentMenuActions(false);
    Workspace workspace = decodeWorkspace();
    if (workspace != null) {
        restoreWorkspace(workspace, SavableToWorkspace.VIEW);

    } else
        initProject();
    //        container.invalidate();
}

From source file:com.maxl.java.amikodesk.AMiKoDesk.java

private static void createAndShowFullGUI() {
    // Create and setup window
    final JFrame jframe = new JFrame(Constants.APP_NAME);
    jframe.setName(Constants.APP_NAME + ".main");

    int min_width = CML_OPT_WIDTH;
    int min_height = CML_OPT_HEIGHT;
    jframe.setPreferredSize(new Dimension(min_width, min_height));
    jframe.setMinimumSize(new Dimension(min_width, min_height));
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - min_width) / 2;
    int y = (screen.height - min_height) / 2;
    jframe.setBounds(x, y, min_width, min_height);

    // Set application icon
    if (Utilities.appCustomization().equals("ywesee")) {
        ImageIcon img = new ImageIcon(Constants.AMIKO_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("desitin")) {
        ImageIcon img = new ImageIcon(Constants.DESITIN_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("meddrugs")) {
        ImageIcon img = new ImageIcon(Constants.MEDDRUGS_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("zurrose")) {
        ImageIcon img = new ImageIcon(Constants.AMIKO_ICON);
        jframe.setIconImage(img.getImage());
    }//from w w w.j a  v  a 2  s .c o  m

    // ------ Setup menubar ------
    JMenuBar menu_bar = new JMenuBar();
    // menu_bar.add(Box.createHorizontalGlue()); // --> aligns menu items to the right!
    // -- Menu "Datei" --
    JMenu datei_menu = new JMenu("Datei");
    if (Utilities.appLanguage().equals("fr"))
        datei_menu.setText("Fichier");
    menu_bar.add(datei_menu);
    JMenuItem print_item = new JMenuItem("Drucken...");
    JMenuItem settings_item = new JMenuItem(m_rb.getString("settings") + "...");
    JMenuItem quit_item = new JMenuItem("Beenden");
    if (Utilities.appLanguage().equals("fr")) {
        print_item.setText("Imprimer");
        quit_item.setText("Terminer");
    }
    datei_menu.add(print_item);
    datei_menu.addSeparator();
    datei_menu.add(settings_item);
    datei_menu.addSeparator();
    datei_menu.add(quit_item);

    // -- Menu "Aktualisieren" --
    JMenu update_menu = new JMenu("Aktualisieren");
    if (Utilities.appLanguage().equals("fr"))
        update_menu.setText("Mise  jour");
    menu_bar.add(update_menu);
    final JMenuItem updatedb_item = new JMenuItem("Aktualisieren via Internet...");
    updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
    JMenuItem choosedb_item = new JMenuItem("Aktualisieren via Datei...");
    update_menu.add(updatedb_item);
    update_menu.add(choosedb_item);
    if (Utilities.appLanguage().equals("fr")) {
        updatedb_item.setText("Tlcharger la banque de donnes...");
        updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
        choosedb_item.setText("Ajourner la banque de donnes...");
    }

    // -- Menu "Hilfe" --
    JMenu hilfe_menu = new JMenu("Hilfe");
    if (Utilities.appLanguage().equals("fr"))
        hilfe_menu.setText("Aide");
    menu_bar.add(hilfe_menu);

    JMenuItem about_item = new JMenuItem("ber " + Constants.APP_NAME + "...");
    JMenuItem ywesee_item = new JMenuItem(Constants.APP_NAME + " im Internet");
    if (Utilities.appCustomization().equals("meddrugs"))
        ywesee_item.setText("med-drugs im Internet");
    JMenuItem report_item = new JMenuItem("Error Report...");
    JMenuItem contact_item = new JMenuItem("Kontakt...");

    if (Utilities.appLanguage().equals("fr")) {
        // Extrawunsch med-drugs
        if (Utilities.appCustomization().equals("meddrugs"))
            about_item.setText(Constants.APP_NAME);
        else
            about_item.setText("A propos de " + Constants.APP_NAME + "...");
        contact_item.setText("Contact...");
        if (Utilities.appCustomization().equals("meddrugs"))
            ywesee_item.setText("med-drugs sur Internet");
        else
            ywesee_item.setText(Constants.APP_NAME + " sur Internet");
        report_item.setText("Rapport d'erreur...");
    }
    hilfe_menu.add(about_item);
    hilfe_menu.add(ywesee_item);
    hilfe_menu.addSeparator();
    hilfe_menu.add(report_item);
    hilfe_menu.addSeparator();
    hilfe_menu.add(contact_item);

    // Menu "Abonnieren" (only for ywesee)
    JMenu subscribe_menu = new JMenu("Abonnieren");
    if (Utilities.appLanguage().equals("fr"))
        subscribe_menu.setText("Abonnement");
    if (Utilities.appCustomization().equals("ywesee")) {
        menu_bar.add(subscribe_menu);
    }

    jframe.setJMenuBar(menu_bar);

    // ------ Setup toolbar ------
    JToolBar toolBar = new JToolBar("Database");
    toolBar.setPreferredSize(new Dimension(jframe.getWidth(), 64));
    final JToggleButton selectAipsButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "aips32x32_bright.png"));
    final JToggleButton selectFavoritesButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "favorites32x32_bright.png"));
    final JToggleButton selectInteractionsButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "interactions32x32_bright.png"));
    final JToggleButton selectShoppingCartButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "shoppingcart32x32_bright.png"));
    final JToggleButton selectComparisonCartButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "comparisoncart32x32_bright.png"));

    final JToggleButton list_of_buttons[] = { selectAipsButton, selectFavoritesButton, selectInteractionsButton,
            selectShoppingCartButton, selectComparisonCartButton };

    if (Utilities.appLanguage().equals("de")) {
        setupButton(selectAipsButton, "Kompendium", "aips32x32_gray.png", "aips32x32_dark.png");
        setupButton(selectFavoritesButton, "Favoriten", "favorites32x32_gray.png", "favorites32x32_dark.png");
        setupButton(selectInteractionsButton, "Interaktionen", "interactions32x32_gray.png",
                "interactions32x32_dark.png");
        setupButton(selectShoppingCartButton, "Warenkorb", "shoppingcart32x32_gray.png",
                "shoppingcart32x32_dark.png");
        setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png",
                "comparisoncart32x32_dark.png");
    } else if (Utilities.appLanguage().equals("fr")) {
        setupButton(selectAipsButton, "Compendium", "aips32x32_gray.png", "aips32x32_dark.png");
        setupButton(selectFavoritesButton, "Favorites", "favorites32x32_gray.png", "favorites32x32_dark.png");
        setupButton(selectInteractionsButton, "Interactions", "interactions32x32_gray.png",
                "interactions32x32_dark.png");
        setupButton(selectShoppingCartButton, "Panier", "shoppingcart32x32_gray.png",
                "shoppingcart32x32_dark.png");
        setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png",
                "comparisoncart32x32_dark.png");
    }

    // Add to toolbar and set up
    toolBar.setBackground(m_toolbar_bg);
    toolBar.add(selectAipsButton);
    toolBar.addSeparator();
    toolBar.add(selectFavoritesButton);
    toolBar.addSeparator();
    toolBar.add(selectInteractionsButton);
    if (!Utilities.appCustomization().equals("zurrose")) {
        toolBar.addSeparator();
        toolBar.add(selectShoppingCartButton);
    }
    if (Utilities.appCustomization().equals("zurrorse")) {
        toolBar.addSeparator();
        toolBar.add(selectComparisonCartButton);
    }
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    // Progress indicator (not working...)
    toolBar.addSeparator(new Dimension(32, 32));
    toolBar.add(m_progress_indicator);

    // ------ Setup settingspage ------
    final SettingsPage settingsPage = new SettingsPage(jframe, m_rb);
    // Attach observer to it
    settingsPage.addObserver(new Observer() {
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            if (m_shopping_cart != null) {
                // Refresh some stuff
                m_shopping_basket.clear();
                int index = m_shopping_cart.getCartIndex();
                if (index > 0)
                    m_web_panel.saveShoppingCartWithIndex(index);
                m_web_panel.updateShoppingHtml();
            }
        }
    });

    jframe.addWindowListener(new WindowListener() {
        // Use WindowAdapter!
        @Override
        public void windowOpened(WindowEvent e) {
        }

        @Override
        public void windowClosed(WindowEvent e) {
            m_web_panel.dispose();
            Runtime.getRuntime().exit(0);
        }

        @Override
        public void windowClosing(WindowEvent e) {
            // Save shopping cart
            int index = m_shopping_cart.getCartIndex();
            if (index > 0 && m_web_panel != null)
                m_web_panel.saveShoppingCartWithIndex(index);
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }
    });
    print_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            m_web_panel.print();
        }
    });
    settings_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            settingsPage.display();
        }
    });
    quit_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                // Save shopping cart
                int index = m_shopping_cart.getCartIndex();
                if (index > 0 && m_web_panel != null)
                    m_web_panel.saveShoppingCartWithIndex(index);
                // Save settings
                WindowSaver.saveSettings();
                m_web_panel.dispose();
                Runtime.getRuntime().exit(0);
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    });
    subscribe_menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI(
                                "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3UM84Z6WLFKZE"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent event) {
            // do nothing
        }

        @Override
        public void menuCanceled(MenuEvent event) {
            // do nothing
        }
    });
    contact_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI
                                .create("mailto:zdavatz@ywesee.com?subject=AmiKo%20Desktop%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("desitin")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI
                                .create("mailto:info@desitin.ch?subject=AmiKo%20Desktop%20Desitin%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("meddrugs")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI.create(
                                "mailto:med-drugs@just-medical.com?subject=med-drugs%20desktop%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("zurrose")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }
    });
    report_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            // Check first m_application_folder otherwise resort to
            // pre-installed report
            String report_file = m_application_data_folder + "\\" + Constants.DEFAULT_AMIKO_REPORT_BASE
                    + Utilities.appLanguage() + ".html";
            if (!(new File(report_file)).exists())
                report_file = System.getProperty("user.dir") + "/dbs/" + Constants.DEFAULT_AMIKO_REPORT_BASE
                        + Utilities.appLanguage() + ".html";
            // Open report file in browser
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new File(report_file).toURI());
                } catch (IOException e) {
                    // TODO:
                }
            }
        }
    });
    ywesee_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("http://www.ywesee.com/AmiKo/Desktop"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("desitin")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(
                                new URI("http://www.desitin.ch/produkte/arzneimittel-kompendium-apps/"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("meddrugs")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        if (Utilities.appLanguage().equals("de"))
                            Desktop.getDesktop().browse(new URI("http://www.med-drugs.ch"));
                        else if (Utilities.appLanguage().equals("fr"))
                            Desktop.getDesktop()
                                    .browse(new URI("http://www.med-drugs.ch/index.cfm?&newlang=fr"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("zurrose")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }
    });
    about_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            AmiKoDialogs ad = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
            ad.AboutDialog();
        }
    });

    // Container
    final Container container = jframe.getContentPane();
    container.setBackground(Color.WHITE);
    container.setLayout(new BorderLayout());

    // ==== Toolbar =====
    container.add(toolBar, BorderLayout.NORTH);

    // ==== Left panel ====
    JPanel left_panel = new JPanel();
    left_panel.setBackground(Color.WHITE);
    left_panel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(2, 2, 2, 2);

    // ---- Search field ----
    final SearchField searchField = new SearchField("Suche Prparat");
    if (Utilities.appLanguage().equals("fr"))
        searchField.setText("Recherche Specialit");
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(searchField, gbc);
    left_panel.add(searchField, gbc);

    // ---- Buttons ----
    // Names
    String l_title = "Prparat";
    String l_author = "Inhaberin";
    String l_atccode = "Wirkstoff / ATC Code";
    String l_regnr = "Zulassungsnummer";
    String l_ingredient = "Wirkstoff";
    String l_therapy = "Therapie";
    String l_search = "Suche";

    if (Utilities.appLanguage().equals("fr")) {
        l_title = "Spcialit";
        l_author = "Titulaire";
        l_atccode = "Principe Active / Code ATC";
        l_regnr = "Nombre Enregistration";
        l_ingredient = "Principe Active";
        l_therapy = "Thrapie";
        l_search = "Recherche";
    }

    ButtonGroup bg = new ButtonGroup();

    JToggleButton but_title = new JToggleButton(l_title);
    setupToggleButton(but_title);
    bg.add(but_title);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_title, gbc);
    left_panel.add(but_title, gbc);

    JToggleButton but_auth = new JToggleButton(l_author);
    setupToggleButton(but_auth);
    bg.add(but_auth);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_auth, gbc);
    left_panel.add(but_auth, gbc);

    JToggleButton but_atccode = new JToggleButton(l_atccode);
    setupToggleButton(but_atccode);
    bg.add(but_atccode);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_atccode, gbc);
    left_panel.add(but_atccode, gbc);

    JToggleButton but_regnr = new JToggleButton(l_regnr);
    setupToggleButton(but_regnr);
    bg.add(but_regnr);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_regnr, gbc);
    left_panel.add(but_regnr, gbc);

    JToggleButton but_therapy = new JToggleButton(l_therapy);
    setupToggleButton(but_therapy);
    bg.add(but_therapy);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_therapy, gbc);
    left_panel.add(but_therapy, gbc);

    // ---- Card layout ----
    final CardLayout cardl = new CardLayout();
    cardl.setHgap(-4); // HACK to make things look better!!
    final JPanel p_results = new JPanel(cardl);
    m_list_titles = new ListPanel();
    m_list_auths = new ListPanel();
    m_list_regnrs = new ListPanel();
    m_list_atccodes = new ListPanel();
    m_list_ingredients = new ListPanel();
    m_list_therapies = new ListPanel();
    // Contraints
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = 1;
    gbc.gridheight = 10;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    //
    p_results.add(m_list_titles, l_title);
    p_results.add(m_list_auths, l_author);
    p_results.add(m_list_regnrs, l_regnr);
    p_results.add(m_list_atccodes, l_atccode);
    p_results.add(m_list_ingredients, l_ingredient);
    p_results.add(m_list_therapies, l_therapy);

    // --> container.add(p_results, gbc);
    left_panel.add(p_results, gbc);
    left_panel.setBorder(null);
    // First card to show
    cardl.show(p_results, l_title);

    // ==== Right panel ====
    JPanel right_panel = new JPanel();
    right_panel.setBackground(Color.WHITE);
    right_panel.setLayout(new GridBagLayout());

    // ---- Section titles ----
    m_section_titles = null;
    if (Utilities.appLanguage().equals("de")) {
        m_section_titles = new IndexPanel(SectionTitle_DE);
    } else if (Utilities.appLanguage().equals("fr")) {
        m_section_titles = new IndexPanel(SectionTitle_FR);
    }
    m_section_titles.setMinimumSize(new Dimension(150, 150));
    m_section_titles.setMaximumSize(new Dimension(320, 1000));

    // ---- Fachinformation ----
    m_web_panel = new WebPanel2();
    m_web_panel.setMinimumSize(new Dimension(320, 150));

    // Add JSplitPane on the RIGHT
    final int Divider_location = 150;
    final int Divider_size = 10;
    final JSplitPane split_pane_right = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, m_section_titles,
            m_web_panel);
    split_pane_right.setOneTouchExpandable(true);
    split_pane_right.setDividerLocation(Divider_location);
    split_pane_right.setDividerSize(Divider_size);

    // Add JSplitPane on the LEFT
    JSplitPane split_pane_left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left_panel,
            split_pane_right /* right_panel */);
    split_pane_left.setOneTouchExpandable(true);
    split_pane_left.setDividerLocation(320); // Sets the pane divider location
    split_pane_left.setDividerSize(Divider_size);
    container.add(split_pane_left, BorderLayout.CENTER);

    // Add status bar on the bottom
    JPanel statusPanel = new JPanel();
    statusPanel.setPreferredSize(new Dimension(jframe.getWidth(), 16));
    statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
    container.add(statusPanel, BorderLayout.SOUTH);

    final JLabel m_status_label = new JLabel("");
    m_status_label.setHorizontalAlignment(SwingConstants.LEFT);
    statusPanel.add(m_status_label);

    // Add mouse listener
    searchField.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            searchField.setText("");
        }
    });

    final String final_title = l_title;
    final String final_author = l_author;
    final String final_atccode = l_atccode;
    final String final_regnr = l_regnr;
    final String final_therapy = l_therapy;
    final String final_search = l_search;

    // Internal class that implements switching between buttons
    final class Toggle {
        public void toggleButton(JToggleButton jbn) {
            for (int i = 0; i < list_of_buttons.length; ++i) {
                if (jbn == list_of_buttons[i])
                    list_of_buttons[i].setSelected(true);
                else
                    list_of_buttons[i].setSelected(false);
            }
        }
    }
    ;

    // ------ Add toolbar action listeners ------
    selectAipsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectAipsButton);
            // Set state 'aips'
            if (!m_curr_uistate.getUseMode().equals("aips")) {
                m_curr_uistate.setUseMode("aips");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        m_query_str = searchField.getText();
                        int num_hits = retrieveAipsSearchResults(false);
                        m_status_label.setText(med_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                        //
                        if (med_index < 0 && prev_med_index >= 0)
                            med_index = prev_med_index;
                        m_web_panel.updateText();
                        if (num_hits == 0) {
                            m_web_panel.emptyPage();
                        }
                    }
                });
            }
        }
    });
    selectFavoritesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectFavoritesButton);
            // Set state 'favorites'
            if (!m_curr_uistate.getUseMode().equals("favorites")) {
                m_curr_uistate.setUseMode("favorites");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        // m_query_str = searchField.getText();
                        // Clear the search container
                        med_search.clear();
                        for (String regnr : favorite_meds_set) {
                            List<Medication> meds = m_sqldb.searchRegNr(regnr);
                            if (!meds.isEmpty()) { // Add med database ID
                                med_search.add(meds.get(0));
                            }
                        }
                        // Sort list of meds
                        Collections.sort(med_search, new Comparator<Medication>() {
                            @Override
                            public int compare(final Medication m1, final Medication m2) {
                                return m1.getTitle().compareTo(m2.getTitle());
                            }
                        });

                        sTitle();
                        cardl.show(p_results, final_title);

                        m_status_label.setText(med_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                    }
                });
            }
        }
    });
    selectInteractionsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectInteractionsButton);
            // Set state 'interactions'
            if (!m_curr_uistate.getUseMode().equals("interactions")) {
                m_curr_uistate.setUseMode("interactions");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_query_str = searchField.getText();
                        retrieveAipsSearchResults(false);
                        // Switch to interaction mode
                        m_web_panel.updateInteractionsCart();
                        m_web_panel.repaint();
                        m_web_panel.validate();
                    }
                });
            }
        }
    });
    selectShoppingCartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String email_adr = m_prefs.get("emailadresse", "");
            if (email_adr != null && email_adr.length() > 2) // Two chars is the minimum lenght for an email address
                m_preferences_ok = true;
            if (m_preferences_ok) {
                m_preferences_ok = false; // Check always
                new Toggle().toggleButton(selectShoppingCartButton);
                // Set state 'shopping'
                if (!m_curr_uistate.getUseMode().equals("shopping")) {
                    m_curr_uistate.setUseMode("shopping");
                    // Show middle pane
                    split_pane_right.setDividerSize(Divider_size);
                    split_pane_right.setDividerLocation(Divider_location);
                    m_section_titles.setVisible(true);
                    // Set right panel title
                    m_web_panel.setTitle(m_rb.getString("shoppingCart"));
                    // Switch to shopping cart
                    int index = 1;
                    if (m_shopping_cart != null) {
                        index = m_shopping_cart.getCartIndex();
                        m_web_panel.loadShoppingCartWithIndex(index);
                        // m_shopping_cart.printShoppingBasket();
                    }
                    // m_web_panel.updateShoppingHtml();
                    m_web_panel.updateListOfPackages();
                    if (m_first_pass == true) {
                        m_first_pass = false;
                        if (Utilities.appCustomization().equals("ywesee"))
                            med_search = m_sqldb.searchAuth("ibsa");
                        else if (Utilities.appCustomization().equals("desitin"))
                            med_search = m_sqldb.searchAuth("desitin");
                        sAuth();
                        cardl.show(p_results, final_author);
                    }
                }
            } else {
                selectShoppingCartButton.setSelected(false);
                settingsPage.display();
            }
        }
    });
    selectComparisonCartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectComparisonCartButton);
            // Set state 'comparison'
            if (!m_curr_uistate.getUseMode().equals("comparison")) {
                m_curr_uistate.setUseMode("comparison");
                // Hide middle pane
                m_section_titles.setVisible(false);
                split_pane_right.setDividerLocation(0);
                split_pane_right.setDividerSize(0);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        // Set right panel title
                        m_web_panel.setTitle(getTitle("priceComp"));
                        if (med_index >= 0) {
                            if (med_id != null && med_index < med_id.size()) {
                                Medication m = m_sqldb.getMediWithId(med_id.get(med_index));
                                String atc_code = m.getAtcCode();
                                if (atc_code != null) {
                                    String atc = atc_code.split(";")[0];
                                    m_web_panel.fillComparisonBasket(atc);
                                    m_web_panel.updateComparisonCartHtml();
                                    // Update pane on the left
                                    retrieveAipsSearchResults(false);
                                }
                            }
                        }

                        m_status_label.setText(rose_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                    }
                });
            }
        }
    });

    // ------ Add keylistener to text field (type as you go feature) ------
    searchField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) { // keyReleased(KeyEvent e)
            // invokeLater potentially in the wrong place... more testing
            // required
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (m_curr_uistate.isLoadCart())
                        m_curr_uistate.restoreUseMode();
                    m_start_time = System.currentTimeMillis();
                    m_query_str = searchField.getText();
                    // Queries for SQLite DB
                    if (!m_query_str.isEmpty()) {
                        if (m_query_type == 0) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchTitle(m_query_str);
                            } else {
                                med_search = m_sqldb.searchTitle(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sTitle();
                            cardl.show(p_results, final_title);
                        } else if (m_query_type == 1) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchSupplier(m_query_str);
                            } else {
                                med_search = m_sqldb.searchAuth(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sAuth();
                            cardl.show(p_results, final_author);
                        } else if (m_query_type == 2) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchATC(m_query_str);
                            } else {
                                med_search = m_sqldb.searchATC(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sATC();
                            cardl.show(p_results, final_atccode);
                        } else if (m_query_type == 3) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchEan(m_query_str);
                            } else {
                                med_search = m_sqldb.searchRegNr(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sRegNr();
                            cardl.show(p_results, final_regnr);
                        } else if (m_query_type == 4) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchTherapy(m_query_str);
                            } else {
                                med_search = m_sqldb.searchApplication(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sTherapy();
                            cardl.show(p_results, final_therapy);
                        } else {
                            // do nothing
                        }
                        int num_hits = 0;
                        if (m_curr_uistate.isComparisonMode())
                            num_hits = rose_search.size();
                        else
                            num_hits = med_search.size();
                        m_status_label.setText(num_hits + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");

                    }
                }
            });
        }
    });

    // Add actionlisteners
    but_title.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_title);
            m_curr_uistate.setQueryType(m_query_type = 0);
            sTitle();
            cardl.show(p_results, final_title);
        }
    });
    but_auth.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_author);
            m_curr_uistate.setQueryType(m_query_type = 1);
            sAuth();
            cardl.show(p_results, final_author);
        }
    });
    but_atccode.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_atccode);
            m_curr_uistate.setQueryType(m_query_type = 2);
            sATC();
            cardl.show(p_results, final_atccode);
        }
    });
    but_regnr.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_regnr);
            m_curr_uistate.setQueryType(m_query_type = 3);
            sRegNr();
            cardl.show(p_results, final_regnr);
        }
    });
    but_therapy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_therapy);
            m_curr_uistate.setQueryType(m_query_type = 4);
            sTherapy();
            cardl.show(p_results, final_therapy);
        }
    });

    // Display window
    jframe.pack();
    // jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    // jframe.setAlwaysOnTop(true);
    jframe.setVisible(true);

    // Check if user has selected an alternative database
    /*
     * NOTE: 21/11/2013: This solution is put on ice. Favored is a solution
     * where the database selected by the user is saved in a default folder
     * (see variable "m_application_data_folder")
     */
    /*
     * try { WindowSaver.loadSettings(jframe); String database_path =
     * WindowSaver.getDbPath(); if (database_path!=null)
     * m_sqldb.loadDBFromPath(database_path); } catch(IOException e) {
     * e.printStackTrace(); }
     */
    // Load AIPS database
    selectAipsButton.setSelected(true);
    selectFavoritesButton.setSelected(false);
    m_curr_uistate.setUseMode("aips");
    med_search = m_sqldb.searchTitle("");
    sTitle(); // Used instead of sTitle (which is slow)
    cardl.show(p_results, final_title);

    // Add menu item listeners
    updatedb_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (m_mutex_update == false) {
                m_mutex_update = true;
                String db_file = m_maindb_update.doIt(jframe, Utilities.appLanguage(),
                        Utilities.appCustomization(), m_application_data_folder, m_full_db_update);
                // ... and update time
                if (m_full_db_update == true) {
                    DateTime dT = new DateTime();
                    m_prefs.put("updateTime", dT.now().toString());
                }
                //
                if (!db_file.isEmpty()) {
                    // Save db path (can't hurt)
                    WindowSaver.setDbPath(db_file);
                }
            }
        }
    });

    choosedb_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String db_file = m_maindb_update.chooseFromFile(jframe, Utilities.appLanguage(),
                    Utilities.appCustomization(), m_application_data_folder);
            // ... and update time
            DateTime dT = new DateTime();
            m_prefs.put("updateTime", dT.now().toString());
            //
            if (!db_file.isEmpty()) {
                // Save db path (can't hurt)
                WindowSaver.setDbPath(db_file);
            }
        }
    });

    /**
     * Observers
     */
    // Attach observer to 'm_update'
    m_maindb_update.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            // Reset flag
            m_full_db_update = true;
            m_mutex_update = false;
            // Refresh some stuff after update
            loadAuthors();
            m_emailer.loadMap();
            settingsPage.load_gln_codes();
            if (m_shopping_cart != null) {
                m_shopping_cart.load_conditions();
                m_shopping_cart.load_glns();
            }
            // Empty shopping basket
            if (m_curr_uistate.isShoppingMode()) {
                m_shopping_basket.clear();
                int index = m_shopping_cart.getCartIndex();
                if (index > 0)
                    m_web_panel.saveShoppingCartWithIndex(index);
                m_web_panel.updateShoppingHtml();
            }
            if (m_curr_uistate.isComparisonMode())
                m_web_panel.setTitle(getTitle("priceComp"));
        }
    });

    // Attach observer to 'm_emailer'
    m_emailer.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            // Empty shopping basket
            m_shopping_basket.clear();
            int index = m_shopping_cart.getCartIndex();
            if (index > 0)
                m_web_panel.saveShoppingCartWithIndex(index);
            m_web_panel.updateShoppingHtml();
        }
    });

    // Attach observer to "m_comparison_cart"
    m_comparison_cart.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            m_web_panel.setTitle(getTitle("priceComp"));
            m_comparison_cart.clearUploadList();
            m_web_panel.updateComparisonCartHtml();
            new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()).UploadDialog((String) arg);
        }
    });

    // If command line options are provided start app with a particular title or eancode
    if (commandLineOptionsProvided()) {
        if (!CML_OPT_TITLE.isEmpty())
            startAppWithTitle(but_title);
        else if (!CML_OPT_EANCODE.isEmpty())
            startAppWithEancode(but_regnr);
        else if (!CML_OPT_REGNR.isEmpty())
            startAppWithRegnr(but_regnr);
    }

    // Start timer
    Timer global_timer = new Timer();
    // Time checks all 2 minutes (120'000 milliseconds)
    global_timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            checkIfUpdateRequired(updatedb_item);
        }
    }, 2 * 60 * 1000, 2 * 60 * 1000);
}

From source file:course_generator.frmMain.java

/**
 * This method is called to initialize the form.
 *//*  w  w w.  j av  a 2s.com*/
private void initComponents() {
    // -- Main windows
    // ------------------------------------------------------
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    // java.util.ResourceBundle bundle =
    // java.util.ResourceBundle.getBundle("course_generator/Bundle");
    setTitle(bundle.getString("frmMain.title"));
    setIconImages(null);
    // setName("FrameMain");
    // setPreferredSize(new java.awt.Dimension(812, 800));
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });

    // -- Layout
    // ------------------------------------------------------------
    Container paneGlobal = getContentPane();
    // paneGlobal.setLayout(new GridBagLayout());
    paneGlobal.setLayout(new BorderLayout());

    // -- Menu bar
    // ----------------------------------------------------------
    Create_MenuBarMain();

    // -- Main toolbar
    // ------------------------------------------------------
    Create_MainToolbar();
    paneGlobal.add(ToolBarMain, BorderLayout.NORTH);

    // -- Status bar
    // ------------------------------------------------------
    Create_Statusbar();
    paneGlobal.add(StatusBar, BorderLayout.SOUTH);

    // -- Main split bar (vertical)
    // -----------------------------------------
    SplitPaneMain = new javax.swing.JSplitPane();
    paneGlobal.add(SplitPaneMain, BorderLayout.CENTER);

    // -- Left side of the split bar
    // ----------------------------------------
    jPanelLeft = new javax.swing.JPanel();
    jPanelLeft.setLayout(new java.awt.BorderLayout());

    // -- Add the left panel to the main split panel
    // ------------------------
    SplitPaneMain.setLeftComponent(jPanelLeft);

    // -- Content of the tree
    javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode(
            "Course Generator");
    javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Parcours");
    javax.swing.tree.DefaultMutableTreeNode treeNode3 = new javax.swing.tree.DefaultMutableTreeNode(
            "Utmb 2011");
    javax.swing.tree.DefaultMutableTreeNode treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Montagnard");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2008");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2009");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2010");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2011");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2012");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2013");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode1.add(treeNode2);
    treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Configuration");
    treeNode1.add(treeNode2);

    // -- Tree
    // --------------------------------------------------------------
    jTreeMain = new javax.swing.JTree();
    jTreeMain.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
    jTreeMain.setPreferredSize(new java.awt.Dimension(109, 25));

    // -- Add the tree to a scroll panel
    // ------------------------------------
    jScrollPaneTree = new javax.swing.JScrollPane();
    jScrollPaneTree.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    jScrollPaneTree.setViewportView(jTreeMain);

    // -- Add the scroll panel to the left panel
    // ----------------------------
    jPanelLeft.add(jScrollPaneTree, java.awt.BorderLayout.CENTER);

    // -- Right split pane
    // --------------------------------------------------
    SplitPaneMainRight = new javax.swing.JSplitPane();
    SplitPaneMainRight.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    SplitPaneMain.setRightComponent(SplitPaneMainRight);

    // -- Tabbed panel
    // ------------------------------------------------------
    TabbedPaneMain = new javax.swing.JTabbedPane();
    // -- Create the listener
    ChangeListener changeListener = new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
            int index = sourceTabbedPane.getSelectedIndex();
            if (index == 4) // Tab Resume
                RefreshResume();
        }
    };
    TabbedPaneMain.addChangeListener(changeListener);

    SplitPaneMainRight.setTopComponent(TabbedPaneMain);

    // -- Tab - data (grid)
    // -------------------------------------------------
    TableMain = new javax.swing.JTable();
    TableMain.setModel(ModelTableMain);
    TableMain.getTableHeader()
            .setDefaultRenderer(new MainHeaderRenderer(TableMain.getTableHeader().getDefaultRenderer()));
    TableMain.getTableHeader().setReorderingAllowed(false);

    TableMain.setDefaultRenderer(ElevationClass.class, new ElevationRenderer());
    TableMain.setDefaultRenderer(DistClass.class, new DistRenderer());
    TableMain.setDefaultRenderer(TotalClass.class, new TotalRenderer());
    TableMain.setDefaultRenderer(DiffClass.class, new DiffRenderer());
    TableMain.setDefaultRenderer(CoeffClass.class, new CoeffRenderer());
    TableMain.setDefaultRenderer(LatClass.class, new LatRenderer());
    TableMain.setDefaultRenderer(LonClass.class, new LonRenderer());
    TableMain.setDefaultRenderer(RecupClass.class, new RecupRenderer());
    TableMain.setDefaultRenderer(TimeClass.class, new TimeRenderer());
    TableMain.setDefaultRenderer(TimelimitClass.class, new TimelimitRenderer());
    TableMain.setDefaultRenderer(HourClass.class, new HourRenderer());
    TableMain.setDefaultRenderer(StationClass.class, new StationRenderer());
    TableMain.setDefaultRenderer(TagClass.class, new TagRenderer());

    TableMain.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
    TableMain.setRowHeight(20);
    TableMain.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() >= 2 && !evt.isConsumed()) {
                evt.consume();
                int row = TableMain.rowAtPoint(evt.getPoint());
                int col = TableMain.columnAtPoint(evt.getPoint());
                frmEditPosition frm = new frmEditPosition();
                if (frm.showDialog(Settings, Track, row, col)) {
                    Track.isModified = true;
                    RefreshTableMain();
                    RefreshProfil();
                    RefreshStatusbar(Track);
                }
            } else
                TableMainMouseClicked(evt);
        }
    });
    TableMain.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
            TableMainKeyReleased(evt);
        }
    });

    // -- Add the grid to a scroll panel
    // ------------------------------------
    jScrollPaneData = new javax.swing.JScrollPane();
    jScrollPaneData.setViewportView(TableMain);

    // -- Add the scroll panel to the tabbed panel
    // --------------------------
    addTab(TabbedPaneMain, jScrollPaneData, bundle.getString("frmMain.TabData.tabTitle"),
            new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/satellite16.png")));

    // -- Tab - Profil
    // ------------------------------------------------------
    jPanelProfil = new javax.swing.JPanel();
    jPanelProfil.setPreferredSize(new java.awt.Dimension(677, 150));
    jPanelProfil.setLayout(new java.awt.BorderLayout());

    // -- Profil tool bar
    // ---------------------------------------------------
    // Create_Profil_Toolbar();
    // jPanelProfil.add(ToolBarProfil, java.awt.BorderLayout.WEST);

    // -- Profil chart
    // ------------------------------------------------------
    jPanelProfilChart = new ChartPanel(chart);
    CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
    xCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f));
    // xCrosshair.setLabelVisible(true);
    xCrosshair.setLabelBackgroundPaint(Color.WHITE);

    yCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f));
    // yCrosshair.setLabelVisible(true);
    yCrosshair.setLabelBackgroundPaint(Color.WHITE);

    crosshairOverlay.addDomainCrosshair(xCrosshair);
    crosshairOverlay.addRangeCrosshair(yCrosshair);

    jPanelProfilChart.addOverlay(crosshairOverlay);
    jPanelProfilChart.setBackground(new java.awt.Color(255, 0, 51));
    jPanelProfilChart.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseClicked(ChartMouseEvent event) {

            ChartEntity chartentity = event.getEntity();
            if (chartentity instanceof XYItemEntity) {
                XYItemEntity e = (XYItemEntity) chartentity;
                XYDataset d = e.getDataset();
                int s = e.getSeriesIndex();
                int i = e.getItem();
                double x = d.getXValue(s, i);
                double y = d.getYValue(s, i);
                xCrosshair.setValue(x);
                yCrosshair.setValue(y);
                RefreshProfilInfo(i);
                //Refresh the position on the data grid
                TableMain.setRowSelectionInterval(i, i);
                Rectangle rect = TableMain.getCellRect(i, 0, true);
                TableMain.scrollRectToVisible(rect);
                //Refresh the marker position on the map
                RefreshCurrentPosMarker(Track.data.get(i).getLatitude(), Track.data.get(i).getLongitude());
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
        }
    });

    jPanelProfil.add(jPanelProfilChart, java.awt.BorderLayout.CENTER);

    // -- Profil info bar
    // ---------------------------------------------------
    jPanelProfilInfo = new javax.swing.JPanel();
    jPanelProfilInfo.setLayout(new GridBagLayout());
    jPanelProfil.add(jPanelProfilInfo, java.awt.BorderLayout.SOUTH);

    // -- Line 0
    // -- Distance
    // ----------------------------------------------------------
    lbProfilDistance = new javax.swing.JLabel();
    lbProfilDistance.setText(" " + bundle.getString("frmMain.lbProfilDistance.text") + "=0.000km ");
    lbProfilDistance.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilDistance, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.BOTH);

    // -- Time
    // --------------------------------------------------------------
    lbProfilTime = new javax.swing.JLabel();
    lbProfilTime.setText(" " + bundle.getString("frmMain.lbProfilTime.text") + "=00:00:00 ");
    lbProfilTime.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilTime, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);

    // -- Slope
    // -------------------------------------------------------------
    lbProfilSlope = new javax.swing.JLabel();
    lbProfilSlope.setText(" " + bundle.getString("frmMain.lbProfilSlope.text") + "=0.0% ");
    lbProfilSlope.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilSlope, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);

    // -- Name
    // --------------------------------------------------------------
    lbProfilName = new javax.swing.JLabel();
    lbProfilName.setText(" " + bundle.getString("frmMain.lbProfilName.text") + "= ");
    lbProfilName.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilName, 3, 0, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);

    // -- Line 1
    // -- Elevation
    // ---------------------------------------------------------
    lbProfilElevation = new javax.swing.JLabel();
    lbProfilElevation.setText(" " + bundle.getString("frmMain.lbProfilElevation.text") + "=0m ");
    lbProfilElevation.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilElevation, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.BOTH);

    // -- Hour
    // --------------------------------------------------------------
    lbProfilHour = new javax.swing.JLabel();
    lbProfilHour.setText(" " + bundle.getString("frmMain.lbProfilHour.text") + "=00:00:00 ");
    lbProfilHour.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilHour, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);

    // -- Speed
    // -------------------------------------------------------------
    lbProfilSpeed = new javax.swing.JLabel();
    lbProfilSpeed.setText(" " + bundle.getString("frmMain.lbProfilSpeed.text") + "=0.0km/h ");
    lbProfilSpeed.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilSpeed, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);

    // -- Comment
    // -----------------------------------------------------------
    lbProfilComment = new javax.swing.JLabel();
    lbProfilComment.setText(" " + bundle.getString("frmMain.lbProfilComment.text") + "= ");
    lbProfilComment.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilComment, 3, 1, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);
    // -- Distance / Temps / Pente / Nom
    // -- Altitude / Heure / Vitesse / Commentaire

    // -- Add the panel to the tabbed panel
    // ---------------------------------
    addTab(TabbedPaneMain, jPanelProfil, bundle.getString("frmMain.TabProfil.tabTitle"),
            new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/profil.png")));

    // -- Tab - Statistic
    // ---------------------------------------------------
    jPanelStatistic = new javax.swing.JPanel();
    jPanelStatistic.setLayout(new java.awt.BorderLayout());

    // -- Statistic tool bar
    // ---------------------------------------------------
    Create_Statistic_Toolbar();
    jPanelStatistic.add(ToolBarStatistic, java.awt.BorderLayout.NORTH);

    // TODO Add the component to display the statistics

    addTab(TabbedPaneMain, jPanelStatistic, bundle.getString("frmMain.TabStatistic.tabTitle"),
            new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/stat.png")));

    // -- Tab - Analysis
    // ----------------------------------------------------
    jPanelAnalyze = new javax.swing.JPanel();

    // TODO Define this panel

    addTab(TabbedPaneMain, jPanelAnalyze, bundle.getString("frmMain.TabAnalyze.tabTitle"),
            new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/search.png")));

    // -- Tab - Resume
    // ------------------------------------------------------
    jPanelResume = new javax.swing.JPanel();
    jPanelResume.setLayout(new java.awt.BorderLayout());

    // -- Resume tool bar
    // ---------------------------------------------------
    Create_Resume_Toolbar();
    jPanelResume.add(ToolBarResume, java.awt.BorderLayout.NORTH);

    TableResume = new javax.swing.JTable();
    TableResume.setModel(ModelTableResume);
    TableResume.setRowHeight(20);
    TableResume.getTableHeader().setReorderingAllowed(false);

    TableResume.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);

    TableResume.getTableHeader()
            .setDefaultRenderer(new ResumeHeaderRenderer(TableResume.getTableHeader().getDefaultRenderer()));

    // TODO Change the Renderer name. Add Resume...
    TableResume.setDefaultRenderer(ResumeNumClass.class, new ResumeNumRenderer());
    TableResume.setDefaultRenderer(ResumeNameClass.class, new ResumeNameRenderer());
    TableResume.setDefaultRenderer(ResumeLineClass.class, new ResumeLineRenderer());
    TableResume.setDefaultRenderer(ResumeElevationClass.class, new ResumeElevationRenderer());
    TableResume.setDefaultRenderer(ResumeClimbPClass.class, new ResumeClimbPRenderer());
    TableResume.setDefaultRenderer(ResumeClimbNClass.class, new ResumeClimbNRenderer());
    TableResume.setDefaultRenderer(ResumeDistanceClass.class, new ResumeDistanceRenderer());
    TableResume.setDefaultRenderer(ResumeTimeClass.class, new ResumeTimeRenderer());
    TableResume.setDefaultRenderer(ResumeHourClass.class, new ResumeHourRenderer());
    TableResume.setDefaultRenderer(ResumedtTimeClass.class, new ResumedtTimeRenderer());
    TableResume.setDefaultRenderer(ResumeTimeLimitClass.class, new ResumeTimeLimitRenderer());
    TableResume.setDefaultRenderer(ResumeStationTimeClass.class, new ResumeStationTimeRenderer());
    TableResume.setDefaultRenderer(ResumedtDistanceClass.class, new ResumedtDistanceRenderer());
    TableResume.setDefaultRenderer(ResumedtClimbPClass.class, new ResumedtClimbPRenderer());
    TableResume.setDefaultRenderer(ResumedtClimbNClass.class, new ResumedtClimbNRenderer());
    TableResume.setDefaultRenderer(ResumeSpeedPClass.class, new ResumeSpeedPRenderer());
    TableResume.setDefaultRenderer(ResumeSpeedNClass.class, new ResumeSpeedNRenderer());
    TableResume.setDefaultRenderer(ResumeAvgSlopePClass.class, new ResumeAvgSlopePRenderer());
    TableResume.setDefaultRenderer(ResumeAvgSlopeNClass.class, new ResumeAvgSlopeNRenderer());
    TableResume.setDefaultRenderer(ResumeAvgSpeedClass.class, new ResumeAvgSpeedRenderer());
    TableResume.setDefaultRenderer(ResumeCommentClass.class, new ResumeCommentRenderer());

    // TableResume.addMouseListener(new java.awt.event.MouseAdapter() {
    // public void mouseClicked(java.awt.event.MouseEvent evt) {
    // TableMainMouseClicked(evt);
    // }
    // });
    // TableResume.addKeyListener(new java.awt.event.KeyAdapter() {
    // public void keyReleased(java.awt.event.KeyEvent evt) {
    // TableMainKeyReleased(evt);
    // }
    // });

    // -- Add the grid to a scroll panel
    // ------------------------------------
    jScrollPaneResume = new javax.swing.JScrollPane();
    jScrollPaneResume.setViewportView(TableResume);
    jPanelResume.add(jScrollPaneResume, java.awt.BorderLayout.CENTER);

    addTab(TabbedPaneMain, jPanelResume, bundle.getString("frmMain.TabResume.tabTitle"),
            new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/grid.png")));

    // -- Map panel
    // ---------------------------------------------------------
    jPanelMap = new javax.swing.JPanel();
    jPanelMap.setLayout(new java.awt.BorderLayout());

    Create_Map_Toolbar();
    jPanelMap.add(jToolBarMapViewer, java.awt.BorderLayout.WEST);

    MapViewer = new org.openstreetmap.gui.jmapviewer.JMapViewer();
    MapViewer.setMapMarkerVisible(true);
    MapViewer.setScrollWrapEnabled(true);
    MapViewer.setZoomButtonStyle(org.openstreetmap.gui.jmapviewer.JMapViewer.ZOOM_BUTTON_STYLE.VERTICAL);
    MapViewer.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            MapViewerMouseClicked(evt);
        }
    });
    jPanelMap.add(MapViewer, java.awt.BorderLayout.CENTER);

    jScrollPanelMap = new javax.swing.JScrollPane();
    jScrollPanelMap.setViewportView(jPanelMap);

    SplitPaneMainRight.setRightComponent(jScrollPanelMap);

    // -- Finished - Pack
    // ---------------------------------------------------
    pack();
}

From source file:edu.harvard.i2b2.analysis.ui.ExplorerC.java

/**
 * @param args/*ww  w  .  jav a2  s  .c  o  m*/
 */
@SuppressWarnings("serial")
protected Control createContents(Composite parent) {
    log.info("Explorer plugin version 1.6.0");
    GridLayout topGridLayout = new GridLayout(1, false);
    topGridLayout.numColumns = 1;
    topGridLayout.marginWidth = 2;
    topGridLayout.marginHeight = 2;
    setLayout(topGridLayout);

    Composite oTreeComposite = new Composite(this, SWT.NONE);
    oTreeComposite.setLayout(new FillLayout(SWT.VERTICAL));
    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.FILL;
    gridData2.verticalAlignment = GridData.FILL;
    gridData2.grabExcessHorizontalSpace = true;
    gridData2.grabExcessVerticalSpace = true;
    oTreeComposite.setLayoutData(gridData2);

    // the horizontal sash form
    SashForm horizontalForm = new SashForm(oTreeComposite, SWT.HORIZONTAL);
    horizontalForm.setOrientation(SWT.HORIZONTAL);
    horizontalForm.setLayout(new GridLayout());

    if (drawLeft) {
        // left sash form
        SashForm leftVerticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
        leftVerticalForm.setOrientation(SWT.VERTICAL);
        leftVerticalForm.setLayout(new GridLayout());

        if (bWantStatusLine) {
            slm.createControl(this, SWT.NULL);
        }
        slm.setMessage("i2b2 Explorer Version 2.0");
        slm.update(true);

        // Create the tab folder
        final TabFolder oTabFolder = new TabFolder(leftVerticalForm, SWT.NONE);

        // Create each tab and set its text, tool tip text,
        // image, and control
        TabItem oTreeTab = new TabItem(oTabFolder, SWT.NONE);
        oTreeTab.setText("Concept trees");
        oTreeTab.setToolTipText("Hierarchically organized patient characteristics");
        oTreeTab.setControl(getConceptTreeTabControl(oTabFolder));

        // Select the first tab (index is zero-based)
        oTabFolder.setSelection(0);

        // Create the tab folder
        final TabFolder queryRunFolder = new TabFolder(leftVerticalForm, SWT.NONE);

        TabItem previousRunTab = new TabItem(queryRunFolder, SWT.NONE);
        previousRunTab.setText("Patient Sets and Previous Queries");
        previousRunTab.setToolTipText("Patient Sets & Previous Queries");
        final Composite runComposite = new Composite(queryRunFolder, SWT.EMBEDDED);
        previousRunTab.setControl(runComposite);

        /* Create and setting up frame */
        ////for mac fix
        //if ( System.getProperty("os.name").toLowerCase().startsWith("mac"))
        //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame";
        Frame runFrame = SWT_AWT.new_Frame(runComposite);
        Panel runPanel = new Panel(new BorderLayout());
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            log.debug("Error setting native LAF: " + e);
        }

        runFrame.add(runPanel);
        JRootPane runRoot = new JRootPane();
        runPanel.add(runRoot);

        // Select the first tab (index is zero-based)
        queryRunFolder.setSelection(0);
    }

    SashForm verticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    verticalForm.setOrientation(SWT.VERTICAL);
    verticalForm.setLayout(new GridLayout());

    // put a tab folder in it...
    tabFolder = new TabFolder(verticalForm, SWT.NONE);

    Composite patientNumsComposite = new Composite(verticalForm, SWT.NONE);
    GridData patientNumData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    patientNumData.grabExcessHorizontalSpace = true;
    patientNumsComposite.setLayoutData(patientNumData);
    patientNumsComposite.setLayout(null);

    Label patientset = new Label(patientNumsComposite, SWT.NONE);
    patientset.setText("Patient Set: ");
    patientset.setBounds(5, 9, 60, 22);

    patientSetText = new Text(patientNumsComposite, SWT.SINGLE | SWT.BORDER);
    patientSetText.setText("");
    // patientSetText.setEditable(false);
    patientSetText.setBounds(70, 5, 300, 35);

    leftArrowButton = new Button(patientNumsComposite, SWT.PUSH);
    leftArrowButton.setText("<<<");
    leftArrowButton.setEnabled(false);
    leftArrowButton.setBounds(380, 5, 38, 22);
    leftArrowButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ConceptTableModel i2b2Model = (ConceptTableModel) table.getModel();
            i2b2Model.fillDataFromTable(rowData);
            if (rowData.size() == 0) {
                oTheParent.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        tabFolder.setSelection(0);
                    }
                });
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("The set up table is empty.");
                mBox.open();
                return;
            }

            String patientSetStr = patientSetText.getText();
            if (patientSetStr.equals("") && !isAll) {
                oTheParent.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        tabFolder.setSelection(0);
                    }
                });
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("Please set a patient set or choose all datamart option.");
                mBox.open();
                return;
            }

            int start = new Integer(patientMinNumText.getText()).intValue();
            int inc = new Integer(patientMaxNumText.getText()).intValue();
            if (start - inc - inc <= 0) {
                leftArrowButton.setEnabled(false);
            }

            if (start <= patientSetSize) {
                rightArrowButton.setEnabled(true);
            } else {
                rightArrowButton.setEnabled(false);
            }

            if ((start - inc) >= 0) {
                patientMinNumText.setText("" + (start - inc));
            } else {
                patientMinNumText.setText("1");
            }

            if (tabFolder.getSelectionIndex() == 1) {
                DestroyMiniVisualization(oAwtContainer);
            } else if (tabFolder.getSelectionIndex() == 0) {
                oTheParent.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        tabFolder.setSelection(1);
                    }
                });
            }

            if (patientSetStr.equalsIgnoreCase("All")) {
                int minPatient = 0;
                try {
                    String minText = patientMinNumText.getText();
                    minPatient = Integer.parseInt(minText);
                } catch (Exception e1) {
                    minPatient = -1;
                }

                int maxPatient = 0;
                try {
                    maxPatient = Integer.parseInt(patientMaxNumText.getText());
                } catch (Exception e2) {
                    maxPatient = -1;
                }

                PerformVisualizationQuery(oAwtContainer, "All", minPatient, maxPatient, bDisplayAllData);
            } else {
                int min = Integer.parseInt(patientMinNumText.getText());
                int max = Integer.parseInt(patientMaxNumText.getText());
                PerformVisualizationQuery(oAwtContainer, patientRefId, min, max, bDisplayAllData);
            }
        }
    });

    final Label patNum1 = new Label(patientNumsComposite, SWT.NONE);
    patNum1.setText(" start: ");
    patNum1.setBounds(425, 9, 31, 20);

    patientMinNumText = new Text(patientNumsComposite, SWT.SINGLE | SWT.BORDER);
    patientMinNumText.setText("1");
    patientMinNumText.setBounds(460, 5, 45, 22);

    final Label patNum2 = new Label(patientNumsComposite, SWT.NONE);
    patNum2.setText("increment:");
    patNum2.setBounds(515, 9, 57, 20);

    patientMaxNumText = new Text(patientNumsComposite, SWT.SINGLE | SWT.BORDER);
    patientMaxNumText.setText("10");
    patientMaxNumText.setBounds(572, 5, 45, 22);

    rightArrowButton = new Button(patientNumsComposite, SWT.PUSH);
    rightArrowButton.setText(">>>");
    rightArrowButton.setEnabled(false);
    rightArrowButton.setBounds(626, 5, 38, 20);
    rightArrowButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ConceptTableModel i2b2Model = (ConceptTableModel) table.getModel();
            i2b2Model.fillDataFromTable(rowData);
            if (rowData.size() == 0) {
                oTheParent.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        tabFolder.setSelection(0);
                    }
                });
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("The set up table is empty.");
                mBox.open();
                return;
            }

            String patientSetStr = patientSetText.getText();
            if (patientSetStr.equals("") && !isAll) {
                oTheParent.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        tabFolder.setSelection(0);
                    }
                });
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("Please set a patient set or choose all datamart option.");
                mBox.open();
                return;
            }

            int start = new Integer(patientMinNumText.getText()).intValue();
            int inc = new Integer(patientMaxNumText.getText()).intValue();
            if (start + inc + inc > patientSetSize) {
                rightArrowButton.setEnabled(false);
            }
            patientMinNumText.setText("" + (start + inc));
            leftArrowButton.setEnabled(true);

            if (tabFolder.getSelectionIndex() == 1) {
                DestroyMiniVisualization(oAwtContainer);
            } else if (tabFolder.getSelectionIndex() == 0) {
                oTheParent.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        tabFolder.setSelection(1);
                    }
                });
            }

            if (patientSetStr.equalsIgnoreCase("All")) {
                int minPatient = 0;
                try {
                    String minText = patientMinNumText.getText();
                    minPatient = Integer.parseInt(minText);
                } catch (Exception e1) {
                    minPatient = -1;
                }

                int maxPatient = 0;
                try {
                    maxPatient = Integer.parseInt(patientMaxNumText.getText());
                } catch (Exception e2) {
                    maxPatient = -1;
                }

                PerformVisualizationQuery(oAwtContainer, "All", minPatient, maxPatient, bDisplayAllData);
            } else {
                int min = Integer.parseInt(patientMinNumText.getText());
                int max = Integer.parseInt(patientMaxNumText.getText());
                PerformVisualizationQuery(oAwtContainer, patientRefId, min, max, bDisplayAllData);
            }
        }
    });

    addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            int w = getBounds().width;
            patientSetText.setBounds(70, 5, w - 357, 24);
            leftArrowButton.setBounds(w - 281, 5, 38, 24);
            patNum1.setBounds(w - 239, 9, 31, 24);
            patientMinNumText.setBounds(w - 204, 5, 45, 24);
            patNum2.setBounds(w - 149, 9, 57, 24);
            patientMaxNumText.setBounds(w - 92, 5, 45, 24);
            rightArrowButton.setBounds(w - 42, 5, 37, 24);
        }
    });

    verticalForm.setWeights(new int[] { 25, 3 });

    // Item 1: a Text Table
    TabItem item1 = new TabItem(tabFolder, SWT.NONE);
    item1.setText("Create model for Timeline");

    Composite oModelComposite = new Composite(tabFolder, SWT.NONE);
    item1.setControl(oModelComposite);

    GridLayout gridLayout = new GridLayout(2, false);

    // gridLayout.marginHeight = 0;
    // gridLayout.marginWidth = 0;
    // gridLayout.verticalSpacing = 0;
    // gridLayout.horizontalSpacing = 0;

    gridLayout.marginTop = 2;
    gridLayout.marginLeft = 0;
    gridLayout.marginBottom = 2;
    gridLayout.verticalSpacing = 1;
    gridLayout.horizontalSpacing = 1;
    oModelComposite.setLayout(gridLayout);

    oModelQueryComposite = new FramedComposite(oModelComposite, SWT.SHADOW_NONE);
    // GridLayout gLq = new GridLayout(25, false);
    oModelQueryComposite.setLayout(new GridLayout(25, false));
    oModelQueryComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    GridData oModelQueryButtonGridData = new GridData(GridData.FILL_HORIZONTAL);
    oModelQueryButtonGridData.grabExcessHorizontalSpace = false;
    oModelQueryButtonGridData.horizontalSpan = 2;
    oModelQueryButtonGridData.verticalAlignment = SWT.CENTER;
    oModelQueryButtonGridData.verticalIndent = 5;
    oModelQueryComposite.setLayoutData(oModelQueryButtonGridData);

    queryNamemrnlistText = new Label(oModelQueryComposite, SWT.NONE);
    queryNamemrnlistText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    queryNamemrnlistText.setText("Query Name: ");
    // queryNamemrnlistText.setBounds(5, 4, 600, 20);

    queryNamemrnlistText.addMouseTrackListener(new MouseTrackListener() {

        public void mouseEnter(MouseEvent arg0) {
            oModelQueryComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
        }

        public void mouseExit(MouseEvent arg0) {
            oModelQueryComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
        }

        public void mouseHover(MouseEvent arg0) {
            oModelQueryComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
        }

    });

    oModelQueryComposite.addMouseMoveListener(new MouseMoveListener() {

        public void mouseMove(MouseEvent arg0) {
            // System.out.println("mouse moved");

        }

    });

    oModelQueryComposite.addDragDetectListener(new DragDetectListener() {

        public void dragDetected(DragDetectEvent arg0) {
            // System.out.println("drag moved");

        }

    });

    Composite oGroupComposite = new Composite(oModelComposite, SWT.NONE);
    // GridLayout gLq = new GridLayout(25, false);
    oGroupComposite.setLayout(gridLayout);
    GridData oGroupGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    oGroupGridData.grabExcessHorizontalSpace = true;
    oGroupGridData.grabExcessVerticalSpace = true;
    oGroupGridData.verticalIndent = 1;
    oGroupGridData.verticalSpan = GridData.VERTICAL_ALIGN_FILL;
    // oGroupGridData.verticalAlignment = GridData.VERTICAL_ALIGN_FILL;
    oGroupComposite.setLayoutData(oGroupGridData);

    oModelGroupComposite = new FramedComposite(oGroupComposite, SWT.SHADOW_NONE);
    // GridLayout gLq = new GridLayout(25, false);
    oModelGroupComposite.setLayout(new GridLayout(25, false));
    GridData oModelGroupButtonGridData = new GridData(GridData.FILL_HORIZONTAL);
    oModelGroupButtonGridData.grabExcessHorizontalSpace = false;
    oModelGroupButtonGridData.horizontalSpan = 2;
    oModelGroupButtonGridData.verticalAlignment = SWT.CENTER;
    oModelGroupButtonGridData.verticalIndent = 5;
    oModelGroupComposite.setLayoutData(oModelGroupButtonGridData);

    // GridData gdAdd = new GridData(GridData.FILL_HORIZONTAL);
    GridData gdDel1 = new GridData(GridData.FILL_HORIZONTAL);

    groupNameText = new Label(oModelGroupComposite, SWT.NONE);
    gdDel1.horizontalSpan = 4;
    groupNameText.setLayoutData(gdDel1);
    groupNameText.setText("Panel Name: ");
    // groupNameText.setBounds(80, 8, 400, 24);
    // groupNameText.setAlignment(SWT.CENTER);
    // createDragSource(queryNamemrnlistText);
    // createDropTarget(queryNamemrnlistText);

    groupNameText.addMouseTrackListener(new MouseTrackListener() {

        public void mouseEnter(MouseEvent arg0) {
            oModelGroupComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
        }

        public void mouseExit(MouseEvent arg0) {
            oModelGroupComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
        }

        public void mouseHover(MouseEvent arg0) {
            oModelGroupComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
        }

    });

    // put a table in tabItem1...
    table = new KTable(oGroupComposite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    table.setFocus();
    table.setBackground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    GridData tableGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    tableGridData.verticalIndent = 5;
    table.setLayoutData(tableGridData);
    table.setRowSelectionMode(true);
    // table.setMultiSelectionMode(true);
    // table.setModel(new KTableForModel());
    table.setModel(new ConceptTableModel());
    // table.getModel().setColumnWidth(0, oModelComposite.getBounds().width
    // - 35);
    table.addCellSelectionListener(new KTableCellSelectionListener() {
        public void cellSelected(int col, int row, int statemask) {
            log.debug("Cell [" + col + ";" + row + "] selected.");
            System.out.println("Cell [" + col + ";" + row + "] selected.");
            table.selectedRow = row;
            table.selectedColumn = col;
        }

        public void fixedCellSelected(int col, int row, int statemask) {
            log.debug("Header [" + col + ";" + row + "] selected.");
            System.out.println("Header [" + col + ";" + row + "] selected.");
        }

    });

    Transfer[] types = new Transfer[] { TextTransfer.getInstance() };

    // create drag source
    /*
     * DragSource source = new DragSource(queryNamemrnlistText,
     * DND.DROP_COPY); source.setTransfer(types); source.addDragListener(new
     * DragSourceAdapter() {
     * 
     * @Override public void dragSetData(DragSourceEvent event) {
     * //DragSource ds = (DragSource) event.widget; StringWriter strWriter =
     * new StringWriter(); DndType dndType = new DndType();
     * edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory pdoFactory
     * = new edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory();
     * PanelType panelType = new PanelType();
     * 
     * //get table rows and fill the panel object for(int i=0; i<3; i++) {
     * ItemType itemType = new ItemType();
     * panelType.getItem().add(itemType);
     * 
     * dndType.getAny().add(pdoFactory.createPanel(panelType));
     * edu.harvard.i2b2.crcxmljaxb.datavo.dnd.ObjectFactory dndFactory = new
     * edu.harvard.i2b2.crcxmljaxb.datavo.dnd.ObjectFactory(); try {
     * ExplorerJAXBUtil
     * .getJAXBUtil().marshaller(dndFactory.createPluginDragDrop(dndType),
     * strWriter); } catch(JAXBUtilException e) { e.printStackTrace(); }
     * 
     * //put the data into the event event.data = strWriter.toString(); }
     * 
     * 
     * });
     */

    Composite oModelAddDelButtonComposite = new Composite(oModelComposite, SWT.NONE);
    GridLayout gL = new GridLayout(25, false);
    oModelAddDelButtonComposite.setLayout(gL);
    GridData oModelAddDelButtonGridData = new GridData(GridData.FILL_HORIZONTAL);// HORIZONTAL_ALIGN_FILL);// |
    // GridData.VERTICAL_ALIGN_FILL);
    oModelAddDelButtonGridData.grabExcessHorizontalSpace = false;
    oModelAddDelButtonGridData.horizontalSpan = 2;
    oModelAddDelButtonComposite.setLayoutData(oModelAddDelButtonGridData);

    // GridData gdAdd = new GridData(GridData.FILL_HORIZONTAL);
    GridData gdDel = new GridData(GridData.FILL_HORIZONTAL);

    Button deleteArrowButton = new Button(oModelAddDelButtonComposite, SWT.PUSH);
    gdDel.horizontalSpan = 4;
    deleteArrowButton.setLayoutData(gdDel);
    deleteArrowButton.setText("Delete From List");
    deleteArrowButton.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("unchecked")
        public void widgetSelected(SelectionEvent event) {
            curRowNumber = 0;
            ConceptTableModel m_Model = (ConceptTableModel) table.getModel();
            int[] selectedRow = table.getRowSelection();
            m_Model.fillDataFromTable(rowData);

            if ((selectedRow != null) && (selectedRow.length > 0)) {
                String conceptName = (String) m_Model.getContentAt(1, selectedRow[0]);
                if (conceptName.equals("Encounter Range Line")) {
                } else if (conceptName.equals("Vital Status Line")) {
                }

                int rowNumber = new Integer((String) (m_Model.getContentAt(0, selectedRow[0]))).intValue();
                int rid = selectedRow[0];
                ArrayList list = (ArrayList) rowData.get(rowNumber - 1);
                for (int i = 0; i < list.size(); i++) {
                    ConceptTableRow tr = (ConceptTableRow) list.get(i);
                    if (tr.rowId == rid) {
                        list.remove(i);
                        break;
                    }
                }
                if (list.size() == 0) {
                    rowData.remove(rowNumber - 1);
                }
                curRowNumber = rowData.size();
                resetRowNumber();
                // m_Model.deleteRow(selectedRow[0]);
                ((ConceptTableModel) table.getModel()).deleteAllRows();
                ((ConceptTableModel) table.getModel()).populateTable(rowData);
                /*
                 * int newRow = 0; for(int i=0; i<rowData.size(); i++) {
                 * ArrayList alist = (ArrayList) rowData.get(i); for(int
                 * j=0; j<alist.size(); j++) { TableRow r = (TableRow)
                 * alist.get(j); newRow++; r.rowId = newRow;
                 * table.getModel().setContentAt(0, newRow, new
                 * Integer(r.rowNumber).toString());
                 * table.getModel().setContentAt(1, newRow, r.conceptName);
                 * table.getModel().setContentAt(2, newRow, r.valueType);
                 * table.getModel().setContentAt(3, newRow, r.valueText);
                 * table.getModel().setContentAt(4, newRow, r.height);
                 * table.getModel().setContentAt(5, newRow, r.color);
                 * table.getModel().setContentAt(6, newRow, r.conceptXml); }
                 * }
                 */
                table.redraw();
            }
        }
    });

    Button deleteAllButton = new Button(oModelAddDelButtonComposite, SWT.PUSH);
    gdDel = new GridData(GridData.FILL_HORIZONTAL);
    gdDel.horizontalSpan = 4;
    deleteAllButton.setLayoutData(gdDel);
    deleteAllButton.setText("Delete All ");
    deleteAllButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ConceptTableModel m_Model = (ConceptTableModel) table.getModel();
            m_Model.deleteAllRows();
            curRowNumber = 0;
            rowData.clear();
            table.redraw();
        }
    });

    Button putInOrderButton = new Button(oModelAddDelButtonComposite, SWT.PUSH);
    gdDel = new GridData(GridData.FILL_HORIZONTAL);
    gdDel.horizontalSpan = 4;
    putInOrderButton.setLayoutData(gdDel);
    putInOrderButton.setText("Put In Order ");
    putInOrderButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {

            ConceptTableModel m_Model = (ConceptTableModel) table.getModel();
            curRowNumber = 0;
            m_Model.fillDataFromTable(rowData);

            Collections.sort(rowData, new Comparator<Object>() {
                @SuppressWarnings("unchecked")
                public int compare(Object o1, Object o2) {
                    int i1 = ((ConceptTableRow) ((ArrayList) o1).get(0)).rowNumber;
                    int i2 = ((ConceptTableRow) ((ArrayList) o2).get(0)).rowNumber;
                    if (i1 > i2) {
                        return 1;
                    } else if (i1 < i2) {
                        return -1;
                    } else {
                        return 0;
                    }
                }
            });
            m_Model.deleteAllRows();
            m_Model.populateTable(rowData);
            table.redraw();
        }
    });

    Button upArrowButton = new Button(oModelAddDelButtonComposite, SWT.PUSH);
    upArrowButton.setText("Move Up");
    upArrowButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {

            ConceptTableModel m_Model = (ConceptTableModel) table.getModel();
            int[] selectedRow = table.getRowSelection();
            curRowNumber = 0;
            // KTableI2B2Model m_Model = (KTableI2B2Model) table.getModel();
            // int[] selectedRow = table.getRowSelection();
            m_Model.fillDataFromTable(rowData);
            int index = new Integer((String) (m_Model.getContentAt(0, selectedRow[0]))).intValue() - 1;
            if (index < 1) {
                return;
            }
            if ((selectedRow != null) && (selectedRow.length > 0)) {
                // m_Model.moveRow(selectedRow[0], selectedRow[0] -1);
                ArrayList<ConceptTableRow> list = rowData.get(index);
                rowData.remove(index);
                rowData.add(index - 1, list);
                resetRowNumber();
                m_Model.populateTable(rowData);
            }
            table.setSelection(0, selectedRow[0] - 1, true);
            table.redraw();
        }
    });

    Button downArrowButton = new Button(oModelAddDelButtonComposite, SWT.PUSH);
    downArrowButton.setText("Move Down");
    downArrowButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {

            ConceptTableModel m_Model = (ConceptTableModel) table.getModel();
            int[] selectedRow = table.getRowSelection();
            curRowNumber = 0;
            // KTableI2B2Model m_Model = (KTableI2B2Model) table.getModel();
            // int[] selectedRow = table.getRowSelection();
            m_Model.fillDataFromTable(rowData);
            int index = new Integer((String) (m_Model.getContentAt(0, selectedRow[0]))).intValue() - 1;
            if (index == (rowData.size() - 1)) {
                return;
            }
            if ((selectedRow != null) && (selectedRow.length > 0)) {
                // m_Model.moveRow(selectedRow[0], selectedRow[0] -1);
                ArrayList<ConceptTableRow> list = rowData.get(index);
                rowData.remove(index);
                rowData.add(index + 1, list);
                resetRowNumber();
                m_Model.populateTable(rowData);
            }
            table.setSelection(0, selectedRow[0] + 1, true);
            table.redraw();
        }
    });

    Composite oModelCheckButtonComposite = new Composite(oModelComposite, SWT.NONE);
    GridLayout gL1 = new GridLayout(20, true);
    oModelCheckButtonComposite.setLayout(gL1);
    GridData oModelCheckButtonGridData = new GridData(
            GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    oModelCheckButtonGridData.grabExcessHorizontalSpace = true;
    oModelCheckButtonGridData.horizontalSpan = 2;
    oModelCheckButtonComposite.setLayoutData(oModelCheckButtonGridData);

    Button displayOrNotButton = new Button(oModelCheckButtonComposite, SWT.CHECK);
    displayOrNotButton.setText("Display concepts with no data");
    displayOrNotButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // do something here- return null
            bDisplayAllData = !bDisplayAllData;
        }
    });

    Button displayDemographicsOrNotButton = new Button(oModelCheckButtonComposite, SWT.CHECK);
    displayDemographicsOrNotButton.setText("Display patient demographics");
    if ((System.getProperty("applicationName") != null)
            && System.getProperty("applicationName").equals("BIRN")) {
        displayDemographicsOrNotButton.setSelection(false);
        displayDemographicsOrNotButton.setEnabled(false);
        bDisplayDemographics = false;
    } else if ((System.getProperty("applicationName") == null)
            || System.getProperty("applicationName").equals("i2b2")) {
        displayDemographicsOrNotButton.setSelection(true);
    }
    displayDemographicsOrNotButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            bDisplayDemographics = !bDisplayDemographics;
        }
    });

    if (UserInfoBean.getInstance().getCellDataUrl("identity") != null) {
        Composite oPatientSetComposite = new Composite(oModelComposite, SWT.NONE);
        GridData patientSetData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        patientSetData.grabExcessHorizontalSpace = true;
        oPatientSetComposite.setLayoutData(patientSetData);
        oPatientSetComposite.setLayout(null);

        Label mrnlabel = new Label(oPatientSetComposite, SWT.NONE);
        mrnlabel.setText("MRN site:");
        mrnlabel.setBounds(5, 9, 50, 20);

        final Combo siteCombo = new Combo(oPatientSetComposite, SWT.NULL);
        siteCombo.add("BWH");
        siteCombo.add("MGH");
        siteCombo.setBounds(57, 5, 60, 20);
        siteCombo.select(1);

        Label mrnNumber = new Label(oPatientSetComposite, SWT.NONE);
        mrnNumber.setText("number:");
        mrnNumber.setBounds(121, 9, 40, 20);

        mrnlistText = new Text(oPatientSetComposite, SWT.SINGLE | SWT.BORDER);
        mrnlistText.setBounds(164, 5, 150, 20);
        mrnlistText.setText("");

        Button runButton = new Button(oPatientSetComposite, SWT.PUSH);
        runButton.setText("Search By MRN");
        runButton.setBounds(315, 5, 85, 23);
        runButton.addSelectionListener(new SelectionAdapter() {
            @SuppressWarnings("unchecked")
            public void widgetSelected(SelectionEvent event) {
                String mrns = mrnlistText.getText();
                if (mrns.equals("")) {
                    return;
                }

                String[] mrnArray = mrns.split(",");
                int[] idlist = new int[mrnArray.length];
                String username = UserInfoBean.getInstance().getUserName();
                String password = UserInfoBean.getInstance().getUserPassword();
                // log.debug("User name: "+username+" password: "+password);
                String site = siteCombo.getText();
                for (int i = 0; i < mrnArray.length; i++) {
                    // String[] tmps = new String[2];
                    String tmp = mrnArray[i].replaceAll(" ", "");
                    // tmps = tmp.split(":");

                    String queryStr = "<?xml version=\"1.0\" standalone=\"yes\"?>\n" + "<search_by_local>"
                            + "<match_id site=\"" + site.toUpperCase()/* EMPI */
                            + "\">" + tmp/* 100016900 */
                            + "</match_id>\n" + "</search_by_local>";

                    String resultStr = QueryClient.query(queryStr, username, password);
                    log.debug(queryStr);
                    log.debug(resultStr);

                    SAXBuilder parser = new SAXBuilder();
                    String masterID = null;
                    java.io.StringReader xmlStringReader = new java.io.StringReader(resultStr);
                    try {
                        org.jdom.Document tableDoc = parser.build(xmlStringReader);
                        org.jdom.Element tableXml = tableDoc.getRootElement();
                        Element responseXml = (Element) tableXml.getChild("person_list");
                        // Element mrnXml = (Element)
                        // responseXml.getChild("MRN");
                        java.util.List listChildren = responseXml.getChildren();
                        if (listChildren.isEmpty()) {
                            MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                            mBox.setText("Please Note ...");
                            mBox.setMessage("No master id found");
                            mBox.open();
                            return;
                        }

                        Element masterXml = (Element) responseXml.getChild("master_record");
                        masterID = masterXml.getAttributeValue("id");
                        log.debug("Patient id: " + masterID);
                        idlist[i] = new Integer(masterID).intValue();
                        log.debug("MRN: " + site + "-" + tmp);
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                }

                if (tabFolder.getSelectionIndex() == 1) {
                    DestroyMiniVisualization(oAwtContainer);
                } else if (tabFolder.getSelectionIndex() == 0) {
                    oTheParent.getDisplay().syncExec(new Runnable() {
                        public void run() {
                            tabFolder.setSelection(1);
                        }
                    });
                }

                PerformVisualizationQuery(oAwtContainer, idlist, bDisplayAllData);
            }
        });
    }

    DropTarget targetLable = new DropTarget(oModelQueryComposite, DND.DROP_COPY);
    targetLable.setTransfer(types);
    targetLable.addDropListener(new DropTargetAdapter() {
        @Override
        public void dragLeave(DropTargetEvent event) {
            super.dragLeave(event);
            oModelQueryComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
        }

        public void dragEnter(DropTargetEvent event) {
            event.detail = DND.DROP_COPY;
            oModelQueryComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
        }

        @SuppressWarnings("unchecked")
        public void drop(DropTargetEvent event) {
            if (event.data == null) {
                event.detail = DND.DROP_NONE;
                return;
            }

            try {
                SAXBuilder parser = new SAXBuilder();
                String xmlContent = (String) event.data;
                java.io.StringReader xmlStringReader = new java.io.StringReader(xmlContent);
                org.jdom.Document tableDoc = parser.build(xmlStringReader);
                org.jdom.Element tableXml = tableDoc.getRootElement().getChild("concepts",
                        Namespace.getNamespace("http://www.i2b2.org/xsd/cell/ont/1.1/"));

                if (tableXml != null) {
                    MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                    mBox.setText("Please Note ...");
                    mBox.setMessage("You can not drop this item here.");
                    mBox.open();
                    event.detail = DND.DROP_NONE;
                    return;
                }

                boolean isQuery = false;
                if (tableXml == null) {
                    tableXml = tableDoc.getRootElement().getChild("query_master",
                            Namespace.getNamespace("http://www.i2b2.org/xsd/cell/crc/psm/1.1/"));
                }

                if (tableXml != null) {
                    isQuery = true;
                } else {

                    MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                    mBox.setText("Please Note ...");
                    mBox.setMessage("You can not drop this item here.");
                    mBox.open();
                    event.detail = DND.DROP_NONE;
                    return;
                }

                if (isQuery) {
                    ArrayList<QueryModel> nodeXmls = new ArrayList<QueryModel>();
                    try {
                        JAXBUtil jaxbUtil = AnalysisJAXBUtil.getJAXBUtil();
                        QueryMasterData ndata = new QueryMasterData();
                        ndata.name(tableXml.getChildText("name"));
                        queryNamemrnlistText.setText("Query Name: " + ndata.name());
                        ndata.xmlContent(null);
                        ndata.id(tableXml.getChildTextTrim("query_master_id"));
                        ndata.userId(tableXml.getChildTextTrim("user_id"));

                        String xmlcontent = null;
                        String xmlrequest = null;

                        xmlrequest = ndata.writeDefinitionQueryXML();
                        lastRequestMessage(xmlrequest);

                        if (System.getProperty("webServiceMethod").equals("SOAP")) {
                            xmlcontent = CRCQueryClient.sendPDQQueryRequestSOAP(xmlrequest);
                        } else {
                            xmlcontent = CRCQueryClient.sendPDQQueryRequestREST(xmlrequest);
                        }
                        lastResponseMessage(xmlcontent);

                        if (xmlcontent == null) {

                            return;
                        } else {
                            log.debug("Query content response: " + xmlcontent);
                            ndata.xmlContent(xmlcontent);
                        }

                        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(ndata.xmlContent());
                        ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();

                        BodyType bt = messageType.getMessageBody();
                        MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper()
                                .getObjectByClass(bt.getAny(), MasterResponseType.class);
                        RequestXmlType requestXmlType = masterResponseType.getQueryMaster().get(0)
                                .getRequestXml();

                        org.w3c.dom.Element element = (org.w3c.dom.Element) requestXmlType.getContent().get(0);
                        if (element != null) {
                            log.debug("query definition not null");
                        } else {
                            log.error("query definition is null");
                        }

                        String domString = edu.harvard.i2b2.common.util.xml.XMLUtil
                                .convertDOMElementToString(element);
                        log.debug("string output" + domString);

                        JAXBContext jc1 = JAXBContext
                                .newInstance(edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory.class);
                        Unmarshaller unMarshaller = jc1.createUnmarshaller();
                        JAXBElement queryDefinitionJaxbElement = (JAXBElement) unMarshaller
                                .unmarshal(new StringReader(domString));

                        QueryDefinitionType queryDefinitionType = (QueryDefinitionType) queryDefinitionJaxbElement
                                .getValue();
                        int numOfPanels = queryDefinitionType.getPanel().size();
                        for (int i = 0; i < numOfPanels; i++) {
                            PanelType panelType = queryDefinitionType.getPanel().get(i);

                            for (int j = 0; j < panelType.getItem().size(); j++) {
                                ItemType itemType = panelType.getItem().get(j);
                                QueryModel nodedata = new QueryModel();

                                nodedata.name(itemType.getItemName());
                                nodedata.visualAttribute("FA");
                                nodedata.tooltip(itemType.getTooltip());
                                nodedata.fullname(itemType.getItemKey());
                                nodedata.hlevel(new Integer(itemType.getHlevel()).toString());

                                if (itemType.getItemShape() != null) {
                                    nodedata.tableRow().height = new String(itemType.getItemShape());
                                    nodedata.tableRow().color = ((ConceptTableModel) table.getModel())
                                            .getColor(itemType.getItemColor());
                                    nodedata.tableRow().rowNumber = Integer
                                            .parseInt(itemType.getItemRowNumber());
                                } else {
                                    nodedata.tableRow().height = "Medium";
                                    nodedata.tableRow().color = new RGB(0, 0, 128);
                                    nodedata.tableRow().rowNumber = j + 1;
                                }

                                nodedata.constrainByValue(itemType.getConstrainByValue());
                                if (itemType.getConstrainByValue().size() > 0) {
                                    nodedata.setValueConstrains(itemType.getConstrainByValue());

                                    if (itemType.getConstrainByValue().size() > 0) {
                                        nodedata.setValueConstrains(itemType.getConstrainByValue());
                                        if (nodedata.valueModel().hasEnumValue()) {
                                            if (nodedata.valueModel().useTextValue()) {
                                                ArrayList<String> results = new ArrayList<String>();
                                                results.toArray(nodedata.valueModel().value().split(","));
                                                nodedata.valueModel().selectedValues = results;
                                            }
                                        }
                                    }
                                }

                                // Handle Constrain By Dates
                                for (int u = 0; u < itemType.getConstrainByDate().size(); u++) {
                                    nodedata.setTimeConstrain(
                                            itemType.getConstrainByDate().get(u).getDateFrom(),
                                            itemType.getConstrainByDate().get(u).getDateTo());
                                }

                                String status = nodedata.setXmlContent();
                                if (status.equalsIgnoreCase("error")) {
                                    MessageBox mBox = new MessageBox(table.getShell(),
                                            SWT.ICON_INFORMATION | SWT.OK);
                                    mBox.setText("Please Note ...");
                                    mBox.setMessage(
                                            "Response delivered from the remote server could not be understood,\n"
                                                    + "you may wish to retry your last action.");
                                    mBox.open();
                                    event.detail = DND.DROP_NONE;

                                    return;
                                }
                                nodeXmls.add(nodedata);
                            }
                        }
                        populateTable(nodeXmls);

                        // get query instance
                        String xmlRequest = ndata.writeContentQueryXML();
                        lastRequestMessage(xmlRequest);
                        String xmlResponse = CRCQueryClient.sendPDQQueryRequestREST(xmlRequest);
                        lastResponseMessage(xmlResponse);

                        jaxbElement = jaxbUtil.unMashallFromString(xmlResponse);
                        messageType = (ResponseMessageType) jaxbElement.getValue();
                        bt = messageType.getMessageBody();
                        InstanceResponseType instanceResponseType = (InstanceResponseType) new JAXBUnWrapHelper()
                                .getObjectByClass(bt.getAny(), InstanceResponseType.class);

                        QueryInstanceData instanceData = null;
                        XMLGregorianCalendar startDate = null;
                        for (QueryInstanceType queryInstanceType : instanceResponseType.getQueryInstance()) {
                            QueryInstanceData runData = new QueryInstanceData();

                            runData.visualAttribute("FA");
                            runData.tooltip("The results of the query run");
                            runData.id(new Integer(queryInstanceType.getQueryInstanceId()).toString());
                            XMLGregorianCalendar cldr = queryInstanceType.getStartDate();
                            runData.name("Results of " + "[" + cldr.getMonth() + "-" + cldr.getDay() + "-"
                                    + cldr.getYear() + " " + cldr.getHour() + ":" + cldr.getMinute() + ":"
                                    + cldr.getSecond() + "]");

                            if (instanceData == null) {
                                startDate = cldr;
                                instanceData = runData;
                            } else {
                                if (cldr.toGregorianCalendar().compareTo(startDate.toGregorianCalendar()) > 0) {
                                    startDate = cldr;
                                    instanceData = runData;
                                }
                            }
                        }
                        // get patient set
                        if (instanceData == null) {
                            event.detail = DND.DROP_NONE;
                            return;
                        }
                        log.debug("Got query instance: " + instanceData.name());

                        xmlRequest = instanceData.writeContentQueryXML();
                        lastRequestMessage(xmlRequest);

                        xmlResponse = CRCQueryClient.sendPDQQueryRequestREST(xmlRequest);
                        lastResponseMessage(xmlResponse);

                        jaxbElement = jaxbUtil.unMashallFromString(xmlResponse);
                        messageType = (ResponseMessageType) jaxbElement.getValue();
                        bt = messageType.getMessageBody();
                        ResultResponseType resultResponseType = (ResultResponseType) new JAXBUnWrapHelper()
                                .getObjectByClass(bt.getAny(), ResultResponseType.class);

                        for (QueryResultInstanceType queryResultInstanceType : resultResponseType
                                .getQueryResultInstance()) {
                            if (!(queryResultInstanceType.getQueryResultType().getName()
                                    .equalsIgnoreCase("PATIENTSET"))) {
                                continue;
                            }

                            String status = queryResultInstanceType.getQueryStatusType().getName();

                            if (status.equalsIgnoreCase("FINISHED")) {

                                String setId = new Integer(queryResultInstanceType.getResultInstanceId())
                                        .toString();
                                String setSize = new Integer(queryResultInstanceType.getSetSize()).toString();
                                patientSetText.setText("Patient Set: " + setSize + " patients");
                                patientRefId = new String(setId);
                                patientMinNumText.setText("1");
                                leftArrowButton.setEnabled(false);

                                int maxPatientNum = new Integer(patientMaxNumText.getText()).intValue();
                                patientSetSize = queryResultInstanceType.getSetSize();
                                if (patientSetSize > maxPatientNum) {
                                    rightArrowButton.setEnabled(true);
                                    patientMaxNumText.setText("10");
                                } else {
                                    rightArrowButton.setEnabled(false);
                                    if (patientSetSize > 0) {
                                        patientMaxNumText.setText(setSize);
                                    }
                                }

                                log.debug("Dropped set of: " + setSize + " patients"/* strs[0] */
                                        + " with refId: " + setId/*
                                                                 * strs[ 1 ]
                                                                 */);
                            } else {
                                // message
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        return;
                    }
                } /*
                  * else { List conceptChildren = tableXml.getChildren();
                  * parseDropConcepts(conceptChildren, event);
                  * table.redraw(); }
                  */

                event.detail = DND.DROP_NONE;
            } catch (JDOMException e) {
                System.err.println(e.getMessage());
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("You can not drop this item here.");
                mBox.open();
                event.detail = DND.DROP_NONE;
                e.printStackTrace();
                return;
            } catch (Exception e) {
                System.err.println(e.getMessage());
                event.detail = DND.DROP_NONE;
                e.printStackTrace();
                return;
            }
        }
    });

    // create drag source
    DragSource source1 = new DragSource(groupNameText, DND.DROP_COPY);
    source1.setTransfer(types);
    source1.addDragListener(new DragSourceAdapter() {

        @Override
        public void dragSetData(DragSourceEvent event) {

            ConceptTableModel i2b2Model = (ConceptTableModel) table.getModel();
            i2b2Model.fillDataFromTable(rowData);
            if (rowData.size() == 0) {
                oTheParent.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        tabFolder.setSelection(0);
                    }
                });
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("The set up table is empty.");
                mBox.open();
                return;
            }

            StringWriter strWriter = new StringWriter();
            DndType dndType = new DndType();
            edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory pdoFactory = new edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory();
            PanelType panelType = new PanelType();
            panelType.setInvert(0);
            PanelType.TotalItemOccurrences totalOccurrences = new PanelType.TotalItemOccurrences();
            totalOccurrences.setValue(1);
            panelType.setTotalItemOccurrences(totalOccurrences);
            panelType.setPanelNumber(0 + 1);
            // panelType.setName(panelData.getItems().get(0).name() + "_"
            // + generateMessageId().substring(0, 4));
            panelType.setName("Panel-1");

            // TO DO: get table rows and fill the panel object
            for (int i = 1; i < i2b2Model.getRowCount(); i++) {
                QueryModel node = (QueryModel) i2b2Model.getContentAt(7, i);
                ItemType itemType = new ItemType();
                itemType.setItemKey(node.fullname());
                itemType.setItemName(node.name());
                itemType.setTooltip(node.tooltip());
                itemType.setHlevel(Integer.parseInt(node.hlevel()));
                itemType.setClazz("ENC");
                itemType.setItemIcon(node.visualAttribute().trim());
                itemType.setItemColor(i2b2Model.getColorString((RGB) i2b2Model.getContentAt(5, i)));
                itemType.setItemRowNumber((String) i2b2Model.getContentAt(0, i));
                itemType.setItemShape((String) i2b2Model.getContentAt(4, i));

                itemType.getConstrainByValue().add(node.valueModel().writeValueConstrain());
                itemType.getConstrainByDate().add(node.writeTimeConstrain());

                panelType.getItem().add(itemType);
            }

            dndType.getAny().add(pdoFactory.createPanel(panelType));
            edu.harvard.i2b2.crcxmljaxb.datavo.dnd.ObjectFactory dndFactory = new edu.harvard.i2b2.crcxmljaxb.datavo.dnd.ObjectFactory();
            try {
                AnalysisJAXBUtil.getJAXBUtil().marshaller(dndFactory.createPluginDragDrop(dndType), strWriter);
            } catch (JAXBUtilException e) {
                e.printStackTrace();
            }

            // put the data into the event
            event.data = strWriter.toString();
        }

    });

    DropTarget nameTarget = new DropTarget(groupNameText, DND.DROP_COPY);
    nameTarget.setTransfer(types);
    nameTarget.addDropListener(new DropTargetAdapter() {

        @Override
        public void dragLeave(DropTargetEvent event) {
            super.dragLeave(event);
            oModelGroupComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
        }

        @SuppressWarnings("unchecked")
        public void drop(DropTargetEvent event) {
            if (event.data == null) {
                event.detail = DND.DROP_NONE;
                return;
            }
            ArrayList<QueryModel> nodeXmls = new ArrayList<QueryModel>();
            try {
                SAXBuilder parser = new SAXBuilder();
                String xmlContent = (String) event.data;
                java.io.StringReader xmlStringReader = new java.io.StringReader(xmlContent);
                org.jdom.Document panelDoc = parser.build(xmlStringReader);
                org.jdom.Element panelXml = panelDoc.getRootElement().getChild("panel",
                        Namespace.getNamespace("http://www.i2b2.org/xsd/cell/crc/psm/querydefinition/1.1/"));

                if (panelXml == null) {
                    MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                    mBox.setText("Please Note ...");
                    mBox.setMessage("You can not drop this item here.");
                    mBox.open();
                    event.detail = DND.DROP_NONE;
                    return;
                }

                else {

                    String domString = (new XMLOutputter()).outputString(panelXml);
                    JAXBContext jc1 = JAXBContext
                            .newInstance(edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory.class);
                    Unmarshaller unMarshaller = jc1.createUnmarshaller();
                    JAXBElement panelJaxbElement = (JAXBElement) unMarshaller
                            .unmarshal(new StringReader(domString));

                    PanelType panelType = (PanelType) panelJaxbElement.getValue();
                    String panelname = panelType.getName();
                    groupNameText.setText("Panel Name: " + panelname);
                    for (int j = 0; j < panelType.getItem().size(); j++) {
                        ItemType itemType = panelType.getItem().get(j);
                        QueryModel nodedata = new QueryModel();

                        nodedata.name(itemType.getItemName());
                        nodedata.visualAttribute("FA");
                        nodedata.tooltip(itemType.getTooltip());
                        nodedata.fullname(itemType.getItemKey());
                        nodedata.hlevel(new Integer(itemType.getHlevel()).toString());

                        // / need to handle query tool generated panels
                        if (itemType.getItemShape() != null) {
                            nodedata.tableRow().height = new String(itemType.getItemShape());
                            nodedata.tableRow().color = ((ConceptTableModel) table.getModel())
                                    .getColor(itemType.getItemColor());
                            nodedata.tableRow().rowNumber = Integer.parseInt(itemType.getItemRowNumber());
                        } else {
                            nodedata.tableRow().height = "Medium";
                            nodedata.tableRow().color = new RGB(0, 0, 128);
                            nodedata.tableRow().rowNumber = j + 1;
                        }

                        nodedata.constrainByValue(itemType.getConstrainByValue());
                        if (itemType.getConstrainByValue().size() > 0) {
                            nodedata.setValueConstrains(itemType.getConstrainByValue());

                            if (itemType.getConstrainByValue().size() > 0) {
                                nodedata.setValueConstrains(itemType.getConstrainByValue());
                                if (nodedata.valueModel().hasEnumValue()) {
                                    if (nodedata.valueModel().useTextValue()) {
                                        ArrayList<String> results = new ArrayList<String>();
                                        results.toArray(nodedata.valueModel().value().split(","));
                                        nodedata.valueModel().selectedValues = results;
                                    }
                                }
                            }
                        }

                        // Handle Constrain By Dates
                        for (int u = 0; u < itemType.getConstrainByDate().size(); u++) {
                            nodedata.setTimeConstrain(itemType.getConstrainByDate().get(u).getDateFrom(),
                                    itemType.getConstrainByDate().get(u).getDateTo());
                        }

                        String status = nodedata.setXmlContent();
                        if (status.equalsIgnoreCase("error")) {
                            MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                            mBox.setText("Please Note ...");
                            mBox.setMessage(
                                    "Response delivered from the remote server could not be understood,\n"
                                            + "you may wish to retry your last action.");
                            mBox.open();
                            event.detail = DND.DROP_NONE;

                            return;
                        }
                        nodeXmls.add(nodedata);
                    }
                    // event.detail = DND.DROP_NONE;
                }
                populateTable(nodeXmls);

            }

            catch (JDOMException e) {
                System.err.println(e.getMessage());
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("You can not drop this item here.");
                mBox.open();
                event.detail = DND.DROP_NONE;
                e.printStackTrace();
                return;
            } catch (Exception e) {
                System.err.println(e.getMessage());
                event.detail = DND.DROP_NONE;
                e.printStackTrace();
                return;
            }
        }

        public void dragEnter(DropTargetEvent event) {
            TextTransfer textTransfer = TextTransfer.getInstance();
            if (textTransfer.isSupportedType(event.currentDataType)) {

                event.detail = DND.DROP_COPY;
            }

            oModelGroupComposite.setForeground(oTheParent.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
        }
    });

    DropTarget target = new DropTarget(table, DND.DROP_COPY);
    target.setTransfer(types);
    target.addDropListener(new DropTargetAdapter() {
        @SuppressWarnings("unchecked")
        public void drop(DropTargetEvent event) {
            if (event.data == null) {
                event.detail = DND.DROP_NONE;
                return;
            }

            try {
                SAXBuilder parser = new SAXBuilder();
                String xmlContent = (String) event.data;
                java.io.StringReader xmlStringReader = new java.io.StringReader(xmlContent);
                org.jdom.Document tableDoc = parser.build(xmlStringReader);
                org.jdom.Element tableXml = tableDoc.getRootElement().getChild("concepts",
                        Namespace.getNamespace("http://www.i2b2.org/xsd/cell/ont/1.1/"));

                boolean isQuery = false;
                if (tableXml == null) {
                    MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                    mBox.setText("Please Note ...");
                    mBox.setMessage("You can not drop this item here.");
                    mBox.open();
                    event.detail = DND.DROP_NONE;
                    return;
                }

                if (isQuery) {
                    ArrayList<QueryModel> nodeXmls = new ArrayList<QueryModel>();
                    try {
                        JAXBUtil jaxbUtil = AnalysisJAXBUtil.getJAXBUtil();
                        QueryMasterData ndata = new QueryMasterData();
                        ndata.name(tableXml.getChildText("name"));
                        queryNamemrnlistText.setText(ndata.name());
                        ndata.xmlContent(null);
                        ndata.id(tableXml.getChildTextTrim("query_master_id"));
                        ndata.userId(tableXml.getChildTextTrim("user_id"));

                        String xmlcontent = null;
                        String xmlrequest = null;

                        xmlrequest = ndata.writeDefinitionQueryXML();
                        lastRequestMessage(xmlrequest);

                        if (System.getProperty("webServiceMethod").equals("SOAP")) {
                            xmlcontent = CRCQueryClient.sendPDQQueryRequestSOAP(xmlrequest);
                        } else {
                            xmlcontent = CRCQueryClient.sendPDQQueryRequestREST(xmlrequest);
                        }
                        lastResponseMessage(xmlcontent);

                        if (xmlcontent == null) {

                            return;
                        } else {
                            log.debug("Query content response: " + xmlcontent);
                            ndata.xmlContent(xmlcontent);
                        }

                        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(ndata.xmlContent());
                        ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();

                        BodyType bt = messageType.getMessageBody();
                        MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper()
                                .getObjectByClass(bt.getAny(), MasterResponseType.class);
                        RequestXmlType requestXmlType = masterResponseType.getQueryMaster().get(0)
                                .getRequestXml();

                        org.w3c.dom.Element element = (org.w3c.dom.Element) requestXmlType.getContent().get(0);
                        if (element != null) {
                            log.debug("query definition not null");
                        } else {
                            log.error("query definition is null");
                        }

                        String domString = edu.harvard.i2b2.common.util.xml.XMLUtil
                                .convertDOMElementToString(element);
                        log.debug("string output" + domString);

                        JAXBContext jc1 = JAXBContext
                                .newInstance(edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory.class);
                        Unmarshaller unMarshaller = jc1.createUnmarshaller();
                        JAXBElement queryDefinitionJaxbElement = (JAXBElement) unMarshaller
                                .unmarshal(new StringReader(domString));

                        QueryDefinitionType queryDefinitionType = (QueryDefinitionType) queryDefinitionJaxbElement
                                .getValue();
                        int numOfPanels = queryDefinitionType.getPanel().size();
                        for (int i = 0; i < numOfPanels; i++) {
                            PanelType panelType = queryDefinitionType.getPanel().get(i);

                            for (int j = 0; j < panelType.getItem().size(); j++) {
                                ItemType itemType = panelType.getItem().get(j);
                                QueryModel nodedata = new QueryModel();

                                nodedata.name(itemType.getItemName());
                                nodedata.visualAttribute("FA");
                                nodedata.tooltip(itemType.getTooltip());
                                nodedata.fullname(itemType.getItemKey());
                                nodedata.hlevel(new Integer(itemType.getHlevel()).toString());

                                String status = nodedata.setXmlContent();
                                if (status.equalsIgnoreCase("error")) {
                                    MessageBox mBox = new MessageBox(table.getShell(),
                                            SWT.ICON_INFORMATION | SWT.OK);
                                    mBox.setText("Please Note ...");
                                    mBox.setMessage(
                                            "Response delivered from the remote server could not be understood,\n"
                                                    + "you may wish to retry your last action.");
                                    mBox.open();
                                    event.detail = DND.DROP_NONE;

                                    return;
                                }
                                nodeXmls.add(nodedata);
                            }
                        }
                        populateTable(nodeXmls);

                        // get query instance
                        String xmlRequest = ndata.writeContentQueryXML();
                        lastRequestMessage(xmlRequest);
                        // log.debug(xmlRequest);
                        String xmlResponse = CRCQueryClient.sendPDQQueryRequestREST(xmlRequest);
                        lastResponseMessage(xmlResponse);

                        jaxbElement = jaxbUtil.unMashallFromString(xmlResponse);
                        messageType = (ResponseMessageType) jaxbElement.getValue();
                        bt = messageType.getMessageBody();
                        InstanceResponseType instanceResponseType = (InstanceResponseType) new JAXBUnWrapHelper()
                                .getObjectByClass(bt.getAny(), InstanceResponseType.class);

                        QueryInstanceData instanceData = null;
                        XMLGregorianCalendar startDate = null;
                        for (QueryInstanceType queryInstanceType : instanceResponseType.getQueryInstance()) {
                            QueryInstanceData runData = new QueryInstanceData();

                            runData.visualAttribute("FA");
                            runData.tooltip("The results of the query run");
                            runData.id(new Integer(queryInstanceType.getQueryInstanceId()).toString());
                            XMLGregorianCalendar cldr = queryInstanceType.getStartDate();
                            runData.name("Results of " + "[" + cldr.getMonth() + "-" + cldr.getDay() + "-"
                                    + cldr.getYear() + " " + cldr.getHour() + ":" + cldr.getMinute() + ":"
                                    + cldr.getSecond() + "]");

                            if (instanceData == null) {
                                startDate = cldr;
                                instanceData = runData;
                            } else {
                                if (cldr.toGregorianCalendar().compareTo(startDate.toGregorianCalendar()) > 0) {
                                    startDate = cldr;
                                    instanceData = runData;
                                }
                            }
                        }
                        // get patient set
                        if (instanceData == null) {
                            event.detail = DND.DROP_NONE;
                            return;
                        }
                        log.debug("Got query instance: " + instanceData.name());

                        xmlRequest = instanceData.writeContentQueryXML();
                        lastRequestMessage(xmlRequest);

                        xmlResponse = CRCQueryClient.sendPDQQueryRequestREST(xmlRequest);
                        lastResponseMessage(xmlResponse);

                        jaxbElement = jaxbUtil.unMashallFromString(xmlResponse);
                        messageType = (ResponseMessageType) jaxbElement.getValue();
                        bt = messageType.getMessageBody();
                        ResultResponseType resultResponseType = (ResultResponseType) new JAXBUnWrapHelper()
                                .getObjectByClass(bt.getAny(), ResultResponseType.class);

                        for (QueryResultInstanceType queryResultInstanceType : resultResponseType
                                .getQueryResultInstance()) {
                            if (!(queryResultInstanceType.getQueryResultType().getName()
                                    .equalsIgnoreCase("PATIENTSET"))) {
                                continue;
                            }

                            String status = queryResultInstanceType.getQueryStatusType().getName();

                            if (status.equalsIgnoreCase("FINISHED")) {
                                // resultData.name("Patient Set - "+resultData
                                // .patientCount()+" Patients");
                                // QueryResultData resultData = new
                                // QueryResultData();
                                String setId = new Integer(queryResultInstanceType.getResultInstanceId())
                                        .toString();
                                String setSize = new Integer(queryResultInstanceType.getSetSize()).toString();
                                patientSetText.setText("Patient Set: " + setSize + " patients");// strs[0]);
                                patientRefId = new String(setId);// strs[1]);
                                patientMinNumText.setText("1");
                                leftArrowButton.setEnabled(false);

                                int maxPatientNum = new Integer(patientMaxNumText.getText()).intValue();
                                patientSetSize = queryResultInstanceType.getSetSize();
                                if (patientSetSize > maxPatientNum) {
                                    rightArrowButton.setEnabled(true);
                                    patientMaxNumText.setText("10");
                                } else {
                                    rightArrowButton.setEnabled(false);
                                    if (patientSetSize > 0) {
                                        patientMaxNumText.setText(setSize);
                                    }
                                }

                                log.debug("Dropped set of: " + setSize + " patients"/* strs[0] */
                                        + " with refId: " + setId/*
                                                                 * strs[ 1 ]
                                                                 */);
                            } else {
                                // message
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        return;
                    }
                } else {
                    List conceptChildren = tableXml.getChildren();
                    parseDropConcepts(conceptChildren, event);
                    // System.setProperty("XMLfrommodel",(String)
                    // event.data);
                    table.redraw();
                }

                event.detail = DND.DROP_NONE;
            } catch (JDOMException e) {
                System.err.println(e.getMessage());
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("You can not drop this item here.");
                mBox.open();
                event.detail = DND.DROP_NONE;
                e.printStackTrace();
                return;
            } catch (Exception e) {
                System.err.println(e.getMessage());
                event.detail = DND.DROP_NONE;
                e.printStackTrace();
                return;
            }
        }

        public void dragEnter(DropTargetEvent event) {
            event.detail = DND.DROP_COPY;
        }
    });

    DropTarget target1 = new DropTarget(patientSetText, DND.DROP_COPY);
    target1.setTransfer(types);
    target1.addDropListener(new DropTargetAdapter() {
        @SuppressWarnings("unchecked")
        public void drop(DropTargetEvent event) {
            if (event.data == null) {
                event.detail = DND.DROP_NONE;
                return;
            }

            String tmp = patientSetText.getText();
            String dragStr = (String) event.data;
            String[] strs = dragStr.split(":");
            if (strs[0].equalsIgnoreCase("logicquery")) {
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("You can not drop this item here. It accepts a patient set only.");
                mBox.open();
                event.detail = DND.DROP_NONE;
                patientSetText.setText(tmp);
                return;
            }

            JAXBUtil jaxbUtil = AnalysisJAXBUtil.getJAXBUtil();

            try {
                JAXBElement jaxbElement = jaxbUtil.unMashallFromString(dragStr);
                DndType dndType = (DndType) jaxbElement.getValue();
                QueryResultInstanceType queryResultInstanceType = (QueryResultInstanceType) new JAXBUnWrapHelper()
                        .getObjectByClass(dndType.getAny(), QueryResultInstanceType.class);

                if (queryResultInstanceType == null) {
                    MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                    mBox.setText("Please Note ...");
                    mBox.setMessage("You can not drop this item here. It accepts a patient set only.");
                    mBox.open();
                    event.detail = DND.DROP_NONE;
                    patientSetText.setText(tmp);
                    return;
                }

                String resultTypeName = queryResultInstanceType.getQueryResultType().getName();
                if (resultTypeName == null || !resultTypeName.equalsIgnoreCase("PATIENTSET")) {
                    MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                    mBox.setText("Please Note ...");
                    mBox.setMessage("You can not drop this item here. It accepts a patient set only.");
                    mBox.open();
                    event.detail = DND.DROP_NONE;
                    patientSetText.setText(tmp);
                    return;
                }

                String setId = queryResultInstanceType.getResultInstanceId();
                String setSize = new Integer(queryResultInstanceType.getSetSize()).toString();
                patientSetText.setText("Patient Set: " + setSize + " patients");// strs[0]);
                patientRefId = new String(setId);// strs[1]);
                patientMinNumText.setText("1");
                leftArrowButton.setEnabled(false);

                int maxPatientNum = new Integer(patientMaxNumText.getText()).intValue();
                patientSetSize = queryResultInstanceType.getSetSize();
                if (patientSetSize > maxPatientNum) {
                    rightArrowButton.setEnabled(true);
                    patientMaxNumText.setText("10");
                } else {
                    rightArrowButton.setEnabled(false);
                    // if(patientSetSize>0) {
                    // patientMaxNumText.setText(setSize);
                    // }
                }

                log.debug("Dropped set of: " + setSize + " patients"/*
                                                                    * strs[0
                                                                    * ]
                                                                    */
                        + " with refId: " + setId/* strs[1] */);
            } catch (Exception e) {
                e.printStackTrace();
                event.detail = DND.DROP_NONE;
                return;
            }
        }

        public void dragEnter(DropTargetEvent event) {
            event.detail = DND.DROP_COPY;
        }
    });

    table.addCellResizeListener(new KTableCellResizeListener() {
        public void columnResized(int col, int newWidth) {
            log.debug("Column " + col + " resized to " + newWidth);
        }

        public void rowResized(int newHeight) {
            log.debug("Rows resized to " + newHeight);
        }

    });

    table.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            int tableWidth = table.getBounds().width;
            table.getModel().setColumnWidth(1, tableWidth - 425);
        }
    });

    table.addMouseTrackListener(new MouseTrackListener() {

        public void mouseEnter(MouseEvent arg0) {

        }

        public void mouseExit(MouseEvent arg0) {

        }

        public void mouseHover(MouseEvent arg0) {
            MouseEvent evt = arg0;

            Rectangle rect = table.getCellRect(3, getRowNumber());
            Rectangle rect1 = table.getCellRect(5, 1);

            // System.out.println("rect X and width: "+rect.x+","+rect.width)
            // ;
            // System.out.println("mouse X and Y: "+evt.x+","+evt.y);
            if (evt.y < rect.y && evt.x > rect1.x && evt.x < rect1.x + rect1.width) {
                table.setToolTipText("Double click the cell to change color.");
            } else {
                table.setToolTipText("");
            }
        }

    });

    // Item 2: a Color Palette
    TabItem item2 = new TabItem(tabFolder, SWT.NONE);
    item2.setText("Render a Timeline");
    final Composite comp2 = new Composite(tabFolder, SWT.NONE);
    item2.setControl(comp2);

    GridLayout oGridLayout0 = new GridLayout();
    oGridLayout0.marginWidth = 1;
    oGridLayout0.marginHeight = 5;
    comp2.setLayout(oGridLayout0);

    if (false) {
        Composite composite = new Composite(comp2, SWT.NO_BACKGROUND | SWT.EMBEDDED);

        /*
         * Set a Windows specific AWT property that prevents heavyweight
         * components from erasing their background. Note that this is a
         * global property and cannot be scoped. It might not be suitable
         * for your application.
         */
        try {
            // System.setProperty("sun.awt.noerasebackground", "true");
        } catch (NoSuchMethodError error) {
        }

        /* Create and setting up frame */
        ////for mac fix
        //if ( System.getProperty("os.name").toLowerCase().startsWith("mac"))
        //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame";
        Frame frame = SWT_AWT.new_Frame(composite);
        Panel panel = new Panel(new BorderLayout()) {
            public void update(java.awt.Graphics g) {
                /* Do not erase the background */
                paint(g);
            }
        };
        frame.add(panel);
        JRootPane root = new JRootPane();
        panel.add(root);
        java.awt.Container contentPane = root.getContentPane();
        log.debug("got to here");

        record record1 = new record();
        record1.start();
        record1.init();

        JScrollPane scrollPane = new JScrollPane(record1);
        contentPane.setLayout(new BorderLayout());
        contentPane.add(scrollPane);
    }

    if (true) {
        Composite composite = new Composite(comp2, SWT.NO_BACKGROUND | SWT.EMBEDDED);
        GridData gridData3 = new GridData();
        gridData3.horizontalIndent = 0;
        gridData3.verticalIndent = 0;
        gridData3.horizontalAlignment = GridData.FILL;
        gridData3.verticalAlignment = GridData.FILL;
        gridData3.grabExcessHorizontalSpace = true;
        gridData3.grabExcessVerticalSpace = true;
        composite.setLayoutData(gridData3);
        /* Create and setting up frame */
        ////for mac fix
        //if ( System.getProperty("os.name").toLowerCase().startsWith("mac"))
        //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame";
        Frame frame = SWT_AWT.new_Frame(composite);
        Panel panel = new Panel(new BorderLayout());// {

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            log.debug("Error setting native LAF: " + e);
        }

        frame.add(panel);
        JRootPane root = new JRootPane();
        panel.add(root);
        oAwtContainer = root.getContentPane();
        log.debug("got to here");
    }

    tabFolder.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {

            ConceptTableModel i2b2Model = (ConceptTableModel) table.getModel();
            i2b2Model.fillDataFromTable(rowData);
            if (rowData.size() == 0) {
                oTheParent.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        tabFolder.setSelection(0);
                    }
                });
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("The set up table is empty.");
                mBox.open();
                return;
            }

            String patientSetStr = patientSetText.getText();
            if (patientSetStr.equals("") && !isAll) {
                oTheParent.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        tabFolder.setSelection(0);
                    }
                });
                MessageBox mBox = new MessageBox(table.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mBox.setText("Please Note ...");
                mBox.setMessage("Please set a patient set or choose all datamart option.");
                mBox.open();
                return;
            }

            if (tabFolder.getSelectionIndex() == 1) {
                if (patientSetStr.equalsIgnoreCase("All")) {
                    int minPatient = 0;
                    try {
                        String minText = patientMinNumText.getText();
                        minPatient = Integer.parseInt(minText);
                    } catch (Exception e1) {
                        minPatient = -1;
                    }

                    int maxPatient = 0;
                    try {
                        maxPatient = Integer.parseInt(patientMaxNumText.getText());
                    } catch (Exception e2) {
                        maxPatient = -1;
                    }
                    PerformVisualizationQuery(oAwtContainer, "All", minPatient, maxPatient, bDisplayAllData);
                } else {
                    int min = Integer.parseInt(patientMinNumText.getText());
                    int max = Integer.parseInt(patientMaxNumText.getText());
                    PerformVisualizationQuery(oAwtContainer, patientRefId, min, max, bDisplayAllData);
                }
            } else {
                DestroyMiniVisualization(oAwtContainer);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });

    if (drawLeft) {
        horizontalForm.setWeights(new int[] { 30, 70 });
    }

    return parent;
}

From source file:AST.DesignPatternDetection.java

private void initComponents() {

    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Murat Oruc
    btPathFinder = new JButton();
    label1 = new JLabel();
    tfPath = new JTextField();
    label2 = new JLabel();
    cbSelectionDP = new JComboBox<>();
    btRun = new JButton();
    label3 = new JLabel();
    tfProjectName = new JTextField();
    label4 = new JLabel();
    tfThreshold = new JTextField();
    chbOverlap = new JCheckBox();
    btRunSgiso = new JButton();
    scrollPane1 = new JScrollPane();
    taInfo = new JTextArea();
    label5 = new JLabel();
    tfProgramPath = new JTextField();
    btProgramPath = new JButton();
    button1 = new JButton();
    button2 = new JButton();
    chbInnerClass = new JCheckBox();

    //======== this ========
    setTitle("DesPaD (Design Pattern Detector)");
    setIconImage(((ImageIcon) UIManager.getIcon("FileView.computerIcon")).getImage());
    addWindowListener(new WindowAdapter() {
        @Override//from  w w w. j a  v a  2s  . co  m
        public void windowClosing(WindowEvent e) {
            thisWindowClosing(e);
        }
    });
    Container contentPane = getContentPane();

    //---- btPathFinder ----
    btPathFinder.setText("...");
    btPathFinder.setFont(btPathFinder.getFont().deriveFont(btPathFinder.getFont().getSize() + 1f));
    btPathFinder.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btPathFinderActionPerformed(e);
        }
    });

    //---- label1 ----
    label1.setText("Source Code Directory Path");

    //---- tfPath ----
    tfPath.setText("...");
    tfPath.setEditable(false);
    tfPath.setForeground(Color.blue);
    tfPath.setFont(tfPath.getFont().deriveFont(tfPath.getFont().getStyle() | Font.BOLD));

    //---- label2 ----
    label2.setText("Select Design Pattern");

    //---- cbSelectionDP ----
    cbSelectionDP.setModel(new DefaultComboBoxModel<>(
            new String[] { "FACTORY_METHOD", "PROTOTYPE", "ABSTRACT_FACTORY", "BUILDER", "SINGLETON",
                    "COMPOSITE", "FACADE", "DECORATOR", "DECORATOR2", "BRIDGE", "FLYWEIGHT", "ADAPTER", "PROXY",
                    "MEDIATOR", "STATE", "OBSERVER", "TEMPLATE_METHOD", "TEMPLATE_METHOD2", "COMMAND",
                    "CHAIN_OF_RESPONSIBILITY", "INTERPRETER", "MEMENTO", "ITERATOR", "STRATEGY", "VISITOR" }));

    //---- btRun ----
    btRun.setText("1. Build Model Graph");
    btRun.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                btRunActionPerformed(e);
            } catch (IOException | InterruptedException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });

    //---- label3 ----
    label3.setText("Project Name");

    //---- label4 ----
    label4.setText("Threshold");

    //---- tfThreshold ----
    tfThreshold.setText("0.0");

    //---- chbOverlap ----
    chbOverlap.setText("Overlap");

    //---- btRunSgiso ----
    btRunSgiso.setText("2. Run Subdue-Sgiso Algorithm");
    btRunSgiso.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                btRunSgisoActionPerformed(e);
            } catch (IOException | InterruptedException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });

    //======== scrollPane1 ========
    {
        scrollPane1.setViewportView(taInfo);
    }

    //---- label5 ----
    label5.setText("Program Directory Path");

    //---- tfProgramPath ----
    tfProgramPath.setEditable(false);
    tfProgramPath.setForeground(Color.blue);
    tfProgramPath.setFont(tfProgramPath.getFont().deriveFont(tfProgramPath.getFont().getStyle() | Font.BOLD));

    //---- btProgramPath ----
    btProgramPath.setText("...");
    btProgramPath.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btProgramPathActionPerformed(e);
        }
    });

    //---- button1 ----
    button1.setText("3. Exclude overlap outputs");
    button1.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                button1ActionPerformed(e);
            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });

    //---- button2 ----
    button2.setText("4. Graph Representations");
    button2.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                button2ActionPerformed(e);
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });

    //---- chbInnerClass ----
    chbInnerClass.setText("Include Inner Classes");
    chbInnerClass.setSelected(true);

    GroupLayout contentPaneLayout = new GroupLayout(contentPane);
    contentPane.setLayout(contentPaneLayout);
    contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup().addGroup(contentPaneLayout.createSequentialGroup()
                    .addContainerGap().addGroup(contentPaneLayout
                            .createParallelGroup().addGroup(GroupLayout.Alignment.TRAILING,
                                    contentPaneLayout.createSequentialGroup().addComponent(label1).addGap(21,
                                            433, Short.MAX_VALUE))
                            .addGroup(contentPaneLayout
                                    .createSequentialGroup().addGroup(contentPaneLayout.createParallelGroup()
                                            .addComponent(label4).addGroup(contentPaneLayout
                                                    .createSequentialGroup().addGroup(contentPaneLayout
                                                            .createParallelGroup(GroupLayout.Alignment.TRAILING,
                                                                    false)
                                                            .addComponent(
                                                                    button1, GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE, 260,
                                                                    Short.MAX_VALUE)
                                                            .addComponent(tfThreshold,
                                                                    GroupLayout.Alignment.LEADING)
                                                            .addComponent(cbSelectionDP,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE, 260,
                                                                    Short.MAX_VALUE)
                                                            .addComponent(label2, GroupLayout.Alignment.LEADING)
                                                            .addComponent(
                                                                    btRun, GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE, 260,
                                                                    Short.MAX_VALUE))
                                                    .addGap(30, 30, 30)
                                                    .addGroup(contentPaneLayout
                                                            .createParallelGroup(GroupLayout.Alignment.LEADING,
                                                                    false)
                                                            .addComponent(label3)
                                                            .addComponent(tfProjectName,
                                                                    GroupLayout.DEFAULT_SIZE, 260,
                                                                    Short.MAX_VALUE)
                                                            .addGroup(contentPaneLayout.createSequentialGroup()
                                                                    .addComponent(chbOverlap)
                                                                    .addPreferredGap(
                                                                            LayoutStyle.ComponentPlacement.RELATED,
                                                                            GroupLayout.DEFAULT_SIZE,
                                                                            Short.MAX_VALUE)
                                                                    .addComponent(chbInnerClass))
                                                            .addComponent(btRunSgiso, GroupLayout.DEFAULT_SIZE,
                                                                    260, Short.MAX_VALUE)
                                                            .addComponent(
                                                                    button2, GroupLayout.DEFAULT_SIZE, 260,
                                                                    Short.MAX_VALUE))))
                                    .addGap(0, 56, Short.MAX_VALUE))
                            .addGroup(GroupLayout.Alignment.TRAILING,
                                    contentPaneLayout.createSequentialGroup().addGroup(contentPaneLayout
                                            .createParallelGroup(GroupLayout.Alignment.TRAILING)
                                            .addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 594,
                                                    Short.MAX_VALUE)
                                            .addGroup(contentPaneLayout.createSequentialGroup()
                                                    .addGroup(contentPaneLayout.createParallelGroup()
                                                            .addGroup(contentPaneLayout.createSequentialGroup()
                                                                    .addComponent(label5)
                                                                    .addGap(0, 418, Short.MAX_VALUE))
                                                            .addComponent(tfProgramPath,
                                                                    GroupLayout.DEFAULT_SIZE, 564,
                                                                    Short.MAX_VALUE)
                                                            .addComponent(
                                                                    tfPath, GroupLayout.Alignment.TRAILING,
                                                                    GroupLayout.DEFAULT_SIZE, 564,
                                                                    Short.MAX_VALUE))
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addGroup(contentPaneLayout
                                                            .createParallelGroup(GroupLayout.Alignment.LEADING,
                                                                    false)
                                                            .addComponent(btPathFinder,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(btProgramPath,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    Short.MAX_VALUE))))
                                            .addContainerGap()))));
    contentPaneLayout.setVerticalGroup(contentPaneLayout.createParallelGroup().addGroup(contentPaneLayout
            .createSequentialGroup().addGap(29, 29, 29).addComponent(label1).addGap(5, 5, 5)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(tfPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(btPathFinder, GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE))
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(label5)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(tfProgramPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(btProgramPath))
            .addGap(18, 18, 18)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(label2)
                    .addComponent(label3))
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(cbSelectionDP, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfProjectName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18).addComponent(label4).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(tfThreshold, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(chbOverlap).addComponent(chbInnerClass))
            .addGap(18, 18, 18)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(btRun, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
                    .addComponent(btRunSgiso, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                    .addComponent(button2, GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
                    .addComponent(button1, GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE))
            .addGap(18, 18, 18).addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
            .addContainerGap()));
    setSize(630, 625);
    setLocationRelativeTo(null);
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}