/*
 * Copyright (C) 2010-2013 Serge Rieder
 * serge@jkiss.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.jkiss.dbeaver.ext.db2.actions;

import org.eclipse.core.runtime.IAdapterFactory;
import org.jkiss.dbeaver.ext.IDatabaseEditor;
import org.jkiss.dbeaver.ext.db2.model.DB2Table;
import org.jkiss.dbeaver.ext.db2.model.DB2TableBase;
import org.jkiss.dbeaver.ext.db2.model.DB2View;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.ui.editors.DatabaseEditorInput;

/**
 * DB2 object adapter
 */
public class DB2ObjectAdapter implements IAdapterFactory {

    public DB2ObjectAdapter() {
    }

    @Override
    public Object getAdapter(Object adaptableObject, Class adapterType) {
        if (DB2TableBase.class.isAssignableFrom(adapterType)) {
            DBSObject dbObject = null;
            if (adaptableObject instanceof DBNDatabaseNode) {
                dbObject = ((DBNDatabaseNode) adaptableObject).getObject();
            } else if (adaptableObject instanceof IDatabaseEditor) {
                dbObject = ((IDatabaseEditor) adaptableObject).getEditorInput().getDatabaseObject();
            } else if (adaptableObject instanceof DatabaseEditorInput) {
                dbObject = ((DatabaseEditorInput) adaptableObject).getDatabaseObject();
            }
            if (dbObject != null && adapterType.isAssignableFrom(dbObject.getClass())) {
                return dbObject;
            }
        }
        return null;
    }

    @Override
    public Class[] getAdapterList() {
        return new Class[] { DB2Table.class, DB2View.class };
    }
}

@@ -1384,59 +1384,52 @@
     
-public DB2ObjectAdapter() %7B%0D%0A    %7D%0D%0A%0D%0A    @Override
+@Override%0D%0A    @SuppressWarnings(%22rawtypes%22)
 %0D%0A  
@@ -1497,16 +1497,21 @@
 terType)
+%0D%0A   
  %7B%0D%0A    
@@ -1762,32 +1762,51 @@
          %7D else 
+%7B%0D%0A                
 if (adaptableObj
@@ -1836,24 +1836,28 @@
 eEditor) %7B%0D%0A
+    
             
@@ -1958,23 +1958,50 @@
         
+    
 %7D else 
+%7B%0D%0A                    
 if (adap
@@ -2043,24 +2043,32 @@
 orInput) %7B%0D%0A
+        
             
@@ -2148,35 +2148,121 @@
 );%0D%0A            
+   
+     
 %7D%0D%0A
+                %7D%0D%0A            %7D%0D%0A%0D%0A            // DF: Check for exact Match%0D%0A
             if (
@@ -2293,32 +2293,22 @@
 terType.
-isAssignableFrom
+equals
 (dbObjec
@@ -2427,24 +2427,59 @@
  @Override%0D%0A
+    @SuppressWarnings(%22rawtypes%22)%0D%0A
     public C
@@ -2501,16 +2501,21 @@
 erList()
+%0D%0A   
  %7B%0D%0A    

Enable table tools only on DB2Table and not on derivec classes (eg. DB2NickName) Former-commit-id: 8eeacc71df9443d2f23c081fc365c2bb35c7a2c2