use of net.sourceforge.sqlexplorer.dbproduct.AliasManager in project tdq-studio-se by Talend.
the class SQLExplorerPlugin method start.
/**
* Initialises the Plugin
*/
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
this.bundleContext = context;
try {
getLog().addLogListener(new ILogListener() {
@Override
public void logging(IStatus status, String plugin) {
Throwable t = status.getException();
if (t != null) {
System.err.println(t.getMessage());
t.printStackTrace(System.err);
}
}
});
driverManager = new DriverManager();
// MOD qiongli TDQ-8893.we will don't use the xml file to maintain the ManagedDrivers later.so no need to
// laod or save the xml files.
// driverManager.loadDrivers();
aliasManager = new AliasManager();
try {
// $NON-NLS-1$
resourceBundle = ResourceBundle.getBundle("net.sourceforge.sqlexplorer.test");
} catch (MissingResourceException x) {
resourceBundle = null;
}
// load SQL History from previous sessions
_history = new SQLHistory();
} catch (Exception e) {
error("Exception during start", e);
throw e;
}
}
use of net.sourceforge.sqlexplorer.dbproduct.AliasManager in project tdq-studio-se by Talend.
the class SqlexplorerService method removeAliasInSQLExplorer.
/*
* (non-Javadoc)
*
* @see
* org.talend.dataprofiler.service.ISqlexplorerService#removeAliasInSQLExplorer(orgomg.cwm.foundation.softwaredeployment
* .DataProvider[])
*/
@Override
public void removeAliasInSQLExplorer(DataProvider... dataproviders) {
SQLExplorerPlugin sqlPlugin = SQLExplorerPlugin.getDefault();
AliasManager aliasManager = sqlPlugin.getAliasManager();
DatabaseStructureView dsView = sqlPlugin.findDatabaseStructureView();
// alias from propertyFile map at the same time.
try {
Collection<Alias> aliases = aliasManager.getAliases();
if (aliases.isEmpty()) {
return;
}
for (DataProvider dataProvider : dataproviders) {
String aliasName = dataProvider.getName();
if (null == aliasName) {
continue;
}
Alias alias = aliasManager.getAlias(aliasName);
if (alias != null) {
sqlPlugin.getPropertyFile().remove(alias);
aliasManager.removeAlias(aliasName);
}
// if the ctabItem is open,close it.
if (dsView != null) {
dsView.closeCurrentCabItem(aliasName);
}
}
} catch (Exception e) {
log.error(e, e);
}
aliasManager.modelChanged();
}
use of net.sourceforge.sqlexplorer.dbproduct.AliasManager in project tdq-studio-se by Talend.
the class SqlexplorerService method updateConnetionAliasByName.
/*
* (non-Javadoc)
*
* @see
* org.talend.dataprofiler.service.ISqlexplorerService#updateConnetionAliasByName(org.talend.core.model.metadata.
* builder.connection.Connection, java.lang.String)
*/
@Override
public void updateConnetionAliasByName(Connection connection, String aliasName) {
if (connection == null || aliasName == null) {
return;
}
SQLExplorerPlugin sqlPlugin = SQLExplorerPlugin.getDefault();
// if the ctabItem is open,close it.
DatabaseStructureView view = sqlPlugin.findDatabaseStructureView();
if (view != null) {
view.closeCurrentCabItem(aliasName);
}
AliasManager aliasManager = sqlPlugin.getAliasManager();
Alias alias = aliasManager.getAlias(aliasName);
if (alias != null) {
try {
aliasManager.removeAlias(aliasName);
addConnetionAliasToSQLPlugin(connection);
} catch (Exception e) {
log.error(e, e);
}
}
}
use of net.sourceforge.sqlexplorer.dbproduct.AliasManager in project tdq-studio-se by Talend.
the class ConnectionTreeContentProvider method getChildren.
/**
* Return all the children
*
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof AliasManager) {
AliasManager aliases = (AliasManager) parentElement;
Object[] children = aliases.getAliases().toArray();
return children;
} else if (parentElement instanceof Alias) {
Alias alias = (Alias) parentElement;
Object[] children = alias.getUsers().toArray();
return children;
} else if (parentElement instanceof User) {
User user = (User) parentElement;
return user.getConnections().toArray();
}
return null;
}
use of net.sourceforge.sqlexplorer.dbproduct.AliasManager in project tdq-studio-se by Talend.
the class SqlexplorerService method aliasExist.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.service.ISqlexplorerService#aliasExist(java.lang.String)
*/
@Override
public boolean aliasExist(String connectionName) {
SQLExplorerPlugin sqlPlugin = SQLExplorerPlugin.getDefault();
AliasManager aliasManager = sqlPlugin.getAliasManager();
Alias alias = aliasManager.getAlias(connectionName);
return alias != null;
}
Aggregations