⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jsimproblemswindow.java

📁 一个用于排队系统仿真的开源软件,有非常形象的图象仿真过程!
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/**    
  * Copyright (C) 2006, Laboratorio di Valutazione delle Prestazioni - Politecnico di Milano

  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.

  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.

  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
  
package jmt.gui.jsim.panels;

import jmt.gui.common.CommonConstants;
import jmt.gui.common.controller.ModelChecker;
import jmt.gui.common.definitions.GuiInterface;
import jmt.gui.common.resources.ImageLoader;
import jmt.gui.jsim.JSIMMain;

import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.*;
import java.util.HashMap;
import java.util.Vector;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author Francesco D'Aquino
 *         Date: 24-ott-2005
 *         Time: 15.22.46
 */
public class JSimProblemsWindow extends JFrame {
    GuiInterface gi;

        //private boolean canBeRun;
        //private boolean operationCanceled;

        private boolean toMVAConversion;

        JLabel title;
        JList problemsList;
        ModelChecker mc;
        Vector problems;

        GridBagLayout gblayout;
        GridBagConstraints gbconstants;

        JButton continueButton;
        JButton cancelButton;

        JButton typeButton;
        JButton descriptionButton;





        public JSimProblemsWindow (ModelChecker checker, GuiInterface gi) {
            setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            //super("Simulation diagnostic");
            mc = checker;
            toMVAConversion = mc.isToJMVA();
            setTitleOfWindow();
            this.gi = gi;
            //canBeRun = false;
            //operationCanceled = true;
            //this.toMVAConversion = toMVAConversion;
            GridBagLayout gblayout = new GridBagLayout();
            GridBagConstraints gbconstants = new GridBagConstraints();
            getContentPane().setLayout(gblayout);
            problems = new Vector(0,1);


            setBounds(20,20,20,20);

            title = new JLabel (CommonConstants.HTML_START + CommonConstants.HTML_FONT_TITLE +
                "Problems found" + CommonConstants.HTML_FONT_TIT_END
                + CommonConstants.HTML_FONT_NORM +"Click on an element to solve the problem" +
                 CommonConstants.HTML_FONT_NOR_END + CommonConstants.HTML_END);

            problemsList = new JList();
            problemsList.setListData(problems);
            problemsList.setCellRenderer(new ProblemElementRenderer());
            problemsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            problemsList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            problemsList.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent e) {
                    ProblemElement temp = (ProblemElement)problemsList.getSelectedValue();
                    if (temp != null) {
                        toBack();
                        int pType = temp.getProblemType();
                        int pSubType = temp.getProblemSubType();
                        getRelatedPanel(pType,pSubType,temp.getRelatedStationKey(),temp.getRelatedClassKey());
                    }
                }
            });

            addWindowListener(new WindowAdapter() {
                public void windowActivated(WindowEvent e) {
                    updateProblemsShown(true);
                }
            });

            JPanel containerPanel = new JPanel();
            containerPanel.setLayout(new BorderLayout());
            JPanel blankPanel = new JPanel();
            blankPanel.setBackground(Color.WHITE);
            containerPanel.add(problemsList,BorderLayout.NORTH);
            containerPanel.add(blankPanel,BorderLayout.CENTER);

            JScrollPane jsp = new JScrollPane(containerPanel,
                    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

            jsp.setPreferredSize(new Dimension(310,230));
            gbconstants.insets.top = 10;
            this.addComponent(title,gblayout,gbconstants,0,0,2,1);
            gbconstants.insets.top = 20;
            gbconstants.insets.left = -38;
            typeButton = new JButton("Type");
            typeButton.setPreferredSize(new Dimension(100,15));
            this.addComponent(typeButton,gblayout,gbconstants,1,0,1,1);
            descriptionButton = new JButton("Description");
            descriptionButton.setPreferredSize(new Dimension(333,15));
            gbconstants.insets.left = -68;
            this.addComponent(descriptionButton,gblayout,gbconstants,1,1,1,1);
            gbconstants.fill = GridBagConstraints.BOTH;
            gbconstants.insets.top = 0;
            gbconstants.weightx = 1;
            gbconstants.weighty = 1;
            gbconstants.insets.right = 10;
            gbconstants.insets.left = 10;
            this.addComponent(jsp,gblayout,gbconstants,2,0,2,1);
            ButtonEventHandler beh = new ButtonEventHandler();
            continueButton = new JButton("Continue");
            continueButton.setPreferredSize(new Dimension(80,25));
            continueButton.addActionListener(beh);
            cancelButton = new JButton("Cancel");
            cancelButton.setPreferredSize(new Dimension(80,25));
            cancelButton.setSelected(true);
            cancelButton.addActionListener(beh);
            continueButton.setEnabled(false);
            gbconstants.fill = GridBagConstraints.NONE;
            gbconstants.insets.left = 50;
            this.addComponent(continueButton,gblayout,gbconstants,3,0,1,1);
            gbconstants.insets.right = -45;
            this.addComponent(cancelButton,gblayout,gbconstants,3,1,1,1);
            this.setSize(450,435);
            this.setLocation(300,190);
            this.setResizable(false);
            this.setIconImage(ImageLoader.loadImage("JSIMIcon").getImage());
            //this.setFocusable(true);
        }

        private void setTitleOfWindow() {
            if (toMVAConversion) setTitle("Problems while trying to convert to JMVA");
            else setTitle("Simulation diagnostic");
        }

        public void setModelChecker(ModelChecker mc) {
            this.mc = mc;
            toMVAConversion = mc.isToJMVA();
        }

        /*public void setToJMVAConversion(boolean toMVAConversion) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -