Revision: 4066
Author: [email protected]
Date: Fri Feb 20 16:55:45 2015 UTC
Log: Improved paste functionality. User can paste copied Table in a
different local workspace by selecting a target tree node((PlayPen
Database) from a left panel and use Edit>paste menu option . Related bug
id# 2979 and bug ID#2895.
https://code.google.com/p/power-architect/source/detail?r=4066
Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/PasteSelectedAction.java
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/PasteSelectedAction.java
Fri Aug 13 20:09:59 2010 UTC
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/PasteSelectedAction.java
Fri Feb 20 16:55:45 2015 UTC
@@ -28,11 +28,17 @@
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
+import javax.swing.tree.TreePath;
import org.apache.log4j.Logger;
import ca.sqlpower.architect.swingui.ArchitectFrame;
+import ca.sqlpower.architect.swingui.DBTree;
import ca.sqlpower.architect.swingui.PlayPen;
+import ca.sqlpower.architect.swingui.PlayPenComponent;
+import ca.sqlpower.architect.swingui.TablePane;
+import ca.sqlpower.sqlobject.SQLTable;
+import ca.sqlpower.swingui.dbtree.SQLObjectSelection;
public class PasteSelectedAction extends AbstractArchitectAction {
private static final Logger logger =
Logger.getLogger(PasteSelectedAction.class);
@@ -46,15 +52,24 @@
public void actionPerformed(ActionEvent e) {
PlayPen playPen = getSession().getPlayPen();
final Component focusOwner =
getSession().getArchitectFrame().getFocusOwner();
- if (playPen.isAncestorOf(focusOwner) || playPen == focusOwner) {
+ DBTree tree = getSession().getDBTree();
+ TreePath tp = tree.getSelectionModel().getSelectionPath();
+ if (playPen.isAncestorOf(focusOwner) || playPen == focusOwner ||
tree.isTargetDatabaseNode(tp)) {
Transferable clipboardContents =
getSession().getContext().getClipboardContents();
logger.debug("Pasting " + clipboardContents + " into the
playpen.");
if (clipboardContents != null) {
+ for( PlayPenComponent comp: playPen.getSelectedItems()) {
+ if (comp instanceof TablePane && (clipboardContents
instanceof SQLObjectSelection &&
((SQLObjectSelection)clipboardContents).getSqlObjects()[0] instanceof
SQLTable )) {
+
JOptionPane.showMessageDialog(getSession().getArchitectFrame(), "cannot
paste Table inside another Table", "Cannot Paste",
JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ }
playPen.pasteData(clipboardContents);
} else {
JOptionPane.showMessageDialog(getSession().getArchitectFrame(), "There is
no contents in the clipboard to paste.", "Clipboard empty",
JOptionPane.INFORMATION_MESSAGE);
}
- }
+ }
+
}
}
--
---
You received this message because you are subscribed to the Google Groups "Architect Commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.