Created
April 24, 2012 20:32
-
-
Save abhishekbh/2483493 to your computer and use it in GitHub Desktop.
EGit Clean Command
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
commit ab2866dcec8afbc7599fe474a2412acba552e24f | |
Author: Abhishek Bhatnagar <abhishekbh@gmail.com> | |
Date: Wed Mar 18 00:32:02 2011 -0500 | |
WIP: Adding CleanCommand functionality to 'Advanced' menu | |
Change-Id: I4bcf97da3e32b609dea6e49ef226daf6fd587777 | |
Signed-off-by: Abhishek Bhatnagar <abhatnag@redhat.com> | |
Change-Id: I4bcf97da3e32b609dea6e49ef226daf6fd587777 | |
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CleanOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CleanOperation.java | |
new file mode 100644 | |
index 0000000..7379210 | |
--- /dev/null | |
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CleanOperation.java | |
@@ -0,0 +1,140 @@ | |
+/******************************************************************************* | |
+ * Copyright (C) 2011, Chris Aniszczyk <zx@redhat.com> | |
+ * Copyright (C) 2011, Abhishek Bhatnagar <abhatnag@redhat.com> | |
+ * All rights reserved. This program and the accompanying materials | |
+ * are made available under the terms of the Eclipse Public License v1.0 | |
+ * which accompanies this distribution, and is available at | |
+ * http://www.eclipse.org/legal/epl-v10.html | |
+ *******************************************************************************/ | |
+package org.eclipse.egit.core.op; | |
+ | |
+import java.util.ArrayList; | |
+import java.util.List; | |
+import java.util.Set; | |
+ | |
+import org.eclipse.core.resources.IContainer; | |
+import org.eclipse.core.resources.IResource; | |
+import org.eclipse.core.resources.IResourceRuleFactory; | |
+import org.eclipse.core.resources.IWorkspaceRoot; | |
+import org.eclipse.core.resources.ResourcesPlugin; | |
+import org.eclipse.core.runtime.CoreException; | |
+import org.eclipse.core.runtime.IProgressMonitor; | |
+import org.eclipse.core.runtime.jobs.ISchedulingRule; | |
+import org.eclipse.core.runtime.jobs.MultiRule; | |
+import org.eclipse.egit.core.project.RepositoryMapping; | |
+import org.eclipse.jgit.api.CleanCommand; | |
+import org.eclipse.jgit.api.Git; | |
+import org.eclipse.jgit.lib.Repository; | |
+ | |
+/** | |
+ * Clean operation cleans a repository or a selected list of resources | |
+ */ | |
+public class CleanOperation implements IEGitOperation { | |
+ | |
+ private IResource[] resources; | |
+ | |
+ private ISchedulingRule schedulingRule; | |
+ | |
+ private Set<String> paths; | |
+ | |
+ /** | |
+ * Construct an CleanOperation | |
+ * | |
+ * @param resources | |
+ */ | |
+ public CleanOperation(IResource[] resources) { | |
+ this.resources = new IResource[resources.length]; | |
+ System.arraycopy(resources, 0, this.resources, 0, resources.length); | |
+ schedulingRule = calcSchedulingRule(); | |
+ } | |
+ | |
+ /** | |
+ * Construct an CleanOperation | |
+ * | |
+ * @param resources | |
+ * @param paths | |
+ */ | |
+ public CleanOperation(IResource[] resources, Set<String> paths) { | |
+ this.resources = new IResource[resources.length]; | |
+ System.arraycopy(resources, 0, this.resources, 0, resources.length); | |
+ schedulingRule = calcSchedulingRule(); | |
+ this.setPaths(paths); | |
+ } | |
+ | |
+ public void execute(IProgressMonitor monitor) throws CoreException { | |
+ Git repoTree; | |
+ | |
+ // discover repositories and run clean on them | |
+ Repository repo = getRepository(resources[0]); | |
+/* if (repo == null) | |
+ continue;*/ | |
+ repoTree = new Git(repo); | |
+ | |
+ if (paths != null) { | |
+ repoTree.clean().setPaths(paths).call(); | |
+ } else { | |
+ repoTree.clean().call(); | |
+ } | |
+ } | |
+ | |
+ /** | |
+ * Dry run on cleancommand | |
+ * @return a Set<String> | |
+ */ | |
+ public Set<String> dryRun() { | |
+ if (resources.length == 0) | |
+ return null; | |
+ | |
+ Repository repo = getRepository(resources[0]); | |
+ CleanCommand clean = new Git(repo).clean(); | |
+ | |
+ return clean.setDryRun(true).call(); | |
+ } | |
+ | |
+ private static Repository getRepository(IResource resource) { | |
+ RepositoryMapping repositoryMapping = RepositoryMapping.getMapping(resource.getProject()); | |
+ | |
+ if (repositoryMapping != null) | |
+ return repositoryMapping.getRepository(); | |
+ else | |
+ return null; | |
+ } | |
+ | |
+ public ISchedulingRule getSchedulingRule() { | |
+ return schedulingRule; | |
+ } | |
+ | |
+ private ISchedulingRule calcSchedulingRule() { | |
+ List<ISchedulingRule> rules = new ArrayList<ISchedulingRule>(); | |
+ IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace() | |
+ .getRuleFactory(); | |
+ for (IResource resource : resources) { | |
+ IContainer container = resource.getParent(); | |
+ if (!(container instanceof IWorkspaceRoot)) { | |
+ ISchedulingRule rule = ruleFactory.modifyRule(container); | |
+ if (rule != null) | |
+ rules.add(rule); | |
+ } | |
+ } | |
+ if (rules.size() == 0) | |
+ return null; | |
+ else | |
+ return new MultiRule(rules.toArray(new IResource[rules.size()])); | |
+ } | |
+ | |
+ /** | |
+ * @param paths the paths to set | |
+ * @return this | |
+ */ | |
+ public CleanOperation setPaths(Set<String> paths) { | |
+ this.paths = paths; | |
+ return this; | |
+ } | |
+ | |
+ /** | |
+ * @return the paths | |
+ */ | |
+ public Set<String> getPaths() { | |
+ return paths; | |
+ } | |
+} | |
diff --git a/org.eclipse.egit.ui/plugin.properties b/org.eclipse.egit.ui/plugin.properties | |
index 1d1bb9e..7528326 100644 | |
--- a/org.eclipse.egit.ui/plugin.properties | |
+++ b/org.eclipse.egit.ui/plugin.properties | |
@@ -24,6 +24,7 @@ GitRemoteQuickDiffProvider_label=A Git Revision | |
DisconnectAction_label=&Disconnect | |
AssumeUnchangedAction_label=A&ssume Unchanged | |
+CleanAction_label=Clean | |
NoAssumeUnchangedAction_label=&No Assume Unchanged | |
UntrackAction_label=&Untrack | |
Decorator_name=Git | |
diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml | |
index d56a986..5f1986c 100644 | |
--- a/org.eclipse.egit.ui/plugin.xml | |
+++ b/org.eclipse.egit.ui/plugin.xml | |
@@ -3087,7 +3087,34 @@ | |
</visibleWhen> | |
</command> | |
<separator | |
- name="org.eclipse.egit.ui.TeamAdvancedFileSeparator" | |
+ name="org.eclipse.egit.ui.TeamAdvancedFileSeparator1" | |
+ visible="true"> | |
+ </separator> | |
+ <command | |
+ commandId="org.eclipse.egit.ui.team.Clean" | |
+ label="%CleanAction_label" | |
+ style="push"> | |
+ <visibleWhen | |
+ checkEnabled="false"> | |
+ <and> | |
+ <count | |
+ value="1"> | |
+ </count> | |
+ <iterate> | |
+ <and> | |
+ <adapt | |
+ type="org.eclipse.core.resources.IProject"> | |
+ <test | |
+ property="GitResource.isShared"> | |
+ </test> | |
+ </adapt> | |
+ </and> | |
+ </iterate> | |
+ </and> | |
+ </visibleWhen> | |
+ </command> | |
+ <separator | |
+ name="org.eclipse.egit.ui.TeamAdvancedFileSeparator2" | |
visible="true"> | |
</separator> | |
<command | |
@@ -3642,6 +3669,10 @@ | |
icon="icons/obj16/new_tag_obj.gif"> | |
</image> | |
<image | |
+ commandId="org.eclipse.egit.ui.team.Clean" | |
+ icon="icons/obj16/clean_obj.gif"> | |
+ </image> | |
+ <image | |
commandId="org.eclipse.egit.ui.team.AssumeUnchanged" | |
icon="icons/obj16/assume-unchanged.gif"> | |
</image> | |
@@ -3932,6 +3963,12 @@ | |
id="org.eclipse.egit.ui.team.NoAssumeUnchanged" | |
name="No Assume Unchanged"> | |
</command> | |
+ <command | |
+ categoryId="org.eclipse.egit.ui.commandCategory" | |
+ defaultHandler="org.eclipse.egit.ui.internal.actions.CleanActionHandler" | |
+ id="org.eclipse.egit.ui.team.Clean" | |
+ name="Clean"> | |
+ </command> | |
</extension> | |
<extension | |
point="org.eclipse.ui.bindings"> | |
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java | |
index 923dbfb..91b6f70 100644 | |
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java | |
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java | |
@@ -79,6 +79,11 @@ | |
public final static Object ASSUME_NOASSUME_UNCHANGED = new Object(); | |
/** | |
+ * Clean | |
+ */ | |
+ public final static Object CLEAN = new Object(); | |
+ | |
+ /** | |
* Untrack | |
*/ | |
public final static Object UNTRACK = new Object(); | |
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java | |
index ef68fb1..b82c0da 100644 | |
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java | |
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java | |
@@ -3184,6 +3184,12 @@ | |
public static String TagAction_taggingFailed; | |
/** */ | |
+ public static String CleanDialog_HeaderMessage; | |
+ | |
+ /** */ | |
+ public static String CleanDialog_TitleMessage; | |
+ | |
+ /** */ | |
public static String CreateTagDialog_tagName; | |
/** */ | |
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CleanActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CleanActionHandler.java | |
new file mode 100644 | |
index 0000000..6b9b6c9 | |
--- /dev/null | |
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CleanActionHandler.java | |
@@ -0,0 +1,118 @@ | |
+/******************************************************************************* | |
+ * Copyright (C) 2011, Chris Aniszczyk <zx@redhat.com> | |
+ * Copyright (C) 2011, Abhishek Bhatnagar <abhatnag@redhat.com> | |
+ * | |
+ * All rights reserved. This program and the accompanying materials | |
+ * are made available under the terms of the Eclipse Public License v1.0 | |
+ * which accompanies this distribution, and is available at | |
+ * http://www.eclipse.org/legal/epl-v10.html | |
+ *******************************************************************************/ | |
+package org.eclipse.egit.ui.internal.actions; | |
+ | |
+import java.util.HashSet; | |
+import java.util.Set; | |
+ | |
+import org.eclipse.core.commands.ExecutionEvent; | |
+import org.eclipse.core.commands.ExecutionException; | |
+import org.eclipse.core.resources.IResource; | |
+import org.eclipse.core.resources.ResourcesPlugin; | |
+import org.eclipse.core.runtime.CoreException; | |
+import org.eclipse.core.runtime.IStatus; | |
+import org.eclipse.egit.core.op.CleanOperation; | |
+import org.eclipse.egit.ui.JobFamilies; | |
+import org.eclipse.egit.ui.UIText; | |
+import org.eclipse.egit.core.internal.job.JobUtil; | |
+import org.eclipse.jface.dialogs.IDialogConstants; | |
+import org.eclipse.jface.viewers.ArrayContentProvider; | |
+import org.eclipse.jface.viewers.ILabelProvider; | |
+import org.eclipse.jface.viewers.ILabelProviderListener; | |
+import org.eclipse.jgit.lib.Repository; | |
+import org.eclipse.ui.dialogs.ListSelectionDialog; | |
+import org.eclipse.egit.ui.Activator; | |
+ | |
+/** | |
+ * This operation cleans the repository | |
+ * | |
+ * @see CleanOperation | |
+ */ | |
+public class CleanActionHandler extends RepositoryActionHandler { | |
+ /** | |
+ * | |
+ */ | |
+ private Repository repo; | |
+ | |
+ private Set<String> fileListReturned; | |
+ | |
+ public Object execute(ExecutionEvent event) throws ExecutionException { | |
+ IResource[] resources = getSelectedResources(event); | |
+ repo = getRepository(true, event); | |
+ fileListReturned = new HashSet<String>(); | |
+ | |
+ // checks | |
+ if (repo == null) | |
+ return null; | |
+ if (resources.length == 0) | |
+ return null; | |
+ | |
+ // Do a dry run on CleanCommand to get list of files that would be deleted | |
+ CleanOperation op = new CleanOperation(resources); | |
+ Set<String> fileList = op.dryRun(); | |
+ | |
+ // create dialog | |
+ ListSelectionDialog dialog = new ListSelectionDialog( | |
+ getShell(event), // shell | |
+ fileList, // set of file names to populate | |
+ new ArrayContentProvider(), // acp | |
+ new ItemLabelProvider(), // ilp | |
+ UIText.CleanDialog_HeaderMessage // branch name | |
+ ); | |
+ dialog.setTitle(UIText.CleanDialog_TitleMessage); | |
+ | |
+ // if cancel clicked, return | |
+ if (dialog.open() != IDialogConstants.OK_ID) | |
+ return null; | |
+ | |
+ // get user selected files | |
+ for (int i = 0; i < dialog.getResult().length; i++) | |
+ fileListReturned.add(dialog.getResult()[i].toString()); | |
+ | |
+ // run clean job | |
+ JobUtil.scheduleUserJob(op.setPaths(fileListReturned), "Clean", //$NON-NLS-1$ | |
+ JobFamilies.CLEAN); | |
+ | |
+ // refresh work-tree in package explorer | |
+ try { | |
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal( | |
+ IResource.DEPTH_INFINITE, null); | |
+ } catch (CoreException e) { | |
+ Activator.getDefault().getLog().log( | |
+ new org.eclipse.core.runtime.Status( | |
+ IStatus.INFO, Activator.getPluginId(), IStatus.ERROR, e.getMessage(), e | |
+ ) | |
+ ); | |
+ } | |
+ | |
+ return null; | |
+ } | |
+ | |
+ class ItemLabelProvider implements ILabelProvider { | |
+ public org.eclipse.swt.graphics.Image getImage(Object element) { | |
+ return null; | |
+ } | |
+ public void dispose() { | |
+ // Unimplemented method | |
+ } | |
+ public String getText(Object element) { | |
+ return (String) element; | |
+ } | |
+ public boolean isLabelProperty(Object element, String property) { | |
+ return false; | |
+ } | |
+ public void addListener(ILabelProviderListener listener) { | |
+ // Unimplemented method | |
+ } | |
+ public void removeListener(ILabelProviderListener listener) { | |
+ // Unimplemented method | |
+ } | |
+ } | |
+} | |
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CleanTreeDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CleanTreeDialog.java | |
new file mode 100644 | |
index 0000000..cb9e79b | |
--- /dev/null | |
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CleanTreeDialog.java | |
@@ -0,0 +1,341 @@ | |
+/******************************************************************************* | |
+ * Copyright (C) 2011, Abhishek Bhatnagar <abhishekbh@gmail.com> | |
+ * | |
+ * All rights reserved. This program and the accompanying materials | |
+ * are made available under the terms of the Eclipse Public License v1.0 | |
+ * which accompanies this distribution, and is available at | |
+ * http://www.eclipse.org/legal/epl-v10.html | |
+ *******************************************************************************/ | |
+package org.eclipse.egit.ui.internal.dialogs; | |
+ | |
+import java.util.Set; | |
+ | |
+import org.eclipse.core.runtime.IProgressMonitor; | |
+import org.eclipse.core.runtime.IStatus; | |
+import org.eclipse.core.runtime.Status; | |
+import org.eclipse.core.runtime.jobs.Job; | |
+import org.eclipse.egit.ui.JobFamilies; | |
+import org.eclipse.egit.ui.UIIcons; | |
+import org.eclipse.egit.ui.UIText; | |
+import org.eclipse.egit.ui.internal.SWTUtils; | |
+import org.eclipse.jface.dialogs.IDialogConstants; | |
+import org.eclipse.jface.dialogs.TitleAreaDialog; | |
+import org.eclipse.jface.layout.GridDataFactory; | |
+import org.eclipse.jface.layout.GridLayoutFactory; | |
+import org.eclipse.jface.resource.JFaceResources; | |
+import org.eclipse.jface.resource.LocalResourceManager; | |
+import org.eclipse.jface.resource.ResourceManager; | |
+import org.eclipse.jface.viewers.ArrayContentProvider; | |
+import org.eclipse.jface.viewers.ColumnWeightData; | |
+import org.eclipse.jface.viewers.ITableLabelProvider; | |
+import org.eclipse.jface.viewers.TableLayout; | |
+import org.eclipse.jface.viewers.TableViewer; | |
+import org.eclipse.jgit.lib.ObjectId; | |
+import org.eclipse.jgit.lib.Ref; | |
+import org.eclipse.jgit.lib.Repository; | |
+import org.eclipse.jgit.revwalk.RevTag; | |
+import org.eclipse.osgi.util.NLS; | |
+import org.eclipse.swt.SWT; | |
+import org.eclipse.swt.custom.SashForm; | |
+import org.eclipse.swt.graphics.Image; | |
+import org.eclipse.swt.layout.GridData; | |
+import org.eclipse.swt.widgets.Composite; | |
+import org.eclipse.swt.widgets.Control; | |
+import org.eclipse.swt.widgets.Label; | |
+import org.eclipse.swt.widgets.Shell; | |
+import org.eclipse.swt.widgets.Table; | |
+import org.eclipse.ui.PlatformUI; | |
+import org.eclipse.ui.model.WorkbenchLabelProvider; | |
+ | |
+/** | |
+ * @author abhishek | |
+ * | |
+ */ | |
+public class CleanTreeDialog extends TitleAreaDialog { | |
+ | |
+ /** | |
+ * Button id for a "Clear" button (value 22). | |
+ */ | |
+ public static final int CLEAR_ID = 22; | |
+ | |
+ private String branchName; | |
+ | |
+ private Repository repo; | |
+ | |
+ private TableViewer deleteFileListViewer; | |
+ | |
+ private Set<String> filesToBeDeleted; | |
+ | |
+ /** | |
+ * Construct dialog to creating or editing tag. | |
+ * | |
+ * @param parent | |
+ * @param branchName | |
+ * @param repo | |
+ * @param filesToBeDeleted | |
+ */ | |
+ public CleanTreeDialog(Shell parent, String branchName, Repository repo, Set<String> filesToBeDeleted) { | |
+ super(parent); | |
+ this.setBranchName(branchName); | |
+ this.setRepo(repo); | |
+ this.setFilesToBeDeleted(filesToBeDeleted); | |
+ setHelpAvailable(false); | |
+ } | |
+ | |
+ /** | |
+ * Construct dialog to creating or editing tag. | |
+ * | |
+ * @param parent | |
+ * @param commitId | |
+ * @param repo | |
+ */ | |
+ public CleanTreeDialog(Shell parent, ObjectId commitId, Repository repo) { | |
+ super(parent); | |
+ this.setBranchName(null); | |
+ this.setRepo(repo); | |
+ setHelpAvailable(false); | |
+ } | |
+ | |
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
+ | |
+ @Override | |
+ protected void configureShell(Shell newShell) { | |
+ super.configureShell(newShell); | |
+ newShell.setText(UIText.CreateTagDialog_NewTag); | |
+ newShell.setMinimumSize(600, 400); | |
+ } | |
+ | |
+ @Override | |
+ protected void createButtonsForButtonBar(Composite parent) { | |
+ parent.setLayout(GridLayoutFactory.swtDefaults().create()); | |
+ parent.setLayoutData(GridDataFactory.fillDefaults().grab(true, false) | |
+ .create()); | |
+ | |
+ Composite margin = new Composite(parent, SWT.NONE); | |
+ margin.setLayoutData(GridDataFactory.fillDefaults().grab(true, false) | |
+ .create()); | |
+ | |
+ super.createButtonsForButtonBar(parent); | |
+ } | |
+ | |
+ @Override | |
+ public void create() { | |
+ super.create(); | |
+ // start a job that fills the tag list lazily | |
+ Job job = new Job(UIText.CreateTagDialog_GetTagJobName) { | |
+ @Override | |
+ public boolean belongsTo(Object family) { | |
+ if (family.equals(JobFamilies.FILL_TAG_LIST)) | |
+ return true; | |
+ return super.belongsTo(family); | |
+ } | |
+ | |
+ @Override | |
+ protected IStatus run(IProgressMonitor monitor) { | |
+ | |
+ // This is most likely the file list loading place | |
+ //final List<Object> filesDelete = getCleanFileList(); | |
+ PlatformUI.getWorkbench().getDisplay() | |
+ .asyncExec(new Runnable() { | |
+ public void run() { | |
+ if (!deleteFileListViewer.getTable().isDisposed()) { | |
+ deleteFileListViewer.setInput(getFilesToBeDeleted()); | |
+ deleteFileListViewer.getTable().setEnabled(true); | |
+ } | |
+ } | |
+ }); | |
+ return Status.OK_STATUS; | |
+ } | |
+ }; | |
+ job.setSystem(true); | |
+ job.schedule(); | |
+ } | |
+ | |
+ @Override | |
+ public boolean close() { | |
+ return super.close(); | |
+ } | |
+ | |
+ @Override | |
+ protected Control createDialogArea(final Composite parent) { | |
+ initializeDialogUnits(parent); | |
+ | |
+ setTitle(getTitle()); | |
+ setMessage(UIText.CreateTagDialog_Message); | |
+ | |
+ Composite composite = (Composite) super.createDialogArea(parent); | |
+ | |
+ final SashForm mainForm = new SashForm(composite, SWT.HORIZONTAL | |
+ | SWT.FILL); | |
+ mainForm.setLayoutData(GridDataFactory.fillDefaults().grab(true, true) | |
+ .create()); | |
+ | |
+ createLeftSection(mainForm); | |
+ createExistingTagsSection(mainForm); | |
+ | |
+ mainForm.setWeights(new int[] { 70, 30 }); | |
+ | |
+ applyDialogFont(parent); | |
+ return composite; | |
+ } | |
+ | |
+ @Override | |
+ protected void buttonPressed(int buttonId) { | |
+ switch (buttonId) { | |
+ case CLEAR_ID: | |
+ | |
+ break; | |
+ case IDialogConstants.OK_ID: | |
+ // read and store data from widgets | |
+ //$FALL-THROUGH$ continue propagating OK button action | |
+ default: | |
+ super.buttonPressed(buttonId); | |
+ } | |
+ } | |
+ | |
+ private void createLeftSection(SashForm mainForm) { | |
+ Composite left = new Composite(mainForm, SWT.RESIZE); | |
+ left.setLayout(GridLayoutFactory.swtDefaults().margins(10, 5).create()); | |
+ left.setLayoutData(GridDataFactory.fillDefaults().grab(true, true) | |
+ .create()); | |
+ | |
+ Label label = new Label(left, SWT.WRAP); | |
+ label.setText(UIText.CreateTagDialog_tagName); | |
+ GridData data = new GridData(GridData.GRAB_HORIZONTAL | |
+ | GridData.HORIZONTAL_ALIGN_FILL | |
+ | GridData.VERTICAL_ALIGN_CENTER); | |
+ data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2); | |
+ label.setLayoutData(data); | |
+ label.setFont(left.getFont()); | |
+ | |
+ new Label(left, SWT.WRAP).setText(UIText.CreateTagDialog_tagMessage); | |
+ } | |
+ | |
+ private void createExistingTagsSection(Composite parent) { | |
+ Composite right = new Composite(parent, SWT.NORMAL); | |
+ right.setLayout(GridLayoutFactory.swtDefaults().create()); | |
+ right.setLayoutData(GridLayoutFactory.fillDefaults().create()); | |
+ | |
+ new Label(right, SWT.WRAP).setText(UIText.CreateTagDialog_existingTags); | |
+ | |
+ Table table = new Table(right, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | |
+ | SWT.SINGLE); | |
+ table.setLayoutData(GridDataFactory.fillDefaults().grab(true, true) | |
+ .hint(80, 100).create()); | |
+ | |
+ TableLayout layout = new TableLayout(); | |
+ layout.addColumnData(new ColumnWeightData(100, 20)); | |
+ table.setLayout(layout); | |
+ | |
+ deleteFileListViewer = new TableViewer(table); | |
+ deleteFileListViewer.setLabelProvider(new TagLabelProvider()); | |
+ deleteFileListViewer.setContentProvider(ArrayContentProvider.getInstance()); | |
+ | |
+ // let's set the table inactive initially and display a "Loading..." | |
+ // message and fill the list asynchronously during create() in order to | |
+ // improve UI responsiveness | |
+ deleteFileListViewer | |
+ .setInput(new String[] { UIText.CreateTagDialog_LoadingMessageText }); | |
+ deleteFileListViewer.getTable().setEnabled(false); | |
+ applyDialogFont(parent); | |
+ } | |
+ | |
+ @Override | |
+ protected boolean isResizable() { | |
+ return true; | |
+ } | |
+ | |
+ private String getTitle() { | |
+ String title = ""; //$NON-NLS-1$ | |
+ if (branchName != null) { | |
+ title = NLS.bind(UIText.CreateTagDialog_questionNewTagTitle, | |
+ branchName); | |
+ } | |
+ return title; | |
+ } | |
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
+ | |
+ /** | |
+ * @param branchName the branchName to set | |
+ */ | |
+ public void setBranchName(String branchName) { | |
+ this.branchName = branchName; | |
+ } | |
+ | |
+ /** | |
+ * @return the branchName | |
+ */ | |
+ public String getBranchName() { | |
+ return branchName; | |
+ } | |
+ | |
+ /** | |
+ * @param repo the repo to set | |
+ */ | |
+ public void setRepo(Repository repo) { | |
+ this.repo = repo; | |
+ } | |
+ | |
+ /** | |
+ * @return the repo | |
+ */ | |
+ public Repository getRepo() { | |
+ return repo; | |
+ } | |
+ | |
+ /** | |
+ * @param filesToBeDeleted the filesToBeDeleted to set | |
+ */ | |
+ public void setFilesToBeDeleted(Set<String> filesToBeDeleted) { | |
+ this.filesToBeDeleted = filesToBeDeleted; | |
+ } | |
+ | |
+ /** | |
+ * @return the filesToBeDeleted | |
+ */ | |
+ public Set<String> getFilesToBeDeleted() { | |
+ return filesToBeDeleted; | |
+ } | |
+ | |
+ private static class TagLabelProvider extends WorkbenchLabelProvider implements | |
+ ITableLabelProvider { | |
+ private final Image IMG_TAG; | |
+ | |
+ private final Image IMG_LIGHTTAG; | |
+ | |
+ private final ResourceManager fImageCache; | |
+ | |
+ private TagLabelProvider() { | |
+ fImageCache = new LocalResourceManager( | |
+ JFaceResources.getResources()); | |
+ IMG_TAG = fImageCache.createImage(UIIcons.TAG); | |
+ IMG_LIGHTTAG = SWTUtils.getDecoratedImage( | |
+ fImageCache.createImage(UIIcons.TAG), UIIcons.OVR_UNTRACKED); | |
+ } | |
+ | |
+ public Image getColumnImage(Object element, int columnIndex) { | |
+ // initially, we just display a single String ("Loading...") | |
+ if (element instanceof String) | |
+ return null; | |
+ else if (element instanceof Ref) | |
+ return IMG_LIGHTTAG; | |
+ else | |
+ return IMG_TAG; | |
+ } | |
+ | |
+ public String getColumnText(Object element, int columnIndex) { | |
+ // initially, we just display a single String ("Loading...") | |
+ if (element instanceof String) | |
+ return (String) element; | |
+ else if (element instanceof Ref) | |
+ return ((Ref) element).getName().substring(10); | |
+ else | |
+ return ((RevTag) element).getTagName(); | |
+ } | |
+ | |
+ public void dispose() { | |
+ fImageCache.dispose(); | |
+ super.dispose(); | |
+ } | |
+ } | |
+} | |
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties | |
index 980778f..7557bcb 100644 | |
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties | |
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties | |
@@ -1121,6 +1121,9 @@ CreateTagDialog_LoadingMessageText=Loading... | |
CreateTagDialog_Message=Create a new tag or replace an existing one | |
CreateTagDialog_NewTag=Create New Tag | |
+CleanDialog_HeaderMessage=Select files to remove | |
+CleanDialog_TitleMessage=Resource Selection | |
+ | |
CommitCombo_showSuggestedCommits=Start typing SHA-1 of existing commit or part of first line in commit message to see suggested commits. | |
CommitCommand_committingNotPossible=Committing not possible | |
CommitCommand_noProjectsImported=No projects are imported into the workspace for this repository. For the time being committing is currently only possible for workspace resources. | |
diff --git a/org.eclipse.egit/.project b/org.eclipse.egit/.project | |
index 4b2dd82..23b0309 100644 | |
--- a/org.eclipse.egit/.project | |
+++ b/org.eclipse.egit/.project | |
@@ -3,6 +3,31 @@ | |
<name>org.eclipse.egit</name> | |
<comment></comment> | |
<projects> | |
+ <project>com.google.protobuf</project> | |
+ <project>com.jcraft.jsch</project> | |
+ <project>javax.servlet</project> | |
+ <project>org.eclipse.jgit</project> | |
+ <project>org.eclipse.jgit.ant</project> | |
+ <project>org.eclipse.jgit.ant.test</project> | |
+ <project>org.eclipse.jgit.console</project> | |
+ <project>org.eclipse.jgit.feature</project> | |
+ <project>org.eclipse.jgit.generated.storage.dht.proto</project> | |
+ <project>org.eclipse.jgit.http.server</project> | |
+ <project>org.eclipse.jgit.http.test</project> | |
+ <project>org.eclipse.jgit.iplog</project> | |
+ <project>org.eclipse.jgit.junit</project> | |
+ <project>org.eclipse.jgit.junit.feature</project> | |
+ <project>org.eclipse.jgit.junit.http</project> | |
+ <project>org.eclipse.jgit.pgm</project> | |
+ <project>org.eclipse.jgit.source.feature</project> | |
+ <project>org.eclipse.jgit.storage.dht</project> | |
+ <project>org.eclipse.jgit.storage.dht.test</project> | |
+ <project>org.eclipse.jgit.test</project> | |
+ <project>org.eclipse.jgit.ui</project> | |
+ <project>org.eclipse.jgit.updatesite</project> | |
+ <project>org.kohsuke.args4j</project> | |
+ <project>org.mockito</project> | |
+ <project>org.objenesis</project> | |
</projects> | |
<buildSpec> | |
<buildCommand> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment