@Override public void actionPerformed(ActionEvent e) { // Handle open button action. if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(GuiFriendlizerApp.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); selectedNetBeansPath = file.getAbsolutePath(); // This is where a real application would open the file. FriendlizerUtilities.Log(logger, "Selected: " + selectedNetBeansPath + "."); patchButton.setEnabled(true); } else { patchButton.setEnabled(false); } // Handle save button action. } else if (e.getSource() == patchButton) { if (selectedNetBeansPath == null || selectedNetBeansPath.isEmpty()) { FriendlizerUtilities.Log(logger, "Not in valid state"); } else { boolean patched = true; for (Module moduleCfg : moduleConfiguration.getModules()) { FriendlizerUtilities.Log( logger, "Patching for:\n\t" + moduleCfg.getKey() + "\n\t" + moduleCfg.getDescription()); patched &= FriendlizerUtilities.patchingNetBeans(selectedNetBeansPath, moduleCfg, logger); } if (patched) { FriendlizerUtilities.Log(logger, "All modules are patched successful!"); patchButton.setEnabled(false); } else { patchButton.setEnabled(false); FriendlizerUtilities.Log(logger, "Patching fail, please re-select netbeans IDE"); } } } }
public GuiFriendlizerApp() { super(new BorderLayout()); // Init jPanel controls initComponent(); // Clear output text area (as a logger) logger.setText(null); try { // Loading configuration moduleConfiguration = new ModuleConfiguration(); // Print guide FriendlizerUtilities.Log(logger, "Steps:"); FriendlizerUtilities.Log(logger, "1.Chosing your NetBeans IDE folder"); FriendlizerUtilities.Log(logger, "2.Patching it."); FriendlizerUtilities.Log(logger, "======================================"); } catch (IOException e) { FriendlizerUtilities.Log(logger, "Loading configuration error: " + e.getMessage()); } }