2014-10-16 102 views
0

我對JIRA很新,我目前正在將JIRA插件與JIRA問題跟蹤系統集成。我的計劃是創建幾個自定義字段,然後創建一個包含這些字段的自定義屏幕(FieldScreen)。我創建了一個自定義字段,但我在創建屏幕時遇到了麻煩。JIRA開發 - 以編程方式創建屏幕(FieldScreen)

// Create issue type: 
IssueType myIssueType = this.issueTypeManager.createIssueType("FOO", "FOOBAR", "/images/icons/issuetypes/genericissue.png"); 

// Create custom field: 
// Create a list of issue types for which the custom field needs to be available  
List<GenericValue> issueTypes = new ArrayList<GenericValue>(); 
issueTypes.add(myIssueType.getGenericValue()); 

// Create a list of project contexts for which the custom field needs to be available 
List<JiraContextNode> contexts = new ArrayList<JiraContextNode>(); 
contexts.add(GlobalIssueContext.getInstance()); 

CustomFieldType fieldType = this.customFieldManager.getCustomFieldType("com.atlassian.jira.plugin.system.customfieldtypes:textfield"); 
CustomFieldSearcher fieldSearcher = this.customFieldManager.getCustomFieldSearcher("com.atlassian.jira.plugin.system.customfieldtypes:textsearcher"); 
CustomField cField = this.customFieldManager.createCustomField("Basic Text Field", "This is a basic text field", fieldType, fieldSearcher, contexts, issueTypes); 

/* 
    Change this next part, instead of adding to the default screen: 
    1) Create a new screen (FieldScreen) 
    2) Add the custom field (cField) to that screen 
*/ 

// Add field to default Screen 
FieldScreen defaultScreen = fieldScreenManager.getFieldScreen(FieldScreen.DEFAULT_SCREEN_ID); 
if (!defaultScreen.containsField(cField.getId())) { 
    FieldScreenTab firstTab = defaultScreen.getTab(0); 
    firstTab.addFieldScreenLayoutItem(cField.getId()); 
} 

回答