diff options
author | Julien Gouesse <[email protected]> | 2015-09-20 20:29:46 +0200 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2015-09-20 20:29:46 +0200 |
commit | bece393c28092ca2d7bb0e312c747193476e8fbf (patch) | |
tree | 4ac987853b9185b490d7ba14c7e8719d5d148def /ardor3d-ui/src/main | |
parent | c17c6772cdb8fd35b4fb245149297182239eb4fa (diff) |
Moves the only dependency on AWT in ardor3d-ui into ardor3d-awt
Diffstat (limited to 'ardor3d-ui/src/main')
3 files changed, 14 insertions, 62 deletions
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/AwtCopyPasteImpl.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/AwtCopyPasteImpl.java deleted file mode 100644 index 7a67258..0000000 --- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/AwtCopyPasteImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2008-2012 Ardor Labs, Inc. - * - * This file is part of Ardor3D. - * - * Ardor3D is free software: you can redistribute it and/or modify it - * under the terms of its license which may be found in the accompanying - * LICENSE file or at <http://www.ardor3d.com/LICENSE>. - */ - -package com.ardor3d.extension.ui.text; - -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.StringSelection; -import java.awt.datatransfer.Transferable; - -public class AwtCopyPasteImpl implements CopyPasteImpl { - - @Override - public String getClipBoardContents() { - final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - final Transferable clipboardContent = clipboard.getContents(null); - - if (clipboardContent != null && clipboardContent.isDataFlavorSupported(DataFlavor.stringFlavor)) { - try { - return (String) clipboardContent.getTransferData(DataFlavor.stringFlavor); - } catch (final Exception e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public void setClipBoardContents(final String contents) { - final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - final StringSelection string = new StringSelection(contents); - clipboard.setContents(string, null); - } -} diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteImpl.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteImpl.java deleted file mode 100644 index b059b98..0000000 --- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2008-2012 Ardor Labs, Inc. - * - * This file is part of Ardor3D. - * - * Ardor3D is free software: you can redistribute it and/or modify it - * under the terms of its license which may be found in the accompanying - * LICENSE file or at <http://www.ardor3d.com/LICENSE>. - */ - -package com.ardor3d.extension.ui.text; - -public interface CopyPasteImpl { - String getClipBoardContents(); - - void setClipBoardContents(String contents); -} diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteManager.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteManager.java index a2d47b0..e501ee6 100644 --- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteManager.java +++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteManager.java @@ -3,13 +3,16 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.extension.ui.text; +import com.ardor3d.ui.text.CopyPasteImpl; +import com.ardor3d.ui.text.NullCopyPasteImpl; + public enum CopyPasteManager { INSTANCE; @@ -21,14 +24,22 @@ public enum CopyPasteManager { public String getClipBoardContents() { if (_impl == null) { - _impl = new AwtCopyPasteImpl(); + try { + _impl = (CopyPasteImpl) Class.forName("com.ardor3d.ui.text.awt.AwtCopyPasteImpl").newInstance(); + } catch (final Throwable t) { + _impl = new NullCopyPasteImpl(); + } } return _impl.getClipBoardContents(); } public void setClipBoardContents(final String contents) { if (_impl == null) { - _impl = new AwtCopyPasteImpl(); + try { + _impl = (CopyPasteImpl) Class.forName("com.ardor3d.ui.text.awt.AwtCopyPasteImpl").newInstance(); + } catch (final Throwable t) { + _impl = new NullCopyPasteImpl(); + } } _impl.setClipBoardContents(contents); } |