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 @@ -24,7 +24,10 @@
import java.util.List;
import java.util.Objects;

import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.value.IValueProperty;
import org.eclipse.core.resources.IProject;
Expand All @@ -42,6 +45,7 @@
import org.eclipse.e4.tools.services.IResourcePool;
import org.eclipse.e4.tools.services.impl.ResourceBundleTranslationProvider;
import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.MUILabel;
import org.eclipse.emf.databinding.EMFDataBindingContext;
Expand All @@ -51,6 +55,8 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.SWT;
Expand All @@ -59,12 +65,14 @@
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
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.Link;

import jakarta.annotation.PreDestroy;
import jakarta.inject.Inject;
Expand Down Expand Up @@ -295,7 +303,7 @@
URL url = null;

try {
final URL uri2url = new URL(uri);

Check warning on line 306 in e4tools/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/component/AbstractComponentEditor.java

View check run for this annotation

Jenkins - eclipse-pde / Compiler

Deprecation

NORMAL: The constructor URL(String) is deprecated since version 20
url = FileLocator.toFileURL(uri2url);
stream = url.openStream();
} catch (final IOException e) {
Expand All @@ -307,7 +315,7 @@
{
try {
// Try to get it using 'platform:/resource'
final URL resUrl = new URL(uri.replace("platform:/plugin", "platform:/resource")); //$NON-NLS-1$//$NON-NLS-2$

Check warning on line 318 in e4tools/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/component/AbstractComponentEditor.java

View check run for this annotation

Jenkins - eclipse-pde / Compiler

Deprecation

NORMAL: The constructor URL(String) is deprecated since version 20
url = FileLocator.toFileURL(resUrl);
stream = url.openStream();

Expand All @@ -316,7 +324,7 @@
// must use find on FileLocator which does not deal with
// platform:/resource !
try {
url = FileLocator.find(new URL(uri));

Check warning on line 327 in e4tools/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/component/AbstractComponentEditor.java

View check run for this annotation

Jenkins - eclipse-pde / Compiler

Deprecation

NORMAL: The constructor URL(String) is deprecated since version 20
stream = url != null ? url.openStream() : null;
} catch (final IOException ex) {
url = null;
Expand Down Expand Up @@ -499,6 +507,41 @@
}
}

/**
* Creates a {@link Link} linking to the {@link MCommand} observed by the given
* observable. If a command is present, the given text is displayed as a
* hyperlink.
*
* @param parent the parent composite
* @param text the text to display
* @param commandObservable the command observable
* @param context the data binding context
* @return the created link widget
*/
protected Link createCommandLink(Composite parent, String text, IObservableValue<MCommand> commandObservable,
EMFDataBindingContext context) {
Link link = new Link(parent, SWT.NONE);
link.setText(text);
ISWTObservableValue<String> textObservable = WidgetProperties.text().observeDelayed(200, link);
context.bindValue(textObservable, commandObservable, new UpdateValueStrategy<>(),
UpdateValueStrategy.create(new Converter<>(MCommand.class, String.class) {
@Override
public String convert(MCommand command) {
if (command != null) {
return "<A>" + text + "</A>"; //$NON-NLS-1$ //$NON-NLS-2$
Comment thread
r-mennig marked this conversation as resolved.
}
return text;
}
}));
link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
MCommand command = commandObservable.getValue();
if (command != null) {
getEditor().gotoEObject(ModelEditor.TAB_FORM, (EObject) command);
}
}));
return link;
Comment thread
r-mennig marked this conversation as resolved.
}

@PreDestroy
public void dispose() {
createdImages.stream().filter(Objects::nonNull).filter(i -> !i.isDisposed()).forEach(Image::dispose);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;

import jakarta.inject.Inject;
Expand Down Expand Up @@ -72,8 +72,8 @@ protected void createFormSubTypeForm(Composite parent, EMFDataBindingContext con

// ------------------------------------------------------------
{
final Label l = new Label(parent, SWT.NONE);
l.setText(Messages.HandledMenuItemEditor_Command);
final Link l = createCommandLink(parent, Messages.HandledMenuItemEditor_Command,
E4Properties.itemCommand(getEditingDomain()).observeDetail(master), context);
l.setLayoutData(new GridData());

final Text t = new Text(parent, SWT.BORDER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;

import jakarta.inject.Inject;
Expand All @@ -60,8 +60,8 @@ protected void createSubTypeFormElements(Composite parent, EMFDataBindingContext
final IWidgetValueProperty<Text, String> textProp = WidgetProperties.text(SWT.Modify);

{
final Label l = new Label(parent, SWT.NONE);
l.setText(Messages.HandledToolItemEditor_Command);
final Link l = createCommandLink(parent, Messages.HandledToolItemEditor_Command,
E4Properties.itemCommand(getEditingDomain()).observeDetail(master), context);
l.setLayoutData(new GridData());

final Text t = new Text(parent, SWT.BORDER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;

import jakarta.inject.Inject;
Expand Down Expand Up @@ -154,8 +154,8 @@ private Composite createForm(Composite parent, EMFDataBindingContext context, IO

// ------------------------------------------------------------
{
final Label l = new Label(parent, SWT.NONE);
l.setText(Messages.HandlerEditor_Command);
final Link l = createCommandLink(parent, Messages.HandlerEditor_Command,
E4Properties.command(getEditingDomain()).observeDetail(master), context);
l.setLayoutData(new GridData());

final Text t = new Text(parent, SWT.BORDER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;

import jakarta.annotation.PostConstruct;
Expand Down Expand Up @@ -188,8 +189,8 @@ private Composite createForm(Composite parent, EMFDataBindingContext context, IO

// ------------------------------------------------------------
{
final Label l = new Label(parent, SWT.NONE);
l.setText(Messages.KeyBindingEditor_Command);
final Link l = createCommandLink(parent, Messages.KeyBindingEditor_Command,
E4Properties.keyBindingCommand(getEditingDomain()).observeDetail(master), context);
l.setLayoutData(new GridData());

final Text t = new Text(parent, SWT.BORDER);
Expand Down
Loading