Commit f91b39d9 authored by agurov's avatar agurov

Prepare a publicly accessible sample of using the commit integration API (bug 500795)

https://bugs.eclipse.org/bugs/show_bug.cgi?id=500795

git-svn-id: https://dev.eclipse.org/svnroot/technology/org.eclipse.subversive/trunk@21610 ee007c2a-0a25-0410-9ab9-bf268980928c
parent e94c21ca
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SubveriveCommitIntegration</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
#Thu Aug 04 21:34:31 EEST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: SubveriveCommitIntegration
Bundle-SymbolicName: SubveriveCommitIntegration;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: subverivecommitintegration.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.team.svn.ui,
org.eclipse.team.svn.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.team.svn.ui.commit">
<commit
class="subverivecommitintegration.CommitActionFactory1">
</commit>
</extension>
</plugin>
package subverivecommitintegration;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "SubveriveCommitIntegration"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns an image descriptor for the image file at the given
* plug-in relative path
*
* @param path the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
package subverivecommitintegration;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.svn.core.operation.CompositeOperation;
import org.eclipse.team.svn.core.operation.IActionOperation;
import org.eclipse.team.svn.core.operation.IRevisionProvider;
import org.eclipse.team.svn.ui.dialog.DefaultDialog;
import org.eclipse.team.svn.ui.event.IResourceSelectionChangeListener;
import org.eclipse.team.svn.ui.extension.factory.ICommentDialogPanel;
import org.eclipse.team.svn.ui.extension.factory.ICommentManager;
import org.eclipse.team.svn.ui.extension.factory.ICommitActionFactory;
import org.eclipse.team.svn.ui.extension.factory.ICommitDialog;
import org.eclipse.team.svn.ui.panel.IDialogManager;
import org.eclipse.ui.IWorkbenchPart;
public class CommitActionFactory1 implements ICommitActionFactory {
public CommitActionFactory1() {
}
public ICommitDialog getCommitDialog(final Shell shell, Collection allFilesToCommit, final ICommentDialogPanel panel) {
// The task we implement is as such: we prevent a commit from happening until the end of working hours
// We do not want to just hide the commit dialog from committer. We want to tell the reason for preventing the commit.
// And that is why we need to set a specific validation message and status in time of dialog initialization.
// Please note, that you can't do so prior to initialization is complete. For that reason we wrap the ICommentDialogPanel panel
// and handle the postInit() event.
return new ICommitDialog(){
public String getMessage() {
return panel.getMessage();
}
public int open() {
ICommentDialogPanel panelWrap = new ICommentDialogPanel() {
private IDialogManager manager;
public void postInit() {
panel.postInit();
Calendar c = Calendar.getInstance();
Date date = c.getTime();
c.set(Calendar.HOUR_OF_DAY, 17);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
Date limitation = c.getTime();
if (limitation.after(date)) {
manager.setMessage(IDialogManager.LEVEL_ERROR, "It is not the time to commit yet! Please wait until work hours are over.");
manager.setButtonEnabled(0, false);
}
}
public void initPanel(IDialogManager manager) {
panel.initPanel(manager);
this.manager = manager;
}
public Point getPrefferedSize() {
return panel.getPrefferedSize();
}
public String getImagePath() {
return panel.getImagePath();
}
public String getHelpId() {
return panel.getHelpId();
}
public String getDialogTitle() {
return panel.getDialogTitle();
}
public String getDialogDescription() {
return panel.getDialogDescription();
}
public String getDefaultMessage() {
return panel.getDefaultMessage();
}
public String[] getButtonNames() {
return panel.getButtonNames();
}
public void dispose() {
panel.dispose();
}
public void createControls(Composite parent) {
panel.createControls(parent);
}
public boolean canClose() {
return panel.canClose();
}
public void buttonPressed(int idx) {
panel.buttonPressed(idx);
}
public void addListeners() {
panel.addListeners();
}
public void removeResourcesSelectionChangedListener(IResourceSelectionChangeListener listener) {
panel.removeResourcesSelectionChangedListener(listener);
}
public String getMessage() {
return panel.getMessage();
}
public void addResourcesSelectionChangedListener(IResourceSelectionChangeListener listener) {
panel.addResourcesSelectionChangedListener(listener);
}
};
DefaultDialog dialog = new DefaultDialog(shell, panelWrap);
return dialog.open();
}
};
}
public void performAfterCommitTasks(CompositeOperation operation, IRevisionProvider revisionProvider, IActionOperation[] dependsOn, IWorkbenchPart part) {
}
public void initCommentManager(ICommentManager commentManager) {
commentManager.addCommentsToSection(ICommentManager.TEMPLATE_HEADER, Arrays.asList(new String[] {"Template comment #1 using integration API"}));
String newSection = "------------------------------ New Section ------------------------------";
commentManager.addCommentsSection(newSection, "Added using integration API");
commentManager.addCommentsToSection(newSection, Arrays.asList(new String[] {"Template comment #2 using integration API"}));
}
public void confirmMessage(ICommentManager commentManager) {
}
public void cancelMessage(ICommentManager commentManager) {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment