Skip to content

Commit 192d9ab

Browse files
committed
Fix before PR
1 parent c21748a commit 192d9ab

File tree

4 files changed

+78
-43
lines changed

4 files changed

+78
-43
lines changed

ui/org.eclipse.pde.spy.adapter/META-INF/MANIFEST.MF

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
3-
Bundle-Name: %Bundle-Name
3+
Bundle-Name: %name
44
Bundle-SymbolicName: org.eclipse.pde.spy.adapter;singleton:=true
55
Bundle-Version: 0.1.0.qualifier
66
Require-Bundle: org.eclipse.core.runtime,
@@ -17,6 +17,6 @@ Require-Bundle: org.eclipse.core.runtime,
1717
Bundle-RequiredExecutionEnvironment: JavaSE-11
1818
Automatic-Module-Name: org.eclipse.pde.spy.adapter
1919
Bundle-ActivationPolicy: lazy
20-
Bundle-Vendor: %Bundle-Vendor
20+
Bundle-Vendor: %provider-name
2121
Import-Package: jakarta.annotation;version="[2.1.0,3.0.0)",
2222
jakarta.inject;version="[2.0.0,3.0.0)"

ui/org.eclipse.pde.spy.adapter/OSGI-INF/l10n/bundle.properties

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
###############################################################################
2+
# Copyright (c) 2025, amelodev.
3+
#
4+
# This program and the accompanying materials
5+
# are made available under the terms of the Eclipse Public License 2.0
6+
# which accompanies this distribution, and is available at
7+
# https://www.eclipse.org/legal/epl-2.0/
8+
#
9+
# SPDX-License-Identifier: EPL-2.0
10+
#
11+
# Contributors:
12+
# Marc SAINT-PIERRE <[email protected]> - initial API and implementation
13+
###############################################################################
14+
#
15+
#
16+
name = Adapter Spy
17+
provider-name = Eclipse.org
18+
description = Adapter spy to display the adapter hierarchy

ui/org.eclipse.pde.spy.adapter/src/org/eclipse/pde/spy/adapter/AdapterSpyPart.java

Lines changed: 58 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
import org.eclipse.swt.widgets.Button;
5252
import org.eclipse.swt.widgets.Composite;
5353
import org.eclipse.swt.widgets.Text;
54-
import org.eclipse.swt.widgets.ToolBar;
55-
import org.eclipse.swt.widgets.ToolItem;
5654
import org.eclipse.swt.widgets.Tree;
5755

5856
import jakarta.annotation.PostConstruct;
@@ -74,8 +72,12 @@ public class AdapterSpyPart {
7472

7573
private static final String NAMED_UPDATE_TREE_SOURCE_TO_DESTINATION = "updateTreeSourceToDestination";
7674
private static final String NAMED_UPDATE_TREE_DESTINATION_TO_SOURCE = "updateTreeDestinationToSource";
77-
private static final String SWITCH_TO_SOURCE = "switch to Source Type first";
78-
private static final String SWITCH_TO_DESTINATION = "switch to Destination Type first";
75+
private static final String SOURCE_TYPE = "Source Type";
76+
private static final String DESTINATION_TYPE = "Destination Type";
77+
private static final String DISPLAY_SOURCE_TYPE = "Display " + SOURCE_TYPE;
78+
private static final String DISPLAY_DESTINATION_TYPE = "Display " + DESTINATION_TYPE;
79+
private static final String TOOLTIP_SOURCE_TYPE = "Display the source type first, and list\nall destination types derived from that source as child elements.";
80+
private static final String TOOLTIP_DESTINATION_TYPE = "Display the destination type first, and list\nall source types that can adapt to it as child elements.";
7981

8082
@Inject
8183
UISynchronize uisync;
@@ -288,7 +290,8 @@ private void createToolBarZone(Composite parent, ImageRegistry imgr) {
288290
comp.setLayout(new GridLayout(4, false));
289291

290292
Text filterText = new Text(comp, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
291-
GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).applyTo(filterText);
293+
GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).hint(250, SWT.DEFAULT).applyTo(filterText);
294+
292295
filterText.setMessage("Search data");
293296
filterText.setToolTipText("Find any element in tree");
294297

@@ -320,41 +323,58 @@ public void widgetSelected(SelectionEvent e) {
320323
}
321324
});
322325

326+
// --- Vertical radio buttons to choose display direction ---
327+
Composite radioGroup = new Composite(comp, SWT.NONE);
328+
radioGroup.setLayout(new GridLayout(1, false));
329+
330+
Button rbSource = new Button(radioGroup, SWT.RADIO);
331+
rbSource.setText(DISPLAY_SOURCE_TYPE);
332+
rbSource.setToolTipText(TOOLTIP_SOURCE_TYPE);
333+
334+
Button rbDestination = new Button(radioGroup, SWT.RADIO);
335+
rbDestination.setText(DISPLAY_DESTINATION_TYPE);
336+
rbDestination.setToolTipText(TOOLTIP_DESTINATION_TYPE);
337+
338+
rbSource.setSelection(sourceToDestination);
339+
rbDestination.setSelection(!sourceToDestination);
340+
341+
// Factorized refresh logic
342+
Runnable refreshView = () -> {
343+
FilterData fdata = getFilterData();
344+
fdata.setSourceToDestination(sourceToDestination);
345+
context.set(AdapterFilter.UPDATE_CTX_FILTER, fdata);
346+
347+
if (sourceToDestination) {
348+
sourceOrDestinationTvc.getColumn().setText(SOURCE_TYPE);
349+
context.set(NAMED_UPDATE_TREE_SOURCE_TO_DESTINATION, adapterRepo.getAdapters());
350+
} else {
351+
sourceOrDestinationTvc.getColumn().setText(DESTINATION_TYPE);
352+
context.set(NAMED_UPDATE_TREE_DESTINATION_TO_SOURCE, adapterRepo.revertSourceToType());
353+
}
354+
adapterTreeViewer.refresh(true);
355+
};
356+
357+
// Listeners
358+
rbSource.addSelectionListener(new SelectionAdapter() {
359+
@Override
360+
public void widgetSelected(SelectionEvent e) {
361+
if (rbSource.getSelection()) {
362+
sourceToDestination = true;
363+
refreshView.run();
364+
}
365+
}
366+
});
323367

324-
ToolBar toolBar = new ToolBar(comp, SWT.NONE);
325-
ToolItem switchButton = new ToolItem(toolBar, SWT.CHECK);
326-
switchButton.setImage(imgr.get(AdapterHelper.DESTINATION_TYPE_IMG_KEY));
327-
switchButton.setToolTipText(SWITCH_TO_DESTINATION);
328-
329-
// sourceToType event
330-
switchButton.addSelectionListener(new SelectionAdapter() {
331-
332-
@Override
333-
public void widgetSelected(SelectionEvent event) {
334-
Object source = event.getSource();
335-
if (source instanceof ToolItem) {
336-
FilterData fdata = getFilterData();
337-
sourceToDestination = !sourceToDestination;
338-
String tooltiptext = sourceToDestination ? SWITCH_TO_DESTINATION :SWITCH_TO_SOURCE;
339-
String imageKey = sourceToDestination ? AdapterHelper.DESTINATION_TYPE_IMG_KEY
340-
: AdapterHelper.SOURCE_TYPE_IMG_KEY;
341-
switchButton.setToolTipText(tooltiptext);
342-
switchButton.setImage(imgr.get(imageKey));
343-
344-
if (sourceToDestination) {
345-
sourceOrDestinationTvc.getColumn().setText("Source Type");
346-
context.set(NAMED_UPDATE_TREE_SOURCE_TO_DESTINATION, adapterRepo.getAdapters());
347-
} else {
348-
sourceOrDestinationTvc.getColumn().setText("Destination Type");
349-
context.set(NAMED_UPDATE_TREE_DESTINATION_TO_SOURCE, adapterRepo.revertSourceToType());
350-
}
351-
fdata.setSourceToDestination(sourceToDestination);
352-
context.set(AdapterFilter.UPDATE_CTX_FILTER, fdata);
353-
adapterTreeViewer.refresh(true);
354-
}
355-
356-
}
368+
rbDestination.addSelectionListener(new SelectionAdapter() {
369+
@Override
370+
public void widgetSelected(SelectionEvent e) {
371+
if (rbDestination.getSelection()) {
372+
sourceToDestination = false;
373+
refreshView.run();
374+
}
375+
}
357376
});
377+
358378
uisync.asyncExec(() -> comp.pack());
359379

360380
}

0 commit comments

Comments
 (0)