|
@@ -11,8 +11,13 @@ import KMComponentLibrary
|
|
|
class KMBatchProcessingView: BaseXibView {
|
|
|
@IBOutlet weak var tableView: KMBatchProcessingTableView!
|
|
|
@IBOutlet weak var selectedFilesView: KMBatchSelectedFilesView!
|
|
|
- @IBOutlet weak var addFilesButton: ComponentDropdownTool!
|
|
|
+// @IBOutlet weak var addFilesButton: ComponentDropdownTool!
|
|
|
@IBOutlet weak var deleteButton: ComponentButton!
|
|
|
+ @IBOutlet weak var addFilesButton: ComponentButton!
|
|
|
+ @IBOutlet weak var addFilesMoreButton: ComponentButton!
|
|
|
+ @IBOutlet weak var lineView: NSView!
|
|
|
+
|
|
|
+ var groupView: ComponentGroup?
|
|
|
|
|
|
weak var delegate: KMBatchProcessingViewDelegate?
|
|
|
var inputType: KMBatchCollectionViewType? {
|
|
@@ -40,19 +45,33 @@ class KMBatchProcessingView: BaseXibView {
|
|
|
}
|
|
|
|
|
|
override func setup() {
|
|
|
+
|
|
|
+ self.backgroundColor(ComponentLibrary.shared.getComponentColorFromKey("colorBg/layout-low"))
|
|
|
self.border(ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider"), 0.5, 0)
|
|
|
+ self.lineView.backgroundColor(ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider"))
|
|
|
|
|
|
- self.addFilesButton.properties = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Add Files..."), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
|
|
|
- self.addFilesButton.delegate = self
|
|
|
|
|
|
- let items = ["Add Files", "Add Folder", "Add Open Files"]
|
|
|
- var menuItemArr: [ComponentMenuitemProperty] = []
|
|
|
- for item in items {
|
|
|
- let menuItem = ComponentMenuitemProperty(type: .normal, text: KMLocalizedString(item, comment: ""), identifier: "")
|
|
|
- menuItemArr.append(menuItem)
|
|
|
- }
|
|
|
- self.addFilesButton.properties.menuItemArr = menuItemArr
|
|
|
- self.addFilesButton.reloadData()
|
|
|
+ let properties = ComponentButtonProperty()
|
|
|
+ properties.type = .gray
|
|
|
+ properties.size = .s
|
|
|
+ properties.buttonText = KMLocalizedString("Add Files...")
|
|
|
+ addFilesButton.properties = properties
|
|
|
+ properties.propertyInfo.cornerRadius_topRight = 0
|
|
|
+ properties.propertyInfo.cornerRadius_bottomRight = 0
|
|
|
+ addFilesButton.reloadData()
|
|
|
+ addFilesButton.setTarget(self, action: #selector(addFileAction))
|
|
|
+
|
|
|
+ let properties2 = ComponentButtonProperty()
|
|
|
+ properties2.type = .gray
|
|
|
+ properties2.size = .s
|
|
|
+ properties2.onlyIcon = true
|
|
|
+ properties2.icon = NSImage(named: "KMImageNameImageToPDFDropdown")
|
|
|
+ addFilesMoreButton.properties = properties2
|
|
|
+ properties2.propertyInfo.cornerRadius_topLeft = 0
|
|
|
+ properties2.propertyInfo.cornerRadius_bottomLeft = 0
|
|
|
+ addFilesMoreButton.reloadData()
|
|
|
+ addFilesMoreButton.setTarget(self, action: #selector(addFileAction))
|
|
|
+
|
|
|
|
|
|
|
|
|
self.deleteButton.properties = ComponentButtonProperty(type: .default_tertiary,
|
|
@@ -81,13 +100,44 @@ class KMBatchProcessingView: BaseXibView {
|
|
|
if (self.tableView.data != nil) && self.tableView.data!.count != 0 {
|
|
|
self.selectedFilesView.isHidden = true
|
|
|
self.tableView.isHidden = false
|
|
|
+ self.lineView.isHidden = false
|
|
|
} else {
|
|
|
self.selectedFilesView.isHidden = false
|
|
|
self.tableView.isHidden = true
|
|
|
+ self.lineView.isHidden = true
|
|
|
}
|
|
|
|
|
|
self.tableView.reloadData()
|
|
|
}
|
|
|
+
|
|
|
+ func showGroupView() {
|
|
|
+
|
|
|
+ var viewHeight: CGFloat = 8
|
|
|
+ var menuItemArr: [ComponentMenuitemProperty] = []
|
|
|
+ for i in ["Add Files", "Add Folder"] {
|
|
|
+ let properties_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false,
|
|
|
+ itemSelected: false,
|
|
|
+ isDisabled: false,
|
|
|
+ keyEquivalent: nil,
|
|
|
+ text: KMLocalizedString(i))
|
|
|
+ menuItemArr.append(properties_Menuitem)
|
|
|
+ viewHeight += 36
|
|
|
+ }
|
|
|
+
|
|
|
+ if groupView == nil {
|
|
|
+ groupView = ComponentGroup.createFromNib(in: ComponentLibrary.shared.componentBundle())
|
|
|
+ }
|
|
|
+ groupView?.groupDelegate = self
|
|
|
+ groupView?.frame = CGRectMake(310, 0, 200, viewHeight)
|
|
|
+ groupView?.updateGroupInfo(menuItemArr)
|
|
|
+
|
|
|
+ var point = addFilesButton.convert(addFilesButton.frame.origin, to: nil)
|
|
|
+ point.y -= viewHeight
|
|
|
+ groupView?.showWithPoint(point, relativeTo: addFilesButton)
|
|
|
+
|
|
|
+// addFileButton_?.properties.state = .pressed
|
|
|
+// addFileButton_?.reloadData()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -107,6 +157,10 @@ extension KMBatchProcessingView: KMBatchProcessingViewAction {
|
|
|
self.reloadData()
|
|
|
}
|
|
|
|
|
|
+ func addFileAction() {
|
|
|
+ self.showGroupView()
|
|
|
+ }
|
|
|
+
|
|
|
func addFiles() {
|
|
|
KMBatchProcessingView.openfiles(window: window!) { [unowned self] openPanel in
|
|
|
if self.inputType == .OCR {
|
|
@@ -234,9 +288,9 @@ protocol KMBatchProcessingViewDelegate: NSObject {
|
|
|
func reloadData(data: [KMBatchProcessingTableViewModel])
|
|
|
}
|
|
|
|
|
|
-extension KMBatchProcessingView: ComponentDropdownToolDelegate {
|
|
|
- func componentDropdownToolDidClicked(_ view: ComponentDropdownTool, menuItem: ComponentMenuitemProperty?) {
|
|
|
- let familyString = menuItem?.text
|
|
|
+extension KMBatchProcessingView: ComponentGroupDelegate {
|
|
|
+ func componentGroupDidSelect(group: ComponentGroup?, menuItemProperty: ComponentMenuitemProperty?) {
|
|
|
+ let familyString = menuItemProperty?.text
|
|
|
|
|
|
if familyString == KMLocalizedString("Add Files", comment: "") {
|
|
|
self.addFiles()
|
|
@@ -246,4 +300,12 @@ extension KMBatchProcessingView: ComponentDropdownToolDelegate {
|
|
|
self.addOpenFiles()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ func componentGroupDidDismiss(group: ComponentGroup?) {
|
|
|
+ self.addFilesButton.properties.state = .normal
|
|
|
+ self.addFilesMoreButton.properties.state = .normal
|
|
|
+
|
|
|
+ self.addFilesButton.reloadData()
|
|
|
+ self.addFilesMoreButton.reloadData()
|
|
|
+ }
|
|
|
}
|