MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / saveChangesAt

Method saveChangesAt

src/org/opensourcephysics/tools/DataTool.java:2139–2167  ·  view source on GitHub ↗

Offers to save changes to the tab at the specified index. @param i the tab index @return true unless canceled by the user

(int i)

Source from the content-addressed store, hash-verified

2137 * @return true unless canceled by the user
2138 */
2139 protected boolean saveChangesAt(int i) {
2140 if (OSPRuntime.appletMode) {
2141 return true;
2142 }
2143 DataToolTab tab = getTab(i);
2144 if (!tab.tabChanged) {
2145 return true;
2146 }
2147 String name = tab.getName();
2148 if (ToolsRes.getString("DataToolTab.DefaultName").equals(name) //$NON-NLS-1$
2149 && (tab.originatorID == 0)) {
2150 return true;
2151 }
2152 int selected = JOptionPane.showConfirmDialog(this, ToolsRes.getString("DataTool.Dialog.SaveChanges.Message1") + //$NON-NLS-1$
2153 " \"" + name + "\" " + //$NON-NLS-1$ //$NON-NLS-2$
2154 ToolsRes.getString("DataTool.Dialog.SaveChanges.Message2"), //$NON-NLS-1$
2155 ToolsRes.getString("DataTool.Dialog.SaveChanges.Title"), //$NON-NLS-1$
2156 JOptionPane.YES_NO_CANCEL_OPTION);
2157 if (selected == JOptionPane.CANCEL_OPTION) {
2158 return false;
2159 }
2160 if (selected == JOptionPane.YES_OPTION) {
2161 // save root and all owned nodes
2162 if (save(tab, tab.fileName) == null) {
2163 return false;
2164 }
2165 }
2166 return true;
2167 }
2168
2169 /**
2170 * Gets the currently selected DataToolTab, if any.

Callers 3

removeTabMethod · 0.95
removeAllButTabMethod · 0.95
removeAllTabsMethod · 0.95

Calls 6

getTabMethod · 0.95
getStringMethod · 0.95
saveMethod · 0.95
showConfirmDialogMethod · 0.80
getNameMethod · 0.65
equalsMethod · 0.65

Tested by

no test coverage detected