-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
81 changed files
with
3,605 additions
and
3,002 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
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
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
33 changes: 33 additions & 0 deletions
33
net.alloyggp.griddle/src/net/alloyggp/griddle/actions/FormatGdlAction.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.alloyggp.griddle.actions; | ||
|
||
import net.alloyggp.griddle.editors.GdlEditor; | ||
import net.alloyggp.griddle.indentation.GameIndenter; | ||
|
||
import org.eclipse.core.commands.AbstractHandler; | ||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.core.commands.IHandler; | ||
import org.eclipse.jface.text.IDocument; | ||
import org.eclipse.ui.IEditorPart; | ||
import org.eclipse.ui.handlers.HandlerUtil; | ||
import org.eclipse.ui.texteditor.IDocumentProvider; | ||
|
||
public class FormatGdlAction extends AbstractHandler implements IHandler { | ||
|
||
@Override | ||
public Object execute(ExecutionEvent event) throws ExecutionException { | ||
IEditorPart editor = HandlerUtil.getActiveEditorChecked(event); | ||
GdlEditor gdlEditor = (GdlEditor) editor; | ||
IDocumentProvider documentProvider = gdlEditor.getDocumentProvider(); | ||
IDocument document = documentProvider.getDocument(gdlEditor.getEditorInput()); | ||
String docAsText = document.get(); | ||
try { | ||
String formatted = GameIndenter.reindentGameDescription(docAsText); | ||
document.set(formatted); | ||
} catch (Exception e) { | ||
throw new ExecutionException("Failed to reformat game description", 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
Oops, something went wrong.