This repository has been archived by the owner on Nov 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from dscho/resource-leak
Fix resource leak warning, generics warning and remove DOS line endings.
- Loading branch information
Showing
20 changed files
with
1,656 additions
and
1,652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
commandCategoryName = EclipseScript | ||
commandCategoryDescription = Commands for using the EclipseScript plug-in | ||
commandRunLastName = EclipseScript: Run Last | ||
commandRunLastDescription = Run the last EclipseScript that has been executed | ||
commandRunCurrentName = EclipseScript: Run Current | ||
commandRunCurrentDescription = Run the currently edited EclipseScript | ||
commandRunScriptParameterName = Script | ||
commandOpenScriptDialogName = EclipseScript: Open Script Dialog | ||
commandOpenScriptDialogDescription = Search and select available scripts | ||
|
||
markerName=EclipseScript Problem | ||
pluginName=EclipseScript | ||
bundleVendor=eclipsescript.org | ||
commandRunLastSequence = Ctrl+R | ||
commandRunCurrentSequence = Alt+R | ||
commandOpenScriptDialogSequence = M1+4 | ||
commandCategoryName = EclipseScript | ||
commandCategoryDescription = Commands for using the EclipseScript plug-in | ||
commandRunLastName = EclipseScript: Run Last | ||
commandRunLastDescription = Run the last EclipseScript that has been executed | ||
commandRunCurrentName = EclipseScript: Run Current | ||
commandRunCurrentDescription = Run the currently edited EclipseScript | ||
commandRunScriptParameterName = Script | ||
commandOpenScriptDialogName = EclipseScript: Open Script Dialog | ||
commandOpenScriptDialogDescription = Search and select available scripts | ||
|
||
markerName=EclipseScript Problem | ||
pluginName=EclipseScript | ||
bundleVendor=eclipsescript.org | ||
commandRunLastSequence = Ctrl+R | ||
commandRunCurrentSequence = Alt+R | ||
commandOpenScriptDialogSequence = M1+4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
package org.eclipsescript.core; | ||
|
||
|
||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.jface.dialogs.MessageDialog; | ||
import org.eclipse.ui.IEditorInput; | ||
import org.eclipse.ui.part.FileEditorInput; | ||
import org.eclipsescript.messages.Messages; | ||
import org.eclipsescript.scripts.ScriptLanguageHandler; | ||
import org.eclipsescript.scripts.ScriptMetadata; | ||
import org.eclipsescript.scripts.ScriptStore; | ||
import org.eclipsescript.ui.ErrorHandlingHandler; | ||
import org.eclipsescript.util.EclipseUtils; | ||
|
||
public class RunCurrentHandler extends ErrorHandlingHandler { | ||
|
||
@Override | ||
protected void doExecute(ExecutionEvent event) throws Exception { | ||
IEditorInput editorInput = EclipseUtils.getCurrentEditorInput(); | ||
if (editorInput instanceof FileEditorInput) { | ||
FileEditorInput fileInput = (FileEditorInput) editorInput; | ||
IFile editedFile = fileInput.getFile(); | ||
boolean isScriptFile = ScriptLanguageHandler.isEclipseScriptFile(editedFile); | ||
if (isScriptFile) { | ||
ScriptMetadata m = new ScriptMetadata(fileInput.getFile()); | ||
ScriptStore.executeScript(m); | ||
return; | ||
} | ||
} | ||
MessageDialog.openInformation(EclipseUtils.getWindowShell(), Messages.cannotRunCurrentScriptTitle, | ||
Messages.cannotRunCurrentScriptText); | ||
} | ||
|
||
} | ||
package org.eclipsescript.core; | ||
|
||
|
||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.jface.dialogs.MessageDialog; | ||
import org.eclipse.ui.IEditorInput; | ||
import org.eclipse.ui.part.FileEditorInput; | ||
import org.eclipsescript.messages.Messages; | ||
import org.eclipsescript.scripts.ScriptLanguageHandler; | ||
import org.eclipsescript.scripts.ScriptMetadata; | ||
import org.eclipsescript.scripts.ScriptStore; | ||
import org.eclipsescript.ui.ErrorHandlingHandler; | ||
import org.eclipsescript.util.EclipseUtils; | ||
|
||
public class RunCurrentHandler extends ErrorHandlingHandler { | ||
|
||
@Override | ||
protected void doExecute(ExecutionEvent event) throws Exception { | ||
IEditorInput editorInput = EclipseUtils.getCurrentEditorInput(); | ||
if (editorInput instanceof FileEditorInput) { | ||
FileEditorInput fileInput = (FileEditorInput) editorInput; | ||
IFile editedFile = fileInput.getFile(); | ||
boolean isScriptFile = ScriptLanguageHandler.isEclipseScriptFile(editedFile); | ||
if (isScriptFile) { | ||
ScriptMetadata m = new ScriptMetadata(fileInput.getFile()); | ||
ScriptStore.executeScript(m); | ||
return; | ||
} | ||
} | ||
MessageDialog.openInformation(EclipseUtils.getWindowShell(), Messages.cannotRunCurrentScriptTitle, | ||
Messages.cannotRunCurrentScriptText); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
package org.eclipsescript.core; | ||
|
||
|
||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.jface.dialogs.MessageDialog; | ||
import org.eclipsescript.messages.Messages; | ||
import org.eclipsescript.scripts.ScriptMetadata; | ||
import org.eclipsescript.scripts.ScriptStore; | ||
import org.eclipsescript.ui.ErrorHandlingHandler; | ||
import org.eclipsescript.util.EclipseUtils; | ||
|
||
public class RunLastHandler extends ErrorHandlingHandler { | ||
|
||
public static ScriptMetadata lastRun = null; | ||
|
||
@Override | ||
public void doExecute(ExecutionEvent event) throws ExecutionException { | ||
if (lastRun == null) { | ||
MessageDialog.openWarning(EclipseUtils.activeWindow().getShell(), "No script to run", //$NON-NLS-1$ | ||
Messages.runScriptBeforeRunningLast); | ||
} else { | ||
ScriptStore.executeScript(lastRun); | ||
} | ||
} | ||
} | ||
package org.eclipsescript.core; | ||
|
||
|
||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.jface.dialogs.MessageDialog; | ||
import org.eclipsescript.messages.Messages; | ||
import org.eclipsescript.scripts.ScriptMetadata; | ||
import org.eclipsescript.scripts.ScriptStore; | ||
import org.eclipsescript.ui.ErrorHandlingHandler; | ||
import org.eclipsescript.util.EclipseUtils; | ||
|
||
public class RunLastHandler extends ErrorHandlingHandler { | ||
|
||
public static ScriptMetadata lastRun = null; | ||
|
||
@Override | ||
public void doExecute(ExecutionEvent event) throws ExecutionException { | ||
if (lastRun == null) { | ||
MessageDialog.openWarning(EclipseUtils.activeWindow().getShell(), "No script to run", //$NON-NLS-1$ | ||
Messages.runScriptBeforeRunningLast); | ||
} else { | ||
ScriptStore.executeScript(lastRun); | ||
} | ||
} | ||
} |
80 changes: 40 additions & 40 deletions
80
src/org/eclipsescript/javascript/JavaScriptLanguageSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
package org.eclipsescript.javascript; | ||
|
||
import org.eclipsescript.javascript.CustomContextFactory.CustomContext; | ||
import org.eclipsescript.rhino.javascript.Context; | ||
import org.eclipsescript.rhino.javascript.ContextAction; | ||
import org.eclipsescript.rhino.javascript.ImporterTopLevel; | ||
import org.eclipsescript.rhino.javascript.ScriptableObject; | ||
import org.eclipsescript.scriptobjects.Eclipse; | ||
import org.eclipsescript.scripts.IScriptLanguageSupport; | ||
import org.eclipsescript.scripts.ScriptMetadata; | ||
|
||
public class JavaScriptLanguageSupport implements IScriptLanguageSupport { | ||
|
||
private final CustomContextFactory contextFactory = new CustomContextFactory(); | ||
|
||
@Override | ||
public void executeScript(final ScriptMetadata script) { | ||
contextFactory.call(new ContextAction() { | ||
@Override | ||
public Object run(Context _context) { | ||
if (!(_context instanceof CustomContext)) | ||
throw new IllegalArgumentException("Wrong context class: " + _context.getClass()); //$NON-NLS-1$ | ||
CustomContext context = (CustomContext) _context; | ||
ScriptableObject scope = new ImporterTopLevel(context); | ||
JavascriptRuntime jsRuntime = new JavascriptRuntime(context, scope, script); | ||
|
||
Eclipse eclipseJavaObject = new Eclipse(jsRuntime); | ||
Object eclipseJsObject = Context.javaToJS(eclipseJavaObject, scope); | ||
ScriptableObject.putConstProperty(scope, Eclipse.VARIABLE_NAME, eclipseJsObject); | ||
|
||
try { | ||
jsRuntime.evaluate(script.getFile(), false); | ||
} catch (Throwable e) { | ||
jsRuntime.handleExceptionFromScriptRuntime(e); | ||
} | ||
return null; | ||
} | ||
}); | ||
} | ||
} | ||
package org.eclipsescript.javascript; | ||
|
||
import org.eclipsescript.javascript.CustomContextFactory.CustomContext; | ||
import org.eclipsescript.rhino.javascript.Context; | ||
import org.eclipsescript.rhino.javascript.ContextAction; | ||
import org.eclipsescript.rhino.javascript.ImporterTopLevel; | ||
import org.eclipsescript.rhino.javascript.ScriptableObject; | ||
import org.eclipsescript.scriptobjects.Eclipse; | ||
import org.eclipsescript.scripts.IScriptLanguageSupport; | ||
import org.eclipsescript.scripts.ScriptMetadata; | ||
|
||
public class JavaScriptLanguageSupport implements IScriptLanguageSupport { | ||
|
||
private final CustomContextFactory contextFactory = new CustomContextFactory(); | ||
|
||
@Override | ||
public void executeScript(final ScriptMetadata script) { | ||
contextFactory.call(new ContextAction() { | ||
@Override | ||
public Object run(Context _context) { | ||
if (!(_context instanceof CustomContext)) | ||
throw new IllegalArgumentException("Wrong context class: " + _context.getClass()); //$NON-NLS-1$ | ||
CustomContext context = (CustomContext) _context; | ||
ScriptableObject scope = new ImporterTopLevel(context); | ||
JavascriptRuntime jsRuntime = new JavascriptRuntime(context, scope, script); | ||
|
||
Eclipse eclipseJavaObject = new Eclipse(jsRuntime); | ||
Object eclipseJsObject = Context.javaToJS(eclipseJavaObject, scope); | ||
ScriptableObject.putConstProperty(scope, Eclipse.VARIABLE_NAME, eclipseJsObject); | ||
|
||
try { | ||
jsRuntime.evaluate(script.getFile(), false); | ||
} catch (Throwable e) { | ||
jsRuntime.handleExceptionFromScriptRuntime(e); | ||
} | ||
return null; | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
package org.eclipsescript.messages; | ||
|
||
import org.eclipse.osgi.util.NLS; | ||
|
||
/** | ||
* Localization messages using the {@link NLS} system. The static initializer block will initialize the fields of this | ||
* class with values loaded from the messages properties file. | ||
*/ | ||
public class Messages extends NLS { | ||
|
||
private static final String BUNDLE_NAME = Messages.class.getPackage().getName() + ".messages"; //$NON-NLS-1$ | ||
|
||
public static String cannotRunCurrentScriptText; | ||
public static String cannotRunCurrentScriptTitle; | ||
public static String clearMarkersJobName; | ||
public static String fileToIncludeDoesNotExist; | ||
public static String fileToReadDoesNotExist; | ||
public static String internalErrorDialogDetails; | ||
public static String internalErrorDialogText; | ||
public static String internalErrorDialogTitle; | ||
public static String noDocumentSelected; | ||
public static String noSelectionSelected; | ||
public static String noTextEditorSelected; | ||
public static String notPossibleToScheduleObject; | ||
public static String removeAllTerminatedConsoles; | ||
public static String Resources_cannotReadFromObject; | ||
public static String runScriptBeforeRunningLast; | ||
public static String scriptAlertDialogTitle; | ||
public static String scriptBackgroundJobName; | ||
public static String scriptConfirmDialogTitle; | ||
public static String scriptConsoleName; | ||
public static String scriptErrorWhenRunningScriptDialogText; | ||
public static String scriptErrorWhenRunningScriptDialogTitle; | ||
public static String scriptErrorWhenRunningScriptJumpToScriptButton; | ||
public static String scriptErrorWhenRunningScriptOkButton; | ||
public static String scriptPromptDialogTitle; | ||
public static String scriptTimeout; | ||
public static String windowOpenArgumentNull; | ||
|
||
static { | ||
NLS.initializeMessages(BUNDLE_NAME, Messages.class); | ||
} | ||
|
||
} | ||
package org.eclipsescript.messages; | ||
|
||
import org.eclipse.osgi.util.NLS; | ||
|
||
/** | ||
* Localization messages using the {@link NLS} system. The static initializer block will initialize the fields of this | ||
* class with values loaded from the messages properties file. | ||
*/ | ||
public class Messages extends NLS { | ||
|
||
private static final String BUNDLE_NAME = Messages.class.getPackage().getName() + ".messages"; //$NON-NLS-1$ | ||
|
||
public static String cannotRunCurrentScriptText; | ||
public static String cannotRunCurrentScriptTitle; | ||
public static String clearMarkersJobName; | ||
public static String fileToIncludeDoesNotExist; | ||
public static String fileToReadDoesNotExist; | ||
public static String internalErrorDialogDetails; | ||
public static String internalErrorDialogText; | ||
public static String internalErrorDialogTitle; | ||
public static String noDocumentSelected; | ||
public static String noSelectionSelected; | ||
public static String noTextEditorSelected; | ||
public static String notPossibleToScheduleObject; | ||
public static String removeAllTerminatedConsoles; | ||
public static String Resources_cannotReadFromObject; | ||
public static String runScriptBeforeRunningLast; | ||
public static String scriptAlertDialogTitle; | ||
public static String scriptBackgroundJobName; | ||
public static String scriptConfirmDialogTitle; | ||
public static String scriptConsoleName; | ||
public static String scriptErrorWhenRunningScriptDialogText; | ||
public static String scriptErrorWhenRunningScriptDialogTitle; | ||
public static String scriptErrorWhenRunningScriptJumpToScriptButton; | ||
public static String scriptErrorWhenRunningScriptOkButton; | ||
public static String scriptPromptDialogTitle; | ||
public static String scriptTimeout; | ||
public static String windowOpenArgumentNull; | ||
|
||
static { | ||
NLS.initializeMessages(BUNDLE_NAME, Messages.class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
internalErrorDialogTitle=EclipseScript Internal Error | ||
internalErrorDialogText=The error has been logged. See below for details. | ||
internalErrorDialogDetails=Plug-in name: {0}\nPlug-in ID: {1}\nVersion: {2}\n\n{3} | ||
runScriptBeforeRunningLast=No EclipseScript script has been run\! | ||
scriptAlertDialogTitle=EclipseScript Alert | ||
scriptConfirmDialogTitle=EclipseScript Prompt | ||
scriptConsoleName=EclipseScript: {0} | ||
scriptErrorWhenRunningScriptDialogTitle=EclipseScript Error | ||
scriptErrorWhenRunningScriptDialogText=Execution of the script "{0}" failed at line {2} with the following message:\n\n{1} | ||
scriptErrorWhenRunningScriptJumpToScriptButton=&Go to script | ||
scriptErrorWhenRunningScriptOkButton=&Ok | ||
scriptTimeout = Script timeout after {0} seconds.\n\nTry using the eclipse.runtime.schedule(runnable) function for long-running background tasks. | ||
scriptBackgroundJobName=EclipseScript: {0} | ||
scriptPromptDialogTitle=EclipseScript Prompt | ||
cannotRunCurrentScriptText=Cannot run the currently edited script | ||
cannotRunCurrentScriptTitle=Cannot run | ||
clearMarkersJobName=Clear script markers | ||
fileToIncludeDoesNotExist=File does not exist: | ||
fileToReadDoesNotExist=File to read does not exist: | ||
noDocumentSelected=No document selected\! | ||
noSelectionSelected=No selection selected\! | ||
noTextEditorSelected=No text editor selected\! | ||
notPossibleToScheduleObject=Not possible to schedule object: | ||
Resources_cannotReadFromObject=Cannot read from object: | ||
windowOpenArgumentNull=The urlString argument to open(urlString) was null | ||
internalErrorDialogTitle=EclipseScript Internal Error | ||
internalErrorDialogText=The error has been logged. See below for details. | ||
internalErrorDialogDetails=Plug-in name: {0}\nPlug-in ID: {1}\nVersion: {2}\n\n{3} | ||
runScriptBeforeRunningLast=No EclipseScript script has been run\! | ||
scriptAlertDialogTitle=EclipseScript Alert | ||
scriptConfirmDialogTitle=EclipseScript Prompt | ||
scriptConsoleName=EclipseScript: {0} | ||
scriptErrorWhenRunningScriptDialogTitle=EclipseScript Error | ||
scriptErrorWhenRunningScriptDialogText=Execution of the script "{0}" failed at line {2} with the following message:\n\n{1} | ||
scriptErrorWhenRunningScriptJumpToScriptButton=&Go to script | ||
scriptErrorWhenRunningScriptOkButton=&Ok | ||
scriptTimeout = Script timeout after {0} seconds.\n\nTry using the eclipse.runtime.schedule(runnable) function for long-running background tasks. | ||
scriptBackgroundJobName=EclipseScript: {0} | ||
scriptPromptDialogTitle=EclipseScript Prompt | ||
cannotRunCurrentScriptText=Cannot run the currently edited script | ||
cannotRunCurrentScriptTitle=Cannot run | ||
clearMarkersJobName=Clear script markers | ||
fileToIncludeDoesNotExist=File does not exist: | ||
fileToReadDoesNotExist=File to read does not exist: | ||
noDocumentSelected=No document selected\! | ||
noSelectionSelected=No selection selected\! | ||
noTextEditorSelected=No text editor selected\! | ||
notPossibleToScheduleObject=Not possible to schedule object: | ||
Resources_cannotReadFromObject=Cannot read from object: | ||
windowOpenArgumentNull=The urlString argument to open(urlString) was null | ||
removeAllTerminatedConsoles=Remove All EclipseScript Consoles |
Oops, something went wrong.