jdplus.sql.desktop.plugin.jdbc.DbExplorerUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdplus-sql-desktop-plugin Show documentation
Show all versions of jdplus-sql-desktop-plugin Show documentation
${project.parent.artifactId} - ${project.artifactId}
The newest version!
/*
* Copyright 2013 National Bank of Belgium
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package jdplus.sql.desktop.plugin.jdbc;
import java.util.Optional;
import java.util.Properties;
import lombok.NonNull;
import org.netbeans.api.db.explorer.ConnectionManager;
import org.netbeans.api.db.explorer.DatabaseConnection;
import org.netbeans.api.db.explorer.DatabaseException;
import org.netbeans.api.db.explorer.JDBCDriver;
import org.netbeans.api.db.explorer.JDBCDriverManager;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
/**
* http://code.metager.de/source/xref/netbeans/db/src/org/netbeans/modules/db/resources/mf-layer.xml
*
* @author Philippe Charles
*/
public final class DbExplorerUtil {
private DbExplorerUtil() {
// static class
}
static boolean isConnected(@NonNull DatabaseConnection conn) {
return conn.getJDBCConnection() != null;
}
static boolean isTableOrView(@NonNull Node node) {
return lookupContains(node.getLookup(),
getClassName("TableNode"),
getClassName("ViewNode"));
}
private static String getClassName(String name) {
return "org.netbeans.modules.db.explorer.node." + name;
}
// some part of the db api is private; we need to cheat a bit
private static boolean lookupContains(Lookup lookup, String... classNames) {
for (Lookup.Item
© 2015 - 2025 Weber Informatics LLC | Privacy Policy