@ -0,0 +1,33 @@
|
||||
package com.tptj.tool.hg.fineui.swing.element; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/10/29 |
||||
**/ |
||||
public abstract class AbstractSingleElement<T extends JComponent> extends AbstractElement<T> { |
||||
protected AbstractSingleElement(T component) { |
||||
super(component); |
||||
} |
||||
|
||||
@Override |
||||
public void css(String name, String val) { |
||||
super.css(name, val); |
||||
Dimension dim = getComponent().getPreferredSize(); |
||||
if ("width".equals(name)) { |
||||
if (val.length() > 0) { |
||||
dim.width = Integer.parseInt(val); |
||||
getComponent().setPreferredSize(dim); |
||||
} |
||||
} |
||||
if ("height".equals(name)) { |
||||
if (val.length() > 0) { |
||||
dim.height = Integer.parseInt(val); |
||||
getComponent().setPreferredSize(dim); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
|
||||
package com.tptj.tool.hg.fineui.swing.element; |
||||
|
||||
import com.fr.general.GeneralUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/10/29 |
||||
**/ |
||||
public class ButtonElement extends AbstractSingleElement<JButton> { |
||||
|
||||
public ButtonElement() { |
||||
super(new JButton()); |
||||
getComponent().addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
callJsMethod("fireEvent", "EVENT_CHANGE", getComponent().getText()); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public Object getVal() { |
||||
return getComponent().getText(); |
||||
} |
||||
|
||||
@Override |
||||
public void setVal(Object val) { |
||||
super.setVal(val); |
||||
getComponent().setText(GeneralUtils.objectToString(val)); |
||||
} |
||||
|
||||
@Override |
||||
public void css(String name, String val) { |
||||
super.css(name, val); |
||||
val = val.toUpperCase(); |
||||
if ("text-align".equals(name)) { |
||||
if ("LEFT".equals(val)) { |
||||
getComponent().setHorizontalAlignment(SwingConstants.LEFT); |
||||
} else if ("CENTER".equals(val)) { |
||||
getComponent().setHorizontalAlignment(SwingConstants.CENTER); |
||||
} else if ("RIGHT".equals(val)) { |
||||
getComponent().setHorizontalAlignment(SwingConstants.RIGHT); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.tptj.tool.hg.fineui.swing.element; |
||||
|
||||
|
||||
import com.eclipsesource.v8.V8Array; |
||||
|
||||
import javax.swing.*; |
||||
import java.util.Vector; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/10/29 |
||||
**/ |
||||
public class ListElement extends AbstractSingleElement<JList> { |
||||
|
||||
public ListElement() { |
||||
super(new JList()); |
||||
} |
||||
|
||||
@Override |
||||
public void populate(V8Array items) { |
||||
Vector<String> vector = new Vector<>(); |
||||
for (int i = 0, len = items.length(); i < len; i++) { |
||||
vector.add(items.getString(i)); |
||||
} |
||||
component.setModel(new DefaultComboBoxModel<>(vector)); |
||||
} |
||||
|
||||
@Override |
||||
public void setVal(Object val) { |
||||
super.setVal(val); |
||||
} |
||||
|
||||
@Override |
||||
public void css(String name, String val) { |
||||
super.css(name, val); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
#### fineui.js |
||||
|
||||
整个fineui打包文件,不包括配置文件 |
||||
|
||||
#### fineui.css |
||||
|
||||
整个fineui打包文件,不包括资源文件 |
||||
|
||||
#### config.js |
||||
|
||||
配置文件,这只是一个案例,集成进系统的时候需要进行配置 |
||||
|
||||
#### resource.css |
||||
|
||||
app.css background.css icon.css font.css的合并文件,集成进系统的时候需要进行配置 |
||||
|
||||
#### router.js |
||||
|
||||
#### 路由文件,使用fineui路由的时候才需要引入 |
||||
|
||||
#### bundle.js bundle.css |
||||
|
||||
所有文件的合并文件, 主要给在线demo和文档用的 |
||||
|
||||
#### core_without_normalize.css |
||||
|
||||
不带标准化的core.css文件,只引入通用css样式的时候才需要 |
||||
|
||||
#### chart.js |
||||
|
||||
封装好的一层图表api |
@ -0,0 +1,199 @@
|
||||
;(function () { |
||||
function initWatch (vm, watch) { |
||||
vm._watchers || (vm._watchers = []); |
||||
for (var key in watch) { |
||||
var handler = watch[key]; |
||||
if (BI.isArray(handler)) { |
||||
for (var i = 0; i < handler.length; i++) { |
||||
vm._watchers.push(createWatcher(vm, key, handler[i])); |
||||
} |
||||
} else { |
||||
vm._watchers.push(createWatcher(vm, key, handler)); |
||||
} |
||||
} |
||||
BI.each(vm.$watchDelayCallbacks, function (i, watchDelayCallback) { |
||||
var innerWatch = watchDelayCallback[0]; |
||||
var innerHandler = watchDelayCallback[1]; |
||||
if (BI.isKey(innerWatch)) { |
||||
var key = innerWatch; |
||||
innerWatch = {}; |
||||
innerWatch[key] = innerHandler; |
||||
} |
||||
for (var key in innerWatch) { |
||||
var handler = innerWatch[key]; |
||||
if (BI.isArray(handler)) { |
||||
for (var i = 0; i < handler.length; i++) { |
||||
vm._watchers.push(createWatcher(vm, key, handler[i])); |
||||
} |
||||
} else { |
||||
vm._watchers.push(createWatcher(vm, key, handler)); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
function createWatcher (vm, keyOrFn, cb, options) { |
||||
if (BI.isPlainObject(cb)) { |
||||
options = cb; |
||||
cb = cb.handler; |
||||
} |
||||
options = options || {}; |
||||
return Fix.watch(vm.model, keyOrFn, _.bind(cb, vm), BI.extend(options, { |
||||
store: vm.store |
||||
})); |
||||
} |
||||
|
||||
var target = null; |
||||
var targetStack = []; |
||||
|
||||
function pushTarget (_target) { |
||||
if (target) targetStack.push(target); |
||||
Fix.Model.target = target = _target; |
||||
} |
||||
|
||||
function popTarget () { |
||||
Fix.Model.target = target = targetStack.pop(); |
||||
} |
||||
|
||||
var oldWatch = Fix.watch; |
||||
Fix.watch = function (model, expOrFn, cb, options) { |
||||
if (BI.isPlainObject(cb)) { |
||||
options = cb; |
||||
cb = cb.handler; |
||||
} |
||||
if (typeof cb === "string") { |
||||
cb = model[cb]; |
||||
} |
||||
return oldWatch.call(this, model, expOrFn, function () { |
||||
options && options.store && pushTarget(options.store); |
||||
try { |
||||
var res = cb.apply(this, arguments); |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
options && options.store && popTarget(); |
||||
return res; |
||||
}, options); |
||||
}; |
||||
|
||||
function findStore (widget) { |
||||
if (target != null) { |
||||
return target; |
||||
} |
||||
widget = widget || BI.Widget.context; |
||||
var p = widget; |
||||
while (p) { |
||||
if (p instanceof Fix.Model || p.store || p.__cacheStore) { |
||||
break; |
||||
} |
||||
p = p._parent || (p.options && p.options.element) || p._context; |
||||
} |
||||
if (p) { |
||||
if (p instanceof Fix.Model) { |
||||
return widget.__cacheStore = p; |
||||
} |
||||
widget.__cacheStore = p.store || p.__cacheStore; |
||||
return p.__cacheStore || p.store; |
||||
} |
||||
} |
||||
|
||||
// _.each(["populate", "addItems", "prependItems"], function (name) {
|
||||
// var old = BI.Loader.prototype[name];
|
||||
// BI.Loader.prototype[name] = function () {
|
||||
// BI.Widget.pushContext(this);
|
||||
// try {
|
||||
// var result = old.apply(this, arguments);
|
||||
// } catch (e) {
|
||||
// console.error(e);
|
||||
// }
|
||||
// BI.Widget.popContext();
|
||||
// return result;
|
||||
// };
|
||||
// });
|
||||
|
||||
function createStore () { |
||||
var needPop = false; |
||||
if (_global.Fix && this._store) { |
||||
var store = findStore(this.options.context || this._parent || this.options.element || this._context); |
||||
if (store) { |
||||
pushTarget(store); |
||||
needPop = true; |
||||
} |
||||
this.store = this._store(); |
||||
this.store && (this.store._widget = this); |
||||
needPop && popTarget(); |
||||
needPop = false; |
||||
pushTarget(this.store); |
||||
if (this.store instanceof Fix.Model) { |
||||
this.model = this.store.model; |
||||
} else { |
||||
this.model = this.store; |
||||
} |
||||
needPop = true; |
||||
} |
||||
return needPop; |
||||
} |
||||
|
||||
var _init = BI.Widget.prototype._init; |
||||
BI.Widget.prototype._init = function () { |
||||
var self = this; |
||||
var needPop = createStore.call(this); |
||||
try { |
||||
_init.apply(this, arguments); |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
needPop && popTarget(); |
||||
}; |
||||
|
||||
var _render = BI.Widget.prototype._render; |
||||
BI.Widget.prototype._render = function () { |
||||
var needPop = false; |
||||
if (_global.Fix && this._store) { |
||||
needPop = true; |
||||
pushTarget(this.store); |
||||
} |
||||
_render.apply(this, arguments); |
||||
if (_global.Fix && this._store) { |
||||
initWatch(this, this.watch); |
||||
} |
||||
needPop && popTarget(); |
||||
}; |
||||
|
||||
var unMount = BI.Widget.prototype.__d; |
||||
BI.Widget.prototype.__d = function () { |
||||
try { |
||||
unMount.apply(this, arguments); |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
this.store && BI.isFunction(this.store.destroy) && this.store.destroy(); |
||||
BI.each(this._watchers, function (i, unwatches) { |
||||
unwatches = BI.isArray(unwatches) ? unwatches : [unwatches]; |
||||
BI.each(unwatches, function (j, unwatch) { |
||||
unwatch(); |
||||
}); |
||||
}); |
||||
this._watchers && (this._watchers = []); |
||||
if (this.store) { |
||||
this.store._parent && (this.store._parent = null); |
||||
this.store._widget && (this.store._widget = null); |
||||
this.store = null; |
||||
} |
||||
delete this.__cacheStore; |
||||
}; |
||||
|
||||
_.each(["__afterRender", "_mount", "__afterMount"], function (name) { |
||||
var old = BI.Widget.prototype[name]; |
||||
old && (BI.Widget.prototype[name] = function () { |
||||
this.store && pushTarget(this.store); |
||||
try { |
||||
var res = old.apply(this, arguments); |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
this.store && popTarget(); |
||||
return res; |
||||
}); |
||||
}); |
||||
}()); |
@ -0,0 +1,157 @@
|
||||
;(function () { |
||||
var contexts = {}; |
||||
|
||||
var WORKER; |
||||
BI.useWorker = function (wk) { |
||||
WORKER = wk; |
||||
|
||||
var _init = BI.Widget.prototype._init; |
||||
BI.Widget.prototype._init = function () { |
||||
this.$destroyWorker = createWorker.call(this); |
||||
try { |
||||
_init.apply(this, arguments); |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
}; |
||||
|
||||
var _initRender = BI.Widget.prototype._initRender; |
||||
var postMessage = function (data) { |
||||
switch (data.eventType) { |
||||
case "create": |
||||
this.model = data.msg; |
||||
_initRender.call(this); |
||||
break; |
||||
case "watch": |
||||
var watchArgs = data.args; |
||||
this.watch[data.currentWatchType].apply(this, watchArgs); |
||||
break; |
||||
} |
||||
}; |
||||
BI.Widget.prototype._initRender = function () { |
||||
if (WORKER && this._worker) { |
||||
this.__asking = true; |
||||
this.__async = true; |
||||
} else { |
||||
_initRender.apply(this, arguments); |
||||
} |
||||
}; |
||||
|
||||
var unMount = BI.Widget.prototype.__d; |
||||
BI.Widget.prototype.__d = function () { |
||||
this.$destroyWorker && this.$destroyWorker(); |
||||
try { |
||||
unMount.apply(this, arguments); |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
}; |
||||
|
||||
if (WORKER) { |
||||
WORKER.addEventListener("message", function (e) { |
||||
var data = e.data; |
||||
postMessage.apply(contexts[data.name], [data]); |
||||
}, false); |
||||
} |
||||
}; |
||||
|
||||
function createWorker () { |
||||
var self = this; |
||||
if (this._worker) { |
||||
var name = this.getName(); |
||||
var modelType = this._worker(); |
||||
var options; |
||||
if (BI.isArray(modelType)) { |
||||
options = modelType[1]; |
||||
modelType = modelType[0]; |
||||
} |
||||
if (WORKER) { |
||||
contexts[name] = this; |
||||
WORKER.postMessage({ |
||||
type: modelType, |
||||
name: name, |
||||
eventType: "create", |
||||
options: options, |
||||
watches: BI.map(this.watch, function (key) { |
||||
return key; |
||||
}) |
||||
}); |
||||
var store = {}; |
||||
this.store = new Proxy(store, { |
||||
get: function (target, key) { |
||||
return function () { |
||||
WORKER.postMessage({ |
||||
type: modelType, |
||||
name: name, |
||||
eventType: "action", |
||||
action: key, |
||||
args: [].slice.call(arguments) |
||||
}); |
||||
}; |
||||
}, |
||||
set: function (target, key, value) { |
||||
return Reflect.set(target, key, value); |
||||
} |
||||
}); |
||||
return function () { |
||||
delete contexts[name]; |
||||
WORKER.postMessage({ |
||||
type: modelType, |
||||
name: name, |
||||
eventType: "destroy" |
||||
}); |
||||
}; |
||||
} else { |
||||
this.store = BI.Models.getModel(modelType, options); |
||||
this.store && (this.store._widget = this); |
||||
if (this.store instanceof Fix.Model) { |
||||
this.model = this.store.model; |
||||
} else { |
||||
this.model = this.store; |
||||
} |
||||
initWatch(this, this.watch); |
||||
return function () { |
||||
this.store && BI.isFunction(this.store.destroy) && this.store.destroy(); |
||||
BI.each(this._watchers, function (i, unwatches) { |
||||
unwatches = BI.isArray(unwatches) ? unwatches : [unwatches]; |
||||
BI.each(unwatches, function (j, unwatch) { |
||||
unwatch(); |
||||
}); |
||||
}); |
||||
this._watchers && (this._watchers = []); |
||||
if (this.store) { |
||||
this.store._parent && (this.store._parent = null); |
||||
this.store._widget && (this.store._widget = null); |
||||
this.store = null; |
||||
} |
||||
}; |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
function initWatch (vm, watch) { |
||||
vm._watchers || (vm._watchers = []); |
||||
for (var key in watch) { |
||||
var handler = watch[key]; |
||||
if (BI.isArray(handler)) { |
||||
for (var i = 0; i < handler.length; i++) { |
||||
vm._watchers.push(createWatcher(vm, key, handler[i])); |
||||
} |
||||
} else { |
||||
vm._watchers.push(createWatcher(vm, key, handler)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function createWatcher (vm, keyOrFn, cb, options) { |
||||
if (BI.isPlainObject(cb)) { |
||||
options = cb; |
||||
cb = cb.handler; |
||||
} |
||||
options = options || {}; |
||||
return Fix.watch(vm.model, keyOrFn, _.bind(cb, vm), BI.extend(options, { |
||||
store: vm.store |
||||
})); |
||||
} |
||||
}()); |
After Width: | Height: | Size: 426 KiB |
After Width: | Height: | Size: 771 B |
After Width: | Height: | Size: 725 B |
After Width: | Height: | Size: 637 B |
After Width: | Height: | Size: 608 B |
After Width: | Height: | Size: 617 B |
After Width: | Height: | Size: 744 B |
After Width: | Height: | Size: 45 B |
After Width: | Height: | Size: 652 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 301 B |
After Width: | Height: | Size: 200 B |
After Width: | Height: | Size: 192 B |
After Width: | Height: | Size: 199 B |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 707 B |
After Width: | Height: | Size: 508 B |
After Width: | Height: | Size: 353 B |
After Width: | Height: | Size: 202 B |
After Width: | Height: | Size: 341 B |
After Width: | Height: | Size: 205 B |
After Width: | Height: | Size: 202 B |
After Width: | Height: | Size: 500 B |
After Width: | Height: | Size: 448 B |
After Width: | Height: | Size: 456 B |
After Width: | Height: | Size: 200 B |
After Width: | Height: | Size: 233 B |
After Width: | Height: | Size: 250 B |
After Width: | Height: | Size: 238 B |
After Width: | Height: | Size: 179 B |
After Width: | Height: | Size: 214 B |
After Width: | Height: | Size: 231 B |
After Width: | Height: | Size: 217 B |
After Width: | Height: | Size: 102 B |
After Width: | Height: | Size: 144 B |
After Width: | Height: | Size: 162 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 138 B |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 225 B |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 200 B |
After Width: | Height: | Size: 199 B |
After Width: | Height: | Size: 388 B |
After Width: | Height: | Size: 371 B |
After Width: | Height: | Size: 398 B |
After Width: | Height: | Size: 384 B |
After Width: | Height: | Size: 382 B |
After Width: | Height: | Size: 416 B |
After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 425 B |
After Width: | Height: | Size: 233 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 456 B |
After Width: | Height: | Size: 199 B |
After Width: | Height: | Size: 233 B |
After Width: | Height: | Size: 247 B |
After Width: | Height: | Size: 236 B |
After Width: | Height: | Size: 179 B |
After Width: | Height: | Size: 209 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 212 B |
After Width: | Height: | Size: 102 B |
After Width: | Height: | Size: 143 B |
After Width: | Height: | Size: 162 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 138 B |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 45 B |
After Width: | Height: | Size: 652 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 534 B |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 707 B |
After Width: | Height: | Size: 1.3 KiB |