提交 c7165811 编写于 作者: A Andrew Khitrin

4 command for GIT (Share, Commit, Pull, Push)


Former-commit-id: 4d6a04eb
上级 d6085454
bin.includes = feature.xml,\
feature.properties
featureName=DBeaver Git
providerName=JKISS
description=DBeaver Git Operations support
copyright=(c) JKISS, 2010-2019
licenseURL=https://dbeaver.io/files/dbeaver_license.txt
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="org.jkiss.dbeaver.git.feature"
label="%featureName"
version="1.0.1.qualifier"
provider-name="%providerName">
<description>
%description
</description>
<copyright>
%copyright
</copyright>
<license url="%licenseURL">
%license
</license>
<plugin
id="org.jkiss.dbeaver.team.git"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.jkiss.dbeaver.team.git.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jkiss.dbeaver</groupId>
<artifactId>dbeaver</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>org.jkiss.dbeaver.db.feature</artifactId>
<version>1.0.2-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: %Bundle-Vendor
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.jkiss.dbeaver.team.git.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Release-Date: 20190611
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime,
org.jkiss.dbeaver.model;visibility:=reexport,
org.jkiss.dbeaver.registry;visibility:=reexport,
org.jkiss.utils;visibility:=reexport,
org.eclipse.ui,
org.eclipse.team.ui,
org.eclipse.egit.core,
org.eclipse.egit.ui,
org.eclipse.core.resources,
org.eclipse.core.expressions,
org.jkiss.dbeaver.ui
Bundle-Localization: OSGI-INF/l10n/bundle
Bundle-Activator: org.jkiss.dbeaver.team.git.ui.Activator
source.. = src/
output.. = target/classes/
bin.includes = .,\
META-INF/,\
OSGI-INF/,\
plugin.xml
jars.compile.order = .
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension name="GitCommandsLabel" point="org.eclipse.ui.commands">
<category
id="org.jkiss.dbeaver.git.commands.category"
name="Git Category">
</category>
<command
categoryId="org.jkiss.dbeaver.git.commands.category"
id="org.jkiss.dbeaver.git.commands.shareCommand"
name="Share">
</command>
<command
categoryId="org.jkiss.dbeaver.git.commands.category"
id="org.jkiss.dbeaver.git.commands.pushCommand"
name="Push">
</command>
<command
categoryId="org.jkiss.dbeaver.git.commands.category"
id="org.jkiss.dbeaver.git.commands.commitCommand"
name="Commit">
</command>
<command
categoryId="org.jkiss.dbeaver.git.commands.category"
id="org.jkiss.dbeaver.git.commands.pullCommand"
name="Pull">
</command>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler
class="org.jkiss.dbeaver.team.git.ui.handlers.ShareHandler"
commandId="org.jkiss.dbeaver.git.commands.shareCommand">
</handler>
<handler
class="org.jkiss.dbeaver.team.git.ui.handlers.PushHandler"
commandId="org.jkiss.dbeaver.git.commands.pushCommand">
</handler>
<handler
class="org.jkiss.dbeaver.team.git.ui.handlers.PullHandler"
commandId="org.jkiss.dbeaver.git.commands.pullCommand">
</handler>
<handler
class="org.jkiss.dbeaver.team.git.ui.handlers.CommitHandler"
commandId="org.jkiss.dbeaver.git.commands.commitCommand">
</handler>
<handler
commandId="org.eclipse.egit.ui.team.SimplePush">
<class
class="org.eclipse.egit.ui.internal.actions.SimplePushActionHandler">
</class>
</handler>
<handler
commandId="org.eclipse.egit.ui.team.Pull">
<class
class="org.eclipse.egit.ui.internal.actions.PullFromUpstreamActionHandler">
</class>
</handler>
<handler
commandId="org.eclipse.egit.ui.team.Commit">
<class
class="org.eclipse.egit.ui.internal.actions.CommitActionHandler">
</class>
</handler>
</extension>
<extension point="org.eclipse.ui.bindings">
<key
commandId="org.jkiss.dbeaver.git.commands.shareCommand"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+6">
</key>
</extension>
<extension point="org.eclipse.ui.bindings">
<key
commandId="org.jkiss.dbeaver.git.commands.pushCommand"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+7">
</key>
</extension>
<extension point="org.eclipse.ui.bindings">
<key
commandId="org.jkiss.dbeaver.git.commands.pullCommand"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+8">
</key>
</extension>
<extension point="org.eclipse.ui.bindings">
<key
commandId="org.jkiss.dbeaver.git.commands.commitCommand"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+9">
</key>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
id="org.jkiss.dbeaver.git.menus.gitMenu"
label="Git"
mnemonic="M">
<command
commandId="org.jkiss.dbeaver.git.commands.shareCommand"
id="org.jkiss.dbeaver.git.menus.shareCommand"
mnemonic="S">
</command>
<command
commandId="org.jkiss.dbeaver.git.commands.pushCommand"
id="org.jkiss.dbeaver.git.menus.pushCommand"
mnemonic="P">
</command>
<command
commandId="org.jkiss.dbeaver.git.commands.pullCommand"
id="org.jkiss.dbeaver.git.menus.pullCommand"
mnemonic="P">
</command>
<command
commandId="org.jkiss.dbeaver.git.commands.commitCommand"
id="org.jkiss.dbeaver.git.menus.commitCommand"
mnemonic="P">
</command>
</menu>
</menuContribution>
<menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar id="org.jkiss.dbeaver.git.toolbars.cloudToolbar">
<command
commandId="org.jkiss.dbeaver.git.commands.shareCommand"
icon="icons/share.png"
id="org.jkiss.dbeaver.git.toolbars.shareCommand"
tooltip="Share project in git repository">
</command>
<command
commandId="org.jkiss.dbeaver.git.commands.pushCommand"
icon="icons/push.png"
id="org.jkiss.dbeaver.git.toolbars.pushCommand"
tooltip="Push in repo">
</command>
<command
commandId="org.jkiss.dbeaver.git.commands.pullCommand"
icon="icons/pull.png"
id="org.jkiss.dbeaver.git.toolbars.pullCommand"
tooltip="Pull from repo">
</command>
<command
commandId="org.jkiss.dbeaver.git.commands.commitCommand"
icon="icons/commit.png"
id="org.jkiss.dbeaver.git.toolbars.commitCommand"
tooltip="Commit changes">
</command>
</toolbar>
</menuContribution>
</extension>
</plugin>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jkiss.dbeaver</groupId>
<artifactId>plugins</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>org.jkiss.dbeaver.team.git.ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* 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.team.git.ui;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Plugin;
import org.jkiss.dbeaver.Log;
import org.osgi.framework.BundleContext;
public class Activator extends Plugin {
//private static final Log log = Log.getLog(Activator.class);
@Override
public void startup() throws CoreException {
//super.startup();
//log.info("Activator git startup");
}
@Override
public void start(BundleContext context) throws Exception {
//super.start(context);
//log.info("Activator git start");
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* 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.team.git.ui.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jkiss.dbeaver.team.git.ui.utils.SelectionUtil;
import org.jkiss.dbeaver.ui.ActionUtils;
public abstract class AbstractGitHandler extends AbstractHandler {
abstract protected String getCmd();
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
IProject project = SelectionUtil.extractProject(window.getActivePage().getSelection());
if (project == null) {
MessageDialog.openInformation(window.getShell(),
"Nothing to operate",
"Select object to operate");
return null;
}
ISelection prjSelection = new StructuredSelection(project);
ActionUtils.runCommand(getCmd(), prjSelection, window);
return null;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* 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.team.git.ui.handlers;
public class CommitHandler extends AbstractGitHandler{
private static final String CMD_COMMIT = "org.eclipse.egit.ui.team.Commit";
@Override
protected String getCmd() {
return CMD_COMMIT;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* 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.team.git.ui.handlers;
public class PullHandler extends AbstractGitHandler {
private static final String CMD_PULL = "org.eclipse.egit.ui.team.Pull";
@Override
protected String getCmd() {
return CMD_PULL;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* 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.team.git.ui.handlers;
public class PushHandler extends AbstractGitHandler{
private static final String CMD_PUSH = "org.eclipse.egit.ui.team.SimplePush";
@Override
protected String getCmd() {
return CMD_PUSH;
}
}
package org.jkiss.dbeaver.team.git.ui.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.Parameterization;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.handlers.IHandlerService;
public class ShareHandler extends AbstractHandler {
private static final String CMD_SHARE = "org.eclipse.egit.ui.command.shareProject";
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
IHandlerService handlerService = window.getService(IHandlerService.class);
ICommandService commandService = window.getService(ICommandService.class);
Command shareCommand = commandService.getCommand(CMD_SHARE);
Parameterization[] params = new Parameterization[1];
try {
params[0] = new Parameterization(shareCommand.getParameters()[0], "General");
} catch (NotDefinedException e) {
throw new ExecutionException("Error in share command parameter", e);
}
ParameterizedCommand pshareCommand = new ParameterizedCommand(shareCommand,
params);
try {
handlerService.executeCommand(pshareCommand, null);
} catch (Exception ex) {
throw new ExecutionException("Unable to execute share",ex);
}
return null;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* 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.team.git.ui.handlers;
import org.eclipse.core.commands.IParameter;
import org.eclipse.core.commands.IParameterValues;
import org.eclipse.core.commands.ParameterValuesException;
public class ShareParameter implements IParameter {
private static final String ID = "org.eclipse.egit.ui.command.projectNameParameter"; //$NON-NLS-1$
private static final String PROJECT_NAME_PARAMETER = "Project"; //$NON-NLS-1$
@Override
public String getId() {
return ID;
}
@Override
public String getName() {
return PROJECT_NAME_PARAMETER;
}
@Override
public IParameterValues getValues() throws ParameterValuesException {
return null;
}
@Override
public boolean isOptional() {
return false;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* 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.team.git.ui.utils;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.jkiss.dbeaver.model.navigator.DBNDataSource;
import org.jkiss.dbeaver.model.navigator.DBNNode;
public class SelectionUtil {
private static DBNDataSource searchDS(DBNNode node) {
if (node == null) return null;
while (!(node instanceof DBNDataSource)) {
if (node.getParentNode() == null) return null;
node = node.getParentNode();
}
return (DBNDataSource) node;
}
public static IProject extractProject(ISelection selection) {
StructuredSelection structSelection = new StructuredSelection(selection);
if (selection != null && !structSelection.isEmpty() && structSelection.size() == 1) {
Object e = structSelection.getFirstElement();
if (e != null && e instanceof StructuredSelection) {
StructuredSelection ts = (StructuredSelection) e;
Object o = ts.getFirstElement();
if (ts.isEmpty()) return null;
if (o instanceof DBNNode) {
DBNDataSource ds = searchDS((DBNNode) o);
return ds == null ? null : ds.getOwnerProject();
}else {
return null;
}
}
return null;
} else {
return null;
}
}
}
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: %Bundle-Vendor
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.jkiss.dbeaver.team.git;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Release-Date: 20190611
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime,
org.jkiss.dbeaver.model;visibility:=reexport,
org.jkiss.dbeaver.registry;visibility:=reexport,
org.jkiss.utils;visibility:=reexport,
org.eclipse.egit.core,
org.eclipse.core.resources,
org.eclipse.core.expressions
Bundle-Localization: OSGI-INF/l10n/bundle
source.. = src/
output.. = target/classes/
bin.includes = .,\
META-INF/,\
OSGI-INF/,\
plugin.xml
jars.compile.order = .
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
</plugin>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jkiss.dbeaver</groupId>
<artifactId>plugins</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>org.jkiss.dbeaver.team.git</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
......@@ -102,6 +102,9 @@
<module>org.jkiss.dbeaver.net.ssh.jsch</module>
<module>org.jkiss.dbeaver.net.ssh.sshj</module>
<module>org.jkiss.dbeaver.net.ssh.ui</module>
<module>org.jkiss.dbeaver.team.git.ui</module>
<module>org.jkiss.dbeaver.team.git</module>
</modules>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册