Skip to content

Commit 4a621ea

Browse files
committed
New design changes
1 parent a2ce293 commit 4a621ea

File tree

6 files changed

+93
-117
lines changed

6 files changed

+93
-117
lines changed

debug/org.eclipse.debug.ui/plugin.properties

+1
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,4 @@ GroupLaunch.description=Launch several other configurations sequentially
419419

420420
prototype.decorator.label = Prototype Decorator
421421
breakpointLabel.label=Label
422+
breakpointLabel.tooltip=Provide a custom label to quickly identify breakpoint

debug/org.eclipse.debug.ui/plugin.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,7 @@
15431543
<action
15441544
label="%breakpointLabel.label"
15451545
icon="$nl$/icons/full/elcl16/bp_label.png"
1546-
helpContextId="remove_breakpoint_action_context"
1546+
tooltip="%breakpointLabel.tooltip"
15471547
class="org.eclipse.debug.internal.ui.actions.breakpoints.BreakpointLabelAction"
15481548
menubarPath="breakpointGroup"
15491549
enablesFor="1"

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java

-2
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,6 @@ public class ActionMessages extends NLS {
252252
public static String EnableAllBreakpointsAction_0;
253253
public static String EnableAllBreakpointsAction_1;
254254
public static String EnableAllBreakpointsAction_3;
255-
public static String BreakpointLabelTitle;
256255
public static String BreakpointLabelDialog;
257-
public static String BreakpointLabelClear;
258256

259257
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties

+1-3
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,4 @@ VirtualFindAction_1=Unable to locate {0} in viewer
236236

237237
ToggleBreakpointsTargetManager_defaultToggleTarget_name = Default
238238
ToggleBreakpointsTargetManager_defaultToggleTarget_description = Default
239-
BreakpointLabelTitle=Set Breakpoint Label
240-
BreakpointLabelDialog=Provide a custom label, or blank for the default label
241-
BreakpointLabelClear=Clear
239+
BreakpointLabelDialog=Provide a custom label, or blank for the default label

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/BreakpointLabelAction.java

+89-101
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,32 @@
1717
import org.eclipse.debug.core.model.Breakpoint;
1818
import org.eclipse.debug.internal.ui.DebugUIPlugin;
1919
import org.eclipse.debug.internal.ui.actions.ActionMessages;
20+
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
21+
import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView;
22+
import org.eclipse.debug.ui.IDebugUIConstants;
2023
import org.eclipse.jface.action.IAction;
21-
import org.eclipse.jface.dialogs.Dialog;
22-
import org.eclipse.jface.dialogs.IDialogConstants;
2324
import org.eclipse.jface.viewers.ISelection;
2425
import org.eclipse.jface.viewers.IStructuredSelection;
25-
import org.eclipse.jface.window.Window;
26+
import org.eclipse.jface.viewers.TreeSelection;
2627
import org.eclipse.swt.SWT;
27-
import org.eclipse.swt.events.SelectionAdapter;
28-
import org.eclipse.swt.events.SelectionEvent;
29-
import org.eclipse.swt.layout.GridData;
30-
import org.eclipse.swt.widgets.Button;
31-
import org.eclipse.swt.widgets.Composite;
32-
import org.eclipse.swt.widgets.Control;
28+
import org.eclipse.swt.events.KeyAdapter;
29+
import org.eclipse.swt.events.KeyEvent;
30+
import org.eclipse.swt.graphics.Font;
31+
import org.eclipse.swt.graphics.GC;
32+
import org.eclipse.swt.graphics.Point;
33+
import org.eclipse.swt.graphics.Rectangle;
3334
import org.eclipse.swt.widgets.Label;
34-
import org.eclipse.swt.widgets.Shell;
3535
import org.eclipse.swt.widgets.Text;
36+
import org.eclipse.swt.widgets.TreeItem;
37+
import org.eclipse.swt.widgets.Widget;
3638
import org.eclipse.ui.IViewActionDelegate;
3739
import org.eclipse.ui.IViewPart;
40+
import org.eclipse.ui.IWorkbenchPage;
41+
import org.eclipse.ui.PlatformUI;
3842

3943
public class BreakpointLabelAction implements IViewActionDelegate {
4044

4145
private IViewPart fView;
42-
4346
protected IViewPart getView() {
4447
return fView;
4548
}
@@ -50,26 +53,85 @@ protected void setView(IViewPart view) {
5053

5154
@Override
5255
public void run(IAction action) {
56+
String emptyString = ""; //$NON-NLS-1$
5357
IStructuredSelection selection = getSelection();
54-
if (selection.getFirstElement() instanceof Breakpoint bp) {
55-
String label = askForLabel(bp);
56-
if (label == null) {
57-
return;
58-
}
59-
if (!label.isEmpty()) {
60-
try {
61-
bp.setBreakpointLabel(label);
62-
} catch (CoreException e) {
63-
DebugUIPlugin.log(e);
64-
}
65-
} else {
66-
try {
67-
bp.setBreakpointLabel(""); //$NON-NLS-1$
68-
} catch (CoreException e) {
69-
DebugUIPlugin.log(e);
58+
59+
if (selection instanceof TreeSelection treeSelect && selection.getFirstElement() instanceof Breakpoint breakpoint) {
60+
if (treeSelect.size() == 1) {
61+
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
62+
IViewPart viewPart = page.findView(IDebugUIConstants.ID_BREAKPOINT_VIEW);
63+
if (viewPart instanceof BreakpointsView breakpointView) {
64+
TreeModelViewer treeViewer = breakpointView.getTreeModelViewer();
65+
Widget item = treeViewer.findItem(treeSelect.getPaths()[0]);
66+
if (item instanceof TreeItem tree) {
67+
String current = tree.getText();
68+
Rectangle bounds;
69+
try {
70+
bounds = tree.getBounds();
71+
} catch (ArrayIndexOutOfBoundsException e) { // TreeItem having FontData [Breakpoints having
72+
// custom label]
73+
tree.setFont(null);
74+
GC gc = new GC(tree.getParent());
75+
Font currentFont = gc.getFont();
76+
gc.setFont(currentFont);
77+
Point textWidth = gc.textExtent(tree.getText());
78+
gc.dispose();
79+
bounds = tree.getBounds(0);
80+
bounds.x = bounds.x + 10;
81+
bounds.width = textWidth.x + 20;
82+
83+
}
84+
Label label = new Label(tree.getParent(), SWT.WRAP);
85+
label.setText(ActionMessages.BreakpointLabelDialog);
86+
label.setBounds(bounds.x, bounds.y - 20, label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
87+
label.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
88+
89+
Text inlineEditor = new Text(tree.getParent(), SWT.BORDER);
90+
inlineEditor.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
91+
inlineEditor.setText(current);
92+
inlineEditor.setFocus();
93+
94+
inlineEditor.addListener(SWT.FocusOut, event -> {
95+
tree.setText(current);
96+
label.dispose();
97+
inlineEditor.dispose();
98+
99+
});
100+
inlineEditor.addKeyListener(new KeyAdapter() {
101+
@Override
102+
public void keyPressed(KeyEvent e) {
103+
if (e.keyCode == SWT.ESC) {
104+
tree.setText(current);
105+
inlineEditor.dispose();
106+
label.dispose();
107+
} else if (e.keyCode == SWT.CR) {
108+
String newLabel = inlineEditor.getText();
109+
if (!newLabel.isEmpty() && !newLabel.equals(current)) {
110+
try {
111+
breakpoint.setBreakpointLabel(newLabel);
112+
} catch (CoreException e1) {
113+
DebugUIPlugin.log(e1);
114+
}
115+
} else if (newLabel.isEmpty()) {
116+
try {
117+
breakpoint.setBreakpointLabel(emptyString); // Set to default
118+
} catch (CoreException e2) {
119+
DebugUIPlugin.log(e2);
120+
}
121+
}
122+
inlineEditor.dispose();
123+
label.dispose();
124+
}
125+
}
126+
});
127+
tree.setText(emptyString);
128+
129+
}
130+
70131
}
71132
}
72133
}
134+
73135
}
74136

75137
protected IStructuredSelection getSelection() {
@@ -85,78 +147,4 @@ public void init(IViewPart view) {
85147
setView(view);
86148
}
87149

88-
private String askForLabel(Breakpoint breakpoint) {
89-
String current = breakpoint.getBreakpointLabel();
90-
91-
class BreakpointLabelBox extends Dialog {
92-
private Text textInput;
93-
private String value;
94-
private Button clearButton;
95-
private String initialLabel;
96-
97-
protected BreakpointLabelBox(Shell parentShell, String intialValue) {
98-
super(parentShell);
99-
initialLabel = intialValue;
100-
}
101-
@Override
102-
protected Control createDialogArea(Composite parent) {
103-
Composite composite = (Composite) super.createDialogArea(parent);
104-
Label label = new Label(composite, SWT.WRAP);
105-
label.setText(ActionMessages.BreakpointLabelDialog);
106-
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
107-
| GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
108-
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
109-
label.setLayoutData(data);
110-
label.setFont(parent.getFont());
111-
textInput = new Text(composite, SWT.SINGLE | SWT.BORDER);
112-
textInput.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
113-
textInput.setText(initialLabel);
114-
applyDialogFont(composite);
115-
return composite;
116-
}
117-
118-
@Override
119-
protected void configureShell(Shell newShell) {
120-
super.configureShell(newShell);
121-
newShell.setText(ActionMessages.BreakpointLabelTitle);
122-
123-
}
124-
125-
@Override
126-
protected void createButtonsForButtonBar(Composite parent) {
127-
super.createButtonsForButtonBar(parent);
128-
clearButton = createButton(parent, IDialogConstants.BACK_ID, ActionMessages.BreakpointLabelClear,
129-
false);
130-
clearButton.addSelectionListener(new SelectionAdapter() {
131-
@Override
132-
public void widgetSelected(SelectionEvent e) {
133-
textInput.setText(""); //$NON-NLS-1$
134-
135-
}
136-
});
137-
}
138-
139-
@Override
140-
protected void buttonPressed(int buttonId) {
141-
if (buttonId == IDialogConstants.OK_ID) {
142-
value = textInput.getText();
143-
} else {
144-
value = null;
145-
}
146-
super.buttonPressed(buttonId);
147-
}
148-
private String getInput() {
149-
return value;
150-
}
151-
152-
}
153-
BreakpointLabelBox dialog = new BreakpointLabelBox(fView.getSite().getShell(), current);
154-
155-
if (dialog.open() != Window.OK) {
156-
return null;
157-
}
158-
String data = dialog.getInput();
159-
return data.trim();
160-
}
161-
162150
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointLabelProvider.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,9 @@ public class BreakpointLabelProvider extends DebugElementLabelProvider {
3333
protected String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId, int columnIndex) throws CoreException {
3434
if (columnIndex == 0) {
3535
if (elementPath.getFirstSegment() instanceof Breakpoint breakpoint) {
36-
String current = super.getLabel(elementPath, presentationContext, columnId, columnIndex);
3736
if (!breakpoint.getBreakpointLabel().isEmpty()) {
38-
String[] currentElements = current.split(" "); //$NON-NLS-1$
39-
if (current.contains("line")) { //$NON-NLS-1$
40-
41-
return currentElements[0] + currentElements[1] + currentElements[2] + " " //$NON-NLS-1$
42-
+ breakpoint.getBreakpointLabel();
43-
}
44-
return currentElements[0] + " " //$NON-NLS-1$
45-
+ breakpoint.getBreakpointLabel();
37+
return breakpoint.getBreakpointLabel();
4638
}
47-
4839
}
4940
return super.getLabel(elementPath, presentationContext, columnId, columnIndex);
5041
} else {

0 commit comments

Comments
 (0)