コード例 #1
0
ファイル: ConversionUI.java プロジェクト: CaoAo/BeehiveZ
  private ProvidedObjectComboItem[] getComboItems(ConvertingPlugin plugin) {
    JInternalFrame[] frames = desktop.getAllFrames();
    ArrayList accepted = new ArrayList();
    comboItems = new ArrayList();

    for (int j = 0; j < frames.length; j++) {
      if (frames[j] instanceof Provider) {
        ProvidedObject[] po = ((Provider) frames[j]).getProvidedObjects();

        for (int i = 0; i < po.length; i++) {
          if (plugin.accepts(po[i])) {
            accepted.add(new ProvidedObjectComboItem(frames[j].getTitle(), po[i]));
            comboItems.add(po[i]);
          }
        }
      }
    }
    ProvidedObject[] po = MainUI.getInstance().getGlobalProvidedObjects();

    for (int i = 0; i < po.length; i++) {
      if (plugin.accepts(po[i])) {
        accepted.add(new ProvidedObjectComboItem("ProM Global Objects", po[i]));
        comboItems.add(po[i]);
      }
    }
    return (ProvidedObjectComboItem[]) accepted.toArray(new ProvidedObjectComboItem[0]);
  }
コード例 #2
0
ファイル: ConversionUI.java プロジェクト: CaoAo/BeehiveZ
 public int compareTo(Object o) {
   if (o == null) {
     return -1;
   }
   return -((ConvertAlgorithm) o)
       .getPlugin()
       .getName()
       .toLowerCase()
       .compareTo(p.getName().toLowerCase());
 }
コード例 #3
0
ファイル: ConversionUI.java プロジェクト: CaoAo/BeehiveZ
  private void showConversion() {
    if (combo == null) {
      return;
    }
    JPanel mainPanel = new JPanel();
    if (algorithmList.getSelectedValue() == null) {
      JOptionPane.showMessageDialog(
          this,
          "Please select a conversion algorithm first.",
          "Conversion",
          JOptionPane.INFORMATION_MESSAGE);
      return;
    }

    final ConvertingPlugin algorithm =
        ((ConvertAlgorithm) algorithmList.getSelectedValue()).getPlugin();
    if ((combo.getSelectedIndex() < 0) || (combo.getSelectedIndex() >= combo.getItemCount())) {
      JOptionPane.showMessageDialog(
          this,
          "Please choose inputs for all items.",
          "Conversion",
          JOptionPane.INFORMATION_MESSAGE);
      return;
    }

    UISettings.getInstance().setLastUsedConversion(algorithm.getName());

    MainUI.getInstance()
        .addAction(
            algorithm,
            LogStateMachine.START,
            new Object[] {comboItems.get(combo.getSelectedIndex())});

    SwingWorker worker =
        new SwingWorker() {
          MiningResult result;
          StopWatch timer = new StopWatch();

          public Object construct() {
            Message.add("Start conversion.");
            timer.start();
            try {
              if (algorithm instanceof DoNotCreateNewInstance) {
                result =
                    algorithm.convert((ProvidedObject) comboItems.get(combo.getSelectedIndex()));
              } else {
                result =
                    ((ConvertingPlugin) algorithm.getClass().newInstance())
                        .convert((ProvidedObject) comboItems.get(combo.getSelectedIndex()));
              }
            } catch (IllegalAccessException ex) {
              Message.add(
                  "No new instantiation of "
                      + algorithm.getName()
                      + " could be made, using"
                      + " old instance instead",
                  Message.ERROR);
              result = algorithm.convert((ProvidedObject) comboItems.get(combo.getSelectedIndex()));
            } catch (InstantiationException ex) {
              Message.add(
                  "No new instantiation of "
                      + algorithm.getName()
                      + " could be made, using"
                      + " old instance instead",
                  Message.ERROR);
              result = algorithm.convert((ProvidedObject) comboItems.get(combo.getSelectedIndex()));
            }
            return result;
          }

          public void finished() {
            timer.stop();
            Message.add("Conversion duration: " + timer.formatDuration());
            MainUI.getInstance()
                .addAction(
                    algorithm,
                    LogStateMachine.COMPLETE,
                    (result instanceof Provider) ? ((Provider) result).getProvidedObjects() : null);

            getContentPane().removeAll();
            getContentPane().add(result.getVisualization(), BorderLayout.CENTER);
            getContentPane().validate();
            getContentPane().repaint();
          }
        };
    worker.start();
  }
コード例 #4
0
ファイル: ConversionUI.java プロジェクト: CaoAo/BeehiveZ
 public String toString() {
   return p.getName();
 }
コード例 #5
0
ファイル: ConversionUI.java プロジェクト: CaoAo/BeehiveZ
  private void jbInit() {
    JPanel buttonsPanel, innerButtonsPanel, mainPanel;
    JButton nextButton, closeButton;
    JSplitPane splitPane;
    String lastUsedConversion = UISettings.getInstance().getLastUsedConversion();

    ConvertingPluginCollection algorithmCollection = ConvertingPluginCollection.getInstance();
    int selection = -1;

    inputsScrollPane = new JScrollPane();

    // construct list of algorithms
    algorithms = new ConvertAlgorithm[algorithmCollection.size()];
    for (int i = 0; i < algorithmCollection.size(); i++) {
      ConvertingPlugin algorithm = ((ConvertingPlugin) algorithmCollection.get(i));

      algorithms[i] = new ConvertAlgorithm(algorithm);

      if (algorithm.getName().equals(lastUsedConversion)) {
        selection = i;
      }
    }
    Arrays.sort(algorithms);

    algorithmList = new JList(algorithms);
    algorithmList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    if (selection >= 0) {
      algorithmList.setSelectedIndex(selection);
    }
    algorithmList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            setSelectedAlgorithm(algorithmList.getSelectedIndex());
          }
        });

    // build UI
    nextButton = new JButton("Next >>");
    nextButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            showConversion();
          }
        });
    closeButton = new JButton("Close");
    closeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    innerButtonsPanel = new JPanel();
    innerButtonsPanel.add(nextButton);
    innerButtonsPanel.add(closeButton);
    buttonsPanel = new JPanel(new BorderLayout());
    buttonsPanel.add(innerButtonsPanel, BorderLayout.EAST);

    splitPane =
        new JSplitPane(
            JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(algorithmList), inputsScrollPane);
    splitPane.setDividerLocation(200);
    splitPane.setOneTouchExpandable(true);

    mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(splitPane, BorderLayout.CENTER);
    mainPanel.add(buttonsPanel, BorderLayout.SOUTH);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(mainPanel, BorderLayout.CENTER);

    addInternalFrameListener(
        new InternalFrameAdapter() {
          public void internalFrameActivated(InternalFrameEvent e) {
            frameActivated();
          }
        });

    setSelectedAlgorithm(selection);
  }