Skip to content

Commit

Permalink
JBIDE-17723: Displaying current selection relative to workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jul 17, 2014
1 parent 9b9e6e0 commit e346d80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import java.util.TreeSet;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.dialogs.PopupDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
Expand All @@ -39,12 +37,12 @@
import org.eclipse.ui.part.FileEditorInput;
import org.jboss.forge.addon.ui.command.UICommand;
import org.jboss.forge.addon.ui.context.UIContext;
import org.jboss.forge.addon.ui.context.UISelection;
import org.jboss.forge.addon.ui.metadata.UICategory;
import org.jboss.forge.addon.ui.util.Categories;
import org.jboss.tools.forge.core.furnace.FurnaceRuntime;
import org.jboss.tools.forge.core.furnace.FurnaceService;
import org.jboss.tools.forge.ui.internal.ForgeUIPlugin;
import org.jboss.tools.forge.ui.internal.ext.context.UISelectionImpl;
import org.jboss.tools.forge.ui.internal.ext.quickaccess.QuickAccessContents;
import org.jboss.tools.forge.ui.internal.ext.quickaccess.QuickAccessElement;
import org.jboss.tools.forge.ui.internal.ext.quickaccess.QuickAccessProvider;
Expand Down Expand Up @@ -79,17 +77,17 @@ public UICommandListDialog(IWorkbenchWindow window) {
}
wizardHelper = new WizardDialogHelper(getParentShell(),
currentSelection);
UISelection<?> uiSelection = wizardHelper.getContext()
UISelectionImpl<?> uiSelection = wizardHelper.getContext()
.getInitialSelection();
if (!uiSelection.isEmpty()) {
setTitleText("Current Selection: " + normalize(uiSelection.get().toString()));
setTitleText("Current Selection: "
+ normalize(uiSelection.getResource()));
}

}

private String normalize(String pathString) {
IPath workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation();
return new Path(pathString).makeRelativeTo(workspaceLocation).makeAbsolute().toOSString();

private String normalize(IResource path) {
return path.getFullPath().toOSString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import java.util.List;
import java.util.Map;

import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.IWizardContainer;
Expand All @@ -27,6 +24,7 @@
import org.jboss.forge.addon.ui.result.Result;
import org.jboss.tools.forge.ui.internal.ForgeUIPlugin;
import org.jboss.tools.forge.ui.internal.ext.context.UIContextImpl;
import org.jboss.tools.forge.ui.internal.ext.context.UISelectionImpl;
import org.jboss.tools.forge.ui.internal.ext.dialog.InterruptableProgressMonitor;
import org.jboss.tools.forge.ui.notifications.NotificationType;

Expand Down Expand Up @@ -54,12 +52,16 @@ public ForgeWizard(String command, CommandController controller,
public UIContextImpl getUIContext() {
return uiContext;
}

private String constructTitle(String command) {
String currentSelection = uiContext.getInitialSelection().get().toString();
IPath workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation();
String normalizedSelection = new Path(currentSelection).makeRelativeTo(workspaceLocation).makeAbsolute().toOSString();
return command + " [Current Selection: " + normalizedSelection + "]";
UISelectionImpl<?> currentSelection = uiContext.getInitialSelection();
StringBuilder title = new StringBuilder(command);
if (!currentSelection.isEmpty()) {
title.append(" [Current Selection: ")
.append(currentSelection.getResource().getFullPath()
.toOSString()).append("]");
}
return title.toString();
}

@Override
Expand Down

0 comments on commit e346d80

Please sign in to comment.