use of net.sourceforge.sqlexplorer.dbproduct.User in project tdq-studio-se by Talend.
the class SQLEditor method init.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
*/
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
// Configure the editor
setSite(site);
// PTODO qzhang fixed bug 3904: syschronize the resource.
if (input instanceof FileEditorInput) {
try {
((FileEditorInput) input).getFile().getParent().refreshLocal(IResource.DEPTH_ONE, null);
} catch (CoreException e) {
e.printStackTrace();
}
}
setInput(input);
// Create the text editor
textEditor = new SQLTextEditor(this);
textEditor.init(site, input);
// setPartName(getSite().getPage().getLabel());
// Make sure we get notification that our editor is closing because
// we may need to stop running queries
getSite().getPage().addPartListener(new PartAdapter2() {
/*
* (non-JavaDoc)
*
* @see net.sourceforge.sqlexplorer.util.PartAdapter2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
*/
@Override
public void partClosed(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == SQLEditor.this) {
onCloseEditor();
}
}
});
// If we havn't got a view, then try for the current session in the ConnectionsView
if (getSession() == null) {
ConnectionsView view = SQLExplorerPlugin.getDefault().getConnectionsView();
if (view != null) {
User user = view.getDefaultUser();
if (user != null) {
user.queueForNewSession(new SessionEstablishedAdapter() {
@Override
public void sessionEstablished(Session session) {
setSession(session);
}
});
}
}
}
}
use of net.sourceforge.sqlexplorer.dbproduct.User in project tdq-studio-se by Talend.
the class CreateAliasDlg method okPressed.
protected void okPressed() {
try {
User previousUser = alias.getDefaultUser();
alias.setName(nameField.getText().trim());
int selIndex = cboDriver.getSelectionIndex();
ManagedDriver driver = comboDriverIndexes.get(selIndex);
alias.setDriver(driver);
alias.setUrl(urlField.getText().trim());
if (noUsernameRequired.getSelection())
alias.setHasNoUserName(true);
else {
alias.setHasNoUserName(false);
if (userField.getText().trim().length() > 0)
alias.setDefaultUser(new User(userField.getText().trim(), passwordField.getText().trim()));
}
alias.setName(this.nameField.getText().trim());
alias.setSchemaFilterExpression("");
alias.setNameFilterExpression("");
alias.setFolderFilterExpression("");
alias.setConnectAtStartup(logonAtStartupButton.getSelection());
alias.setAutoLogon(autoLogonButton.getSelection());
if (type != Type.CHANGE)
SQLExplorerPlugin.getDefault().getAliasManager().addAlias(alias);
else // objects even though we have explicitly created a new instance of User above)
if (alias.getDefaultUser() != previousUser) {
if (!previousUser.isInUse())
alias.removeUser(previousUser);
}
User user = alias.getDefaultUser();
if (user != null) {
user.setAutoCommit(autoCommitButton.getSelection());
user.setCommitOnClose(commitOnCloseButton.getSelection());
}
} catch (ExplorerException excp) {
// $NON-NLS-1$
SQLExplorerPlugin.error("Validation Exception", excp);
// System.out.println(Messages.getString("Error_Validation_Exception_4"));//$NON-NLS-1$
}
// Notify that ther has been changes
SQLExplorerPlugin.getDefault().getAliasManager().modelChanged();
close();
}
use of net.sourceforge.sqlexplorer.dbproduct.User in project tdq-studio-se by Talend.
the class OpenInEditorAction method run.
public void run() {
try {
TableItem[] ti = _table.getSelection();
if (ti == null || ti.length == 0) {
return;
}
String queryDelimiter = SQLExplorerPlugin.getDefault().getPluginPreferences().getString(IConstants.SQL_QRY_DELIMITER);
StringBuffer copiedText = new StringBuffer();
for (int i = 0; i < ti.length; i++) {
SQLHistoryElement el = (SQLHistoryElement) ti[i].getData();
copiedText.append(el.getRawSQLString());
if (ti.length > 0) {
copiedText.append(queryDelimiter);
copiedText.append("\n");
}
}
SQLHistoryElement sqlHistoryElement = (SQLHistoryElement) ti[0].getData();
User user = sqlHistoryElement.getUser();
Alias alias;
if (user != null)
alias = user.getAlias();
else {
alias = sqlHistoryElement.getAlias();
if (alias != null)
user = alias.getDefaultUser();
if (user == null) {
ConnectionsView view = SQLExplorerPlugin.getDefault().getConnectionsView();
if (view != null)
user = view.getDefaultUser();
}
}
if (user != null && !user.hasAuthenticated()) {
boolean okToOpen = MessageDialog.openConfirm(_table.getShell(), Messages.getString("SQLHistoryView.OpenInEditor.Confirm.Title"), Messages.getString("SQLHistoryView.OpenInEditor.Confirm.Message.Prefix") + " " + user.getDescription() + Messages.getString("SQLHistoryView.OpenInEditor.Confirm.Message.Postfix"));
if (okToOpen) {
OpenPasswordConnectDialogAction openDlgAction = new OpenPasswordConnectDialogAction(alias, user, false);
openDlgAction.run();
}
}
SQLEditorInput input = new SQLEditorInput("SQL Editor (" + SQLExplorerPlugin.getDefault().getEditorSerialNo() + ").sql");
input.setUser(user);
IWorkbenchPage page = SQLExplorerPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (page == null)
return;
SQLEditor editorPart = (SQLEditor) page.openEditor(input, SQLEditor.class.getName());
editorPart.setText(copiedText.toString());
} catch (Throwable e) {
SQLExplorerPlugin.error("Error creating sql editor", e);
}
}
Aggregations