Search in sources :

Example 1 with INonPersistentEditorInput

use of org.jkiss.dbeaver.ui.editors.INonPersistentEditorInput in project dbeaver by dbeaver.

the class SQLEditor method getTitleToolTip.

@Override
public String getTitleToolTip() {
    DBPDataSourceContainer dataSourceContainer = getDataSourceContainer();
    if (dataSourceContainer == null) {
        return super.getTitleToolTip();
    }
    final IEditorInput editorInput = getEditorInput();
    String scriptPath;
    if (editorInput instanceof IFileEditorInput) {
        scriptPath = ((IFileEditorInput) editorInput).getFile().getFullPath().toString();
    } else if (editorInput instanceof IPathEditorInput) {
        scriptPath = ((IPathEditorInput) editorInput).getPath().toString();
    } else if (editorInput instanceof IURIEditorInput) {
        final URI uri = ((IURIEditorInput) editorInput).getURI();
        if ("file".equals(uri.getScheme())) {
            scriptPath = new File(uri).getAbsolutePath();
        } else {
            scriptPath = uri.toString();
        }
    } else if (editorInput instanceof INonPersistentEditorInput) {
        scriptPath = "SQL Console";
    } else {
        scriptPath = editorInput.getName();
        if (CommonUtils.isEmpty(scriptPath)) {
            scriptPath = "<not a file>";
        }
    }
    StringBuilder tip = new StringBuilder();
    tip.append("Script: ").append(scriptPath).append(" \nConnection: ").append(dataSourceContainer.getName()).append(" \nType: ").append(dataSourceContainer.getDriver().getFullName()).append(" \nURL: ").append(dataSourceContainer.getConnectionConfiguration().getUrl());
    Map<String, Object> vars = getScriptVariables(null, scriptPath);
    if (vars.get(VAR_ACTIVE_DATABASE) != null) {
        tip.append(" \nDatabase: ").append(vars.get(VAR_ACTIVE_DATABASE));
    }
    if (vars.get(VAR_ACTIVE_SCHEMA) != null) {
        tip.append(" \nSchema: ").append(vars.get(VAR_ACTIVE_SCHEMA));
    }
    return tip.toString();
}
Also used : INonPersistentEditorInput(org.jkiss.dbeaver.ui.editors.INonPersistentEditorInput) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) URI(java.net.URI) IFile(org.eclipse.core.resources.IFile)

Example 2 with INonPersistentEditorInput

use of org.jkiss.dbeaver.ui.editors.INonPersistentEditorInput in project dbeaver by serge-rider.

the class SQLEditor method getTitleToolTip.

@Override
public String getTitleToolTip() {
    DBPDataSourceContainer dataSourceContainer = getDataSourceContainer();
    if (dataSourceContainer == null) {
        return super.getTitleToolTip();
    }
    final IEditorInput editorInput = getEditorInput();
    String scriptPath;
    if (editorInput instanceof IFileEditorInput) {
        scriptPath = ((IFileEditorInput) editorInput).getFile().getFullPath().toString();
    } else if (editorInput instanceof IPathEditorInput) {
        scriptPath = ((IPathEditorInput) editorInput).getPath().toString();
    } else if (editorInput instanceof IURIEditorInput) {
        final URI uri = ((IURIEditorInput) editorInput).getURI();
        if ("file".equals(uri.getScheme())) {
            scriptPath = new File(uri).getAbsolutePath();
        } else {
            scriptPath = uri.toString();
        }
    } else if (editorInput instanceof INonPersistentEditorInput) {
        scriptPath = "SQL Console";
    } else {
        scriptPath = editorInput.getName();
        if (CommonUtils.isEmpty(scriptPath)) {
            scriptPath = "<not a file>";
        }
    }
    StringBuilder tip = new StringBuilder();
    tip.append("Script: ").append(scriptPath).append(" \nConnection: ").append(dataSourceContainer.getName()).append(" \nType: ").append(dataSourceContainer.getDriver().getFullName()).append(" \nURL: ").append(dataSourceContainer.getConnectionConfiguration().getUrl());
    Map<String, Object> vars = getScriptVariables(null, scriptPath);
    if (vars.get(VAR_ACTIVE_DATABASE) != null) {
        tip.append(" \nDatabase: ").append(vars.get(VAR_ACTIVE_DATABASE));
    }
    if (vars.get(VAR_ACTIVE_SCHEMA) != null) {
        tip.append(" \nSchema: ").append(vars.get(VAR_ACTIVE_SCHEMA));
    }
    return tip.toString();
}
Also used : INonPersistentEditorInput(org.jkiss.dbeaver.ui.editors.INonPersistentEditorInput) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) URI(java.net.URI) IFile(org.eclipse.core.resources.IFile)

Aggregations

URI (java.net.URI)2 IFile (org.eclipse.core.resources.IFile)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2 INonPersistentEditorInput (org.jkiss.dbeaver.ui.editors.INonPersistentEditorInput)2