forked from dbeaver/dbeaver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dbeaver#7822 Add "Open separate connection" option to the main menu. …
…Extra logging.
- Loading branch information
1 parent
7977190
commit 6fed550
Showing
9 changed files
with
135 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...c/org/jkiss/dbeaver/ui/editors/sql/handlers/SQLEditorHandlerSeparateConnectionOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* DBeaver - Universal Database Manager | ||
* Copyright (C) 2010-2019 Serge Rider ([email protected]) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jkiss.dbeaver.ui.editors.sql.handlers; | ||
|
||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.ui.IEditorPart; | ||
import org.eclipse.ui.commands.IElementUpdater; | ||
import org.eclipse.ui.handlers.HandlerUtil; | ||
import org.eclipse.ui.menus.UIElement; | ||
import org.jkiss.code.NotNull; | ||
import org.jkiss.dbeaver.model.DBPDataSourceContainer; | ||
import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; | ||
import org.jkiss.dbeaver.runtime.DBWorkbench; | ||
import org.jkiss.dbeaver.ui.UIUtils; | ||
import org.jkiss.dbeaver.ui.actions.AbstractDataSourceHandler; | ||
import org.jkiss.dbeaver.ui.editors.sql.SQLEditor; | ||
import org.jkiss.dbeaver.ui.editors.sql.SQLPreferenceConstants; | ||
import org.jkiss.dbeaver.ui.editors.sql.internal.SQLEditorMessages; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
public class SQLEditorHandlerSeparateConnectionOption extends AbstractDataSourceHandler implements IElementUpdater { | ||
|
||
public SQLEditorHandlerSeparateConnectionOption() | ||
{ | ||
} | ||
|
||
@Override | ||
public Object execute(ExecutionEvent event) throws ExecutionException | ||
{ | ||
final DBPPreferenceStore prefs = getPreferenceStore(event); | ||
prefs.setValue(SQLPreferenceConstants.EDITOR_SEPARATE_CONNECTION, | ||
!prefs.getBoolean(SQLPreferenceConstants.EDITOR_SEPARATE_CONNECTION)); | ||
try { | ||
prefs.save(); | ||
} catch (IOException e) { | ||
throw new ExecutionException("Error saving configuration", e); | ||
} | ||
|
||
IEditorPart editor = HandlerUtil.getActiveEditor(event); | ||
if (editor instanceof SQLEditor) { | ||
((SQLEditor) editor).updateExecutionContextState(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@NotNull | ||
private DBPPreferenceStore getPreferenceStore(ExecutionEvent event) { | ||
DBPDataSourceContainer dsContainer = getActiveDataSourceContainer(event, false); | ||
return dsContainer == null ? DBWorkbench.getPlatform().getPreferenceStore() : dsContainer.getPreferenceStore(); | ||
} | ||
|
||
@Override | ||
public void updateElement(UIElement element, Map parameters) { | ||
element.setText(SQLEditorMessages.pref_page_sql_editor_label_separate_connection_each_editor); | ||
element.setTooltip(SQLEditorMessages.pref_page_sql_editor_label_separate_connection_each_editor); | ||
|
||
IEditorPart activeEditor = UIUtils.getActiveWorkbenchWindow().getActivePage().getActiveEditor(); | ||
DBPDataSourceContainer dsContainer = activeEditor == null ? null : getDataSourceContainerFromPart(activeEditor); | ||
DBPPreferenceStore prefStore = dsContainer == null ? DBWorkbench.getPlatform().getPreferenceStore() : dsContainer.getPreferenceStore(); | ||
|
||
element.setChecked(prefStore.getBoolean(SQLPreferenceConstants.EDITOR_SEPARATE_CONNECTION)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters