Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,32 @@
import org.abapgit.adt.backend.IObject;
import org.abapgit.adt.backend.IRepository;
import org.abapgit.adt.ui.internal.i18n.Messages;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.RowLayoutFactory;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
Expand All @@ -46,7 +54,7 @@ public class AbapGitDialogObjLog extends TitleAreaDialog {
private final Image errorImage;
private final Image successImage;
private final Image infoImage;
// private final Image blankImage;
private Action actionCopy;
private final static String ERROR_FLAG = "E"; //$NON-NLS-1$
private final static String WARNING_FLAG = "W"; //$NON-NLS-1$
private final static String INFO_FLAG = "I"; //$NON-NLS-1$
Expand All @@ -62,7 +70,6 @@ public AbapGitDialogObjLog(Shell parentShell, List<IObject> pullObjects, IReposi
this.errorImage = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/obj16/error_tsk.png").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
this.successImage = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/obj16/activity.png").createImage(); //$NON-NLS-1$//$NON-NLS-2$
this.infoImage = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/obj16/info_tsk.png").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
// this.blankImage = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/obj16/blank.png").createImage(); //$NON-NLS-1$ //$NON-NLS-2$

}

Expand Down Expand Up @@ -120,7 +127,6 @@ protected boolean isParentMatch(Viewer viewer, Object element) {
};

ToolItem expandAllToolItem = new ToolItem(bar, SWT.PUSH | SWT.FLAT);
// expandAllToolItem.setText(Messages.AbapGitDialogPageObjLog_filter_expand_all);
expandAllToolItem.setToolTipText(Messages.AbapGitDialogPageObjLog_filter_expand_all_tooltip);
expandAllToolItem
.setImage(AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/elcl16/expandall.png").createImage()); //$NON-NLS-1$ //$NON-NLS-2$
Expand All @@ -134,7 +140,6 @@ public void widgetSelected(SelectionEvent e) {
});

ToolItem collapseAllToolItem = new ToolItem(bar, SWT.PUSH | SWT.FLAT);
// collapseAllToolItem.setText(Messages.AbapGitDialogPageObjLog_filter_collapse_all);
collapseAllToolItem.setToolTipText(Messages.AbapGitDialogPageObjLog_filter_collapse_all_tooltip);
collapseAllToolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_COLLAPSEALL));
collapseAllToolItem.addSelectionListener(new SelectionAdapter() {
Expand All @@ -147,7 +152,6 @@ public void widgetSelected(SelectionEvent e) {
});

ToolItem filterErrorToolItem = new ToolItem(bar, SWT.PUSH | SWT.FLAT);
// filterErrorToolItem.setText(Messages.AbapGitDialogPageObjLog_filter_error);
filterErrorToolItem.setToolTipText(Messages.AbapGitDialogPageObjLog_filter_error_tooltip);
filterErrorToolItem.setImage(this.errorImage);
filterErrorToolItem.addSelectionListener(new SelectionAdapter() {
Expand All @@ -159,7 +163,6 @@ public void widgetSelected(SelectionEvent e) {
});

ToolItem filterWarningToolItem = new ToolItem(bar, SWT.PUSH | SWT.FLAT);
// filterWarningToolItem.setText(Messages.AbapGitDialogPageObjLog_filter_warning);
filterWarningToolItem.setToolTipText(Messages.AbapGitDialogPageObjLog_filter_warning_tooltip);
filterWarningToolItem.setImage(this.warningImage);
filterWarningToolItem.addSelectionListener(new SelectionAdapter() {
Expand All @@ -171,7 +174,6 @@ public void widgetSelected(SelectionEvent e) {
});

ToolItem filterAllToolItem = new ToolItem(bar, SWT.PUSH | SWT.FLAT);
// filterAllToolItem.setText(Messages.AbapGitDialogPageObjLog_filter_all);
filterAllToolItem.setToolTipText(Messages.AbapGitDialogPageObjLog_filter_all_tooltip);
filterAllToolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE));
filterAllToolItem.addSelectionListener(new SelectionAdapter() {
Expand Down Expand Up @@ -199,6 +201,10 @@ public void widgetSelected(SelectionEvent e) {

this.abapObjTable.setInput(this.abapObjects);


makeActions();
// hookContextMenu();

return parent;
}

Expand Down Expand Up @@ -227,42 +233,7 @@ public String getText(Object element) {
return result;
}
});

// createTableViewerColumn(Messages.AbapGitDialogImport_column_obj_status, 50).setLabelProvider(new ColumnLabelProvider() {
// @Override
// public String getText(Object element) {
// return null;
// }
//
// @Override
// public Image getImage(Object element) {
// IObject p = (IObject) element;
// String objStatus = p.getObjStatus();
//
// if (objStatus != null && objStatus.equals("W")) { //$NON-NLS-1$
// return AbapGitDialogObjLog.this.warningImage;
// }
//
// if (objStatus != null && objStatus.equals("E")) { //$NON-NLS-1$
// return AbapGitDialogObjLog.this.errorImage;
// }
//
// if (objStatus != null && objStatus.equals("A")) { //$NON-NLS-1$
// return AbapGitDialogObjLog.this.stopImage;
// }
//
// if (objStatus != null && objStatus.equals("S")) { //$NON-NLS-1$
// return AbapGitDialogObjLog.this.successImage;
// }
//
// if (objStatus != null && objStatus.equals("I")) { //$NON-NLS-1$
// return AbapGitDialogObjLog.this.infoImage;
// }
//
// return AbapGitDialogObjLog.this.blankImage;
// }
//
// });
hookContextMenu(this.abapObjTable);

createTableViewerColumn(Messages.AbapGitDialogImport_column_msg_type, 200).setLabelProvider(new ColumnLabelProvider() {
@Override
Expand Down Expand Up @@ -377,6 +348,45 @@ private TreeViewerColumn createTableViewerColumn(String title, int bound) {
return viewerColumn;
}

private void hookContextMenu(TreeViewer treeViewer) {
final MenuManager menuManager = new MenuManager("#PopupMenu"); //$NON-NLS-1$
menuManager.setRemoveAllWhenShown(true);

Menu menu = menuManager.createContextMenu(treeViewer.getTree());
treeViewer.getTree().setMenu(menu);

menuManager.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
fillContextMenu(manager);
}

private void fillContextMenu(IMenuManager manager) {

IStructuredSelection selection = (IStructuredSelection) AbapGitDialogObjLog.this.tree.getViewer().getSelection();
if (selection.size() != 1) {
return;
}
menuManager.add(AbapGitDialogObjLog.this.actionCopy);

}
});

}

private void makeActions() {
this.actionCopy = new Action() {
public void run() {
copy();
}
};
this.actionCopy.setText(Messages.AbapGitView_action_copy);
this.actionCopy.setToolTipText(Messages.AbapGitView_action_copy);

this.actionCopy.setAccelerator(SWT.ALT | 'C');
this.actionCopy.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
}

@Override
protected boolean isResizable() {
return true;
Expand All @@ -387,8 +397,30 @@ protected void okPressed() {
super.okPressed();
}

/**
* Copies the current selection to the clipboard.
*
* @param table
* the data source
*/
protected void copy() {

Object firstElement = AbapGitDialogObjLog.this.tree.getViewer().getStructuredSelection().getFirstElement();
final StringBuilder data = new StringBuilder();

IObject selectedAbapObj = (IObject) firstElement;
data.append(selectedAbapObj.getObjName() + " | " + selectedAbapObj.getObjType() + " | " + selectedAbapObj.getMsgType() + " | " //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ selectedAbapObj.getMsgText());

final Clipboard clipboard = new Clipboard(AbapGitDialogObjLog.this.tree.getViewer().getControl().getDisplay());
clipboard.setContents(new String[] { data.toString() }, new TextTransfer[] { TextTransfer.getInstance() });
clipboard.dispose();

}

}


class ObjectTreeContentProvider implements ITreeContentProvider {

public String filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public class Messages extends NLS {
public static String AbapGitView_repos_not_loaded;
public static String AbapGitView_task_fetch_repos;
public static String AbapGitView_task_fetch_repos_error;
public static String AbapGitView_ConfDialog_title;
public static String AbapGitView_ConfDialog_MsgText;
public static String AbapGitView_ConfDialog_Btn_confirm;
public static String AbapGitView_ConfDialog_Btn_cancel;
public static String AbapGitWizard_task_cloning_repository;
public static String AbapGitWizard_task_pulling_repository;
public static String AbapGitWizard_title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ AbapGitView_repos_in_project=abapGit repositories in project {0}\:
AbapGitView_repos_not_loaded=abapGit repositories in project {0} are not loaded, yet. Press 'Refresh' to load the repository list.
AbapGitView_task_fetch_repos=Fetching abapGit Repositories
AbapGitView_task_fetch_repos_error=Error fetching abapGit Repositories
AbapGitView_ConfDialog_title=Confirm pull action
AbapGitView_ConfDialog_MsgText=Attention: Local changes will be overwritten, please confirm by clicking on Continue.
AbapGitView_ConfDialog_Btn_confirm=Continue
AbapGitView_ConfDialog_Btn_cancel=Cancel
AbapGitWizard_task_cloning_repository=Linking repository...
AbapGitWizard_task_pulling_repository=Pulling from repository...
AbapGitWizard_title=Link abapGit Repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,16 @@ public void run() {

WizardDialog wizardDialog = new WizardDialog(AbapGitView.this.viewer.getControl().getShell(),
new AbapGitWizardPull(AbapGitView.this.lastProject, this.selRepo, allRepositories));
wizardDialog.open();

// customized MessageDialog with configured buttons
MessageDialog dialog = new MessageDialog(getSite().getShell(), Messages.AbapGitView_ConfDialog_title, null,
Messages.AbapGitView_ConfDialog_MsgText,
MessageDialog.CONFIRM,
new String[] { Messages.AbapGitView_ConfDialog_Btn_confirm, Messages.AbapGitView_ConfDialog_Btn_cancel }, 0);
int confirmResult = dialog.open();
if (confirmResult == 0) {
wizardDialog.open();
}

}

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.3</version>
<version>3.1.11</version>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>3.1.3</version>
<version>3.1.12</version>
</dependency>
</dependencies>
<executions>
Expand Down