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

Method pasteAction

src/org/opensourcephysics/tools/DataTool.java:3293–3366  ·  view source on GitHub ↗
(String dataString, Object source)

Source from the content-addressed store, hash-verified

3291 }
3292
3293 protected void pasteAction(String dataString, Object source) {
3294 boolean failed = false;
3295 try { // we will check for failure finally, before returning
3296 if (dataString == null) {
3297 return;
3298 }
3299 if (dataString.startsWith("<?xml")) { //$NON-NLS-1$
3300 // pasted string is xml, so load into XMLControl
3301 control = new XMLControlElement();
3302 control.readXML(dataString);
3303 if (control.failedToRead()) {
3304 failed = true;
3305 return;
3306 }
3307 // we now have a valid XMLControl
3308 // OSPLog.finest("pasting clipboard XML into new tabs"); //$NON-NLS-1$
3309 if (Data.class.isAssignableFrom(control.getObjectClass())) {
3310 Data data = (Data) control.loadObject(null, true, true);
3311 if (data == null) {
3312 failed = true;
3313 return;
3314 }
3315 for (Data next : getSelfContainedData(data)) {
3316 DataToolTab tab = createTab(next);
3317 addTab(tab);
3318 }
3319 int i = getTabCount() - 1;
3320 tabbedPane.setSelectedIndex(i);
3321 return;
3322 }
3323 addTabs(control, new Consumer<ArrayList<DataToolTab>>() {
3324
3325 @Override
3326 public void accept(ArrayList<DataToolTab> tabs) {
3327 for (DataToolTab tab : tabs) {
3328 tab.setUserEditable(true);
3329 }
3330 tabbedPane.setSelectedIndex(getTabCount() - 1);
3331 refreshDataBuilder();
3332 }
3333
3334 });
3335 } else {
3336 // pasted string is not xml, so parse to import Data //$NON-NLS-1$
3337 setMultipleTabPolicy(dataString);
3338 Data[] importedData = parseData(dataString, null);
3339 if (importedData == null) {
3340 failed = true;
3341 return;
3342 }
3343 if (source != null) {
3344 DataToolTab first = null;
3345 for (int i = 0; i < importedData.length; i++) {
3346 DataToolTab tab = createTab(importedData[i]);
3347 if (first == null)
3348 first = tab;
3349 addTab(tab);
3350 tab.userEditable = true;

Callers 2

pasteTabMethod · 0.95
cloneTabMethod · 0.95

Calls 15

getSelfContainedDataMethod · 0.95
createTabMethod · 0.95
addTabMethod · 0.95
getTabCountMethod · 0.95
addTabsMethod · 0.95
setMultipleTabPolicyMethod · 0.95
parseDataMethod · 0.95
refreshGUIMethod · 0.95
tabChangedMethod · 0.95
setSelectedTabMethod · 0.95
getStringMethod · 0.95
refreshDataBuilderMethod · 0.95

Tested by

no test coverage detected