All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.glass.ui.ios.IosSystemClipboard Maven / Gradle / Ivy

There is a newer version: 24-ea+15
Show newest version
/*
 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy