Skip to content

Commit 1648d2a

Browse files
Package navigation added, pull feature removed (#91)
1 parent 95e3bc7 commit 1648d2a

File tree

4 files changed

+166
-17
lines changed

4 files changed

+166
-17
lines changed

org.abapgit.adt.ui/src/org/abapgit/adt/ui/internal/i18n/Messages.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class Messages extends NLS {
77
public static String AbapGitView_action_clone;
88
public static String AbapGitView_action_refresh;
99
public static String AbapGitView_action_copy;
10+
public static String AbapGitView_action_showMyRepos;
1011
public static String AbapGitView_action_pull;
1112
public static String AbapGitView_column_branch;
1213
public static String AbapGitView_column_firstcommitat;
@@ -30,6 +31,8 @@ public class Messages extends NLS {
3031
public static String AbapGitWizard_task_cloning_repository;
3132
public static String AbapGitWizard_title;
3233
public static String AbapGitWizardPull_title;
34+
public static String AbapGitWizardPageBranchAndPackage_chbox_activate;
35+
public static String AbapGitWizardPageBranchAndPackage_chbox_activate_tooltip;
3336
public static String AbapGitWizardPageBranchAndPackage_btn_browse;
3437
public static String AbapGitWizardPageBranchAndPackage_combobox_branch_message;
3538
public static String AbapGitWizardPageBranchAndPackage_description;

org.abapgit.adt.ui/src/org/abapgit/adt/ui/internal/i18n/messages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
AbapGitView_action_clone=Clone a abapGit Repository
22
AbapGitView_action_refresh=Refresh
3+
AbapGitView_action_showMyRepos=My repositories
34
AbapGitView_action_copy=Copy to clipboard
45
AbapGitView_action_pull=Pull
56
AbapGitView_column_branch=Branch
@@ -24,6 +25,8 @@ AbapGitView_task_fetch_repos_error=Error fetching abapGit Repositories
2425
AbapGitWizard_task_cloning_repository=Cloning repository...
2526
AbapGitWizard_title=Clone abapGit Repository
2627
AbapGitWizardPull_title=Pull from abapGit Repository
28+
AbapGitWizardPageBranchAndPackage_chbox_activate=Try to activate
29+
AbapGitWizardPageBranchAndPackage_chbox_activate_tooltip=Try to activate all objects during import
2730
AbapGitWizardPageBranchAndPackage_btn_browse=Browse...
2831
AbapGitWizardPageBranchAndPackage_combobox_branch_message=Specify a branch
2932
AbapGitWizardPageBranchAndPackage_description=Select repository branch and target ABAP package

org.abapgit.adt.ui/src/org/abapgit/adt/ui/internal/views/AbapGitView.java

Lines changed: 140 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.eclipse.jface.operation.IRunnableWithProgress;
2929
import org.eclipse.jface.viewers.ArrayContentProvider;
3030
import org.eclipse.jface.viewers.ColumnLabelProvider;
31+
import org.eclipse.jface.viewers.DoubleClickEvent;
32+
import org.eclipse.jface.viewers.IDoubleClickListener;
3133
import org.eclipse.jface.viewers.ISelection;
3234
import org.eclipse.jface.viewers.IStructuredSelection;
3335
import org.eclipse.jface.viewers.ITableLabelProvider;
@@ -55,16 +57,22 @@
5557
import org.eclipse.ui.statushandlers.StatusManager;
5658

5759
import com.sap.adt.destinations.logon.AdtLogonServiceFactory;
60+
import com.sap.adt.destinations.model.IDestinationData;
5861
import com.sap.adt.destinations.ui.logon.AdtLogonServiceUIFactory;
5962
import com.sap.adt.project.ui.util.ProjectUtil;
63+
import com.sap.adt.tools.core.model.adtcore.IAdtObjectReference;
6064
import com.sap.adt.tools.core.project.AdtProjectServiceFactory;
65+
import com.sap.adt.tools.core.project.IAbapProject;
66+
import com.sap.adt.tools.core.ui.navigation.AdtNavigationServiceFactory;
67+
import com.sap.adt.tools.core.ui.packages.AdtPackageServiceUIFactory;
68+
import com.sap.adt.tools.core.ui.packages.IAdtPackageServiceUI;
6169

6270
public class AbapGitView extends ViewPart {
6371

6472
public static final String ID = "org.abapgit.adt.ui.views.AbapGitView"; //$NON-NLS-1$
6573

6674
private TableViewer viewer;
67-
private Action actionRefresh, actionWizard, actionCopy;
75+
private Action actionRefresh, actionWizard, actionCopy, actionShowMyRepos;
6876
private ISelection lastSelection;
6977
private IProject lastProject;
7078

@@ -117,7 +125,7 @@ private void showLastSelectedElement() {
117125
IProject currentProject = ProjectUtil.getActiveAdtCoreProject(this.lastSelection, null, null, null);
118126
if (currentProject != this.lastProject) {
119127
this.lastProject = currentProject;
120-
updateView(false);
128+
updateView(false, false);
121129
}
122130

123131
this.lastSelection = null;
@@ -152,7 +160,7 @@ public void createPartControl(Composite parent) {
152160
hookContextMenu();
153161
contributeToActionBars();
154162

155-
updateView(false);
163+
updateView(false, false);
156164

157165
// add listener for selections
158166
getSite().getPage().addPostSelectionListener(this.selectionListener);
@@ -239,13 +247,27 @@ public void menuAboutToShow(IMenuManager manager) {
239247
if (AbapGitView.this.viewer.getStructuredSelection().size() == 1) {
240248
Object firstElement = AbapGitView.this.viewer.getStructuredSelection().getFirstElement();
241249
if (firstElement instanceof IRepository) {
242-
if (((IRepository) firstElement).getLink(IRepositoryService.RELATION_PULL) != null) {
243-
manager.add(AbapGitView.this.actionPullWizard);
244-
manager.add(new Separator());
245-
}
250+
251+
//Check if repos are created by current user
252+
// String destinationId = getDestination(AbapGitView.this.lastProject);
253+
// IProject currProject = AdtProjectServiceFactory.createProjectService().findProject(destinationId);
254+
// IAbapProject currAbapProject = currProject.getAdapter(IAbapProject.class);
255+
// IDestinationData ProjectDestData = currAbapProject.getDestinationData();
256+
257+
// if ((((IRepository) firstElement).getCreatedBy().equalsIgnoreCase(ProjectDestData.getUser()))) {
258+
//
259+
// if (((IRepository) firstElement).getLink(IRepositoryService.RELATION_PULL) != null) {
260+
// manager.add(AbapGitView.this.actionPullWizard);
261+
// manager.add(new Separator());
262+
// }
263+
//
264+
// }
265+
246266
manager.add(AbapGitView.this.actionCopy);
267+
manager.add(new Separator());
247268
manager.add(new UnlinkAction(AbapGitView.this.lastProject, (IRepository) firstElement));
248269

270+
249271
}
250272
}
251273
}
@@ -257,20 +279,31 @@ public void menuAboutToShow(IMenuManager manager) {
257279
private void contributeToActionBars() {
258280
IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
259281
toolBarManager.add(this.actionRefresh);
282+
toolBarManager.add(this.actionShowMyRepos);
260283
toolBarManager.add(this.actionWizard);
261284
}
262285

263286
private void makeActions() {
264287
this.actionRefresh = new Action() {
265288
public void run() {
266-
updateView(true);
289+
updateView(true, false);
267290
}
268291
};
269292
this.actionRefresh.setText(Messages.AbapGitView_action_refresh);
270293
this.actionRefresh.setToolTipText(Messages.AbapGitView_action_refresh);
271294
this.actionRefresh
272295
.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(AbapGitUIPlugin.PLUGIN_ID, "icons/etool/refresh.png")); //$NON-NLS-1$
273296

297+
this.actionShowMyRepos = new Action() {
298+
public void run() {
299+
updateView(true, true);
300+
}
301+
};
302+
this.actionShowMyRepos.setText(Messages.AbapGitView_action_showMyRepos);
303+
this.actionShowMyRepos.setToolTipText(Messages.AbapGitView_action_showMyRepos);
304+
this.actionShowMyRepos
305+
.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_HOME_NAV));
306+
274307
this.actionCopy = new Action() {
275308
public void run() {
276309
copy();
@@ -282,9 +315,6 @@ public void run() {
282315
this.actionCopy.setAccelerator(SWT.ALT | 'C');
283316
this.actionCopy.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
284317

285-
// this.actionCopy
286-
// .setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(AbapGitUIPlugin.PLUGIN_ID, "icons/etool/refresh.png")); //$NON-NLS-1$
287-
288318
this.actionWizard = new Action() {
289319
public void run() {
290320
if (!AdtLogonServiceUIFactory.createLogonServiceUI().ensureLoggedOn(AbapGitView.this.lastProject).isOK()) {
@@ -294,7 +324,7 @@ public void run() {
294324
new AbapGitWizard(AbapGitView.this.lastProject));
295325

296326
wizardDialog.open();
297-
updateView(true);
327+
updateView(true, false);
298328
}
299329
};
300330
this.actionWizard.setText(Messages.AbapGitView_action_clone);
@@ -322,16 +352,17 @@ public void run() {
322352
wizardDialog.open();
323353

324354
}
325-
updateView(true);
355+
updateView(true, false);
326356
}
327357
};
328358
this.actionPullWizard.setText(Messages.AbapGitView_context_pull);
329359
// this.actionPullWizard
330360
// .setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED));
331361
}
332362

333-
private List<IRepository> getRepositories(String destinationId) {
363+
private List<IRepository> getRepositories(String destinationId, Boolean byCurrUser) {
334364
List<IRepository> repos = new LinkedList<>();
365+
List<IRepository> myrepos = new LinkedList<>();
335366
boolean[] isSupported = new boolean[1];
336367
try {
337368
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
@@ -344,7 +375,27 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException, Inte
344375
return;
345376
}
346377
isSupported[0] = true;
378+
347379
repos.addAll(repoService.getRepositories(monitor).getRepositories());
380+
381+
if (byCurrUser) {
382+
//Check if repos are created by current user
383+
IProject currProject = AdtProjectServiceFactory.createProjectService().findProject(destinationId);
384+
IAbapProject currAbapProject = currProject.getAdapter(IAbapProject.class);
385+
IDestinationData ProjectDestData = currAbapProject.getDestinationData();
386+
387+
for (IRepository r : repos) {
388+
if (r.getCreatedBy().equalsIgnoreCase(ProjectDestData.getUser())) {
389+
myrepos.add(r);
390+
}
391+
}
392+
}
393+
394+
if (!myrepos.isEmpty()) {
395+
repos.clear();
396+
repos.addAll(myrepos);
397+
}
398+
348399
}
349400
});
350401

@@ -364,7 +415,7 @@ private static String getDestination(IProject project) {
364415
return AdtProjectServiceFactory.createProjectService().getDestinationId(project);
365416
}
366417

367-
private void updateView(boolean ensureLogon) {
418+
private void updateView(boolean ensureLogon, boolean byCurrUser) {
368419
if (this.lastProject == null) {
369420
setContentDescription(Messages.AbapGitView_no_abap_project);
370421
setControlsEnabled(false);
@@ -381,7 +432,11 @@ private void updateView(boolean ensureLogon) {
381432
return;
382433
}
383434

384-
List<IRepository> repos = getRepositories(destinationId);
435+
List<IRepository> repos = getRepositories(destinationId, false);
436+
437+
if (byCurrUser) {
438+
repos = getRepositories(destinationId, true);
439+
}
385440

386441
if (repos != null) {
387442
setContentDescription(NLS.bind(Messages.AbapGitView_repos_in_project, this.lastProject.getName()));
@@ -392,11 +447,79 @@ private void updateView(boolean ensureLogon) {
392447
setControlsEnabled(false);
393448
this.viewer.setInput(null);
394449
}
450+
451+
this.viewer.addDoubleClickListener(new IDoubleClickListener() {
452+
453+
@Override
454+
public void doubleClick(DoubleClickEvent event) {
455+
456+
IRepository currRepository;
457+
// IWorkbenchPage page = getSite().getPage();
458+
// IViewPart view = page.findView(IPageLayout.ID_PROJECT_EXPLORER);
459+
currRepository = null;
460+
461+
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
462+
463+
Object firstElement = selection.getFirstElement();
464+
if (firstElement instanceof IRepository) {
465+
currRepository = ((IRepository) firstElement);
466+
}
467+
468+
if (currRepository != null) {
469+
470+
IAdtPackageServiceUI packageServiceUI = AdtPackageServiceUIFactory.getOrCreateAdtPackageServiceUI();
471+
List<IAdtObjectReference> pkgRefs = packageServiceUI.find(destinationId, currRepository.getPackage(), null);
472+
IProject currProject = AbapGitView.this.lastProject; //AdtProjectServiceFactory.createProjectService().findProject(destinationId);
473+
if (!pkgRefs.isEmpty()) {
474+
IAdtObjectReference gitPackageRef = pkgRefs.stream().findFirst().get();
475+
if (gitPackageRef != null) {
476+
AdtNavigationServiceFactory.createNavigationService().navigate(currProject, gitPackageRef, true);
477+
}
478+
}
479+
480+
// IWorkbenchPart workbenchPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
481+
// IFile file = workbenchPart.getSite().getPage().getActiveEditor().getEditorInput().getAdapter(IFile.class);
482+
// if (file == null) {
483+
// System.out.println("FileNotFoundException");
484+
// }
485+
// expandProjectExlorer(file);
486+
487+
}
488+
489+
}
490+
});
395491
}
396492

493+
// public void expandProjectExlorer(IFile file) {
494+
// if (file == null) {
495+
// return;
496+
// }
497+
// try {
498+
// IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage();
499+
// IViewPart view = page.showView(IPageLayout.ID_PROJECT_EXPLORER);
500+
// if (view instanceof ISetSelectionTarget) {
501+
//
502+
// AbapGitView.this.viewer.getControl().getShell().getDisplay().asyncExec(new Runnable() {
503+
// @Override
504+
// public void run() {
505+
//
506+
// ISelection selection = new StructuredSelection(file);
507+
//
508+
// System.out.println(selection);
509+
// ((ISetSelectionTarget) view).selectReveal(selection);
510+
// }
511+
// });
512+
//
513+
// }
514+
// } catch (PartInitException e) {
515+
// System.out.println(e.getMessage());
516+
// }
517+
// }
518+
397519
private void setControlsEnabled(boolean enabled) {
398520
this.viewer.getControl().setEnabled(enabled);
399521
this.actionRefresh.setEnabled(enabled);
522+
this.actionShowMyRepos.setEnabled(enabled);
400523
this.actionWizard.setEnabled(enabled);
401524
this.actionCopy.setEnabled(enabled);
402525
}
@@ -479,7 +602,7 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException, Inte
479602
.unlinkRepository(UnlinkAction.this.repository.getKey(), monitor);
480603
}
481604
});
482-
updateView(true);
605+
updateView(true, false);
483606
} catch (InvocationTargetException e) {
484607
StatusManager.getManager().handle(new Status(IStatus.ERROR, AbapGitUIPlugin.PLUGIN_ID,
485608
Messages.AbapGitView_context_unlink_error, e.getTargetException()), StatusManager.SHOW);

org.abapgit.adt.ui/src/org/abapgit/adt/ui/internal/wizards/AbapGitWizardPageBranchAndPackage.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class AbapGitWizardPageBranchAndPackage extends WizardPage {
4040
private final String destination;
4141
private final CloneData cloneData;
4242

43+
// private Button checkbox_Tta;
4344
private TextViewer txtPackage;
4445
private ComboViewer comboBranches;
4546

@@ -121,6 +122,25 @@ public void widgetSelected(SelectionEvent e) {
121122
}
122123
});
123124

125+
// /////// CHECKBOX Try to Activate
126+
// Label lblTta = new Label(container, SWT.NONE);
127+
// lblTta.setText(Messages.AbapGitWizardPageBranchAndPackage_chbox_activate);
128+
// lblTta.setToolTipText(Messages.AbapGitWizardPageBranchAndPackage_chbox_activate_tooltip);
129+
// GridDataFactory.swtDefaults().applyTo(lblTta);
130+
//
131+
//
132+
// this.checkbox_Tta = new Button(container, SWT.CHECK);
133+
// GridDataFactory.swtDefaults().applyTo(this.checkbox_Tta);
134+
//
135+
// this.checkbox_Tta.addSelectionListener(new SelectionAdapter() {
136+
//
137+
// @Override
138+
// public void widgetSelected(SelectionEvent event) {
139+
// Button chbox = (Button) event.getSource();
140+
// System.out.println(chbox.getSelection());
141+
// }
142+
// });
143+
124144
setControl(container);
125145

126146
validateClientOnly();

0 commit comments

Comments
 (0)