use of net.sourceforge.sqlexplorer.dbproduct.Alias in project tdq-studio-se by Talend.
the class ConnectionTreeLabelProvider method getText.
/**
* Return the text to display
*
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
public String getText(Object element) {
if (element instanceof Alias) {
Alias alias = (Alias) element;
String label = alias.getName();
int numSessions = 0;
for (User user : alias.getUsers()) numSessions += user.getConnections().size();
if (numSessions == 1)
return label + " (" + numSessions + " " + Messages.getString("ConnectionsView.ConnectedAlias.single.Postfix") + // $NON-NLS-1$
")";
if (numSessions > 1)
return label + " (" + numSessions + " " + Messages.getString("ConnectionsView.ConnectedAlias.multiple.Postfix") + // $NON-NLS-1$
")";
return label;
} else if (element instanceof User) {
User user = (User) element;
return user.getUserName();
} else if (element instanceof SQLConnection) {
SQLConnection connection = (SQLConnection) element;
String label;
if (connection.getDescription() == null) {
// $NON-NLS-1$
SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss");
// $NON-NLS-2$
label = Messages.getString("ConnectionsView.ConnectedAlias.ConnectedSince") + ' ' + fmt.format(new Date(connection.getCreatedTime()));
} else
// $NON-NLS-2$
label = Messages.getString("ConnectionsView.ConnectedAlias.Connection") + ' ' + connection.getDescription();
if (connection.isPooled())
// $NON-NLS-1$
label += ' ' + Messages.getString("ConnectionsView.ConnectedAlias.Pooled");
return label;
}
return null;
}
use of net.sourceforge.sqlexplorer.dbproduct.Alias in project tdq-studio-se by Talend.
the class DeleteAction method run.
public void run() {
boolean okToDelete = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), Messages.getString("ConnectionsView.ConfirmDelete.WindowTitle"), Messages.getString("ConnectionsView.ConfirmDelete.Message"));
if (!okToDelete)
return;
for (User user : getView().getSelectedUsers(false)) user.getAlias().removeUser(user);
for (Alias alias : getView().getSelectedAliases(false)) alias.remove();
getView().refresh();
}
use of net.sourceforge.sqlexplorer.dbproduct.Alias in project tdq-studio-se by Talend.
the class DeleteAction method isAvailable.
/**
* Only show action when there is at least 1 alias selected
*
* @see net.sourceforge.sqlexplorer.connections.actions.AbstractConnectionTreeAction#isAvailable()
*/
public boolean isAvailable() {
if (getView() == null)
return false;
Set<Alias> aliases = getView().getSelectedAliases(false);
Set<User> users = getView().getSelectedUsers(false);
if (aliases.isEmpty() && users.isEmpty())
return false;
for (User user : users) if (user.getAlias().hasNoUserName())
return false;
return true;
}
use of net.sourceforge.sqlexplorer.dbproduct.Alias in project tdq-studio-se by Talend.
the class NewAliasAction method run.
public void run() {
CreateAliasDlg dlg = new CreateAliasDlg(Display.getCurrent().getActiveShell(), CreateAliasDlg.Type.CREATE, new Alias());
dlg.open();
getView().refresh();
}
use of net.sourceforge.sqlexplorer.dbproduct.Alias 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();
}
Aggregations