import com.jgoodies.forms.layout.FormSpecs;
import com.jgoodies.forms.layout.RowSpec;
import com.ranfa.lib.CheckVersion;
+import com.ranfa.lib.Easter;
import com.ranfa.lib.EstimateAlbumTypeCycle;
+import com.ranfa.lib.ManualUpdateThreadImpl;
import com.ranfa.lib.Scraping;
import com.ranfa.lib.SettingJSONProperty;
import com.ranfa.lib.Settings;
import com.ranfa.lib.TwitterIntegration;
import com.ranfa.lib.Version;
-@Version(major = 2, minor = 0, patch = 3)
+@Version(major = 3, minor = 0, patch = 0)
public class DelesteRandomSelector extends JFrame {
private static ArrayList<Song> selectedSongsList = new ArrayList<>();
private CompletableFuture<Void> albumTypeEstimateFuture = null;
private String albumType = Messages.MSGAlbumTypeBeingCalculated.toString();
private Logger logger = LoggerFactory.getLogger(DelesteRandomSelector.class);
+ private ManualUpdateThreadImpl impl;
+ private Thread manualUpdateThread;
+ private JButton btnManualUpdate;
+ private Easter easter;
/**
* Launch the application.
};
Runnable setEnabled = () -> {
try {
- Thread.sleep(1000);
+ Thread.sleep(3 * 1000L);
} catch (InterruptedException e1) {
this.logger.error("Thread has been interrupted during waiting cooldown.", e1);
}
CompletableFuture<Void> updatedFuture = getWholeDataFuture.thenAcceptBothAsync(getFromJsonFuture, updateConsumer, es);
updatedFuture.thenRunAsync(setEnabled, es);
}
+ this.easter = new Easter();
+ this.setTitle(this.easter.getTodaysBirth());
this.logger.debug("Version: {}", CheckVersion.getVersion());
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setBounds(100, 100, this.property.getWindowWidth(), this.property.getWindowHeight());
- // this.setBounds(100, 100, 640, 360);
+ // this.setBounds(100, 100, this.property.getWindowWidth(), this.property.getWindowHeight());
+ this.setBounds(100, 100, 640, 360);
this.contentPane = new JPanel();
this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
this.setContentPane(this.contentPane);
this.btnImport = new JButton(Messages.MSGUpdatingDatabase.toString());
this.btnImport.setEnabled(false);
this.btnImport.addActionListener(e -> {
+ if(this.impl != null) {
+ if(!this.impl.getFlag()) {
+ JOptionPane.showMessageDialog(null, Messages.MSGManualUpdateNotCompleteYet.toString());
+ }
+ }
ArrayList<Song> fromJson = Scraping.getFromJson();
ArrayList<Song> specificlevelList = Scraping.getSpecificLevelSongs(fromJson, (Integer)DelesteRandomSelector.this.spinnerLevel.getValue(), DelesteRandomSelector.this.checkLessLv.isSelected(), DelesteRandomSelector.this.checkMoreLv.isSelected());
ArrayList<Song> specificDifficultyList = Scraping.getSpecificDifficultySongs(specificlevelList, DelesteRandomSelector.this.comboDifficultySelect.getSelectedItem().toString());
DelesteRandomSelector.this.logger.info("seems to reject the permission.it should need try again.");
}
});
+
+ this.btnManualUpdate = new JButton(Messages.MSGManualUpdate.toString());
+ this.btnManualUpdate.addActionListener(e -> {
+ this.impl = new ManualUpdateThreadImpl();
+ es.submit(this.impl);
+ });
+ this.panelEast.add(this.btnManualUpdate, "1, 9");
this.panelEast.add(this.btnTwitterIntegration, "1, 11");
this.btnExit = new JButton(Messages.MSGTerminate.toString());
this.btnExit.addActionListener(e -> {
- if(DelesteRandomSelector.this.softwareUpdateFuture.isDone() || DelesteRandomSelector.this.albumTypeEstimateFuture.isDone()) {
- DelesteRandomSelector.this.logger.info("Requested Exit by Button");
+ if(DelesteRandomSelector.this.softwareUpdateFuture.isDone() || DelesteRandomSelector.this.albumTypeEstimateFuture.isDone() || !this.impl.getFlag()) {
+ DelesteRandomSelector.this.logger.info("Requested Exit by Button.");
+ this.logger.info("Shut down thread pool.");
+ es.shutdown();
System.exit(0);
} else {
JOptionPane.showMessageDialog(null, Messages.MSGInternalYpdateNotDoneYet.toString());