/* * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package com.sun.glass.ui.ios; import com.sun.glass.ui.Clipboard; import com.sun.glass.ui.Pixels; import com.sun.glass.ui.SystemClipboard; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.ByteBuffer; import java.util.HashMap; /** * System (copy/paste) UIPasteboard wrapper class. */ class IosSystemClipboard extends SystemClipboard { static final String FILE_SCHEME = "file"; static final private String BAD_URI_MSG = "bad URI in com.sun.glass.ui.ios.IosSystemClipboard for file: "; static final private String BAD_URL_MSG = "bad URL in com.sun.glass.ui.ios.IosSystemClipboard for file: "; long seed = 0; final IosPasteboard pasteboard; public IosSystemClipboard(String name) { super(name); if (name.equals(Clipboard.SYSTEM) == true) { this.pasteboard = new IosPasteboard(IosPasteboard.General); } else { this.pasteboard = new IosPasteboard(name); } } @Override protected boolean isOwner() { return (this.seed == this.pasteboard.getSeed()); } @Override protected void pushToSystem(HashMap data, int supportedActions) { HashMap itemFirst = null; // used to handle paste as one item if we can HashMap itemList[] = null; // special case: multiple items for handling urls 10.6 style java.util.Set keys = data.keySet(); java.util.Iterator iterator = keys.iterator(); while (iterator.hasNext() == true) { String mime = (String)iterator.next(); Object object = data.get(mime); if (object != null) { if (mime.equals(URI_TYPE) == true) { // synthesize list of urls as seperate pasteboard items String list = (String)object; String split[] = list.split("\n"); int count = 0; for (int i=0; i 0) { itemList = new HashMap[count]; count = 0; for (int i=0; i list = new java.util.ArrayList(); for (int i=0; i 0) { object = list.get(0); } } } else if (mimeType.equals(RAW_IMAGE_TYPE) == true) { if (utfs != null) { java.util.ArrayList list = new java.util.ArrayList(); for (int i=0; i 0) { object = list.get(0); } } } else if ((mimeType.equals(TEXT_TYPE) == true) || (mimeType.equals(HTML_TYPE) == true) || (mimeType.equals(RTF_TYPE) == true)) { if (utfs != null) { java.util.ArrayList list = new java.util.ArrayList(); for (int i=0; i 0) { object = list.get(0); } } } else if (mimeType.equals(FILE_LIST_TYPE) == true) { // synthesize the list from individual URLs if (utfs != null) { java.util.ArrayList list = new java.util.ArrayList(); for (int i=0; i 0) { object = new String[list.size()]; list.toArray((String[])object); } } } else { if (utfs != null) { java.util.ArrayList list = new java.util.ArrayList(); for (int i=0; i 0) { object = list.get(0); } } } return object; } @Override protected int supportedSourceActionsFromSystem() { return this.pasteboard.getAllowedOperation(); } @Override protected String[] mimesFromSystem() { String[][] all = this.pasteboard.getUTFs(); java.util.ArrayList mimes = new java.util.ArrayList(); if (all != null) { for (int i=0; i