Re: [问题] 请问有人在玩GWT-BootStrap的吗

楼主: PsMonkey (痞子军团团长)   2014-04-11 12:52:14
反正也没人来寻求 free support,就只好倒贴了
我不是很喜欢写这种 step-by-step
不过有时候不写这种文章人家还以为...
======== 以上纯碎念,与原 po 无关 ========
※ 引述《BignoZe (BignoZe)》之铭言:
: ※ 引述《PsMonkey (痞子军团团长)》之铭言:
: : 喔对,我是看 gwtbootstrap,不是看 gwtbootstrap3
: : pom 档肉眼看起来...
: : 阿等等,明明有这个
: : http://gwtbootstrap.github.io/gwt-bootstrap/dependencies.html
: : 如果我没有解读错,除非你要“开发 / 测试”gwt-bootstrap
: : 不然... 没什么相依性可言
: : “看起来”你直接把 source code 倒进 project 里头也能动
: 我尝试以下列步骤使用gwt-bootstrap
: 1. Add the GWT-bootstrap jar to your project build path
: 2. In the gwt.xml config file add a reference to the gwt-bootstrap library.
: <inherits name ="com.github.gwtbootstrap.Bootstrap"/>
: 3. add the following namespace to the <ui:UiBinder>
: xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
: 设定完之后在uiBinder输入
: <b:heading size="2">Hello World</b:heading>
我昨天只挣扎着要不要用版规办你 [喂喂]
有些细节倒是忘记注意
那个 heading 为什么是小写开头阿阿阿阿 [指]
: 结果会出现莫名的错误
: 因此我推测应该不能直接把source code倒进专案中
首先,你的 jar 档哪来的我不知道
不过 jar 档里头万一没包 source code
那 GWT 肯定让你炸光不让你 compile
再者“source code 倒进专案当中”
不是你说的这种吧......
anyway,空虚硬干完全没技术层次的操作步骤
连 git 都不用,科科
(以下假设用 GPE 的标准 GWT project)
1. 去 https://github.com/gwtbootstrap/gwt-bootstrap
按右下角的 download ZIP
会得到一个 gwt-bootstrap-master.zip
2. 新增一个 Google / Web Application Project
假设 project 名称是 GB、package 名称为 test
3. 将 gwt-bootstrap-master.zip 当中
/src/main/java
底下的 com 目录丢到你的 project
/src
理论上 Eclipse 不会找到什么 error
4. 将 GB.gwt.xml 加入
<inherits name ="com.github.gwtbootstrap.Bootstrap"/>
4. test.GB 这个 class 改成
package test.client;
import com.github.gwtbootstrap.client.ui.Heading;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
public class GB implements EntryPoint {
@Override
public void onModuleLoad() {
RootPanel.get().add(new Heading(1, "Heading1 by new instance"));
RootPanel.get().add(new MyWidget());
}
}
5. 补个 MyWidget.java
package test.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public class MyWidget extends Composite {
private static MyWidgetUiBinder uiBinder =
GWT.create(MyWidgetUiBinder.class);
interface MyWidgetUiBinder extends UiBinder<Widget, MyWidget> {}
public MyWidget() {
initWidget(uiBinder.createAndBindUi(this));
}
}
还有 MyWidget.ui.xml
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:gwtbootstrap="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
</ui:style>
<g:HTMLPanel>
<gwtbootstrap:Heading size="2">Heading 2</gwtbootstrap:Heading>
</g:HTMLPanel>
</ui:UiBinder>
6. 开 develop mode,看结果 [下略]
因为没什么技术含量,所以懒得丢 github
: : 个人观点来说 UI 美化,到最后都是恶梦
: : 你用野生的 bootstrap 还是跟 GWT 合体的 gwt-bootstrap
: 请问有野生的bootstrap例子可以观摩吗
: 对于这个做法没什么头绪
: 我找了一阵子看到的方法是:先将元件的css移除再加上bootstrap的css
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
阿这不就是 Gwt-Bootstrap 在做的事情
你列的讨论串也这样讲了
> you will made a class that extend the original component and
> use this new class everywhere, which is basically what GWT-Bootstrap do.
: 这是原讨论串
: http://ppt.cc/voSQ
======== 以下纯粹插花外提闲聊 ========
UI 方面我不是什么专家
我只能简单说一下我那其实也没很多的经验中
弄 UI 会遇到什么问题
以我的分类,UI 大概就会切成三块
1. 操作功能
2. 样式
3. layout
第一点在 browser + GWT 的架构下不太需要担心
除了 DnD(的功能)没有直接内建之外,基本款大致都有
至少你要把 native browser event 包进来,不会是问题
当然需要一点 JSNI / GWT UI 架构的知识
后面两样跟“美化”会有些关系
我的“样式”就侷限在颜色、字体大小、边框...
这基本上也没啥问题,或著说,有问题也是 CSS 技术的问题
然后就马上自己打枪自己 =="
这在 GWT 当中还蛮多哏的
因为 GWT 可以卡 style 的机会很多
从 host page、gwt.xml 指定 theme 或是 stylesheet
程式码当中还有 UiBinder / CssResource 等等可以乱搞
不说别的,光到底是 setStyleName() 还是 addStyleName() 就很费思量
尤其万一你是要作 widget 给别人用的时候
最麻烦的应该还是 3
光是谁会依内容撑开、谁撑开谁、谁跟谁排在一起的时候要怎么决定顺序
别人我不知道,至少把我搞的很死 Orz
如果又希望 layout 是可以跟着视窗 / 萤幕大小调整
(算初期的 responsive design,还不用删减内容无访)
那就会是恶梦中的恶梦
这会牵扯到 resize 触发之后,各个计算时间点的问题
然后再搭配考量如何在 GWT 中实做... 喔耶... \囧/
组合爆炸,我放弃....... [逃]
所以光是拿掉 CSS、挂上 bootstrap 的 CSS
这最多只是让你的画面看起来像 bootstrap 做出来的东西
(是好事吗? XD)
实际上... 尤其如果你是作 application 导向的东西
bootstrap 够用吗? 我是抱持怀疑的态度啦...
说穿了,UI 就是把玩 CSS / DOM,然后搭配一些 JS
你 or 那个 stackoverflow 说的没啥太大问题
但我会说,这只是打开了恶梦的第一页
阿们
作者: BignoZe (BignoZe)   2014-04-11 14:53:00
刚刚试出来一回来看发现板大已经发了详细教学 (跪违反板规真的很抱歉 以后不会再犯 很多知识了解不多谢指教
楼主: PsMonkey (痞子军团团长)   2014-04-11 15:02:00
所以错误讯息到底是什么阿阿阿 [敲碗]
作者: BignoZe (BignoZe)   2014-04-11 15:20:00
是没有把source code倒进专案的关系 我整理一下m2e的问题

Links booklink

Contact Us: admin [ a t ] ucptt.com