Skip to content

Commit

Permalink
JBIDE-17914: External files are now handled correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jul 17, 2014
1 parent 04b1f05 commit beef7c2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jboss.tools.forge.ui.internal.ext.dialog;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
Expand All @@ -12,6 +13,7 @@
import java.util.TreeSet;

import org.eclipse.core.resources.IFile;
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 @@ -33,6 +35,7 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.jboss.forge.addon.ui.command.UICommand;
import org.jboss.forge.addon.ui.context.UIContext;
Expand Down Expand Up @@ -79,10 +82,15 @@ public UICommandListDialog(IWorkbenchWindow window) {
UISelectionImpl<?> uiSelection = wizardHelper.getContext()
.getInitialSelection();
if (!uiSelection.isEmpty()) {
setTitleText("Current Selection: "
+ uiSelection.getResource().getFullPath().toOSString());
String currentSelectionLabel;
IResource resource = uiSelection.getResource();
if (resource != null) {
currentSelectionLabel = resource.getFullPath().toOSString();
} else {
currentSelectionLabel = uiSelection.get().toString();
}
setTitleText("Current Selection: " + currentSelectionLabel);
}

}

/**
Expand All @@ -100,6 +108,12 @@ private static Object getActiveEditorInput(IWorkbenchWindow window) {
if (fileEditorInput != null) {
return fileEditorInput.getFile();
}
FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput
.getAdapter(FileStoreEditorInput.class);
if (fileStoreEditorInput != null) {
return new File(fileStoreEditorInput.getURI());
}

}
} else {
IWorkbenchPart part = page.getActivePart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.List;
import java.util.Map;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
Expand Down Expand Up @@ -57,9 +58,15 @@ private String constructTitle(String command) {
UISelectionImpl<?> currentSelection = uiContext.getInitialSelection();
StringBuilder title = new StringBuilder(command);
if (!currentSelection.isEmpty()) {
title.append(" [Current Selection: ")
.append(currentSelection.getResource().getFullPath()
.toOSString()).append("]");
String currentSelectionLabel;
IResource resource = currentSelection.getResource();
if (resource != null) {
currentSelectionLabel = resource.getFullPath().toOSString();
} else {
currentSelectionLabel = currentSelection.get().toString();
}
title.append(" [Current Selection: ").append(currentSelectionLabel)
.append("]");
}
return title.toString();
}
Expand Down

0 comments on commit beef7c2

Please sign in to comment.