jmodelproblemswindow.java

来自「一个用于排队系统仿真的开源软件,有非常形象的图象仿真过程!」· Java 代码 · 共 531 行 · 第 1/2 页

JAVA
531
字号
            }
            if (mc.isThereBCMPNonStateIndependentRoutingWarning()) {
                problems.add(new ProblemElement(ModelChecker.WARNING_PROBLEM,ModelChecker.BCMP_NON_STATE_INDEPENDENT_ROUTING_WARNING,"<html><font color=\"white\">--</font><i>Warning</i><font color=\"white\">--------</font>A non state independent routing strategy was found",null,null));
            }
            //TODO: Lcfs case handling
            //TODO: Processor Sharing handling
        }
        else {
            if (mc.isThereNoClassesError()) {
                problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.NO_CLASSES_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>No classes defined",null,null));
            }
            if (mc.isThereNoStationError()) {
                problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.NO_STATION_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>No station defined",null,null));
            }
            if (mc.isThereStationLinkError()) {
                Vector temp = mc.getKeysOfStationsWithLinkProblems();
                for (int i=0;i<temp.size();i++) {
                    Object stationKey = temp.get(i);
                    String stationName = mc.getStationModel().getStationName(stationKey);
                    String description;
                    if (mc.getStationModel().getStationType(stationKey).equals(CommonConstants.STATION_TYPE_SINK)) {
                        description = ("<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>" + stationName + " is not backward linked");
                    }
                    else description = ("<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>" + stationName + " is not forward linked");
                    problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.STATION_LINK_ERROR,description,stationKey,null));
                }
            }
            if (mc.isThereAllForwardStationsAreSinkErrors()) {
                HashMap temp = mc.getKeysOfAllForwardStationsAreSinkErrors();
                Vector classKeys = mc.getClassModel().getClassKeys();
                for (int i=0;i<classKeys.size();i++ ) {
                    Object classKey = classKeys.get(i);
                    String className = mc.getClassModel().getClassName(classKey);
                    Vector stationWithAllForwardStationsAreSinkErrors = (Vector)temp.get(classKey);
                    if (stationWithAllForwardStationsAreSinkErrors != null){
                        for (int j=0;j<stationWithAllForwardStationsAreSinkErrors.size();j++) {
                            Object stationKey = stationWithAllForwardStationsAreSinkErrors.get(j);
                            String stationName = mc.getStationModel().getStationName(stationKey);
                            problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.ALL_FORWARD_STATION_ARE_SINK_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>Close class " + className + " routed to station " + stationName + " linked only to sink",stationKey,classKey));
                        }
                    }
                }
            }
            if (mc.isThereRoutingError()) {
                HashMap temp = mc.getKeysOfRoutingProblems();
                Vector classKeys = mc.getClassModel().getClassKeys();
                for (int i=0;i<classKeys.size();i++ ) {
                    Object classKey = classKeys.get(i);
                    String className = mc.getClassModel().getClassName(classKey);
                    Vector stationWithRoutingProblems = (Vector)temp.get(classKey);
                    if (stationWithRoutingProblems != null){
                        for (int j=0;j<stationWithRoutingProblems.size();j++) {
                            Object stationKey = stationWithRoutingProblems.get(j);
                            String stationName = mc.getStationModel().getStationName(stationKey);
                            problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.ROUTING_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>Close class " + className + " at station " + stationName +" is routed to sink with p=1",stationKey,classKey));
                        }
                    }
                }
            }
            if (mc.isThereSimulationError()) {
                problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.SIMULATION_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>No performance indices defined",null,null));
            }
            if (mc.isThereClassesWithoutRefStationError()) {
                Vector temp = mc.getKeysOfClassesWithoutRefStation();
                for (int i=0;i<temp.size();i++) {
                    Object classKey = temp.get(i);
                    String className = mc.getClassModel().getClassName(classKey);
                    problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.REFERENCE_STATION_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>No reference station defined for " + className ,null,classKey));
                }
            }
            if (mc.isThereNoSinkWithOpenClassesError()) {
                problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.NO_SINK_WITH_OPEN_CLASSES_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>Open classes were found but no sink have been defined",null,null));
            }
            if (mc.isThereSinkButNoOpenClassError()) {
                problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.SINK_BUT_NO_OPEN_CLASSES_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>Sink without open classes",null,null));
            }
            if (mc.isThereOpenClassButNoSourceError()) {
                problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.OPEN_CLASS_BUT_NO_SOURCE_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>An open class was found but no source has been defined",null,null));
            }
            if (mc.isThereSourceWithNoClassesError()) {
                Vector temp = mc.getKeysOfSourceWithoutClasses();
                for (int i=0;i<temp.size();i++) {
                    Object sourceKey = temp.get(i);
                    String sourceName = mc.getStationModel().getStationName(sourceKey);
                    problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.SOURCE_WITH_NO_OPEN_CLASSES_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>" + sourceName + " without open classes associated" ,sourceKey,null));
                }
            }
            if (mc.isThereInconsistentMeasureError()) {
                problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.INCONSISTENT_MEASURE_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>Undefined station in performance index",null,null));
            }
            if (mc.isThereMeasureError()) {
                problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.DUPLICATE_MEASURE_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>A performance index is defined more than once",null,null));
            }
            if (mc.isTherejoinWithoutForkError()) {
                problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.JOIN_WITHOUT_FORK_ERROR,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>Join without fork",null,null));
            }
            if(mc.isThereEmptyBlockingRegionError()) {
                Vector regionKeys = mc.getKeysOfEmptyBlockingRegions();
                for (int i=0; i<regionKeys.size(); i++) {
                    String name = mc.getBlockingModel().getRegionName(regionKeys.get(i));
                    problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.EMPTY_BLOCKING_REGION,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>Finite Capacity Region "+ name+" is empty",regionKeys.get(i),null));
                }
            }
            if (mc.isTherePreloadingInBlockingRegionError()) {
                problems.add(new ProblemElement(ModelChecker.ERROR_PROBLEM,ModelChecker.PRELOADING_WITH_BLOCKING,"<html><font color=\"white\">----</font><b>Error</b><font color=\"white\">---------</font>Preloading of stations inside a blocking region is not supported",null,null));
            }
            if (mc.isThereMoreThanOneSinkWarning()) {
                problems.add(new ProblemElement(ModelChecker.WARNING_PROBLEM,ModelChecker.MORE_THAN_ONE_SINK_WARNING,"<html><font color=\"white\">--</font><i>Warning</i><font color=\"white\">--------</font>More than one sink defined, measures may not be accurate",null,null));
            }
            if (mc.isThereNoBackwardLinkWarning()) {
                Vector temp = mc.getKeysOfStationWithoutBackwardLinks();
                for (int i=0; i<temp.size(); i++) {
                    Object stationKey = temp.get(i);
                    String stationName = mc.getStationModel().getStationName(stationKey);
                    problems.add(new ProblemElement(ModelChecker.WARNING_PROBLEM,ModelChecker.NO_BACKWARD_LINK_WARNING,"<html><font color=\"white\">--</font><i>Warning</i><font color=\"white\">--------</font>" + stationName + " is not backward linked",stationKey,null));
                }
            }
            if (mc.isThereParametricAnalysisModelModifiedWarning()) {
                problems.add(new ProblemElement(ModelChecker.WARNING_PROBLEM,ModelChecker.PARAMETRIC_ANALYSIS_MODEL_MODIFIED_WARNING,"<html><font color=\"white\">--</font><i>Warning</i><font color=\"white\">--------</font>What-if analysis model modified",null,null));
            }
            if (mc.isThereParametricAnalysisNoMoreAvaibleWarning()) {
                problems.add(new ProblemElement(ModelChecker.WARNING_PROBLEM,ModelChecker.PARAMETRIC_ANALYSIS_NO_MORE_AVAIBLE_WARNING,"<html><font color=\"white\">--</font><i>Warning</i><font color=\"white\">--------</font>What-if analysis not avaible",null,null));
            }
            if (mc.isThereForkWithoutJoinWarnings()) {
                problems.add(new ProblemElement(ModelChecker.WARNING_PROBLEM,ModelChecker.FORK_WITHOUT_JOIN_WARNING,"<html><font color=\"white\">--</font><i>Warning</i><font color=\"white\">--------</font>Fork found but no join",null,null));
            }
        }
    }

    /**
     * Enable or not to run simulation/conversion to JMVA
     * @return true if the simulation is runnable and user wants to run simulation
     */
    public boolean continued() {
        if (isToJMVAConversion) {
            if ((!operationCanceled)&&(mc.isErrorFreeToJMVA())) canBeRun = true;
        }
        else {
            if ((!operationCanceled)&&(mc.isErrorFreeNormal())) canBeRun = true;
        }
        return canBeRun;
    }

    private void addComponent (Component component,GridBagLayout gbl,GridBagConstraints gbc, int row, int column, int width, int heigth) {
     Container c = this.getContentPane();

     gbc.gridx=column;
     gbc.gridy=row;

     gbc.gridwidth=width;
     gbc.gridheight=heigth;

     gbl.setConstraints(component,gbc);
     c.add(component);
  }

  private void getRelatedPanel(int problemType,int problemSubType,Object relatedStation, Object relatedClass) {
      gi.showRelatedPanel(problemType,problemSubType,relatedStation,relatedClass);
  }

    private class ProblemElementRenderer implements ListCellRenderer{
        private String[] iconNames = new String[] {"Error", "Warning"};
        private Icon[] icons = new Icon[iconNames.length];
        private int[] problemTypes = {ModelChecker.ERROR_PROBLEM, ModelChecker.WARNING_PROBLEM};

        public ProblemElementRenderer(){
            for(int i=0; i<iconNames.length; i++){
                icons[i] = ImageLoader.loadImage(iconNames[i], new Dimension(16,16));
            }
        }

        public Component getListCellRendererComponent(
                JList list,
                Object value,
                int index,
                boolean isSelected,
                boolean cellHasFocus) {
            JLabel label = null;
            for(int i=0; i<problemTypes.length; i++){
                if(problemTypes[i] == ((ProblemElement)value).getProblemType()) {
                String errorDescription = ((ProblemElement) value).getDescription();
                label = new JLabel(errorDescription,
                            icons[i],
                            JLabel.LEFT);
                }
            }
            if(label==null){
                String errorDescription;
                if (((Integer)value).intValue() == 0) errorDescription = "Error";
                else errorDescription = "Warning";
                label = new JLabel(errorDescription);
            }
            label.setOpaque(true);
            label.setBorder(
                    new LineBorder(cellHasFocus ? Color.BLUE : Color.WHITE)
            );
            label.setBackground(
                    isSelected ? list.getSelectionBackground() : Color.WHITE
            );
            label.setForeground(
                    isSelected ? list.getSelectionForeground() : Color.BLACK
            );
            label.setFont(isSelected ?
                    label.getFont().deriveFont(Font.BOLD) :
                    label.getFont().deriveFont(Font.ROMAN_BASELINE));

            return label;
        }
    }


    private class ProblemElement {
        int type;
        int subType;
        String description;
        Object relatedStationKey;
        Object relatedClassKey;

        public ProblemElement(int type,int subType, String description,Object relatedStationKey,Object relatedClassKey) {
            this.type = type;
            this.subType = subType;
            this.description = description;
            this.relatedStationKey = relatedStationKey;
            this.relatedClassKey = relatedClassKey;
        }

        public int getProblemType() {
            return type;
        }

        public int getProblemSubType() {
            return subType;
        }

        public String getDescription() {
            return description;
        }

         public Object getRelatedStationKey() {
            return relatedStationKey;
        }

        public Object getRelatedClassKey() {
            return relatedClassKey;
        }
    }

    private class ButtonEventHandler implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == cancelButton) {
                operationCanceled = true;
                dispose();
            }

            else if (e.getSource() == continueButton) {
                operationCanceled = false;
                dispose();
            }
        }


    }

}

⌨️ 快捷键说明

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