See #56. Add Atom-Message-Panel to display Unsupported Language messages

This commit is contained in:
Glavin Wiechert 2014-09-08 01:02:23 -03:00
parent 6b2b306b9d
commit ffa2249c3e
3 changed files with 28 additions and 14 deletions

View File

@ -13,6 +13,8 @@ path = null
strip = null strip = null
yaml = null yaml = null
LoadingView = null LoadingView = null
MessagePanelView = null
PlainMessageView = null
#MessageView = require "./message-view" #MessageView = require "./message-view"
findFileResults = {} findFileResults = {}
@ -117,7 +119,11 @@ getConfigOptionsFromSettings = (langs) ->
options options
beautify = -> beautify = ->
MessagePanelView ?= require('atom-message-panel').MessagePanelView
PlainMessageView ?= require('atom-message-panel').PlainMessageView
LoadingView ?= require "./loading-view" LoadingView ?= require "./loading-view"
@messagePanel ?= new MessagePanelView title: 'Atom Beautify'
@messagePanel.attach();
@loadingView ?= new LoadingView() @loadingView ?= new LoadingView()
@loadingView.show() @loadingView.show()
forceEntireFile = atom.config.get("atom-beautify.beautifyEntireFileOnSave") forceEntireFile = atom.config.get("atom-beautify.beautifyEntireFileOnSave")
@ -142,7 +148,6 @@ beautify = ->
externalOptions = JSON.parse(strip(contents)) externalOptions = JSON.parse(strip(contents))
catch e catch e
console.log "Failed parsing config as JSON: " + configPath console.log "Failed parsing config as JSON: " + configPath
# Attempt as YAML # Attempt as YAML
try try
yaml ?= require("js-yaml") yaml ?= require("js-yaml")
@ -219,7 +224,15 @@ beautify = ->
] ]
grammarName = editor.getGrammar().name grammarName = editor.getGrammar().name
# Finally, beautify! # Finally, beautify!
try
beautifier.beautify text, grammarName, allOptions, beautifyCompleted beautifier.beautify text, grammarName, allOptions, beautifyCompleted
catch e
console.log(e)
@loadingView.hide()
@messagePanel.add(new PlainMessageView({
message: e.message,
className: 'text-error'
}));
return return
handleSaveEvent = -> handleSaveEvent = ->

View File

@ -213,13 +213,11 @@ module.exports =
# Check if Analytics is enabled # Check if Analytics is enabled
if atom.config.get("atom-beautify.analytics") if atom.config.get("atom-beautify.analytics")
# Setup Analytics # Setup Analytics
analytics = new Analytics(analyticsWriteKey) analytics = new Analytics(analyticsWriteKey)
unless atom.config.get("atom-beautify._analyticsUserId") unless atom.config.get("atom-beautify._analyticsUserId")
uuid = require("node-uuid") uuid = require("node-uuid")
atom.config.set "atom-beautify._analyticsUserId", uuid.v4() atom.config.set "atom-beautify._analyticsUserId", uuid.v4()
# Setup Analytics User Id # Setup Analytics User Id
userId = atom.config.get("atom-beautify._analyticsUserId") userId = atom.config.get("atom-beautify._analyticsUserId")
analytics.identify userId: userId analytics.identify userId: userId
@ -233,7 +231,9 @@ module.exports =
options: allOptions options: allOptions
label: grammar label: grammar
category: version category: version
#
if unsupportedGrammar
throw new Error("Unsupported language for grammar '#{grammar}'.")
return return
getOptions: (selection, allOptions) -> getOptions: (selection, allOptions) ->

View File

@ -88,6 +88,7 @@
"prettydiff": "^1.0.23", "prettydiff": "^1.0.23",
"node-uuid": "^1.4.1", "node-uuid": "^1.4.1",
"analytics-node": "^1.0.2", "analytics-node": "^1.0.2",
"coffee-formatter": "git+https://github.com/Glavin001/Coffee-Formatter.git" "coffee-formatter": "git+https://github.com/Glavin001/Coffee-Formatter.git",
"atom-message-panel": "^1.1.1"
} }
} }