Example usage for javax.swing JDialog setModal

List of usage examples for javax.swing JDialog setModal

Introduction

In this page you can find the example usage for javax.swing JDialog setModal.

Prototype

public void setModal(boolean modal) 

Source Link

Document

Specifies whether this dialog should be modal.

Usage

From source file:userinterface.properties.GUIGraphHandler.java

public void defineConstantsAndPlot(Expression expr, JPanel graph, String seriesName, Boolean isNewGraph,
        boolean is2D) {

    JDialog dialog;
    JButton ok, cancel;/*  ww w  .  ja v  a  2  s  . c o m*/
    JScrollPane scrollPane;
    ConstantPickerList constantList;
    JComboBox<String> xAxis, yAxis;

    //init everything
    dialog = new JDialog(GUIPrism.getGUI());
    dialog.setTitle("Define constants and select axes");
    dialog.setSize(500, 400);
    dialog.setLocationRelativeTo(GUIPrism.getGUI());
    dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS));
    dialog.setModal(true);

    constantList = new ConstantPickerList();
    scrollPane = new JScrollPane(constantList);

    xAxis = new JComboBox<String>();
    yAxis = new JComboBox<String>();

    ok = new JButton("Ok");
    ok.setMnemonic('O');
    cancel = new JButton("Cancel");
    cancel.setMnemonic('C');

    //add all components to their dedicated panels
    JPanel exprPanel = new JPanel(new FlowLayout());
    exprPanel.setBorder(new TitledBorder("Function"));
    exprPanel.add(new JLabel(expr.toString()));

    JPanel axisPanel = new JPanel();
    axisPanel.setBorder(new TitledBorder("Select axis constants"));
    axisPanel.setLayout(new BoxLayout(axisPanel, BoxLayout.Y_AXIS));
    JPanel xAxisPanel = new JPanel(new FlowLayout());
    xAxisPanel.add(new JLabel("X axis:"));
    xAxisPanel.add(xAxis);
    JPanel yAxisPanel = new JPanel(new FlowLayout());
    yAxisPanel.add(new JLabel("Y axis:"));
    yAxisPanel.add(yAxis);
    axisPanel.add(xAxisPanel);
    axisPanel.add(yAxisPanel);

    JPanel constantPanel = new JPanel(new BorderLayout());
    constantPanel.setBorder(new TitledBorder("Please define the following constants"));
    constantPanel.add(scrollPane, BorderLayout.CENTER);
    constantPanel.add(new ConstantHeader(), BorderLayout.NORTH);

    JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    bottomPanel.add(ok);
    bottomPanel.add(cancel);

    //fill the axes components

    for (int i = 0; i < expr.getAllConstants().size(); i++) {

        xAxis.addItem(expr.getAllConstants().get(i));

        if (!is2D)
            yAxis.addItem(expr.getAllConstants().get(i));
    }

    if (!is2D) {
        yAxis.setSelectedIndex(1);
    }

    //fill the constants table

    for (int i = 0; i < expr.getAllConstants().size(); i++) {

        ConstantLine line = new ConstantLine(expr.getAllConstants().get(i), TypeDouble.getInstance());
        constantList.addConstant(line);

        if (!is2D) {
            if (line.getName().equals(xAxis.getSelectedItem().toString())
                    || line.getName().equals(yAxis.getSelectedItem().toString())) {

                line.doFuncEnables(false);
            } else {
                line.doFuncEnables(true);
            }
        }

    }

    //do enables

    if (is2D) {
        yAxis.setEnabled(false);
    }

    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok");
    ok.getActionMap().put("ok", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ok.doClick();
        }
    });

    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "cancel");
    cancel.getActionMap().put("cancel", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cancel.doClick();
        }
    });

    //add action listeners

    xAxis.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (is2D) {
                return;
            }

            String item = xAxis.getSelectedItem().toString();

            if (item.equals(yAxis.getSelectedItem().toString())) {

                int index = yAxis.getSelectedIndex();

                if (index != yAxis.getItemCount() - 1) {
                    yAxis.setSelectedIndex(++index);
                } else {
                    yAxis.setSelectedIndex(--index);
                }

            }

            for (int i = 0; i < constantList.getNumConstants(); i++) {

                ConstantLine line = constantList.getConstantLine(i);

                if (line.getName().equals(xAxis.getSelectedItem().toString())
                        || line.getName().equals(yAxis.getSelectedItem().toString())) {

                    line.doFuncEnables(false);
                } else {

                    line.doFuncEnables(true);
                }

            }
        }
    });

    yAxis.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            String item = yAxis.getSelectedItem().toString();

            if (item.equals(xAxis.getSelectedItem().toString())) {

                int index = xAxis.getSelectedIndex();

                if (index != xAxis.getItemCount() - 1) {
                    xAxis.setSelectedIndex(++index);
                } else {
                    xAxis.setSelectedIndex(--index);
                }
            }

            for (int i = 0; i < constantList.getNumConstants(); i++) {

                ConstantLine line = constantList.getConstantLine(i);

                if (line.getName().equals(xAxis.getSelectedItem().toString())
                        || line.getName().equals(yAxis.getSelectedItem().toString())) {

                    line.doFuncEnables(false);
                } else {

                    line.doFuncEnables(true);
                }

            }
        }
    });

    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            try {

                constantList.checkValid();

            } catch (PrismException e2) {
                JOptionPane.showMessageDialog(dialog,
                        "<html> One or more of the defined constants are invalid. <br><br> <font color=red>Error: </font>"
                                + e2.getMessage() + "</html>",
                        "Parse Error", JOptionPane.ERROR_MESSAGE);
                return;
            }

            if (is2D) {

                // it will always be a parametric graph in 2d case
                ParametricGraph pGraph = (ParametricGraph) graph;

                ConstantLine xAxisConstant = constantList.getConstantLine(xAxis.getSelectedItem().toString());

                if (xAxisConstant == null) {
                    //should never happen
                    JOptionPane.showMessageDialog(dialog, "The selected axis is invalid.", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                double xStartValue = Double.parseDouble(xAxisConstant.getStartValue());
                double xEndValue = Double.parseDouble(xAxisConstant.getEndValue());
                double xStepValue = Double.parseDouble(xAxisConstant.getStepValue());

                int seriesCount = 0;

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line.getName().equals(xAxis.getSelectedItem().toString())) {
                        seriesCount++;
                    } else {

                        seriesCount += line.getTotalNumOfValues();

                    }
                }

                // if there will be too many series to be plotted, ask the user if they are sure they know what they are doing
                if (seriesCount > 10) {

                    int res = JOptionPane.showConfirmDialog(dialog,
                            "This configuration will create " + seriesCount + " series. Continue?", "Confirm",
                            JOptionPane.YES_NO_OPTION);

                    if (res == JOptionPane.NO_OPTION) {
                        return;
                    }

                }

                Values singleValuesGlobal = new Values();

                //add the single values to a global values list

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line.getTotalNumOfValues() == 1) {

                        double singleValue = Double.parseDouble(line.getSingleValue());
                        singleValuesGlobal.addValue(line.getName(), singleValue);
                    }
                }

                // we just have one variable so we can plot directly
                if (constantList.getNumConstants() == 1
                        || singleValuesGlobal.getNumValues() == constantList.getNumConstants() - 1) {

                    SeriesKey key = pGraph.addSeries(seriesName);

                    pGraph.hideShape(key);
                    pGraph.getXAxisSettings().setHeading(xAxis.getSelectedItem().toString());
                    pGraph.getYAxisSettings().setHeading("function");

                    for (double x = xStartValue; x <= xEndValue; x += xStepValue) {

                        double ans = -1;

                        Values vals = new Values();
                        vals.addValue(xAxis.getSelectedItem().toString(), x);

                        for (int ii = 0; ii < singleValuesGlobal.getNumValues(); ii++) {

                            try {
                                vals.addValue(singleValuesGlobal.getName(ii),
                                        singleValuesGlobal.getDoubleValue(ii));
                            } catch (PrismLangException e1) {
                                e1.printStackTrace();
                            }

                        }

                        try {
                            ans = expr.evaluateDouble(vals);
                        } catch (PrismLangException e1) {
                            e1.printStackTrace();
                        }

                        pGraph.addPointToSeries(key, new PrismXYDataItem(x, ans));

                    }

                    if (isNewGraph) {
                        addGraph(pGraph);
                    }

                    dialog.dispose();
                    return;
                }

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line == xAxisConstant || singleValuesGlobal.contains(line.getName())) {
                        continue;
                    }

                    double lineStart = Double.parseDouble(line.getStartValue());
                    double lineEnd = Double.parseDouble(line.getEndValue());
                    double lineStep = Double.parseDouble(line.getStepValue());

                    for (double j = lineStart; j < lineEnd; j += lineStep) {

                        SeriesKey key = pGraph.addSeries(seriesName);
                        pGraph.hideShape(key);

                        for (double x = xStartValue; x <= xEndValue; x += xStepValue) {

                            double ans = -1;

                            Values vals = new Values();
                            vals.addValue(xAxis.getSelectedItem().toString(), x);
                            vals.addValue(line.getName(), j);

                            for (int ii = 0; ii < singleValuesGlobal.getNumValues(); ii++) {

                                try {
                                    vals.addValue(singleValuesGlobal.getName(ii),
                                            singleValuesGlobal.getDoubleValue(ii));
                                } catch (PrismLangException e1) {
                                    // TODO Auto-generated catch block
                                    e1.printStackTrace();
                                }

                            }

                            for (int ii = 0; ii < constantList.getNumConstants(); ii++) {

                                if (constantList.getConstantLine(ii) == xAxisConstant
                                        || singleValuesGlobal
                                                .contains(constantList.getConstantLine(ii).getName())
                                        || constantList.getConstantLine(ii) == line) {

                                    continue;
                                }

                                ConstantLine temp = constantList.getConstantLine(ii);
                                double val = Double.parseDouble(temp.getStartValue());

                                vals.addValue(temp.getName(), val);
                            }

                            try {
                                ans = expr.evaluateDouble(vals);
                            } catch (PrismLangException e1) {
                                e1.printStackTrace();
                            }

                            pGraph.addPointToSeries(key, new PrismXYDataItem(x, ans));
                        }
                    }

                }

                if (isNewGraph) {
                    addGraph(graph);
                }
            } else {

                // this will always be a parametric graph for the 3d case
                ParametricGraph3D pGraph = (ParametricGraph3D) graph;

                //add the graph to the gui
                addGraph(pGraph);

                //Get the constants we want to put on the x and y axis
                ConstantLine xAxisConstant = constantList.getConstantLine(xAxis.getSelectedItem().toString());
                ConstantLine yAxisConstant = constantList.getConstantLine(yAxis.getSelectedItem().toString());

                //add the single values to a global values list

                Values singleValuesGlobal = new Values();

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line.getTotalNumOfValues() == 1) {

                        double singleValue = Double.parseDouble(line.getSingleValue());
                        singleValuesGlobal.addValue(line.getName(), singleValue);
                    }
                }

                pGraph.setGlobalValues(singleValuesGlobal);
                pGraph.setAxisConstants(xAxis.getSelectedItem().toString(), yAxis.getSelectedItem().toString());
                pGraph.setBounds(xAxisConstant.getStartValue(), xAxisConstant.getEndValue(),
                        yAxisConstant.getStartValue(), yAxisConstant.getEndValue());

                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        //plot the graph
                        pGraph.plot(expr.toString(), xAxis.getSelectedItem().toString(), "Function",
                                yAxis.getSelectedItem().toString());

                        //calculate the sampling rates from the step sizes as given by the user

                        int xSamples = (int) ((Double.parseDouble(xAxisConstant.getEndValue())
                                - Double.parseDouble(xAxisConstant.getStartValue()))
                                / Double.parseDouble(xAxisConstant.getStepValue()));
                        int ySamples = (int) ((Double.parseDouble(xAxisConstant.getEndValue())
                                - Double.parseDouble(xAxisConstant.getStartValue()))
                                / Double.parseDouble(xAxisConstant.getStepValue()));

                        pGraph.setSamplingRates(xSamples, ySamples);
                    }
                });

            }

            dialog.dispose();
        }
    });

    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });

    //add everything to the dialog show the dialog

    dialog.add(exprPanel);
    dialog.add(axisPanel);
    dialog.add(constantPanel);
    dialog.add(bottomPanel);
    dialog.setVisible(true);

}

From source file:jatoo.proxy.dialog.ProxyDialog.java

/**
 * Shows the dialog relative to the specified owner.
 *///www .  java  2 s  . c o m
public static synchronized void show(Component owner) {

    JDialog dialogTmp;

    if (owner == null) {
        dialogTmp = new JDialog();
    } else {
        dialogTmp = new JDialog(SwingUtilities.getWindowAncestor(owner));
    }

    final JDialog dialog = dialogTmp;

    //
    // the panel

    final ProxyDialogPanel dialogPanel = PROXY_DIALOG_PANEL_FACTORY.createDialogPanel();

    try {

        Proxy proxy = new Proxy();
        proxy.load();

        dialogPanel.setProxyEnabled(proxy.isEnabled());
        dialogPanel.setHost(proxy.getHost());
        dialogPanel.setPort(proxy.getPort());
        dialogPanel.setProxyRequiringAuthentication(proxy.isRequiringAuthentication());
        dialogPanel.setUsername(proxy.getUsername());
        dialogPanel.setPassword(proxy.getPassword());
    }

    catch (FileNotFoundException e) {
        // do nothing, maybe is the first time and the file is missing
    }

    catch (Exception e) {
        logger.error("Failed to load the properties.", e);
    }

    //
    // buttons

    JButton okButton = new JButton("Ok");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {

            try {

                if (dialogPanel.isProxyEnabled()) {

                    if (dialogPanel.isProxyRequiringAuthentication()) {
                        ProxyUtils.setProxy(dialogPanel.getHost(), dialogPanel.getPort(),
                                dialogPanel.getUsername(), dialogPanel.getPassword());
                    } else {
                        ProxyUtils.setProxy(dialogPanel.getHost(), dialogPanel.getPort());
                    }
                }

                else {
                    ProxyUtils.removeProxy();
                }

                dialog.dispose();
            }

            catch (Exception e) {
                JOptionPane.showMessageDialog(dialog, "Failed to set the proxy:\n" + e.toString());
                return;
            }

            try {

                Proxy proxy = new Proxy();

                proxy.setEnabled(dialogPanel.isProxyEnabled());
                proxy.setUsername(dialogPanel.getUsername());
                proxy.setPassword(dialogPanel.getPassword());
                proxy.setRequiringAuthentication(dialogPanel.isProxyRequiringAuthentication());
                proxy.setHost(dialogPanel.getHost());
                proxy.setPort(dialogPanel.getPort());

                proxy.store();
            }

            catch (Exception e) {
                logger.error("Failed to save the properties.", e);
            }
        }
    });

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });

    //
    // layout dialog

    dialogPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel buttonsGroup = new JPanel(new GridLayout(1, 2, 5, 5));
    buttonsGroup.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    buttonsGroup.add(okButton);
    buttonsGroup.add(cancelButton);

    JPanel buttonsPanel = new JPanel(new BorderLayout());
    buttonsPanel.add(buttonsGroup, BorderLayout.LINE_END);

    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.add(dialogPanel, BorderLayout.CENTER);
    contentPane.add(buttonsPanel, BorderLayout.PAGE_END);

    //
    // setup dialog

    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setTitle("Proxy Settings");
    dialog.setContentPane(contentPane);
    dialog.pack();
    dialog.setLocationRelativeTo(dialog.getOwner());
    dialog.setModal(true);

    //
    // and show

    dialog.setVisible(true);
}

From source file:userinterface.properties.GUIGraphHandler.java

public void plotNewFunction() {

    JDialog dialog;
    JRadioButton radio2d, radio3d, newGraph, existingGraph;
    JTextField functionField, seriesName;
    JButton ok, cancel;//from   w ww  . j av a  2  s .c om
    JComboBox<String> chartOptions;
    JLabel example;

    //init all the fields of the dialog
    dialog = new JDialog(GUIPrism.getGUI());
    radio2d = new JRadioButton("2D");
    radio3d = new JRadioButton("3D");
    newGraph = new JRadioButton("New Graph");
    existingGraph = new JRadioButton("Exisiting");
    chartOptions = new JComboBox<String>();
    functionField = new JTextField();
    ok = new JButton("Plot");
    cancel = new JButton("Cancel");
    seriesName = new JTextField();
    example = new JLabel("<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>");
    example.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            example.setCursor(new Cursor(Cursor.HAND_CURSOR));
            example.setForeground(Color.BLUE);
        }

        @Override
        public void mouseExited(MouseEvent e) {
            example.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            example.setForeground(Color.BLACK);
        }

        @Override
        public void mouseClicked(MouseEvent e) {

            if (e.getButton() == MouseEvent.BUTTON1) {

                if (radio2d.isSelected()) {
                    functionField.setText("x/2 + 5");
                } else {
                    functionField.setText("x+y+5");
                }

                functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15));
                functionField.setForeground(Color.BLACK);

            }
        }

    });

    //set dialog properties
    dialog.setSize(400, 350);
    dialog.setTitle("Plot a new function");
    dialog.setModal(true);
    dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS));
    dialog.setLocationRelativeTo(GUIPrism.getGUI());

    //add every component to their dedicated panels
    JPanel graphTypePanel = new JPanel(new FlowLayout());
    graphTypePanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function type"));
    graphTypePanel.add(radio2d);
    graphTypePanel.add(radio3d);

    JPanel functionFieldPanel = new JPanel(new BorderLayout());
    functionFieldPanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function"));
    functionFieldPanel.add(functionField, BorderLayout.CENTER);
    functionFieldPanel.add(example, BorderLayout.SOUTH);

    JPanel chartSelectPanel = new JPanel();
    chartSelectPanel.setLayout(new BoxLayout(chartSelectPanel, BoxLayout.Y_AXIS));
    chartSelectPanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Plot function to"));
    JPanel radioPlotPanel = new JPanel(new FlowLayout());
    radioPlotPanel.add(newGraph);
    radioPlotPanel.add(existingGraph);
    JPanel chartOptionsPanel = new JPanel(new FlowLayout());
    chartOptionsPanel.add(chartOptions);
    chartSelectPanel.add(radioPlotPanel);
    chartSelectPanel.add(chartOptionsPanel);

    JPanel bottomControlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    bottomControlPanel.add(ok);
    bottomControlPanel.add(cancel);

    JPanel seriesNamePanel = new JPanel(new BorderLayout());
    seriesNamePanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name"));
    seriesNamePanel.add(seriesName, BorderLayout.CENTER);

    // add all the panels to the dialog

    dialog.add(graphTypePanel);
    dialog.add(functionFieldPanel);
    dialog.add(chartSelectPanel);
    dialog.add(seriesNamePanel);
    dialog.add(bottomControlPanel);

    // do all the enables and set properties

    radio2d.setSelected(true);
    newGraph.setSelected(true);
    chartOptions.setEnabled(false);
    functionField.setText("Add function expression here....");
    functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15));
    functionField.setForeground(Color.GRAY);
    seriesName.setText("New function");
    ok.setMnemonic('P');
    cancel.setMnemonic('C');
    example.setToolTipText("click to try out");

    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok");
    ok.getActionMap().put("ok", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ok.doClick();
        }
    });

    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "cancel");
    cancel.getActionMap().put("cancel", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cancel.doClick();
        }
    });

    boolean found = false;

    for (int i = 0; i < theTabs.getTabCount(); i++) {

        if (theTabs.getComponentAt(i) instanceof Graph) {
            chartOptions.addItem(getGraphName(i));
            found = true;
        }
    }

    if (!found) {

        existingGraph.setEnabled(false);
        chartOptions.setEnabled(false);
    }

    //add all the action listeners

    radio2d.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (radio2d.isSelected()) {

                radio3d.setSelected(false);

                if (chartOptions.getItemCount() > 0) {
                    existingGraph.setEnabled(true);
                    chartOptions.setEnabled(true);
                }

                example.setText(
                        "<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>");
            }
        }
    });

    radio3d.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (radio3d.isSelected()) {

                radio2d.setSelected(false);
                newGraph.setSelected(true);
                existingGraph.setEnabled(false);
                chartOptions.setEnabled(false);
                example.setText("<html><font size=3 color=red>Example:</font><font size=3>x+y+5</font></html>");

            }

        }
    });

    newGraph.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (newGraph.isSelected()) {
                existingGraph.setSelected(false);
                chartOptions.setEnabled(false);
            }
        }
    });

    existingGraph.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (existingGraph.isSelected()) {

                newGraph.setSelected(false);
                chartOptions.setEnabled(true);
            }
        }
    });

    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            String function = functionField.getText();

            Expression expr = null;

            try {

                expr = GUIPrism.getGUI().getPrism().parseSingleExpressionString(function);
                expr = (Expression) expr.accept(new ASTTraverseModify() {

                    @Override
                    public Object visit(ExpressionIdent e) throws PrismLangException {
                        return new ExpressionConstant(e.getName(), TypeDouble.getInstance());
                    }

                });

                expr.typeCheck();
                expr.semanticCheck();

            } catch (PrismLangException e1) {

                // for copying style
                JLabel label = new JLabel();

                // html content in our case the error we want to show
                JEditorPane ep = new JEditorPane("text/html",
                        "<html> There was an error parsing the function. To read about what built-in"
                                + " functions are supported <br>and some more information on the functions, visit "
                                + "<a href='http://www.prismmodelchecker.org/manual/ThePRISMLanguage/Expressions'>Prism expressions site</a>."
                                + "<br><br><font color=red>Error: </font>" + e1.getMessage() + " </html>");

                // handle link events
                ep.addHyperlinkListener(new HyperlinkListener() {
                    @Override
                    public void hyperlinkUpdate(HyperlinkEvent e) {
                        if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                            try {
                                Desktop.getDesktop().browse(e.getURL().toURI());
                            } catch (IOException | URISyntaxException e1) {

                                e1.printStackTrace();
                            }
                        }
                    }
                });
                ep.setEditable(false);
                ep.setBackground(label.getBackground());

                // show the error dialog
                JOptionPane.showMessageDialog(dialog, ep, "Parse Error", JOptionPane.ERROR_MESSAGE);
                return;
            }

            if (radio2d.isSelected()) {

                ParametricGraph graph = null;

                if (newGraph.isSelected()) {

                    graph = new ParametricGraph("");
                } else {

                    for (int i = 0; i < theTabs.getComponentCount(); i++) {

                        if (theTabs.getTitleAt(i).equals(chartOptions.getSelectedItem())) {

                            graph = (ParametricGraph) theTabs.getComponent(i);
                        }
                    }

                }

                dialog.dispose();
                defineConstantsAndPlot(expr, graph, seriesName.getText(), newGraph.isSelected(), true);

            } else if (radio3d.isSelected()) {

                try {

                    expr = (Expression) expr.accept(new ASTTraverseModify() {
                        @Override
                        public Object visit(ExpressionIdent e) throws PrismLangException {
                            return new ExpressionConstant(e.getName(), TypeDouble.getInstance());
                        }

                    });

                    expr.semanticCheck();
                    expr.typeCheck();

                } catch (PrismLangException e1) {
                    e1.printStackTrace();
                }

                if (expr.getAllConstants().size() < 2) {

                    JOptionPane.showMessageDialog(dialog,
                            "There are not enough variables in the function to plot a 3D chart!", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                // its always a new graph
                ParametricGraph3D graph = new ParametricGraph3D(expr);
                dialog.dispose();
                defineConstantsAndPlot(expr, graph, seriesName.getText(), true, false);
            }

            dialog.dispose();
        }
    });

    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });

    // we will show info about the function when field is out of focus
    functionField.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {

            if (!functionField.getText().equals("")) {
                return;
            }

            functionField.setText("Add function expression here....");
            functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15));
            functionField.setForeground(Color.GRAY);
        }

        @Override
        public void focusGained(FocusEvent e) {

            if (!functionField.getText().equals("Add function expression here....")) {
                return;
            }

            functionField.setForeground(Color.BLACK);
            functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15));
            functionField.setText("");
        }
    });

    // show the dialog
    dialog.setVisible(true);
}

From source file:org.nuclos.client.ui.collect.Chart.java

private void actionCommandShow() {
    final JOptionPane optpn = new JOptionPane(subform, JOptionPane.PLAIN_MESSAGE, JOptionPane.CLOSED_OPTION);

    // perform the dialog:
    final JDialog dlg = optpn.createDialog(panel, "Chart-Daten anzeigen");
    dlg.setModal(true);
    dlg.setResizable(true);/*  w ww . ja  va 2 s  .co  m*/
    dlg.pack();
    dlg.setLocationRelativeTo(panel);
    dlg.setVisible(true);
}

From source file:fxts.stations.util.preferences.EditAction.java

public void actionPerformed(ActionEvent aEvent) {
    JButton okButton = UIManager.getInst().createButton();
    JButton cancelButton = UIManager.getInst().createButton();
    final JDialog dialog = new JDialog(mEditorPanel.getParentDialog());
    dialog.setTitle(mEditorPanel.getTitle());
    JPanel editPanel = new JPanel();
    JPanel buttonPanel = new JPanel();
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(UIFrontEnd.getInstance().getSideLayout());
    //mainPanel.setLayout(new SideLayout());

    //sets button panel
    buttonPanel.setLayout(UIFrontEnd.getInstance().getSideLayout());
    okButton.setText(mResMan.getString("IDS_OK_BUTTON"));
    //okButton.setPreferredSize(new Dimension(80, 27));
    GridBagConstraints sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.insets = new Insets(10, 10, 10, 10);
    sideConstraints.gridx = 0;/*from  ww w.j  av a  2s  . co m*/
    sideConstraints.gridy = 0;
    ResizeParameterWrapper resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.5, 0.0, 0.5, 0.0);
    resizeParameter.setToConstraints(sideConstraints);
    buttonPanel.add(okButton, sideConstraints);
    cancelButton.setText(mResMan.getString("IDS_CANCEL_BUTTON"));
    //cancelButton.setPreferredSize(new Dimension(80, 27));
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.insets = new Insets(10, 10, 10, 10);
    sideConstraints.gridx = 1;
    sideConstraints.gridy = 0;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.5, 0.0, 0.5, 0.0);
    resizeParameter.setToConstraints(sideConstraints);
    buttonPanel.add(cancelButton, sideConstraints);

    //adds button panel
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.insets = new Insets(10, 10, 10, 10);
    sideConstraints.gridx = 0;
    sideConstraints.gridy = 1;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 1.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    mainPanel.add(buttonPanel, sideConstraints);

    //sets edit panel
    final IEditor editor = mType.getEditor();
    editor.setValue(mValue);
    editPanel.setLayout(UIFrontEnd.getInstance().getSideLayout());
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 0.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    Component editComp = editor.getComponent();

    //Mar 25 2004 - kav: added for right tab order at Font Chooser at java 1.4.
    if (editComp instanceof FontChooser) {
        FontChooser fc = (FontChooser) editComp;
        fc.setNextFocusedComp(okButton);
    }
    editPanel.add(editComp, sideConstraints);

    //adds editor panel
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.gridx = 0;
    sideConstraints.gridy = 0;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 0.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    mainPanel.add(editPanel, sideConstraints);

    //adds main panel
    dialog.getContentPane().setLayout(UIFrontEnd.getInstance().getSideLayout());
    //dialog.getContentPane().setLayout(new SideLayout());
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.fill = GridBagConstraints.BOTH;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 0.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    dialog.getContentPane().add(mainPanel, sideConstraints);

    //adds listeners to buttons
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            if (editor.getValue().equals(mValue)) {
                //
            } else {
                mValue = editor.getValue();
                mEditorPanel.setValue(mValue);
                mEditorPanel.refreshControls();
                mEditorPanel.setValueChanged(true);
            }
            dialog.setVisible(false);
            dialog.dispose();
        }
    });
    okButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "ExitAction");
    okButton.getActionMap().put("ExitAction", new AbstractAction() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent aEvent) {
            editor.setValue(mValue);
            dialog.setVisible(false);
            dialog.dispose();
        }
    });
    okButton.requestFocus();
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            editor.setValue(mValue);
            dialog.setVisible(false);
            dialog.dispose();
        }
    });
    //dialog.setResizable(false);
    dialog.setModal(true);
    dialog.pack();

    //sets minimal sizes for components
    Dimension dim = mainPanel.getSize();
    mainPanel.setMinimumSize(dim);
    mainPanel.setPreferredSize(dim);

    //sets size of buttons
    Dimension dimOkButton = okButton.getSize();
    Dimension dimCancelButton = cancelButton.getSize();
    int nMaxWidth = dimOkButton.getWidth() > dimCancelButton.getWidth() ? (int) dimOkButton.getWidth()
            : (int) dimCancelButton.getWidth();
    okButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight()));
    okButton.setSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight()));
    cancelButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight()));
    cancelButton.setSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight()));
    dialog.setLocationRelativeTo(dialog.getOwner());
    dialog.setVisible(true);
}

From source file:org.apache.marmotta.splash.common.ui.MessageDialog.java

public static void show(String title, String message, String description) {
    final JDialog dialog = new JDialog((Frame) null, title);
    dialog.setModal(true);
    dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    final JPanel root = new JPanel(new GridBagLayout());
    root.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    dialog.getRootPane().setContentPane(root);

    final JButton close = new JButton("OK");
    close.addActionListener(new ActionListener() {
        @Override//from   w ww. j  ava2s  . c o m
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
        }
    });
    GridBagConstraints cClose = new GridBagConstraints();
    cClose.gridx = 0;
    cClose.gridy = 2;
    cClose.gridwidth = 2;
    cClose.weightx = 1;
    cClose.weighty = 0;
    cClose.insets = new Insets(5, 5, 5, 5);

    root.add(close, cClose);
    dialog.getRootPane().setDefaultButton(close);

    Icon icon = loadIcon(MARMOTTA_ICON);
    if (icon != null) {
        JLabel lblIcn = new JLabel(icon);

        GridBagConstraints cIcon = new GridBagConstraints();
        cIcon.gridx = 1;
        cIcon.gridy = 0;
        cIcon.gridheight = 2;
        cIcon.fill = GridBagConstraints.NONE;
        cIcon.weightx = 0;
        cIcon.weighty = 1;
        cIcon.anchor = GridBagConstraints.NORTH;
        cIcon.insets = new Insets(10, 5, 5, 0);
        root.add(lblIcn, cIcon);
    }

    JLabel lblMsg = new JLabel("<html>" + StringEscapeUtils.escapeHtml3(message).replaceAll("\\n", "<br>"));
    lblMsg.setFont(lblMsg.getFont().deriveFont(Font.BOLD, 16f));
    GridBagConstraints cLabel = new GridBagConstraints();
    cLabel.gridx = 0;
    cLabel.gridy = 0;
    cLabel.fill = GridBagConstraints.BOTH;
    cLabel.weightx = 1;
    cLabel.weighty = 0.5;
    cLabel.insets = new Insets(5, 5, 5, 5);
    root.add(lblMsg, cLabel);

    JLabel lblDescr = new JLabel(
            "<html>" + StringEscapeUtils.escapeHtml3(description).replaceAll("\\n", "<br>"));
    cLabel.gridy++;
    cLabel.insets = new Insets(0, 5, 5, 5);
    root.add(lblDescr, cLabel);

    dialog.pack();
    dialog.setLocationRelativeTo(null);

    dialog.setVisible(true);
    dialog.dispose();
}

From source file:org.apache.marmotta.splash.common.ui.SelectionDialog.java

public static int select(String title, String message, String description, List<Option> options,
        int defaultOption) {
    final JDialog dialog = new JDialog((Frame) null, title);
    dialog.setModal(true);
    dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    final AtomicInteger result = new AtomicInteger(Math.max(defaultOption, -1));

    JButton defaultBtn = null;/*from   w  ww .  java  2s.  c  o m*/

    final JPanel root = new JPanel(new GridBagLayout());
    root.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    dialog.getRootPane().setContentPane(root);

    JLabel lblMsg = new JLabel("<html>" + StringEscapeUtils.escapeHtml3(message).replaceAll("\\n", "<br>"));
    lblMsg.setFont(lblMsg.getFont().deriveFont(Font.BOLD, 16f));
    GridBagConstraints cLabel = new GridBagConstraints();
    cLabel.gridx = 0;
    cLabel.gridy = 0;
    cLabel.fill = GridBagConstraints.BOTH;
    cLabel.weightx = 1;
    cLabel.weighty = 0.5;
    cLabel.insets = new Insets(5, 5, 5, 5);
    root.add(lblMsg, cLabel);

    JLabel lblDescr = new JLabel(
            "<html>" + StringEscapeUtils.escapeHtml3(description).replaceAll("\\n", "<br>"));
    cLabel.gridy++;
    cLabel.insets = new Insets(0, 5, 5, 5);
    root.add(lblDescr, cLabel);

    // All the options
    cLabel.ipadx = 10;
    cLabel.ipady = 10;
    cLabel.insets = new Insets(5, 15, 0, 15);
    for (int i = 0; i < options.size(); i++) {
        cLabel.gridy++;

        final Option o = options.get(i);
        final JButton btn = new JButton(
                "<html>" + StringEscapeUtils.escapeHtml3(o.label).replaceAll("\\n", "<br>"),
                MessageDialog.loadIcon(o.icon));
        if (StringUtils.isNotBlank(o.info)) {
            btn.setToolTipText("<html>" + StringEscapeUtils.escapeHtml3(o.info).replaceAll("\\n", "<br>"));
        }

        btn.setHorizontalAlignment(AbstractButton.LEADING);
        btn.setVerticalTextPosition(AbstractButton.CENTER);
        btn.setHorizontalTextPosition(AbstractButton.TRAILING);

        final int myAnswer = i;
        btn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                result.set(myAnswer);
                dialog.setVisible(false);
            }
        });

        root.add(btn, cLabel);
        if (i == defaultOption) {
            dialog.getRootPane().setDefaultButton(btn);
            defaultBtn = btn;
        }
    }

    final Icon icon = MessageDialog.loadIcon();
    if (icon != null) {
        JLabel lblIcn = new JLabel(icon);

        GridBagConstraints cIcon = new GridBagConstraints();
        cIcon.gridx = 1;
        cIcon.gridy = 0;
        cIcon.gridheight = 2 + options.size();
        cIcon.fill = GridBagConstraints.NONE;
        cIcon.weightx = 0;
        cIcon.weighty = 1;
        cIcon.anchor = GridBagConstraints.NORTH;
        cIcon.insets = new Insets(10, 5, 5, 0);
        root.add(lblIcn, cIcon);
    }

    final JButton close = new JButton("Cancel");
    close.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            result.set(-1);
            dialog.setVisible(false);
        }
    });
    GridBagConstraints cClose = new GridBagConstraints();
    cClose.gridx = 0;
    cClose.gridy = 2 + options.size();
    cClose.gridwidth = 2;
    cClose.weightx = 1;
    cClose.weighty = 0;
    cClose.insets = new Insets(15, 5, 5, 5);

    root.add(close, cClose);
    if (defaultOption < 0) {
        dialog.getRootPane().setDefaultButton(close);
        defaultBtn = close;
    }

    dialog.pack();
    dialog.setLocationRelativeTo(null);
    defaultBtn.requestFocusInWindow();

    dialog.setVisible(true);
    dialog.dispose();

    return result.get();
}

From source file:org.javaswift.cloudie.CloudiePanel.java

public void onLogin() {
    final JDialog loginDialog = new JDialog(owner, "Login");
    final LoginPanel loginPanel = new LoginPanel(new LoginCallback() {
        @Override//from w w  w.  ja v  a  2s  .  c  o m
        public void doLogin(AccountConfig accountConfig) {
            CloudieCallback cb = GuiTreadingUtils.guiThreadSafe(CloudieCallback.class,
                    new CloudieCallbackWrapper(callback) {
                        @Override
                        public void onLoginSuccess() {
                            loginDialog.setVisible(false);
                            super.onLoginSuccess();
                        }

                        @Override
                        public void onError(CommandException ex) {
                            JOptionPane.showMessageDialog(loginDialog, "Login Failed\n" + ex.toString(),
                                    "Error", JOptionPane.ERROR_MESSAGE);
                        }
                    });
            ops.login(accountConfig, cb);
        }
    }, credentialsStore);
    try {
        loginPanel.setOwner(loginDialog);
        loginDialog.getContentPane().add(loginPanel);
        loginDialog.setModal(true);
        loginDialog.setSize(480, 340);
        loginDialog.setResizable(false);
        loginDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        center(loginDialog);
        loginDialog.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                loginPanel.onCancel();
            }

            @Override
            public void windowOpened(WindowEvent e) {
                loginPanel.onShow();
            }
        });
        loginDialog.setVisible(true);
    } finally {
        loginDialog.dispose();
    }
}

From source file:org.kontalk.view.View.java

void showPasswordDialog(boolean wasWrong) {
    WebPanel passPanel = new WebPanel();
    WebLabel passLabel = new WebLabel(Tr.tr("Please enter your key password:"));
    passPanel.add(passLabel, BorderLayout.NORTH);
    final WebPasswordField passField = new WebPasswordField();
    passPanel.add(passField, BorderLayout.CENTER);
    if (wasWrong) {
        WebLabel wrongLabel = new WebLabel(Tr.tr("Wrong password"));
        wrongLabel.setForeground(Color.RED);
        passPanel.add(wrongLabel, BorderLayout.SOUTH);
    }/*www .  j  av  a 2 s  . co m*/
    WebOptionPane passPane = new WebOptionPane(passPanel, WebOptionPane.QUESTION_MESSAGE,
            WebOptionPane.OK_CANCEL_OPTION);
    JDialog dialog = passPane.createDialog(mMainFrame, Tr.tr("Enter password"));
    dialog.setModal(true);
    dialog.addWindowFocusListener(new WindowAdapter() {
        @Override
        public void windowGainedFocus(WindowEvent e) {
            passField.requestFocusInWindow();
        }
    });
    // blocking
    dialog.setVisible(true);

    Object value = passPane.getValue();
    if (value != null && value.equals(WebOptionPane.OK_OPTION))
        mControl.connect(passField.getPassword());
}

From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java

private void editMasterdataRelation(mxCell cell) {
    EntityFieldMetaDataVO voField = null;
    RelationAttributePanel panel = new RelationAttributePanel(RelationAttributePanel.TYPE_ENTITY);
    String sSource = "";
    String sTarget = "";
    EntityMetaDataVO voSourceModify = null;
    if (cell.getValue() != null && cell.getValue() instanceof EntityFieldMetaDataVO) {
        voField = (EntityFieldMetaDataVO) cell.getValue();

        EntityMetaDataVO voSource = (EntityMetaDataVO) cell.getSource().getValue();
        voSourceModify = voSource;/*from   w  ww . j  av a 2 s  .  co  m*/
        EntityMetaDataVO voTarget = (EntityMetaDataVO) cell.getTarget().getValue();
        sSource = voSource.getEntity();
        sTarget = voTarget.getEntity();
        EntityMetaDataVO voForeign = MetaDataClientProvider.getInstance().getEntity(voSource.getEntity());
        EntityMetaDataVO voEntity = MetaDataClientProvider.getInstance().getEntity(voTarget.getEntity());
        panel.setEntity(voEntity);
        panel.setEntitySource(voForeign);
        panel.setEntityFields(
                MetaDataDelegate.getInstance().getAllEntityFieldsByEntity(voForeign.getEntity()).values());

        if (voField.getId() != null) {
            voField = MetaDataClientProvider.getInstance().getEntityField(voForeign.getEntity(),
                    voField.getField());
            List<TranslationVO> lstTranslation = new ArrayList<TranslationVO>();
            for (LocaleInfo lInfo : LocaleDelegate.getInstance().getAllLocales(false)) {
                Map<String, String> mp = new HashMap<String, String>();

                mp.put(TranslationVO.labelsField[0], LocaleDelegate.getInstance().getResourceByStringId(lInfo,
                        voField.getLocaleResourceIdForLabel()));
                mp.put(TranslationVO.labelsField[1], LocaleDelegate.getInstance().getResourceByStringId(lInfo,
                        voField.getLocaleResourceIdForDescription()));
                TranslationVO voTrans = new TranslationVO(lInfo.localeId, lInfo.title, lInfo.language, mp);
                lstTranslation.add(voTrans);
            }
            panel.setTranslation(lstTranslation);
            panel.setFieldValues(voField);
        } else {
            MyGraphModel model = (MyGraphModel) graphComponent.getGraph().getModel();
            panel.setFieldValues(voField);
            panel.setTranslationAndMore(model.getTranslation().get(voField));
        }
    } else if (cell.getValue() != null && cell.getValue() instanceof String) {
        EntityMetaDataVO voSource = (EntityMetaDataVO) cell.getSource().getValue();
        EntityMetaDataVO voTarget = (EntityMetaDataVO) cell.getTarget().getValue();
        sSource = voSource.getEntity();
        sTarget = voTarget.getEntity();

        EntityMetaDataVO voForeign = MetaDataClientProvider.getInstance().getEntity(voSource.getEntity());
        EntityMetaDataVO voEntity = MetaDataClientProvider.getInstance().getEntity(voTarget.getEntity());
        voSourceModify = voForeign;
        panel.setEntity(voEntity);
        panel.setEntitySource(voForeign);
        panel.setEntityFields(
                MetaDataDelegate.getInstance().getAllEntityFieldsByEntity(voSource.getEntity()).values());
    }

    double cellsDialog[][] = { { 5, TableLayout.PREFERRED, 5 }, { 5, TableLayout.PREFERRED, 5 } };
    JDialog dia = new JDialog(mf);
    dia.setLayout(new TableLayout(cellsDialog));
    dia.setTitle("Verbindung von " + sSource + " zu " + sTarget + " bearbeiten");
    dia.setLocationRelativeTo(EntityRelationshipModelEditPanel.this);
    dia.add(panel, "1,1");
    dia.setModal(true);
    panel.setDialog(dia);
    dia.pack();
    dia.setVisible(true);

    if (panel.getState() == 1) {
        EntityFieldMetaDataVO vo = panel.getField();
        cell.setValue(vo);

        EntityRelationshipModelEditPanel.this.fireChangeListenEvent();

        List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>();

        EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO();
        toField.setEntityFieldMeta(vo);
        toField.setTranslation(panel.getTranslation().getRows());
        toList.add(toField);

        MetaDataDelegate.getInstance().modifyEntityMetaData(voSourceModify, toList);

        MyGraphModel model = (MyGraphModel) graphComponent.getGraph().getModel();
        model.getTranslation().put(vo, panel.getTranslation().getRows());
        getGraphComponent().refresh();

        loadReferenz();

    } else {
        if (cell.getValue() instanceof String)
            getGraphModel().remove(cell);
    }
}