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]); }
private void jButton_new_printPreviewformed(ActionEvent evt) { if (mainUi == null) { mainUi = MainUI.getInstance(1); } if (jComboBox_deviceName.getSelectedIndex() > 0) { String deviceID = getDeviceID(); deviceID = toFormedMAC(StringFilter(getDeviceID())); if (!chechMAC(deviceID)) { JOptionPane.showMessageDialog(getParent(), "MAC地址格式错误!", "错误", JOptionPane.WARNING_MESSAGE); return; } jTextField_DeviceID.setText(deviceID); String deviceSN = getDeviceSN().substring(0, 6) + StringFilter(deviceID); jTextField_DeviceSN.setText(deviceSN); String manageIP = getManageIP(); productPowerLineQRCode(head, deviceID, deviceSN, manageIP); jButton_new_printPreviewActionPerformed(evt); } else { // mainUi.appendTextareaText(mainUi.jTextArea_status,"\n请选择设备"); JOptionPane.showMessageDialog(getParent(), "请选择设备!", "错误", JOptionPane.WARNING_MESSAGE); return; } }
private void jButton_new_printBinaryPerformed(ActionEvent evt) { if (mainUi == null) { mainUi = MainUI.getInstance(1); } if (jComboBox_deviceName.getSelectedIndex() > 0) { String deviceID = toFormedMAC(StringFilter(getDeviceID())); if (!chechMAC(deviceID)) { JOptionPane.showMessageDialog(getParent(), "MAC地址格式错误!", "错误", JOptionPane.WARNING_MESSAGE); return; } if (StringUtils.isEmpty(jTextField_PrintNum.getText())) { JOptionPane.showMessageDialog(getParent(), "请输入打印数量!", "错误", JOptionPane.WARNING_MESSAGE); return; } String deviceSN = getDeviceSN().substring(0, 6) + StringFilter(deviceID); jTextField_DeviceSN.setText(deviceSN); printNewBinaryPicture(); } else { JOptionPane.showMessageDialog(getParent(), "请选择设备!", "错误", JOptionPane.WARNING_MESSAGE); return; } }
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(); }
/** * 当选择设备后做一些初始化 * * @param evt */ private void jComboBox_new_chooseDeviceItemStateChanged(ItemEvent evt) { if (mainUi == null) { mainUi = MainUI.getInstance(1); } if (evt.getStateChange() == ItemEvent.SELECTED) { mainUi.appendTextareaText(mainUi.jTextArea_status, '\n' + "选择设备:" + (String) evt.getItem()); String item = (String) jComboBox_deviceName.getSelectedItem(); Map manageip = LabelsUtil.readFileForMap("manageIP.txt"); switch (item) { case "电力线适配器": jLabel_UserName.setVisible(false); jTextField_UserName.setVisible(false); jLabel_Password.setVisible(false); jTextField_Password.setVisible(false); Map map = LabelsUtil.readFileForMap("PowerLineDevice.txt"); Map mapStyle = LabelsUtil.readFileForMap("deviceStyle.txt"); String style = (String) map.get(jComboBox_deviceName.getSelectedItem()); String styleCode = (String) mapStyle.get(style); String manageiIP = (String) manageip.get(style); jComboBox_deviceModel.setSelectedItem(style); jComboBox_deviceVersion.setSelectedIndex(0); jComboBox_deviceVersion.setEnabled(false); jComboBox_Power.setSelectedIndex(4); String mac = jTextField_DeviceID.getText(); jTextField_DeviceSN.setText(styleCode + StringFilter(mac)); jTextField_ManageIP.setText(manageiIP); head = new Head(); // 设置head head.ip = "IP:"; head.mac = "MAC:"; head.sn = "S/N:"; break; case "电力线无线路由器": jLabel_UserName.setVisible(true); jTextField_UserName.setVisible(true); jLabel_Password.setVisible(true); jTextField_Password.setVisible(true); Map map2 = LabelsUtil.readFileForMap("PowerLineDevice.txt"); Map mapStyle2 = LabelsUtil.readFileForMap("deviceStyle.txt"); String style2 = (String) map2.get(jComboBox_deviceName.getSelectedItem()); String styleCode2 = (String) mapStyle2.get(style2); String manageiIP2 = (String) manageip.get(style2); jComboBox_deviceModel.setSelectedItem(style2); jComboBox_deviceVersion.setSelectedIndex(0); jComboBox_deviceVersion.setEnabled(false); jComboBox_Power.setSelectedIndex(5); String mac2 = jTextField_DeviceID.getText(); jTextField_DeviceSN.setText(styleCode2 + StringFilter(mac2)); jTextField_ManageIP.setText(manageiIP2); head = new Head(); // 设置head head.ip = "IP:"; head.mac = "PLC MAC:"; head.sn = "S/N:"; break; default: jLabel_UserName.setVisible(false); jTextField_UserName.setVisible(false); jLabel_Password.setVisible(false); jTextField_Password.setVisible(false); jComboBox_deviceModel.setSelectedIndex(0); jComboBox_deviceVersion.setEnabled(true); jComboBox_deviceVersion.setSelectedIndex(0); jComboBox_Power.setSelectedIndex(0); break; } } }