一條老狗

                     老狗拉破車
          posts - 12, comments - 11, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          2007年10月24日

          今天由XNA3.0升級到4.0,竟然報錯:

          No suitable graphics card supported. Could not find a Direct3D device that supports the XNA Framework HiDef Profile.

          原來是因為我的顯卡不支持DirectX 10,在工程屬性中把Hidef修改為Reach即可。

          http://msdn.microsoft.com/en-us/library/ff604995.aspx

          posted @ 2010-09-24 21:07 一條老狗 閱讀(4038) | 評論 (2)編輯 收藏

          JIRA插件開發的工作本早已結束。
          但近日有個朋友來問,如何在IssueNavigator顯示時,顯示用戶的帳號名(username),而不是其FullName。

          當時我為他提供了兩種思路:

          思路1。寫一個自定義字段插件,這個插件就是按用戶名來顯示報告者及被分派者。
          然后再自定義問題導航欄,把你的自定義字段添加進去即可。

          思路2。繼承并覆蓋問題導航功能的Action,直接修改其顯示的數據。

          這個問題挺有意思,今日閑來無事,對第二種思路寫了點代碼來實現一下。

          首先我們繼承IssueNavigator類:

          public class IssueNavigator extends com.atlassian.jira.web.action.issue.IssueNavigator {

              
          private boolean convertedResults = false;
              
          public SearchResults getSearchResults() throws SearchException {
                  SearchResults results 
          = super.getSearchResults();
                  
          if (!convertedResults && results != null{
                      convertedResults 
          = true;

                      List issueList 
          = results.getIssues();
                      
          for (int i = 0; i < issueList.size(); i++{
                          com.atlassian.jira.issue.DocumentIssueImpl issue 
          =
                                  (com.atlassian.jira.issue.DocumentIssueImpl)issueList.get(i);

                          Document document 
          = null;
                          
          try {
                              Field f 
          = issue.getClass().getDeclaredField("document");
                              f.setAccessible(
          true);
                              document 
          = (Document)f.get(issue);
                              f.setAccessible(
          false);
                          }
           catch (NoSuchFieldException e) {
                              e.printStackTrace();
                          }
           catch (IllegalAccessException e) {
                              e.printStackTrace();
                          }


                          DocumentIssueImpl newIssue 
          = new DocumentIssueImpl(
                                  document,
                                  ComponentManager.getInstance().getConstantsManager(),
                                  ComponentManager.getInstance().getFieldManager(),
                                  ComponentManager.getInstance().getIssueManager(),
                                  ComponentManager.getInstance().getIssueFactory(),
                                  ComponentManager.getInstance().getAttachmentManager(),
                                  ComponentManager.getInstance().getProjectFactory()
                          );

                          issueList.set(i, newIssue); 
                      }

                  }


                  
          return results;
              }


          }

          然后覆蓋其 getSearchResults() 方法,將issueList中的對象換為我們的新對象(DocumentIssueImpl)。
          注意: 這里面為了取回document對象,使有了反射。或許有其它辦法,這里只做一個測試,不考慮其它問題。

          為此,我們需要再繼承一個類 DocumentIssueImpl:
          public class DocumentIssueImpl extends com.atlassian.jira.issue.DocumentIssueImpl {

              
          private User resetUserFullName(User user) {
                  user.setFullName(user.getName());
                  
          return user;
              }


              
          public User getAssignee()
              
          {
                  
          return resetUserFullName(super.getAssignee());
              }


              
          public User getReporter()
              
          {
                  
          return resetUserFullName(super.getReporter());
              }

          }

          然后我們覆蓋其 getAssignee() getReporter() 方法,把username賦值給fullname
          這樣當調用 getFullName 時返回的就是 username了。

          然后插件配置文件中覆蓋IssueNavigation Action

          <action name="xxx.IssueNavigator" alias="IssueNavigator">
              
          <view name="success">/secure/views/navigator/navigator.jsp</view>
              
          <view name="error">/secure/views/navigator/navigator.jsp</view>
          </action>

          完成!

          posted @ 2007-10-24 11:40 一條老狗 閱讀(2155) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 平利县| 房产| 如皋市| 射阳县| 保靖县| 板桥市| 邯郸市| 龙泉市| 柳州市| 娄底市| 平度市| 东港市| 鄯善县| 巫山县| 高要市| 饶阳县| 遵义县| 潍坊市| 娄烦县| 巫山县| 佳木斯市| 玛纳斯县| 宝兴县| 环江| 宜黄县| 吉首市| 江城| 巴南区| 彩票| 云和县| 武宁县| 阳谷县| 昆明市| 南溪县| 麻江县| 天等县| 宜阳县| 福鼎市| 南通市| 涞源县| 清水河县|