📄 jiggle.java~2~
字号:
str = "Event "+sol[i].id.longValue()+" has changes since last save.\nSave current event?";
int yn = JOptionPane.showConfirmDialog(
null, str,
"Jiggle: Save event "+sol[i].id.longValue()+"?",
JOptionPane.YES_NO_OPTION);
if (yn == JOptionPane.YES_OPTION) {
saveToDb(sol[i]);
}
}
}
// Use pop dialog to confirm reload of loaded Solution
if (mv.solList != null && mv.solList.contains(id)) {
str = "Are you sure you want to RELOAD event "
+ id + "?\n This will unload any other events in view.";
int yn = JOptionPane.showConfirmDialog(
null, str,
"Jiggle: Reload event?",
JOptionPane.YES_NO_OPTION);
if (yn == JOptionPane.NO_OPTION) return false;
}
// release previously held locks.
releaseAllSolutionLocks();
// lock the event, show dialog & bail if event is locked by someone else
if (!handleLock(id)) return false;
// Read the data source and build a master view
if (verbose) bench1 = new BenchMark (" * Elapse time to load event "+id+": ");
// Create a brand new MasterView
str = "Creating new MasterView for "+id+"....";
if (verbose) System.out.println (str);
statusPanel.setText(str);
// kill the old master view (stops old cache manager) prevent memory leaks
clearMasterView();
// only continue if this was successfull
// if (mv.defineByDataSource(id)) { // load the event
if (mv.defineByCurrentModel(id)) { // load the event
// Update the tabs DK 082802 (must be done within Jiggle)
updateLocationTab();
updateMagTab();
updateWhereTab();
// loading phases, amps, etc. sets staleness 'true', so fix it.
mv.getSelectedSolution().setStale(false);
str = "Loaded: " + mv.wfvList.size() + " views";
if (verbose) System.out.println (str);
statusPanel.setText(str);
if (verbose) bench1.print(); // timestamp
resetGUI();
// set back to normal (not "working") cursor
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
//debug
/*
System.out.println ("++++++++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println ("masterWFPanelModel = "+ mv.masterWFViewModel.countListeners());
System.out.println ("masterWFWindowModel = "+ mv.masterWFWindowModel.countListeners());
System.out.println ("++++++++++++++++++++++++++++++++++++++++++++++++++++");
*/
return true;
}
return false;
}
/** Reload the current solution. Used when the model is changed. */
public void reloadSolution() {
if (mv == null || mv.getSelectedSolution() == null) return;
loadSolution(mv.getSelectedSolution().getId().longValue());
}
/** Dialog to get event ID number and load it. */
public void loadIdDialog() {
String defId = "";
if (mv != null) {
Solution selSol = mv.getSelectedSolution();
if (selSol != null) defId = selSol.id.toString();
}
String idStr = (String) JOptionPane.showInputDialog(
null, "Enter the ID to load.",
"Load ID", JOptionPane.QUESTION_MESSAGE,
null, null, defId);
if (idStr != null) { // is null if [cancel] is hit
long evid = Long.valueOf(idStr.trim()).longValue();
if (!loadSolution(evid)) {
// bad ID #
String str = "No data found for ID = "+evid;
JOptionPane.showMessageDialog(null,
str, "Bad Solution ID",
JOptionPane.INFORMATION_MESSAGE);
}
}
}
/** Load the event following the currently selected one. Does not wrap so if
there is no next solution a dialog box says so and this method returns
false. */
public boolean loadNextSolution() {
return loadNextSolution(mv.solList.getSelected());
}
/** Load the event following this one. Does not wrap so if there is no next
solution a dialog box says so and this method returns false. */
public boolean loadNextSolution(Solution currentSol) {
// Whats next?
Solution nextsol = catSolList.getNext(currentSol);
// nada
if (nextsol == null) {
JOptionPane.showMessageDialog(null,
"There are no solutions following this one.", "No Next Solution",
JOptionPane.INFORMATION_MESSAGE);
return false;
} else {
if (loadSolution(nextsol)) {
return true;
} else { // next event was locked, recursively try next...
return loadNextSolution (nextsol);
}
}
}
/**
* Delete the current selected solution from the data source. This is
* NOT just setting a flag internal to Jiggle.
* It commits the delete after confirming with a
* dialog box. */
public boolean deleteCurrentSolution() {
// locEng.reset();
return deleteSolution(mv.solList.getSelected());
}
/**
* Delete this solution from the data source. This is NOT just setting a
* flag. It commits the delete after confirming with a dialog box. */
public boolean deleteSolution(long evid) {
return deleteSolution(mv.solList.getById(evid));
}
/**
* Delete this solution from the data source. This is NOT just setting a
* flag. It commits the delete after confirming with a dialog box. */
public boolean deleteSolution(Solution sol) {
if (sol == null) {
JOptionPane.showMessageDialog(null,
"There is no currently selected solution.", "No Solution",
JOptionPane.INFORMATION_MESSAGE);
menuEvent.setEnabled(false);
return false;
}
// confirm delete action
String str =
"WARNING: This action will permanently delete \n"+
"solution "+sol.id.toString()+" and all related data. \n"+
"Is this what you want to do?";
//pop-up confirming yes/no dialog:
int check = JOptionPane.showConfirmDialog(
null, str,
"DELETE SOLUTION",
JOptionPane.YES_NO_OPTION);
if (check == JOptionPane.YES_OPTION) {
if (debug) System.out.println ("Deleting: "+ sol.toString());
boolean status = true;
boolean wasSelected = (mv.getSelectedSolution() == sol) ;
// set delete flag of sol
if (sol.delete()) {
// remove solution and all its data from MasterView
// mv.removeSolution(sol);
// commit to dbase
try {
if ( sol.commit() ) {
if (wasSelected) locEng.reset();
mv.solList.delete(sol); // remove solution from solList, tell all listeners
if (mv.solList.size() < 1) { // clear the GUI if no more solutions
clearGUI();
selectTab(TAB_CATALOG);
}
} else {
String msg = "Could not delete this solution from the data source.\n"+
sol.getCommitStatus();
JOptionPane.showMessageDialog(null, msg, "Can't delete",
JOptionPane.INFORMATION_MESSAGE);
status = false;
}
} catch (JasiCommitException ex) {
long evid = sol.id.longValue();
// bad save
String msg = "WARNING: Error during delete of event "+evid+". \n"+
ex.toString();
String title = "Delete Error "+ evid;
JOptionPane.showMessageDialog(null,
msg, title,
JOptionPane.INFORMATION_MESSAGE);
status = false;
}
}
return status;
}
// the JOptionPane answer was no
return false;
}
/**
* Create a new solution from scratch. Adds it to our list. Locks it. Updates views.
*/
public Solution createNewSolution() {
long parentId = mv.getSelectedSolution().id.longValue();
Solution newSol = Solution.create();
long newId = newSol.setUniqueId(); // need unique ID from dbase
// set parent ID #
newSol.setParentId(parentId);
// associate waveforms (needed to associate waveforms with the event if required
// by the underlying data source)
// NOTE: in TN version of Solution this is done via jasi.cloneAssocWaE()
newSol.addWaveforms(chooseWaveformSet(newSol));
newSol.setEventType(EventTypeMap.LOCAL);
newSol.setStale(true);
mv.addSolution (newSol);
mv.setSelectedSolution(newSol);
// lock the new id
handleLock(newId);
// updateTextViews(); // now done by listener
return newSol;
}
/** Manually edit event parameters. */
public void editEventParams () {
Solution sol = mv.solList.getSelected();
EventEditDialog dialog = new EventEditDialog(sol);
// apply results if [OK] was hit
if (dialog.getButtonStatus() == JOptionPane.OK_OPTION) {
// get modified solution
sol = dialog.getSolution();
// update the text the tabs & frame title
updateTextViews();
}
}
/** Pop a comment dialog box that allows editing the current or adding a
new comment. String is the default comment */
public void addComment(String str){
Solution sol = mv.getSelectedSolution();
if (sol != null) {
// pop the dialog
CommentDialog dialog = new CommentDialog (str);
if (dialog.getButtonStatus() == JOptionPane.OK_OPTION) {
// get the results
String newComment = dialog.getString();
if (newComment != null) {
sol.setComment(newComment);
updateTextViews();
}
// delete the comment
} else if (dialog.getButtonStatus() == JOptionPane.NO_OPTION) {
sol.comment.setNull(true);
}
}
}
/** Pop a comment dialog box that allows editing the current or adding a
new comment. The default comment string is set to current solution's comment if
there is one. */
public void addComment(){
String str = "";
if (mv.getSelectedSolution().hasComment())
str = mv.getSelectedSolution().getComment();
addComment(str);
}
/**
* Return a Collection of Waveforms that are associated with this solution. This is
* a decision making method. It scans the available Waveforms (that are in the
* WFViews) and decides which should be connected to this solution based on an
* algorithm. The current algorithm is EVERYTHING. <p>
* Other possibilities are: <br>
* Only waveforms with phase picks.<br>
* Waveforms base on a distance decay function.<br>
* Let operator pick <br>*/
public Collection chooseWaveformSet (Solution sol) {
// sol is not currently used but may be later when the logic is more sophistocated
return mv.getWaveformList(); // just get ALL waveforms in the MasterView
}
/**
* Reset the GUI using the new MasterView
*/
public void resetGUI () {
int k = 0;
// make new picking (zoom) panel
pickPanel = new PickingPanel(mv);
// allow filtering
pickPanel.setFilterEnabled(true);
pickPanel.getActiveWFPanel().setShowPhaseCues(props.getBoolean("showPhaseCues"));
pickPanel.getActiveWFPanel().setShowSegments(props.getBoolean("showSegments"));
// not sure why this is necessary again but if you don't do it nothing
// appears in bottom of splitPane
wfSplit.setTopComponent(pickPanel);
pickPanel.repaint(); // attempt to fix failure of zoomed wf to repaint
// remake the scrolling group panel
resetScroller();
toolBar.setMasterView(mv); // Sets origin list etc.
// set/reset the min drag time
mv.masterWFWindowModel.setMinTimeSize(props.getFloat("minDragTime"));
// No selected solution: disable some buttons and menu items
boolean theresAsolution = (mv.solList.getSelected() != null);
toolBar.setEventEnabled(theresAsolution);
menuEvent.setEnabled(theresAsolution);
// Set mainframe title to sol summary string and tab text
updateTextViews();
// if waveforms are in a tab bring that tab to the front
if (props.getBoolean("waveformInTab"))
tabPane.setSelectedIndex(tabPane.indexOfTab(tabTitle[TAB_WAVEFORM]));
// NOTE: these will not update dynamically!
statusBar.setWFViewCount(mv.wfvList.size());
statusBar.setPhaseCount(mv.getPhaseCount());
statusBar.setAmpCount(mv.getAmpCount());
statusBar.setCodaCount(mv.getCodaCount());
statusBar.setSolutionCount(mv.solList.size());
updateDataSourceLabels(); // datasource, wfsource, etc.
// Must reset selected WFPanel because PickingPanel and WFScroller are
// new and must be notified (via listeners) of the selected WFPanel.
// It might be null if no data is loaded, if none default to the first WFPanel in the list
WFView wfvSel = mv.masterWFViewModel.get();
// none selected, use the 1st one in the scroller
if (wfvSel == null) {
if (mv.getWFViewCount() > 0) {
wfvSel = (WFView) mv.wfvList.get(0);
mv.masterWFViewModel.set(wfvSel);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -