Skip to content

Commit

Permalink
Fixed #740 - Process Method Editor - add delete all option
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Sep 16, 2021
1 parent 56dd7c2 commit e0fca17
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ public void removeProcessEntry(IProcessEntry processEntry) {
getEntries().remove(processEntry);
}

public void removeAllProcessEntries() {

getEntries().clear();
}

public boolean isReadOnly() {

return readOnly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class ProcessMethodToolbar extends ToolBar {
private ToolItem buttonAdd;
private ToolItem buttonCopy;
private ToolItem buttonRemove;
private ToolItem buttonRemoveAll;
private ToolItem buttonMoveUp;
private ToolItem buttonMoveDown;
private ToolItem buttonClipboard;
Expand Down Expand Up @@ -138,7 +139,9 @@ public void updateTableButtons() {
buttonAdd.setEnabled(isEditable);
//
IStructuredSelection selection = structuredViewer.getStructuredSelection();
boolean writeable = processMethod != null && !processMethod.isFinal() && !selection.isEmpty();
boolean canEdit = processMethod != null && !processMethod.isFinal();
boolean writeable = canEdit && !selection.isEmpty();
//
Iterator<?> iterator = selection.iterator();
while(iterator.hasNext() && writeable) {
Object object = iterator.next();
Expand All @@ -151,6 +154,7 @@ public void updateTableButtons() {
boolean readOnly = processMethod != null && (processMethod.isReadOnly() || this.readOnly);
buttonCopy.setEnabled(writeable && !readOnly);
buttonRemove.setEnabled(writeable && !readOnly);
buttonRemoveAll.setEnabled(canEdit && processMethod.getNumberOfEntries() > 0 && !readOnly);
buttonMoveUp.setEnabled(writeable && !readOnly);
buttonMoveDown.setEnabled(writeable && !readOnly);
buttonClipboard.setEnabled(true);
Expand Down Expand Up @@ -234,6 +238,7 @@ private void createControl() {

buttonAdd = createAddButton(this);
buttonRemove = createRemoveButton(this);
buttonRemoveAll = createRemoveAllButton(this);
buttonCopy = createCopyButton(this);
buttonMoveUp = createMoveUpButton(this);
buttonMoveDown = createMoveDownButton(this);
Expand Down Expand Up @@ -371,6 +376,26 @@ public void widgetSelected(SelectionEvent e) {
return item;
}

private ToolItem createRemoveAllButton(ToolBar toolBar) {

final ToolItem item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(ApplicationImageFactory.getInstance().getImage(IApplicationImage.IMAGE_DELETE_ALL, IApplicationImage.SIZE_16x16));
item.setToolTipText("Remove all process method(s).");
item.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {

if(MessageDialog.openQuestion(toolBar.getShell(), "Delete Process Method(s)", "Would you like to delete all processor(s)?")) {
processMethod.removeAllProcessEntries();
fireUpdate();
select(Collections.emptyList());
}
}
});
return item;
}

private ToolItem createCopyButton(ToolBar toolBar) {

final ToolItem item = new ToolItem(toolBar, SWT.PUSH);
Expand Down

0 comments on commit e0fca17

Please sign in to comment.