Skip to content

Commit

Permalink
Merge pull request #93 from narlei/master
Browse files Browse the repository at this point in the history
Changed icon / Fix UpsideDown text
  • Loading branch information
Ahmed-Ali authored Nov 15, 2017
2 parents bf8134e + 6916779 commit 16893c7
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 78 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>JSONExport.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
48 changes: 26 additions & 22 deletions JSONExport/FilePreviewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,29 @@ class FilePreviewCell: NSTableCellView, NSTextViewDelegate {
var file: FileRepresenter!{
didSet{
if file != nil{
var fileName = file.className
fileName += "."
if file is HeaderFileRepresenter{
fileName += file.lang.headerFileData.headerFileExtension
}else{
fileName += file.lang.fileExtension
}
classNameLabel.stringValue = fileName
if(textView != nil){
textView.string = file.toString()
}

if file.includeConstructors{
constructors.state = NSOnState
}else{
constructors.state = NSOffState
}
if file.includeUtilities{
utilities.state = NSOnState
}else{
utilities.state = NSOffState
DispatchQueue.main.async {
var fileName = self.file.className
fileName += "."
if self.file is HeaderFileRepresenter{
fileName += self.file.lang.headerFileData.headerFileExtension
}else{
fileName += self.file.lang.fileExtension
}
self.classNameLabel.stringValue = fileName
if(self.textView != nil){
self.textView.string = self.file.toString()
}

if self.file.includeConstructors{
self.constructors.state = NSOnState
}else{
self.constructors.state = NSOffState
}
if self.file.includeUtilities{
self.utilities.state = NSOnState
}else{
self.utilities.state = NSOffState
}
}
}else{
classNameLabel.stringValue = ""
Expand All @@ -55,7 +57,9 @@ class FilePreviewCell: NSTableCellView, NSTextViewDelegate {
super.awakeFromNib()
if textView != nil{
textView.delegate = self
setupNumberedTextView()
DispatchQueue.main.async {
self.setupNumberedTextView()
}
}
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
34 changes: 19 additions & 15 deletions JSONExport/Images.xcassets/AppIcon.appiconset/Contents.json
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,64 +1,68 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"images" : [
{
"filename" : "icon_16x16.png",
"size" : "16x16",
"idiom" : "mac",
"filename" : "16x16.png",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"size" : "16x16",
"idiom" : "mac",
"filename" : "32x32.png",
"scale" : "2x"
},
{
"filename" : "icon_32x32.png",
"size" : "32x32",
"idiom" : "mac",
"filename" : "32x32-1.png",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"size" : "32x32",
"idiom" : "mac",
"filename" : "64x64.png",
"scale" : "2x"
},
{
"filename" : "icon_128x128.png",
"size" : "128x128",
"idiom" : "mac",
"filename" : "128x128.png",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"size" : "128x128",
"idiom" : "mac",
"filename" : "256x256.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"filename" : "icon_256x256.png",
"size" : "256x256",
"idiom" : "mac",
"scale" : "1x"
},
{
"idiom" : "mac",
"filename" : "[email protected]",
"size" : "256x256",
"idiom" : "mac",
"scale" : "2x"
},
{
"idiom" : "mac",
"filename" : "icon_512x512.png",
"size" : "512x512",
"idiom" : "mac",
"scale" : "1x"
},
{
"idiom" : "mac",
"filename" : "[email protected]",
"size" : "512x512",
"idiom" : "mac",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 44 additions & 41 deletions JSONExport/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl

//Connected to the languages pop up
@IBOutlet weak var languagesPopup: NSPopUpButton!


//Holds the currently selected language
var selectedLang : LangModel!

//Returns the title of the selected language in the languagesPopup
var selectedLanguageName : String
{
{
return languagesPopup.titleOfSelectedItem!
}

Expand All @@ -99,8 +99,8 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
}

/**
Sets the values of languagesPopup items' titles
*/
Sets the values of languagesPopup items' titles
*/
func setLanguagesSelection()
{
let langNames = Array(langs.keys).sorted()
Expand All @@ -110,8 +110,8 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
}

/**
Sets the needed configurations for show the line numbers in the input text view
*/
Sets the needed configurations for show the line numbers in the input text view
*/
func setupNumberedTextView()
{
let lineNumberView = NoodleLineNumberView(scrollView: scrollView)
Expand All @@ -124,8 +124,8 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
}

/**
Updates the visible fields according to the selected language
*/
Updates the visible fields according to the selected language
*/
func updateUIFieldsForSelectedLanguage()
{
loadSelectedLanguageModel()
Expand All @@ -144,7 +144,7 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
}

/**
Loads last selected language by user
Loads last selected language by user
*/
func loadLastSelectedLanguage()
{
Expand Down Expand Up @@ -176,7 +176,7 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
}

}




Expand Down Expand Up @@ -270,7 +270,7 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl

//MARK: - NSUserNotificationCenterDelegate
func userNotificationCenter(_ center: NSUserNotificationCenter,
shouldPresent notification: NSUserNotification) -> Bool
shouldPresent notification: NSUserNotification) -> Bool
{
return true
}
Expand All @@ -295,13 +295,13 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
}
})
}


/**
Saves all the generated files in the specified path

- parameter path: in which to save the files
*/
/**
Saves all the generated files in the specified path

- parameter path: in which to save the files
*/
func saveToPath(_ path : String)
{
var error : NSError?
Expand Down Expand Up @@ -331,23 +331,23 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl

//MARK: - Messages
/**
Shows the top right notification. Call it after saving the files successfully
*/
Shows the top right notification. Call it after saving the files successfully
*/
func showDoneSuccessfully()
{
let notification = NSUserNotification()
notification.title = "Success!"
notification.informativeText = "Your \(selectedLang.langName) model files have been generated successfully."
notification.deliveryDate = Date()

let center = NSUserNotificationCenter.default
center.delegate = self
center.deliver(notification)
}

/**
Shows an NSAlert for the passed error
*/
Shows an NSAlert for the passed error
*/
func showError(_ error: NSError!)
{
if error == nil{
Expand All @@ -358,18 +358,18 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
}

/**
Shows the passed error status message
*/
Shows the passed error status message
*/
func showErrorStatus(_ errorMessage: String)
{

statusTextField.textColor = NSColor.red
statusTextField.stringValue = errorMessage
}

/**
Shows the passed success status message
*/
Shows the passed success status message
*/
func showSuccessStatus(_ successMessage: String)
{

Expand All @@ -381,17 +381,19 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl

//MARK: - Generate files content
/**
Validates the sourceText string input, and takes any needed action to generate the model classes and view them in the preview panel
*/
Validates the sourceText string input, and takes any needed action to generate the model classes and view them in the preview panel
*/
func generateClasses()
{
saveButton.isEnabled = false
var str = sourceText.string!

if str.characters.count == 0{
//Nothing to do, just clear any generated files
files.removeAll(keepingCapacity: false)
tableView.reloadData()
runOnUiThread{
//Nothing to do, just clear any generated files
self.files.removeAll(keepingCapacity: false)
self.tableView.reloadData()
}
return;
}
var rootClassName = classNameField.stringValue
Expand All @@ -415,16 +417,17 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
}
self.loadSelectedLanguageModel()
self.files.removeAll(keepingCapacity: false)
let fileGenerator = self.prepareAndGetFilesBuilder()
fileGenerator.addFileWithName(&rootClassName, jsonObject: json, files: &self.files)
fileGenerator.fixReferenceMismatches(inFiles: self.files)
self.files = Array(self.files.reversed())
runOnUiThread{
let fileGenerator = self.prepareAndGetFilesBuilder()
fileGenerator.addFileWithName(&rootClassName, jsonObject: json, files: &self.files)
fileGenerator.fixReferenceMismatches(inFiles: self.files)
self.files = Array(self.files.reversed())
self.sourceText.isEditable = true
self.showSuccessStatus("Valid JSON structure")
self.saveButton.isEnabled = true

self.tableView.reloadData()
self.tableView.layout()
}
} catch let error1 as NSError {
error = error1
Expand All @@ -445,10 +448,10 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
}

/**
Creates and returns an instance of FilesContentBuilder. It also configure the values from the UI components to the instance. I.e includeConstructors

- returns: instance of configured FilesContentBuilder
*/
Creates and returns an instance of FilesContentBuilder. It also configure the values from the UI components to the instance. I.e includeConstructors
- returns: instance of configured FilesContentBuilder
*/
func prepareAndGetFilesBuilder() -> FilesContentBuilder
{
let filesBuilder = FilesContentBuilder.instance
Expand Down Expand Up @@ -480,8 +483,8 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl

return cell
}



}

0 comments on commit 16893c7

Please sign in to comment.