From 5db4b47d2c9eb151c34a6e4d54424f110b9f1281 Mon Sep 17 00:00:00 2001 From: jcadavid Date: Tue, 27 May 2014 17:42:52 +0200 Subject: Bug 434633: [Control Mode] "Browse workspace" in control mode dialog not working https://bugs.eclipse.org/bugs/show_bug.cgi?id=434633 Override prepareBrowseWorkspaceButton() so that the file text field of the "Browse Workspace" dialog shows the default file name. When the user selects a folder, the string returned by this dialog will contain the full path including the selected folder. Change-Id: I8c7eb9630e282845800178411adbfa46d385880f Signed-off-by: jcadavid --- .../controlmode/ui/CreateModelFragmentDialog.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/ui/CreateModelFragmentDialog.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/ui/CreateModelFragmentDialog.java index fe63d837fa6..b86ae0e58e6 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/ui/CreateModelFragmentDialog.java +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/ui/CreateModelFragmentDialog.java @@ -9,11 +9,17 @@ ******************************************************************************/ package org.eclipse.papyrus.infra.services.controlmode.ui; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.Path; import org.eclipse.emf.common.ui.dialogs.ResourceDialog; +import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.edit.ui.EMFEditUIPlugin; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; @@ -46,6 +52,23 @@ public class CreateModelFragmentDialog extends ResourceDialog { this.defaultName = defaultName; } + @Override + protected void prepareBrowseWorkspaceButton(Button browseWorkspaceButton) { + browseWorkspaceButton.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent event) { + IFile file = null; + String path = URI.createURI(computeDefaultURI()).lastSegment(); + file = WorkspaceResourceDialog.openNewFile(getShell(), null, null, path != null ? new Path(path) : null, null); + if(file != null) { + uriField.setText(URI.createPlatformResourceURI(file.getFullPath().toString(), true).toString()); + } + } + + }); + } + public String computeDefaultURI() { String ext = currentResource.getURI().fileExtension(); URI uri = currentResource.getURI().trimSegments(1); -- cgit v1.2.3