X-Git-Url: http://secure.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkView.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkView.java index efc055f..f43a99a 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkView.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkView.java @@ -81,10 +81,9 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener { private static BookmarkNode getRoot(TreeNode node){ if (node == null) return null; - if (! (node instanceof TreeNode)) return null; while (!( node instanceof BookmarkNode)) { - node = (TreeNode) node.getParent(); + node = node.getParent(); } if (node instanceof BookmarkNode) return (BookmarkNode) node; else return null; @@ -97,7 +96,7 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener { treeViewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - treeViewer.setContentProvider(new BookmarkContentProvider()); + treeViewer.setContentProvider(new BookmarkContentProvider(this)); treeViewer.setLabelProvider(this.labelProvider); BookmarkListNode input = BookmarkListNode.getInstance(); treeViewer.setInput(input); @@ -166,25 +165,6 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener { this.actionGroup = new BookmarkViewActionGroup(this, this.treeViewer); -// openDataEditorAction = new OpenDataEditorAction(); -// openDataEditorAction.setText("Edit Data"); -// openDataEditorAction.setImageDescriptor( -// QuantumPlugin.getImageDescriptor("greentable.gif")); //$NON-NLS-1$ -// openDataEditorAction.init(this); - - IPreferenceStore store = QuantumPlugin.getDefault().getPreferenceStore(); - this.customCopyAction1 = new CustomCopyAction(this,1); // 1 is unused, just in case more custom copies are defined - this.customCopyAction1.setText(store.getString("customCopyName1")); //$NON-NLS-1$ - this.customCopyAction1.setImageDescriptor( - QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$ - this.customCopyAction2 = new CustomCopyAction(this,2); // 1 is unused, just in case more custom copies are defined - this.customCopyAction2.setText(store.getString("customCopyName2")); //$NON-NLS-1$ - this.customCopyAction2.setImageDescriptor( - QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$ - this.customCopyAction3 = new CustomCopyAction(this,3); // 1 is unused, just in case more custom copies are defined - this.customCopyAction3.setText(store.getString("customCopyName3")); //$NON-NLS-1$ - this.customCopyAction3.setImageDescriptor( - QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$ extensionVector = new Vector(); try { @@ -193,8 +173,35 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener { e.printStackTrace(); } - } + } + /** + * + */ + private void initCustomCopyActions() { + IPreferenceStore store = QuantumPlugin.getDefault().getPreferenceStore(); + String text1 = store.getString("customCopyName1"); + if (text1 != null && text1.trim().length() > 0) { + this.customCopyAction1 = new CustomCopyAction(this,1); // 1 is unused, just in case more custom copies are defined + this.customCopyAction1.setText(text1); //$NON-NLS-1$ + this.customCopyAction1.setImageDescriptor( + QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$ + } + String text2 = store.getString("customCopyName2"); + if (text2 != null && text1.trim().length() > 0) { + this.customCopyAction2 = new CustomCopyAction(this,2); // 1 is unused, just in case more custom copies are defined + this.customCopyAction2.setText(text2); //$NON-NLS-1$ + this.customCopyAction2.setImageDescriptor( + QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$ + } + String text3 = store.getString("customCopyName3"); + if (text3 != null && text1.trim().length() > 0) { + this.customCopyAction3 = new CustomCopyAction(this,3); // 1 is unused, just in case more custom copies are defined + this.customCopyAction3.setText(text3); //$NON-NLS-1$ + this.customCopyAction3.setImageDescriptor( + QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$ + } + } public void dispose(){ super.dispose(); BookmarkListNode.getInstance().removePropertyChangeListener(this); @@ -226,6 +233,7 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener { private void fillContextMenu(IMenuManager mgr) { // TODO: this method is pretty barfy... make it cleaner + initCustomCopyActions(); IStructuredSelection selection = getSelection(); ActionContext context = new ActionContext(selection); this.actionGroup.setContext(context); @@ -236,12 +244,22 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener { if (sel instanceof EntityNode) { EntityNode entityNode = (EntityNode) sel; if (!entityNode.isSequence()) { - mgr.add(new Separator()); - MenuManager subMenu = new MenuManager(Messages.getString("bookmarkview.customCopyAction")); - subMenu.add(customCopyAction1); - subMenu.add(customCopyAction2); - subMenu.add(customCopyAction3); - mgr.add(subMenu); + if (this.customCopyAction1 != null + || this.customCopyAction2 != null + || this.customCopyAction3 != null) { + mgr.add(new Separator()); + MenuManager subMenu = new MenuManager(Messages.getString("bookmarkview.customCopyAction")); + if (this.customCopyAction1 != null) { + subMenu.add(customCopyAction1); + } + if (this.customCopyAction2 != null) { + subMenu.add(customCopyAction2); + } + if (this.customCopyAction3 != null) { + subMenu.add(customCopyAction3); + } + mgr.add(subMenu); + } MenuManager subMenuExtension = new MenuManager("Extensions"); for (int i = 0; i < extensionVector.size(); i++) { @@ -250,13 +268,20 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener { } if (extensionVector.size() > 0) mgr.add(subMenuExtension); } - } else if (sel instanceof ColumnNode) { + } else if ((sel instanceof ColumnNode) && (this.customCopyAction1 != null + || this.customCopyAction2 != null + || this.customCopyAction3 != null)) { MenuManager subMenu = new MenuManager(Messages.getString("bookmarkview.customCopyAction")); + if (this.customCopyAction1 != null) { subMenu.add(customCopyAction1); - subMenu.add(customCopyAction2); - subMenu.add(customCopyAction3); + } + if (this.customCopyAction2 != null) { + subMenu.add(customCopyAction2); + } + if (this.customCopyAction3 != null) { + subMenu.add(customCopyAction3); + } mgr.add(subMenu); - } } /**