コード例 #1
0
ファイル: AlgorithmsPanel.java プロジェクト: Yaqiang/sextante
  private void updateSelectedAlgorithm() {

    m_Alg = null;
    m_Action = null;

    if (m_Path != null) {
      menuItemExecuteAsBatch.setVisible(false);
      menuItemExecuteAsBatchFromGIS.setVisible(false);
      menuItemExecute.setVisible(false);
      menuItemShowHelp.setVisible(false);
      for (int i = 0; i < menuItemExecuteIterative.length; i++) {
        menuItemExecuteIterative[i].setVisible(false);
      }
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode) m_Path.getLastPathComponent();
      if (!(node.getUserObject() instanceof GeoAlgorithm)) {
        if ((node.getUserObject() instanceof ToolboxAction)) {
          m_Action = (ToolboxAction) node.getUserObject();
        }
        return;
      }
      m_Alg = ((GeoAlgorithm) node.getUserObject());
      menuItemExecuteAsBatch.setVisible(true);
      menuItemShowHelp.setVisible(true);
      menuItemExecute.setVisible(true);
      final Object[] objs = SextanteGUI.getInputFactory().getDataObjects();
      menuItemExecuteAsBatchFromGIS.setVisible(true);
      final boolean bMeets = m_Alg.meetsDataRequirements(objs);
      menuItemExecuteAsBatchFromGIS.setEnabled(bMeets);
      menuItemExecute.setEnabled(bMeets);

      final IToolboxRightButtonAction[] actions = SextanteGUI.getToolboxRightButtonActions();
      for (int i = 0; i < menuItemToolboxAction.length; i++) {
        menuItemToolboxAction[i].setVisible(actions[i].canBeExecutedOnAlgorithm(m_Alg));
      }

      if (bMeets && m_Alg.requiresIndividualVectorLayers()) {
        m_iExecuteIterativeMenuCount = 0;
        final int iParams = m_Alg.getParameters().getNumberOfParameters();
        for (int i = 0; i < iParams; i++) {
          final Parameter param = m_Alg.getParameters().getParameter(i);
          if (param instanceof ParameterVectorLayer) {
            final ParameterVectorLayer pvl = (ParameterVectorLayer) param;
            boolean bMandatory;
            try {
              bMandatory =
                  ((AdditionalInfoVectorLayer) pvl.getParameterAdditionalInfo()).getIsMandatory();
              if (bMandatory) {
                menuItemExecuteIterative[m_iExecuteIterativeMenuCount].setText(
                    Sextante.getText("Run_iterative")
                        + " ("
                        + param.getParameterDescription()
                        + ")");
                menuItemExecuteIterative[m_iExecuteIterativeMenuCount].setVisible(true);
                m_iExecuteIterativeMenuCount++;
              }
            } catch (final NullParameterAdditionalInfoException e) {
            }
          }
        }
      }
    }
  }