Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 173457 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.properties (-7 / +24 lines)
Lines 23-39 Link Here
23
TextPreferencePage.name=File Content
23
TextPreferencePage.name=File Content
24
IgnorePreferencePage.name=Ignored Resources
24
IgnorePreferencePage.name=Ignored Resources
25
25
26
ConfigureProject.label=&Share Project...
26
ConfigureProject.label=Share Project...
27
ConfigureProject.tooltip=Share the project with others using a version and configuration management system.
27
ConfigureProject.tooltip=Share the project with others using a version and configuration management system.
28
ConfigureProject.mnemonic=S
28
29
29
ApplyPatch.label=Appl&y Patch...
30
ApplyPatch.label=Apply Patch...
30
ApplyPatch.tooltip=Apply a patch to one or more workspace projects.
31
ApplyPatch.tooltip=Apply a patch to one or more workspace projects.
32
ApplyPatch.mnemonic=y
31
Command.applyPatch.name=Apply Patch...
33
Command.applyPatch.name=Apply Patch...
32
Command.applyPatch.description=Apply a patch to one or more workspace projects.
34
Command.applyPatch.description=Apply a patch to one or more workspace projects.
33
35
34
ImportProjectSet.label=Import Project &Set...
36
ImportProjectSet.label=Import Project &Set...
35
37
36
TeamGroupMenu.label=T&eam
38
TeamGroupMenu.label=Team
39
TeamGroupMenu.mnemonic=e
37
Team.viewCategory=Team
40
Team.viewCategory=Team
38
41
39
Synchronizing.perspective=Team Synchronizing
42
Synchronizing.perspective=Team Synchronizing
Lines 60-65 Link Here
60
Command.syncLast.name=Repeat last synchronization
63
Command.syncLast.name=Repeat last synchronization
61
Command.syncLast.description=Repeat the last synchronization
64
Command.syncLast.description=Repeat the last synchronization
62
65
66
Command.importProjectSet.name=Import Project Set...
67
Command.importProjectSet.description=Import Project Set into the workspace
68
69
Command.showLocalHistory.name=Show Local History
70
Command.showLocalHistory.description=Show Local History
71
72
Command.compareLocalHistory.name=Local History...
73
Command.compareLocalHistory.description=Compare the Selected Resource with Local History
74
75
Command.configureProject.name=Share Project...
76
63
CompressFolderView.name=Compress Folders
77
CompressFolderView.name=Compress Folders
64
CompressFolderView.description=Compress in-sync folders paths
78
CompressFolderView.description=Compress in-sync folders paths
65
79
Lines 74-81 Link Here
74
EnabledModels = Models
88
EnabledModels = Models
75
Workspace=Workspace
89
Workspace=Workspace
76
90
77
ShowLocalHistory.label=Show Local &History
91
ShowLocalHistory.label=Show Local History
78
CompareLocalHistory.label= &Local History...
92
ShowLocalHistory.mnemonic=H
79
CompareLocalHistory.tooltip= Compare the Selected Resource with Local History
93
CompareLocalHistory.label=Local History...
80
ReplaceLocalHistory.label= &Local History...
94
CompareLocalHistory.tooltip=Compare the Selected Resource with Local History
95
CompareLocalHistory.mnemonic=L
96
ReplaceLocalHistory.label= Local History...
81
ReplaceLocalHistory.tooltip= Replace the Selected Resource with Local History
97
ReplaceLocalHistory.tooltip= Replace the Selected Resource with Local History
98
ReplaceLocalHistory.mnemonic=L
(-)plugin.xml (-12 / +211 lines)
Lines 49-55 Link Here
49
<!-- ****************** POPUP ACTIONS *************** -->
49
<!-- ****************** POPUP ACTIONS *************** -->
50
   <extension
50
   <extension
51
         point="org.eclipse.ui.popupMenus">
51
         point="org.eclipse.ui.popupMenus">
52
      <objectContribution
52
      <!--objectContribution
53
            objectClass="org.eclipse.core.resources.mapping.ResourceMapping"
53
            objectClass="org.eclipse.core.resources.mapping.ResourceMapping"
54
            adaptable="true"
54
            adaptable="true"
55
            id="org.eclipse.team.ui.ResourceContributions">
55
            id="org.eclipse.team.ui.ResourceContributions">
Lines 94-101 Link Here
94
                  name="projectGroup">
94
                  name="projectGroup">
95
            </separator>
95
            </separator>
96
         </menu>
96
         </menu>
97
      </objectContribution>
97
      </objectContribution-->
98
      <objectContribution
98
      <!--objectContribution
99
            objectClass="org.eclipse.core.resources.mapping.ResourceMapping"
99
            objectClass="org.eclipse.core.resources.mapping.ResourceMapping"
100
            adaptable="true"
100
            adaptable="true"
101
            id="org.eclipse.team.ui.ProjectContributions">
101
            id="org.eclipse.team.ui.ProjectContributions">
Lines 114-121 Link Here
114
           </adapt>
114
           </adapt>
115
           </not>
115
           </not>
116
         </enablement>
116
         </enablement>
117
      </objectContribution>        
117
      </objectContribution-->
118
      <objectContribution
118
      <!--objectContribution
119
            objectClass="org.eclipse.core.resources.IFile"
119
            objectClass="org.eclipse.core.resources.IFile"
120
            nameFilter="*.psf"
120
            nameFilter="*.psf"
121
            id="org.eclipse.team.ui.ProjectSetFileContributions">
121
            id="org.eclipse.team.ui.ProjectSetFileContributions">
Lines 126-151 Link Here
126
               enablesFor="*"
126
               enablesFor="*"
127
               id="nonbound.org.eclipse.team.ui.ImportProjectSetAction">
127
               id="nonbound.org.eclipse.team.ui.ImportProjectSetAction">
128
         </action>
128
         </action>
129
      </objectContribution>
129
      </objectContribution-->
130
      <objectContribution
130
      <objectContribution
131
            adaptable="true"
131
            adaptable="true"
132
            id="org.eclipse.team.ui.UnmanagedFileContributions"
132
            id="org.eclipse.team.ui.UnmanagedFileContributions"
133
            objectClass="org.eclipse.core.resources.IFile">
133
            objectClass="org.eclipse.core.resources.IFile">
134
         <action
134
         <!--action
135
               class="org.eclipse.team.internal.ui.history.ShowLocalHistory"
135
               class="org.eclipse.team.internal.ui.history.ShowLocalHistory"
136
               id="org.eclipse.team.ui.showLocalHistory"
136
               id="org.eclipse.team.ui.showLocalHistory"
137
               label="%ShowLocalHistory.label"
137
               label="%ShowLocalHistory.label"
138
               menubarPath="team.main/group4"
138
               menubarPath="team.main/group4"
139
               enablesFor="1"
139
               enablesFor="1"
140
               tooltip="%ShowLocalHistory.label"/>
140
               tooltip="%ShowLocalHistory.label"/-->
141
         <action
141
         <!--action
142
               class="org.eclipse.team.internal.ui.history.CompareLocalHistory"
142
               class="org.eclipse.team.internal.ui.history.CompareLocalHistory"
143
               id="org.eclipse.team.ui.compareLocalHistory"
143
               id="org.eclipse.team.ui.compareLocalHistory"
144
               label="%CompareLocalHistory.label"
144
               label="%CompareLocalHistory.label"
145
               menubarPath="compareWithMenu/compareWithGroup"
145
               menubarPath="compareWithMenu/compareWithGroup"
146
               enablesFor="1"
146
               enablesFor="1"
147
               overrideActionId="compareWithHistory"
147
               overrideActionId="compareWithHistory"
148
               tooltip="%CompareLocalHistory.tooltip"/>
148
               tooltip="%CompareLocalHistory.tooltip"/-->
149
         <action
149
         <action
150
               class="org.eclipse.team.internal.ui.history.ReplaceLocalHistory"
150
               class="org.eclipse.team.internal.ui.history.ReplaceLocalHistory"
151
               id="org.eclipse.team.ui.replaceLocalHistory"
151
               id="org.eclipse.team.ui.replaceLocalHistory"
Lines 317-322 Link Here
317
            description="%ViewCommand.historyView.description"
317
            description="%ViewCommand.historyView.description"
318
            categoryId="org.eclipse.ui.category.views"
318
            categoryId="org.eclipse.ui.category.views"
319
            id="org.eclipse.team.ui.GenericHistoryView"/>
319
            id="org.eclipse.team.ui.GenericHistoryView"/>
320
      <!-- TZarna: added commands -->
321
      <command
322
            categoryId="org.eclipse.team.ui.category.team"
323
            defaultHandler="org.eclipse.team.internal.ui.handlers.ApplyPatchHandler"
324
            description="%Command.applyPatch.description"
325
            id="org.eclipse.team.ui.applyPatch"
326
            name="%Command.applyPatch.name">
327
      </command>
328
      <command
329
            categoryId="org.eclipse.team.ui.category.team"
330
            defaultHandler="org.eclipse.team.internal.ui.handlers.ConfigureProjectHandler"
331
            id="org.eclipse.team.ui.configureProject"
332
            name="%Command.configureProject.name">
333
      </command>
334
      <command
335
            categoryId="org.eclipse.team.ui.category.team"
336
            defaultHandler="org.eclipse.team.internal.ui.handlers.SynchronizeHandler"
337
            description="%Command.syncAll.description"
338
            id="org.eclipse.team.ui.synchronizeAll"
339
            name="%Command.syncAll.name">
340
      </command>
341
      <command
342
            categoryId="org.eclipse.team.ui.category.team"
343
            defaultHandler="org.eclipse.team.internal.ui.handlers.ImportProjectSetHandler"
344
            description="%Command.importProjectSet.description"
345
            id="org.eclipse.team.ui.importProjectSet"
346
            name="%Command.importProjectSet.name">
347
      </command>
348
      <command
349
            categoryId="org.eclipse.team.ui.category.team"
350
            defaultHandler="org.eclipse.team.internal.ui.history.ShowLocalHistoryHandler"
351
            description="%Command.showLocalHistory.description"
352
            id="org.eclipse.team.ui.showLocalHistory"
353
            name="%Command.showLocalHistory.name">
354
      </command>
355
      <command
356
            categoryId="org.eclipse.team.ui.category.team"
357
            defaultHandler="org.eclipse.team.internal.ui.history.CompareLocalHistoryHandler"
358
            description="%Command.compareLocalHistory.description"
359
            id="org.eclipse.team.ui.compareLocalHistory"
360
            name="%Command.compareLocalHistory.name">
361
      </command>
320
   </extension>
362
   </extension>
321
   
363
   
322
   <extension
364
   <extension
Lines 333-339 Link Here
333
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
375
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
334
   </extension>
376
   </extension>
335
<!-- action sets -->
377
<!-- action sets -->
336
   <extension
378
   <!--extension
337
         point="org.eclipse.ui.actionSets">
379
         point="org.eclipse.ui.actionSets">
338
      <actionSet
380
      <actionSet
339
            label="%Command.category.name"
381
            label="%Command.category.name"
Lines 366-372 Link Here
366
               menubarPath="project/additions"
408
               menubarPath="project/additions"
367
               tooltip="%ApplyPatch.tooltip"/>
409
               tooltip="%ApplyPatch.tooltip"/>
368
      </actionSet>
410
      </actionSet>
369
   </extension>
411
   </extension-->
370
   
412
   
371
 <!-- file modification validator -->
413
 <!-- file modification validator -->
372
   
414
   
Lines 494-497 Link Here
494
      </triggerPoint>
536
      </triggerPoint>
495
    </extension>
537
    </extension>
496
    
538
    
539
    <!-- *************** Menus **************** -->
540
    <extension
541
          point="org.eclipse.ui.menus">
542
       <menuContribution
543
             locationURI="menu:project?after=additions">
544
             <!-- always enabled -->
545
             <command
546
                   commandId="org.eclipse.team.ui.applyPatch"
547
                   label="%ApplyPatch.label"
548
                   mnemonic="%ApplyPatch.mnemonic"
549
                   style="push"
550
                   tooltip="%ApplyPatch.tooltip">
551
                <visibleWhen
552
                      checkEnabled="false">
553
                </visibleWhen>
554
             </command>
555
       </menuContribution>
556
       <menuContribution
557
             locationURI="menu:project?after=open.ext">
558
             <!-- enablement? -->
559
             <command
560
                   commandId="org.eclipse.team.ui.configureProject"
561
                   id="org.eclipse.team.ui.ConfigureProject"
562
                   label="%ConfigureProject.label"
563
                   mnemonic="%ConfigureProject.mnemonic"
564
                   style="push"
565
                   tooltip="%ConfigureProject.tooltip">
566
             </command>
567
       </menuContribution>
568
       <menuContribution
569
             locationURI="toolbar:org.eclipse.ui.main.toolbar">
570
          <toolbar
571
                id="whatever">
572
             <command
573
                   commandId="org.eclipse.team.ui.synchronizeAll"
574
                   icon="$nl$/icons/full/elcl16/synch_participants.gif"
575
                   label="%Command.syncAll.name"
576
                   style="pulldown">
577
             </command>
578
             </toolbar>
579
          <!--toolbar
580
                id="toolbar:org.eclipse.ui.main.toolbar?after=search">
581
                         <command
582
                   commandId="org.eclipse.team.ui.synchronizeAll2"
583
                   icon="$nl$/icons/full/elcl16/synch_participants.gif"
584
                   label="%Command.syncAll.name"
585
                   style="pulldown">
586
             </command>
587
          </toolbar-->
588
       </menuContribution>
589
       <menuContribution
590
             locationURI="popup:org.eclipse.ui.popup.any?after=team.main">
591
          <!-- should be enabled only for IFiles with *.psf extension, multiselection is allowed -->
592
          <command
593
                commandId="org.eclipse.team.ui.importProjectSet"
594
                label="%Command.importProjectSet.name"
595
                style="push">
596
          </command>
597
       </menuContribution>
598
       <menuContribution
599
             locationURI="popup:team.main?after=projectGroup">
600
          <command
601
                commandId="org.eclipse.team.ui.configureProject"
602
                id="nonbound.org.eclipse.team.ui.ConfigureProject"
603
                label="%ConfigureProject.label"
604
                mnemonic="%ConfigureProject.mnemonic"
605
                style="push"
606
                tooltip="%ConfigureProject.tooltip">
607
          </command>
608
       </menuContribution>
609
       <menuContribution
610
             locationURI="popup:org.eclipse.ui.popup.any">
611
             <menu
612
                   id="team.main"
613
                   label="%TeamGroupMenu.label"
614
                   mnemonic="%TeamGroupMenu.mnemonic">
615
                  <separator
616
                        name="group1"
617
                        visible="true">
618
            </separator>
619
            <separator
620
                  name="group2"
621
                  visible="true">
622
            </separator>
623
            <separator
624
                  name="group3"
625
                  visible="true">
626
            </separator>
627
            <separator
628
                  name="group4"
629
                  visible="true">
630
            </separator>
631
            <separator
632
                  name="group5"
633
                  visible="true">
634
            </separator>
635
            <separator
636
                  name="group6"
637
                  visible="true">
638
            </separator>
639
            <separator
640
                  name="group7"
641
                  visible="true">
642
            </separator>
643
            <separator
644
                  name="group8"
645
                  visible="true">
646
            </separator>
647
            <separator
648
                  name="group9"
649
                  visible="true">
650
            </separator>
651
            <separator
652
                  name="group10"
653
                  visible="true">
654
            </separator>
655
            <separator
656
                  name="targetGroup"
657
                  visible="true">
658
                  </separator>
659
    <separator
660
                  name="projectGroup"
661
                  visible="true">
662
            </separator>
663
            </menu>
664
       </menuContribution>
665
       <menuContribution
666
             locationURI="popup:compareWithMenu?after=compareWithGroup">
667
          <command
668
                commandId="org.eclipse.team.ui.compareLocalHistory"
669
                label="%CompareLocalHistory.label"
670
                style="push"
671
                tooltip="%CompareLocalHistory.tooltip">
672
          </command>
673
       </menuContribution>
674
       <menuContribution
675
             locationURI="popup:team.main?after=group4">
676
          <command
677
                commandId="org.eclipse.team.ui.showLocalHistory"
678
                label="%ShowLocalHistory.label"
679
                mnemonic="%ShowLocalHistory.mnemonic"
680
                style="push"
681
                >
682
          </command>
683
       </menuContribution>
684
       <menuContribution
685
             locationURI="popup:compareWithMenu?after=compareWithGroup">
686
          <command
687
                commandId="org.eclipse.team.ui.compareLocalHistory"
688
                label="%CompareLocalHistory.label"
689
                mnemonic="%CompareLocalHistory.mnemonic"
690
                style="push"
691
                tooltip="%CompareLocalHistory.tooltip">
692
          </command>
693
       </menuContribution>
694
    </extension>
695
    
497
</plugin>
696
</plugin>
(-)src/org/eclipse/team/internal/ui/actions/ImportProjectSetAction.java (-16 / +30 lines)
Lines 30-60 Link Here
30
import org.eclipse.ui.IWorkbenchPart;
30
import org.eclipse.ui.IWorkbenchPart;
31
import org.eclipse.ui.actions.ActionDelegate;
31
import org.eclipse.ui.actions.ActionDelegate;
32
32
33
public class ImportProjectSetAction extends ActionDelegate implements IObjectActionDelegate {
33
/**
34
	
34
 * @deprecated Use
35
 *             <code>org.eclipse.team.internal.ui.handlers.ImportProjectSetHandler</code>
36
 *             instead.
37
 */
38
public class ImportProjectSetAction extends ActionDelegate implements
39
		IObjectActionDelegate {
40
35
	private IStructuredSelection fSelection;
41
	private IStructuredSelection fSelection;
36
	
42
37
	public void run(IAction action) {
43
	public void run(IAction action) {
38
		final Shell shell= Display.getDefault().getActiveShell();
44
		final Shell shell = Display.getDefault().getActiveShell();
39
		try {
45
		try {
40
			new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() {
46
			new ProgressMonitorDialog(shell).run(true, true,
41
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
47
					new IRunnableWithProgress() {
42
					Iterator iterator= fSelection.iterator();
48
						public void run(IProgressMonitor monitor)
43
					while (iterator.hasNext()) {
49
								throws InvocationTargetException,
44
						IFile file= (IFile) iterator.next();
50
								InterruptedException {
45
						ProjectSetImporter.importProjectSet(file.getLocation().toString(), shell, monitor);
51
							Iterator iterator = fSelection.iterator();
46
					}
52
							while (iterator.hasNext()) {
47
				}
53
								IFile file = (IFile) iterator.next();
48
			});
54
								ProjectSetImporter.importProjectSet(file
55
										.getLocation().toString(), shell,
56
										monitor);
57
							}
58
						}
59
					});
49
		} catch (InvocationTargetException exception) {
60
		} catch (InvocationTargetException exception) {
50
			ErrorDialog.openError(shell, null, null, new Status(IStatus.ERROR, TeamUIPlugin.PLUGIN_ID, IStatus.ERROR, TeamUIMessages.ImportProjectSetAction_0, exception.getTargetException()));
61
			ErrorDialog.openError(shell, null, null, new Status(IStatus.ERROR,
62
					TeamUIPlugin.PLUGIN_ID, IStatus.ERROR,
63
					TeamUIMessages.ImportProjectSetAction_0, exception
64
							.getTargetException()));
51
		} catch (InterruptedException exception) {
65
		} catch (InterruptedException exception) {
52
		}
66
		}
53
	}
67
	}
54
	
68
55
	public void selectionChanged(IAction action, ISelection sel) {
69
	public void selectionChanged(IAction action, ISelection sel) {
56
		if (sel instanceof IStructuredSelection) {
70
		if (sel instanceof IStructuredSelection) {
57
			fSelection= (IStructuredSelection) sel;
71
			fSelection = (IStructuredSelection) sel;
58
		}
72
		}
59
	}
73
	}
60
74
(-)src/org/eclipse/team/internal/ui/actions/ApplyPatchAction.java (-3 / +10 lines)
Lines 17-36 Link Here
17
import org.eclipse.swt.widgets.Display;
17
import org.eclipse.swt.widgets.Display;
18
import org.eclipse.team.core.TeamException;
18
import org.eclipse.team.core.TeamException;
19
19
20
/**
21
 * @deprecated Use
22
 *             <code>org.eclipse.team.internal.ui.handlers.ApplyPatchHandler</code>
23
 *             instead.
24
 */
20
public class ApplyPatchAction extends TeamAction {
25
public class ApplyPatchAction extends TeamAction {
21
26
22
	protected boolean isEnabled() throws TeamException {
27
	protected boolean isEnabled() throws TeamException {
23
		return true;
28
		return true;
24
	}
29
	}
25
	
30
26
	public void run(IAction action) {
31
	public void run(IAction action) {
32
		System.out.println("applyPatchAction");
27
		IResource[] resources = getSelectedResources();
33
		IResource[] resources = getSelectedResources();
28
		IResource resource = null;
34
		IResource resource = null;
29
		if (resources.length > 0) {
35
		if (resources.length > 0) {
30
			resource = resources[0];
36
			resource = resources[0];
31
		}
37
		}
32
		ApplyPatchOperation op = new ApplyPatchOperation(getTargetPart(), resource);
38
		ApplyPatchOperation op = new ApplyPatchOperation(getTargetPart(),
33
		BusyIndicator.showWhile(Display.getDefault(), op); 
39
				resource);
40
		BusyIndicator.showWhile(Display.getDefault(), op);
34
	}
41
	}
35
42
36
}
43
}
(-)src/org/eclipse/team/internal/ui/actions/ConfigureProjectAction.java (+2 lines)
Lines 31-36 Link Here
31
 * Action for configuring a project. Configuring involves associating
31
 * Action for configuring a project. Configuring involves associating
32
 * the project with a Team provider and performing any provider-specific
32
 * the project with a Team provider and performing any provider-specific
33
 * configuration that is necessary.
33
 * configuration that is necessary.
34
 * 
35
 * @deprecated Use <code>org.eclipse.team.internal.ui.handlers.ConfigureProjectHandler</code> instead. 
34
 */
36
 */
35
public class ConfigureProjectAction extends TeamAction implements IWorkbenchWindowActionDelegate {
37
public class ConfigureProjectAction extends TeamAction implements IWorkbenchWindowActionDelegate {
36
	private static class ResizeWizardDialog extends WizardDialog {
38
	private static class ResizeWizardDialog extends WizardDialog {
(-)src/org/eclipse/team/internal/ui/history/CompareLocalHistoryHandler.java (+24 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.history;
12
13
import org.eclipse.team.internal.ui.TeamUIMessages;
14
15
public class CompareLocalHistoryHandler extends ShowLocalHistoryHandler {
16
17
	protected boolean isCompare() {
18
		return true;
19
	}
20
	
21
	protected String getPromptTitle() {
22
		return TeamUIMessages.CompareLocalHistory_0;
23
	}
24
}
(-)src/org/eclipse/team/internal/ui/handlers/TeamHandler.java (+167 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.handlers;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.ArrayList;
15
16
import org.eclipse.core.commands.AbstractHandler;
17
import org.eclipse.core.commands.ExecutionEvent;
18
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.resources.IResource;
20
import org.eclipse.core.runtime.NullProgressMonitor;
21
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
22
import org.eclipse.jface.operation.IRunnableWithProgress;
23
import org.eclipse.jface.viewers.*;
24
import org.eclipse.swt.custom.BusyIndicator;
25
import org.eclipse.swt.widgets.Display;
26
import org.eclipse.swt.widgets.Shell;
27
import org.eclipse.team.internal.ui.TeamUIPlugin;
28
import org.eclipse.team.internal.ui.Utils;
29
import org.eclipse.ui.*;
30
import org.eclipse.ui.handlers.HandlerUtil;
31
32
public abstract class TeamHandler extends AbstractHandler {
33
34
	// Constants for determining the type of progress. Subclasses may
35
	// pass one of these values to the run method.
36
	public final static int PROGRESS_DIALOG = 1;
37
	public final static int PROGRESS_BUSYCURSOR = 2;
38
39
	/**
40
	 * Convenience method for running an operation with progress and error
41
	 * feedback.
42
	 * 
43
	 * @param runnable
44
	 *            the runnable which executes the operation
45
	 * @param problemMessage
46
	 *            the message to display in the case of errors
47
	 * @param progressKind
48
	 *            one of PROGRESS_BUSYCURSOR or PROGRESS_DIALOG
49
	 */
50
	final protected void run(final IRunnableWithProgress runnable,
51
			final String problemMessage, int progressKind, ExecutionEvent event) {
52
		final Exception[] exceptions = new Exception[] { null };
53
		switch (progressKind) {
54
		case PROGRESS_BUSYCURSOR:
55
			BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
56
				public void run() {
57
					try {
58
						runnable.run(new NullProgressMonitor());
59
					} catch (InvocationTargetException e) {
60
						exceptions[0] = e;
61
					} catch (InterruptedException e) {
62
						exceptions[0] = null;
63
					}
64
				}
65
			});
66
			break;
67
		default:
68
		case PROGRESS_DIALOG:
69
			try {
70
				new ProgressMonitorDialog(HandlerUtil.getActiveShell(event))
71
						.run(true, true, runnable);
72
			} catch (InvocationTargetException e) {
73
				exceptions[0] = e;
74
			} catch (InterruptedException e) {
75
				exceptions[0] = null;
76
			}
77
			break;
78
		}
79
		if (exceptions[0] != null) {
80
			handle(exceptions[0], null, problemMessage, event);
81
		}
82
	}
83
84
	/**
85
	 * Shows the given errors to the user.
86
	 * 
87
	 * @param exception
88
	 *            the status containing the error
89
	 * @param title
90
	 *            the title of the error dialog
91
	 * @param message
92
	 *            the message for the error dialog
93
	 */
94
	protected void handle(Exception exception, String title, String message,
95
			ExecutionEvent event) {
96
		Utils.handleError(HandlerUtil.getActiveShell(event), exception, title,
97
				message);
98
	}
99
100
	protected IResource[] getSelectedResources(ExecutionEvent event) {
101
		ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
102
		if (currentSelection == null
103
				|| !(currentSelection instanceof IStructuredSelection))
104
			currentSelection = StructuredSelection.EMPTY;
105
106
		return Utils
107
				.getContributedResources(((IStructuredSelection) currentSelection)
108
						.toArray());
109
	}
110
111
	protected IProject[] getSelectedProjects(ExecutionEvent event) {
112
		IResource[] selectedResources = getSelectedResources(event);
113
		if (selectedResources.length == 0)
114
			return new IProject[0];
115
		ArrayList projects = new ArrayList();
116
		for (int i = 0; i < selectedResources.length; i++) {
117
			IResource resource = selectedResources[i];
118
			if (resource.getType() == IResource.PROJECT) {
119
				projects.add(resource);
120
			}
121
		}
122
		return (IProject[]) projects.toArray(new IProject[projects.size()]);
123
	}
124
125
	protected IWorkbenchPart getTargetPart(ExecutionEvent event) {
126
		return HandlerUtil.getActivePart(event);
127
	}
128
129
	protected Shell getShell(ExecutionEvent event) {
130
		Shell shell = HandlerUtil.getActiveShell(event);
131
		if (shell != null) {
132
			return shell;
133
		} else if (HandlerUtil.getActivePart(event) != null) {
134
			return HandlerUtil.getActivePart(event).getSite().getShell();
135
		} else if (HandlerUtil.getActiveWorkbenchWindow(event) != null) {
136
			return HandlerUtil.getActiveWorkbenchWindow(event).getShell();
137
		} else {
138
			IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench();
139
			if (workbench == null)
140
				return null;
141
			IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
142
			if (window == null)
143
				return null;
144
			return window.getShell();
145
		}
146
147
	}
148
149
	protected ISelection getSelection(ExecutionEvent event) {
150
		// ISelection selection = (ISelection) context
151
		// .getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
152
		ISelection selection = HandlerUtil.getCurrentSelection(event);
153
		if (selection != null)
154
			return selection;
155
		// IWorkbenchWindow activeWorkbenchWindow =
156
		// getActiveWorkbenchWindow(context);
157
		IWorkbenchWindow activeWorkbenchWindow = HandlerUtil
158
				.getActiveWorkbenchWindow(event);
159
		if (activeWorkbenchWindow != null) {
160
			IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
161
			if (activePage != null) {
162
				return activePage.getSelection();
163
			}
164
		}
165
		return null;
166
	}
167
}
(-)src/org/eclipse/team/internal/ui/handlers/ApplyPatchHandler.java (+41 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.handlers;
12
13
import org.eclipse.compare.patch.ApplyPatchOperation;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.swt.custom.BusyIndicator;
18
import org.eclipse.swt.widgets.Display;
19
20
public class ApplyPatchHandler extends TeamHandler {
21
22
	public Object execute(ExecutionEvent event) throws ExecutionException {
23
		System.out.println("applyPatchHandler");
24
		IResource[] resources = getSelectedResources(event);
25
26
		IResource resource = null;
27
		if (resources.length > 0) {
28
			resource = resources[0];
29
		}
30
		ApplyPatchOperation op = new ApplyPatchOperation(getTargetPart(event),
31
				resource);
32
		BusyIndicator.showWhile(Display.getDefault(), op);
33
34
		return null;
35
	}
36
37
	public boolean isEnabled() {
38
		return true;
39
	}
40
41
}
(-)src/org/eclipse/team/internal/ui/handlers/ConfigureProjectHandler.java (+66 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.handlers;
12
13
import java.lang.reflect.InvocationTargetException;
14
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.jface.operation.IRunnableWithProgress;
20
import org.eclipse.jface.wizard.IWizard;
21
import org.eclipse.jface.wizard.WizardDialog;
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.team.internal.ui.TeamUIMessages;
25
import org.eclipse.team.internal.ui.actions.TeamAction;
26
import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;
27
28
public class ConfigureProjectHandler extends TeamHandler {
29
	
30
	private static class ResizeWizardDialog extends WizardDialog {
31
		public ResizeWizardDialog(Shell parentShell, IWizard newWizard) {
32
			super(parentShell, newWizard);
33
			setShellStyle(getShellStyle() | SWT.RESIZE);
34
		}		
35
	}
36
	
37
	public Object execute(final ExecutionEvent event) throws ExecutionException {
38
		System.out.println("ConfigureProjectHandler:execute");
39
		run(new IRunnableWithProgress() {
40
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
41
				try {
42
					IProject project = getSelectedProjects(event)[0];
43
					ConfigureProjectWizard wizard = new ConfigureProjectWizard();
44
					wizard.init(null, project);
45
					WizardDialog dialog = new ResizeWizardDialog(getShell(event), wizard);
46
					//dialog.
47
					dialog.open();
48
				} catch (Exception e) {
49
					throw new InvocationTargetException(e);
50
				}
51
			}
52
		}, TeamUIMessages.ConfigureProjectAction_configureProject, TeamAction.PROGRESS_BUSYCURSOR,event); 
53
54
		return null;
55
	}
56
	
57
	public boolean isEnabled() {
58
//		IProject[] selectedProjects = getSelectedProjects();
59
//		if (selectedProjects.length != 1) return false;
60
//		if (!selectedProjects[0].isAccessible()) return false;
61
//		if (!RepositoryProvider.isShared(selectedProjects[0])) return true;
62
//		return false;
63
		return true;
64
	}
65
	
66
}
(-)src/org/eclipse/team/internal/ui/handlers/ImportProjectSetHandler.java (+62 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.handlers;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.Iterator;
15
16
import org.eclipse.core.commands.ExecutionEvent;
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.runtime.*;
20
import org.eclipse.jface.dialogs.ErrorDialog;
21
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
22
import org.eclipse.jface.operation.IRunnableWithProgress;
23
import org.eclipse.jface.viewers.ITreeSelection;
24
import org.eclipse.swt.widgets.Display;
25
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.team.internal.ui.*;
27
import org.eclipse.ui.handlers.HandlerUtil;
28
29
public class ImportProjectSetHandler extends TeamHandler {
30
31
	public Object execute(final ExecutionEvent event) throws ExecutionException {
32
33
		final ITreeSelection treeSelection = ((ITreeSelection) HandlerUtil
34
				.getCurrentSelection(event));
35
36
		final Shell shell = Display.getDefault().getActiveShell();
37
		try {
38
			new ProgressMonitorDialog(shell).run(true, true,
39
					new IRunnableWithProgress() {
40
						public void run(IProgressMonitor monitor)
41
								throws InvocationTargetException,
42
								InterruptedException {
43
							Iterator iterator = treeSelection.iterator();
44
							while (iterator.hasNext()) {
45
								IFile file = (IFile) iterator.next();
46
								ProjectSetImporter.importProjectSet(file
47
										.getLocation().toString(), shell,
48
										monitor);
49
							}
50
						}
51
					});
52
		} catch (InvocationTargetException exception) {
53
			ErrorDialog.openError(shell, null, null, new Status(IStatus.ERROR,
54
					TeamUIPlugin.PLUGIN_ID, IStatus.ERROR,
55
					TeamUIMessages.ImportProjectSetAction_0, exception
56
							.getTargetException()));
57
		} catch (InterruptedException exception) {
58
		}
59
60
		return null;
61
	}
62
}
(-)src/org/eclipse/team/internal/ui/history/ShowLocalHistoryHandler.java (+158 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.history;
12
13
import java.lang.reflect.InvocationTargetException;
14
15
import org.eclipse.core.commands.*;
16
import org.eclipse.core.resources.*;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.jface.dialogs.ErrorDialog;
19
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.jface.operation.IRunnableWithProgress;
21
import org.eclipse.jface.viewers.*;
22
import org.eclipse.swt.widgets.Shell;
23
import org.eclipse.team.internal.ui.TeamUIMessages;
24
import org.eclipse.team.internal.ui.TeamUIPlugin;
25
import org.eclipse.team.ui.TeamUI;
26
import org.eclipse.team.ui.history.IHistoryPage;
27
import org.eclipse.team.ui.history.IHistoryView;
28
import org.eclipse.ui.*;
29
import org.eclipse.ui.handlers.HandlerUtil;
30
31
public class ShowLocalHistoryHandler extends AbstractHandler /*ActionDelegate implements IObjectActionDelegate */{
32
33
//	private IStructuredSelection fSelection;
34
//	private IWorkbenchPart targetPart;
35
	
36
	public Object execute(final ExecutionEvent event) throws ExecutionException {
37
		System.out.println("ShowLocalHistoryHandler:execute");
38
		IFileState states[]= getLocalHistory(event);
39
		if (states == null || states.length == 0)
40
			return null;
41
		try {
42
			PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
43
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
44
					final IResource resource = (IResource) getSelection(event).getFirstElement();
45
					Runnable r = new Runnable() {
46
						public void run() {
47
							IHistoryView view = TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), resource,  LocalHistoryPageSource.getInstance());
48
							IHistoryPage page = view.getHistoryPage();
49
							if (page instanceof LocalHistoryPage){
50
								LocalHistoryPage historyPage = (LocalHistoryPage) page;
51
								historyPage.setClickAction(isCompare());
52
							}
53
						}
54
					};
55
					TeamUIPlugin.getStandardDisplay().asyncExec(r);				
56
				}
57
			});
58
		} catch (InvocationTargetException exception) {
59
			ErrorDialog.openError(getShell(event), null, null, new Status(IStatus.ERROR, TeamUIPlugin.PLUGIN_ID, IStatus.ERROR, TeamUIMessages.ShowLocalHistory_1, exception.getTargetException()));
60
		} catch (InterruptedException exception) {
61
		}
62
		return null;
63
	}
64
	
65
//	public void run(IAction action) {
66
//		IFileState states[]= getLocalHistory();
67
//		if (states == null || states.length == 0)
68
//			return;
69
//		try {
70
//			PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
71
//				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
72
//					final IResource resource = (IResource) fSelection.getFirstElement();
73
//					Runnable r = new Runnable() {
74
//						public void run() {
75
//							IHistoryView view = TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), resource,  LocalHistoryPageSource.getInstance());
76
//							IHistoryPage page = view.getHistoryPage();
77
//							if (page instanceof LocalHistoryPage){
78
//								LocalHistoryPage historyPage = (LocalHistoryPage) page;
79
//								historyPage.setClickAction(isCompare());
80
//							}
81
//						}
82
//					};
83
//					TeamUIPlugin.getStandardDisplay().asyncExec(r);				
84
//				}
85
//			});
86
//		} catch (InvocationTargetException exception) {
87
//			ErrorDialog.openError(getShell(), null, null, new Status(IStatus.ERROR, TeamUIPlugin.PLUGIN_ID, IStatus.ERROR, TeamUIMessages.ShowLocalHistory_1, exception.getTargetException()));
88
//		} catch (InterruptedException exception) {
89
//		}
90
//	}
91
	
92
//	public void selectionChanged(IAction action, ISelection sel) {
93
//		if (sel instanceof IStructuredSelection) {
94
//			fSelection= (IStructuredSelection) sel;
95
//		}
96
//	}
97
//	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
98
//		this.targetPart = targetPart;
99
//	}
100
	
101
	protected Shell getShell(ExecutionEvent event) {
102
//		if (targetPart != null)
103
//			return targetPart.getSite().getShell();
104
//		return TeamUIPlugin.getActivePage().getActivePart().getSite().getShell();
105
		Shell shell = HandlerUtil.getActiveShell(event);
106
		if (shell != null) {
107
			return shell;
108
		} else if (HandlerUtil.getActivePart(event) != null) {
109
			return HandlerUtil.getActivePart(event).getSite().getShell();
110
		} else if (HandlerUtil.getActiveWorkbenchWindow(event) != null) {
111
			return HandlerUtil.getActiveWorkbenchWindow(event).getShell();
112
		} else {
113
			IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench();
114
			if (workbench == null)
115
				return null;
116
			IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
117
			if (window == null)
118
				return null;
119
			return window.getShell();
120
		}
121
	}
122
123
	protected boolean isCompare() {
124
		return false;
125
	}
126
127
	public IStructuredSelection getSelection(ExecutionEvent event) {
128
//		return fSelection;
129
		ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
130
		if (currentSelection == null
131
				|| !(currentSelection instanceof IStructuredSelection))
132
			currentSelection = StructuredSelection.EMPTY;
133
		
134
		return (IStructuredSelection) currentSelection;
135
	}
136
	
137
	protected IFileState[] getLocalHistory(ExecutionEvent event) {
138
		final IFile file = (IFile) getSelection(event).getFirstElement();
139
		IFileState states[];
140
		try {
141
			states= file.getHistory(null);
142
		} catch (CoreException ex) {		
143
			MessageDialog.openError(getShell(event), getPromptTitle(), ex.getMessage());
144
			return null;
145
		}
146
		
147
		if (states == null || states.length <= 0) {
148
			MessageDialog.openInformation(getShell(event), getPromptTitle(), TeamUIMessages.ShowLocalHistory_0);
149
			return states;
150
		}
151
		return states;
152
	}
153
154
	protected String getPromptTitle() {
155
		return TeamUIMessages.ShowLocalHistory_2;
156
	}
157
158
}
(-)src/org/eclipse/team/internal/ui/handlers/SynchronizeHandler.java (+29 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.handlers;
12
13
import org.eclipse.core.commands.*;
14
import org.eclipse.jface.dialogs.MessageDialog;
15
import org.eclipse.ui.IWorkbenchWindow;
16
import org.eclipse.ui.handlers.HandlerUtil;
17
18
public class SynchronizeHandler extends AbstractHandler {
19
20
	public Object execute(ExecutionEvent event) throws ExecutionException {
21
		IWorkbenchWindow window = HandlerUtil
22
				.getActiveWorkbenchWindowChecked(event);
23
		MessageDialog.openInformation(window.getShell(), "Synchronize",
24
				"Synchronize Handler Dialog!");
25
26
		return null;
27
	}
28
29
}
(-)src/org/eclipse/team/ui/CompoundContributionItem2.java (+45 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.ui;
12
13
import java.util.ArrayList;
14
15
import org.eclipse.jface.action.*;
16
import org.eclipse.ui.actions.CompoundContributionItem;
17
import org.eclipse.ui.internal.WorkbenchMessages;
18
19
public class CompoundContributionItem2 extends CompoundContributionItem {
20
21
	public CompoundContributionItem2() {
22
		super();
23
	}
24
25
	public CompoundContributionItem2(String id) {
26
		super(id);
27
		// TODO Auto-generated constructor stub
28
	}
29
30
	protected IContributionItem[] getContributionItems() {
31
		ArrayList list = new ArrayList();
32
		
33
		String text = WorkbenchMessages.Workbench_noApplicableItems;
34
        Action dummyAction = new Action(text) {
35
            // dummy inner class; no methods
36
        };
37
        dummyAction.setEnabled(false);
38
        list.add(new ActionContributionItem(dummyAction));
39
        
40
        return (IContributionItem[]) list.toArray(new IContributionItem[list.size()]);
41
        
42
//        return null;
43
	}
44
45
}

Return to bug 173457