Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add open Library jar explorer view #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
35 changes: 22 additions & 13 deletions src/openexplorer/actions/AbstractOpenExplorerAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
* @version 1.4.0
*/
public abstract class AbstractOpenExplorerAction implements IActionDelegate,
IPropertyChangeListener {
IPropertyChangeListener {
protected IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
.getActiveWorkbenchWindow();
protected Shell shell;
protected ISelection currentSelection;

Expand All @@ -63,7 +63,7 @@ public abstract class AbstractOpenExplorerAction implements IActionDelegate,
public AbstractOpenExplorerAction() {
this.systemBrowser = OperatingSystem.INSTANCE.getSystemBrowser();
Activator.getDefault().getPreferenceStore()
.addPropertyChangeListener(this);
.addPropertyChangeListener(this);
}

/*
Expand All @@ -85,44 +85,53 @@ public void run(IAction action) {
}
if (this.currentSelection instanceof ITreeSelection) {
ITreeSelection treeSelection = (ITreeSelection) this.currentSelection;

TreePath[] paths = treeSelection.getPaths();

for (int i = 0; i < paths.length; i++) {
TreePath path = paths[i];
IResource resource = null;
String location = null;
String browser = this.systemBrowser;
Object segment = path.getLastSegment();
if ((segment instanceof IResource))
resource = (IResource) segment;
else if ((segment instanceof IJavaElement)) {
resource = ((IJavaElement) segment).getResource();
if (resource == null) {
location = ((IJavaElement) segment).getPath().toOSString();
if (location != null) {
if (OperatingSystem.INSTANCE.isWindows()) {
browser = this.systemBrowser + " /select,";
}
openInBrowser(browser, location);
continue;
}
}
}
if (resource == null) {
continue;
}
String browser = this.systemBrowser;
String location = resource.getLocation().toOSString();
location = resource.getLocation().toOSString();
if ((resource instanceof IFile)) {
location = ((IFile) resource).getParent().getLocation()
.toOSString();
.toOSString();
if (OperatingSystem.INSTANCE.isWindows()) {
browser = this.systemBrowser + " /select,";
location = ((IFile) resource).getLocation()
.toOSString();
.toOSString();
}
}
openInBrowser(browser, location);
}
} else if (this.currentSelection instanceof ITextSelection
|| this.currentSelection instanceof IStructuredSelection) {
|| this.currentSelection instanceof IStructuredSelection) {
// open current editing file
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor != null) {
IFile current_editing_file = (IFile) editor.getEditorInput()
.getAdapter(IFile.class);
.getAdapter(IFile.class);
String browser = this.systemBrowser;
String location = current_editing_file.getParent()
.getLocation().toOSString();
.getLocation().toOSString();
if (OperatingSystem.INSTANCE.isWindows()) {
browser = this.systemBrowser + " /select,";
location = current_editing_file.getLocation().toOSString();
Expand All @@ -141,7 +150,7 @@ protected void openInBrowser(String browser, String location) {
}
} catch (IOException e) {
MessageDialog.openError(shell, Messages.OpenExploer_Error,
Messages.Cant_Open + " \"" + location + "\"");
Messages.Cant_Open + " \"" + location + "\"");
e.printStackTrace();
}
}
Expand Down