Avoid NPE in EntryPointTab
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / actions / CustomCopyAction.java
index 24ea456..071df6e 100644 (file)
@@ -4,11 +4,14 @@
  */
 package com.quantum.actions;
 
+import java.sql.SQLException;
 import java.util.Iterator;
 
+import com.quantum.Messages;
 import com.quantum.QuantumPlugin;
 import com.quantum.model.Column;
 import com.quantum.model.EntityHolder;
+import com.quantum.model.NotConnectedException;
 import com.quantum.util.NthLevelConverter;
 import com.quantum.util.QuantumUtil;
 import com.quantum.util.StringUtil;
@@ -17,24 +20,18 @@ import com.quantum.view.bookmark.ColumnNode;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.dnd.TextTransfer;
 import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.actions.SelectionListenerAction;
 
 
 public class CustomCopyAction extends SelectionListenerAction {
-       private final IViewPart view;
        private final int ind;
-       /**
-        * @param BookmarkView
-        */
-       public CustomCopyAction(IViewPart view, int ind) {
-        super(null);
-               this.view = view;
+       public CustomCopyAction( int ind ) {
+        super(Messages.getString(CustomCopyAction.class.getName() + ".text"));
                this.ind = ind;
        }
        public void run() {
                String copyText = "";
-               Iterator iter = getSelectedNonResources().iterator();
+               Iterator iter =  getSelectedNonResources().iterator();
                NthLevelConverter converter = new NthLevelConverter();
                // Fill up the converter. We iterate the selection items
                while (iter.hasNext()) {
@@ -43,18 +40,22 @@ public class CustomCopyAction extends SelectionListenerAction {
                                ColumnNode column = (ColumnNode) current;
                                if (column != null) {
                                        converter.add(column.getColumn().getName(), 
-                        column.getColumn().getParentEntity().getCondQualifiedName(), 0);
+                        column.getColumn().getParentEntity().getQualifiedName(), 0);
                                }
                        } else if (current instanceof EntityHolder) {
                 EntityHolder currentSelec = (EntityHolder) current;
-                               converter.add(currentSelec.getEntity().getCondQualifiedName(), null, 1);
-                               Column[] columns = currentSelec.getEntity().getColumns();
-                               for (int i = 0, length = (columns == null) ? 0 : columns.length;
-                    i < length;
-                    i++) {
-                                       converter.add(columns[i].getName(), 
-                        currentSelec.getEntity().getCondQualifiedName(), 0);
-                               }                                       
+                               converter.add(currentSelec.getEntity().getQualifiedName(), null, 1);
+                               try {
+                                       Column[] columns = currentSelec.getEntity().getColumns();
+                                       for (int i = 0, length = (columns == null) ? 0 : columns.length;
+                           i < length;
+                           i++) {
+                                               converter.add(columns[i].getName(), 
+                               currentSelec.getEntity().getQualifiedName(), 0);
+                                       }                                       
+                               } catch (NotConnectedException e) {
+                               } catch (SQLException e) {
+                               }
                        }
                }
                IPreferenceStore store = QuantumPlugin.getDefault().getPreferenceStore();
@@ -70,4 +71,5 @@ public class CustomCopyAction extends SelectionListenerAction {
                        new Object[] { copyText },
                        new Transfer[] { TextTransfer.getInstance()});
        }
+
 }