mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Bug 567336 - Allow double-click on elements in Source Location and Output Location tab
Change-Id: Ifed7b5d005977db30f3c9ba4c7dc6a366691df53 Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
This commit is contained in:
parent
cb8e2c6887
commit
7a938095be
1 changed files with 40 additions and 19 deletions
|
@ -19,6 +19,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
@ -45,6 +46,8 @@ import org.eclipse.jface.viewers.Viewer;
|
|||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
@ -144,6 +147,15 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
|
|||
updateButtons();
|
||||
}
|
||||
});
|
||||
tree.getTree().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDoubleClick(MouseEvent e) {
|
||||
TreeItem[] sel = tree.getTree().getSelection();
|
||||
Optional<_Entry> entry = getSelectedEntry(sel);
|
||||
if (entry.isPresent())
|
||||
handleEditEntry(entry.get());
|
||||
}
|
||||
});
|
||||
|
||||
initButtons(new String[] { Messages.CLocationTab_4, Messages.CLocationTab_5, Messages.CLocationTab_6,
|
||||
Messages.CLocationTab_7 }, 150);
|
||||
|
@ -237,25 +249,9 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
|
|||
break;
|
||||
// edit filter
|
||||
case 2:
|
||||
if (sel.length == 0)
|
||||
return;
|
||||
Object data = sel[0].getData();
|
||||
_Entry entry = null;
|
||||
if (data instanceof _Entry)
|
||||
entry = (_Entry) data;
|
||||
else if (data instanceof _Filter)
|
||||
entry = ((_Filter) data).entry;
|
||||
else
|
||||
return;
|
||||
ExPatternDialog dialog = new ExPatternDialog(usercomp.getShell(), entry.ent.getExclusionPatterns(),
|
||||
entry.getPath(), page.getProject());
|
||||
if (dialog.open() == Window.OK) {
|
||||
IPath[] ps = dialog.getExclusionPattern();
|
||||
IPath path = entry.getPath();
|
||||
boolean isWsp = entry.ent.isValueWorkspacePath();
|
||||
entry.ent = newEntry(path, ps, isWsp);
|
||||
saveData();
|
||||
}
|
||||
Optional<_Entry> entry = getSelectedEntry(sel);
|
||||
if (entry.isPresent())
|
||||
handleEditEntry(entry.get());
|
||||
break;
|
||||
case 3:
|
||||
if (sel.length == 0)
|
||||
|
@ -271,6 +267,31 @@ public abstract class CLocationTab extends AbstractCPropertyTab {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleEditEntry(_Entry entry) {
|
||||
ExPatternDialog dialog = new ExPatternDialog(usercomp.getShell(), entry.ent.getExclusionPatterns(),
|
||||
entry.getPath(), page.getProject());
|
||||
if (dialog.open() == Window.OK) {
|
||||
IPath[] ps = dialog.getExclusionPattern();
|
||||
IPath path = entry.getPath();
|
||||
boolean isWsp = entry.ent.isValueWorkspacePath();
|
||||
entry.ent = newEntry(path, ps, isWsp);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<_Entry> getSelectedEntry(TreeItem[] sel) {
|
||||
if (sel.length == 0)
|
||||
return Optional.empty();
|
||||
Object data = sel[0].getData();
|
||||
_Entry entry = null;
|
||||
if (data instanceof _Entry)
|
||||
entry = (_Entry) data;
|
||||
else if (data instanceof _Filter)
|
||||
entry = ((_Filter) data).entry;
|
||||
|
||||
return Optional.ofNullable(entry);
|
||||
}
|
||||
|
||||
private void saveData() {
|
||||
ICExclusionPatternPathEntry[] p = new ICExclusionPatternPathEntry[src.size()];
|
||||
Iterator<_Entry> it = src.iterator();
|
||||
|
|
Loading…
Add table
Reference in a new issue