Package org.codinjutsu.tools.mongo.view

Source Code of org.codinjutsu.tools.mongo.view.ErrorPanel

/*
* Copyright (c) 2013 David Boissier
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.codinjutsu.tools.mongo.view;

import com.intellij.openapi.ui.Messages;
import com.intellij.ui.HoverHyperlinkLabel;
import com.intellij.ui.JBColor;
import com.intellij.ui.components.JBLabel;

import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.*;

public class ErrorPanel extends JPanel {

    public ErrorPanel(final Exception ex) {
        setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
        setBackground(JBColor.RED);
        add(new JBLabel("Error during query execution"));
        final HoverHyperlinkLabel hoverHyperlinkLabel = new HoverHyperlinkLabel("more detail...");
        hoverHyperlinkLabel.addHyperlinkListener(new HyperlinkListener() {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
                if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    Messages.showErrorDialog(ex.toString(), "Error During Query Execution");
                }
            }
        });
        add(Box.createRigidArea(new Dimension(10, 10)));
        add(hoverHyperlinkLabel);

    }
}
TOP

Related Classes of org.codinjutsu.tools.mongo.view.ErrorPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.