|
Added
Link Here
|
| 1 |
package com.ibm.etools.symptom.presentation; |
| 2 |
|
| 3 |
import java.text.DateFormat; |
| 4 |
import java.text.SimpleDateFormat; |
| 5 |
import java.util.GregorianCalendar; |
| 6 |
import java.util.Date; |
| 7 |
import org.eclipse.hyades.models.symptom.SimpleMatchPattern; |
| 8 |
import org.eclipse.swt.SWT; |
| 9 |
import org.eclipse.swt.custom.CCombo; |
| 10 |
import org.eclipse.swt.layout.GridData; |
| 11 |
import org.eclipse.swt.layout.GridLayout; |
| 12 |
import org.eclipse.swt.widgets.Composite; |
| 13 |
import org.eclipse.swt.widgets.Label; |
| 14 |
import org.eclipse.swt.widgets.Text; |
| 15 |
import org.eclipse.ui.forms.events.ExpansionAdapter; |
| 16 |
import org.eclipse.ui.forms.events.ExpansionEvent; |
| 17 |
import org.eclipse.ui.forms.widgets.Section; |
| 18 |
import com.ibm.etools.symptom.editor.SymptomEditPlugin; |
| 19 |
import com.ibm.etools.symptom.editor.internal.util.GridUtil; |
| 20 |
import com.ibm.etools.symptom.editor.internal.util.SymptomEditMessages; |
| 21 |
|
| 22 |
public class AnalysisMatchPatternDetails extends SimpleMatchPatternDetails { |
| 23 |
protected Text creationTime; |
| 24 |
protected final int CREATION_TIME_ID = 8; |
| 25 |
|
| 26 |
public AnalysisMatchPatternDetails(SymptomEditor analysisEditor){ |
| 27 |
super(analysisEditor); |
| 28 |
} |
| 29 |
|
| 30 |
public void createClientArea() { |
| 31 |
//match pattern properties section |
| 32 |
|
| 33 |
Section matchPatternSection = toolkit.createSection(client, |
| 34 |
Section.DESCRIPTION|Section.TWISTIE|Section.EXPANDED); |
| 35 |
GridLayout detailsLayout = new GridLayout(); |
| 36 |
detailsLayout.marginWidth = detailsLayout.marginHeight = 2; |
| 37 |
matchPatternSection.setLayout(detailsLayout); |
| 38 |
GridData data = GridUtil.createFill(); |
| 39 |
data.horizontalSpan = 2; |
| 40 |
matchPatternSection.setLayoutData(data); |
| 41 |
matchPatternSection.addExpansionListener(new ExpansionAdapter() { |
| 42 |
public void expansionStateChanged(ExpansionEvent e) { |
| 43 |
client.layout(); |
| 44 |
} |
| 45 |
}); |
| 46 |
matchPatternSection.setText(SymptomEditMessages._108); |
| 47 |
toolkit.createCompositeSeparator(matchPatternSection); |
| 48 |
matchPatternSection.setDescription(SymptomEditMessages._107); |
| 49 |
|
| 50 |
Composite sectionClient = toolkit.createComposite(matchPatternSection); |
| 51 |
detailsLayout = new GridLayout(); |
| 52 |
detailsLayout.marginWidth = detailsLayout.marginHeight = 2; |
| 53 |
detailsLayout.numColumns = 2; |
| 54 |
sectionClient.setLayout(detailsLayout); |
| 55 |
data = GridUtil.createFill(); |
| 56 |
sectionClient.setLayoutData(data); |
| 57 |
matchPatternSection.setClient(sectionClient); |
| 58 |
|
| 59 |
Label l = toolkit.createLabel(sectionClient, getString("_UI_SimpleMatchPattern_name_feature")+":", SWT.WRAP); |
| 60 |
name = toolkit.createText(sectionClient, "", SWT.NONE); |
| 61 |
name.setData(new Integer(NAME_ID)); |
| 62 |
setLayout(l,name); |
| 63 |
name.setToolTipText(SymptomEditMessages._159); |
| 64 |
|
| 65 |
l = toolkit.createLabel(sectionClient, getString("_UI_SimpleMatchPattern_value_feature")+":", SWT.WRAP); |
| 66 |
value = toolkit.createText(sectionClient, "", SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); |
| 67 |
value.setData(new Integer(VALUE_ID)); |
| 68 |
setLayout(l,value); |
| 69 |
value.setToolTipText(SymptomEditMessages._164); |
| 70 |
|
| 71 |
l = toolkit.createLabel(sectionClient, getString("_UI_KnowledgeType_knowledgeCategory_feature")+":", SWT.WRAP); |
| 72 |
knowledgeCategory = toolkit.createText(sectionClient, "", SWT.NONE); |
| 73 |
knowledgeCategory.setData(new Integer(KNOWLEDGE_CAT_ID)); |
| 74 |
setLayout(l,knowledgeCategory); |
| 75 |
knowledgeCategory.setToolTipText(SymptomEditMessages._142); |
| 76 |
|
| 77 |
l = toolkit.createLabel(sectionClient, getString("_UI_KnowledgeType_knowledgeScope_feature")+":", SWT.WRAP); |
| 78 |
knowledgeScope = toolkit.createText(sectionClient, "", SWT.NONE); |
| 79 |
knowledgeScope.setData(new Integer(KNOWLEDGE_SCOPE_ID)); |
| 80 |
setLayout(l,knowledgeScope); |
| 81 |
knowledgeScope.setToolTipText(SymptomEditMessages._143); |
| 82 |
|
| 83 |
toolkit.paintBordersFor(sectionClient); |
| 84 |
|
| 85 |
//createSpace(toolkit,client,2); |
| 86 |
|
| 87 |
//symptom properties section |
| 88 |
Section symptomInfoSection = toolkit.createSection(client, |
| 89 |
Section.DESCRIPTION|Section.TWISTIE|Section.EXPANDED); |
| 90 |
detailsLayout = new GridLayout(); |
| 91 |
detailsLayout.marginWidth = detailsLayout.marginHeight = 2; |
| 92 |
symptomInfoSection.setLayout(detailsLayout); |
| 93 |
data = GridUtil.createFill(); |
| 94 |
data.horizontalSpan = 2; |
| 95 |
symptomInfoSection.setLayoutData(data); |
| 96 |
symptomInfoSection.addExpansionListener(new ExpansionAdapter() { |
| 97 |
public void expansionStateChanged(ExpansionEvent e) { |
| 98 |
client.layout(); |
| 99 |
} |
| 100 |
}); |
| 101 |
symptomInfoSection.setText(SymptomEditMessages._176); |
| 102 |
toolkit.createCompositeSeparator(symptomInfoSection); |
| 103 |
symptomInfoSection.setDescription(SymptomEditMessages._175); |
| 104 |
|
| 105 |
Composite symptomSectionClient = toolkit.createComposite(symptomInfoSection); |
| 106 |
detailsLayout = new GridLayout(); |
| 107 |
detailsLayout.marginWidth = detailsLayout.marginHeight = 2; |
| 108 |
detailsLayout.numColumns = 2; |
| 109 |
symptomSectionClient.setLayout(detailsLayout); |
| 110 |
data = GridUtil.createFill(); |
| 111 |
symptomSectionClient.setLayoutData(data); |
| 112 |
symptomInfoSection.setClient(symptomSectionClient); |
| 113 |
|
| 114 |
l = toolkit.createLabel(symptomSectionClient,SymptomEditPlugin.INSTANCE.getString("_UI_AnalysisMatchPattern_creationTime_feature")+":", SWT.WRAP); |
| 115 |
creationTime = toolkit.createText(symptomSectionClient, "", SWT.NONE); |
| 116 |
creationTime.setData(new Integer(CREATION_TIME_ID)); |
| 117 |
setLayout(l,creationTime); |
| 118 |
creationTime.setToolTipText(SymptomEditMessages._190); |
| 119 |
|
| 120 |
l = toolkit.createLabel(symptomSectionClient, SymptomEditPlugin.INSTANCE.getString("_UI_SimpleMatchPattern_expirationTime_feature")+":", SWT.WRAP); |
| 121 |
expirationTime = toolkit.createText(symptomSectionClient, "", SWT.NONE); |
| 122 |
expirationTime.setData(new Integer(EXPIRATION_TIME_ID)); |
| 123 |
setLayout(l,expirationTime); |
| 124 |
expirationTime.setToolTipText(SymptomEditMessages._158); |
| 125 |
|
| 126 |
l = toolkit.createLabel(symptomSectionClient, getString("_UI_SimpleMatchPattern_priority_feature")+":", SWT.WRAP); |
| 127 |
priority = toolkit.createText(symptomSectionClient, "", SWT.NONE); |
| 128 |
priority.setData(new Integer(PRIORITY_ID)); |
| 129 |
setLayout(l,priority); |
| 130 |
priority.setToolTipText(SymptomEditMessages._160); |
| 131 |
|
| 132 |
l = toolkit.createLabel(symptomSectionClient, getString("_UI_SimpleMatchPattern_probability_feature")+":", SWT.WRAP); |
| 133 |
probability = toolkit.createText(symptomSectionClient, "", SWT.NONE); |
| 134 |
probability.setData(new Integer(PROBABILITY_ID)); |
| 135 |
setLayout(l,probability); |
| 136 |
probability.setToolTipText(SymptomEditMessages._161); |
| 137 |
|
| 138 |
l = toolkit.createLabel(symptomSectionClient, getString("_UI_KnowledgeType_state_feature")+":", SWT.WRAP); |
| 139 |
state = new CCombo(symptomSectionClient, SWT.FLAT); |
| 140 |
toolkit.adapt(state,false,false); |
| 141 |
state.setData(new Integer(STATE_ID)); |
| 142 |
setLayout(l,state); |
| 143 |
state.setToolTipText(SymptomEditMessages._162); |
| 144 |
|
| 145 |
l = toolkit.createLabel(symptomSectionClient, getString("_UI_SimpleMatchPattern_symptomType_feature")+":", SWT.WRAP); |
| 146 |
type = toolkit.createText(symptomSectionClient, "", SWT.NONE); |
| 147 |
type.setData(new Integer(TYPE_ID)); |
| 148 |
setLayout(l,type); |
| 149 |
type.setToolTipText(SymptomEditMessages._163); |
| 150 |
|
| 151 |
// l = toolkit.createLabel(symptomSectionClient, getString("_UI_SimpleMatchPattern_version_feature")+":", SWT.WRAP); |
| 152 |
// version = toolkit.createText(symptomSectionClient, "", SWT.NONE); |
| 153 |
// version.setEditable(true); |
| 154 |
// version.setData(new Integer(VERSION_ID)); |
| 155 |
// version.addModifyListener(this); |
| 156 |
// setLayout(l,version); |
| 157 |
// version.setToolTipText(SymptomEditMessages._165); |
| 158 |
|
| 159 |
name.addModifyListener(this); |
| 160 |
value.addModifyListener(this); |
| 161 |
knowledgeCategory.addModifyListener(this); |
| 162 |
knowledgeScope.addModifyListener(this); |
| 163 |
expirationTime.addModifyListener(this); |
| 164 |
priority.addModifyListener(this); |
| 165 |
probability.addModifyListener(this); |
| 166 |
state.addSelectionListener(this); |
| 167 |
type.addModifyListener(this); |
| 168 |
|
| 169 |
toolkit.paintBordersFor(symptomSectionClient); |
| 170 |
|
| 171 |
} |
| 172 |
|
| 173 |
private long getSymptomDescriptionCreationTime(String creationTime) { |
| 174 |
return( new GregorianCalendar(Integer |
| 175 |
.parseInt(creationTime.substring(0, 4)), Integer |
| 176 |
.parseInt(creationTime.substring(5, 7)), Integer |
| 177 |
.parseInt(creationTime.substring(8, 10)), Integer |
| 178 |
.parseInt(creationTime.substring(11, 13)), Integer |
| 179 |
.parseInt(creationTime.substring(14, 16)), Integer |
| 180 |
.parseInt(creationTime.substring(17))).getTimeInMillis()); |
| 181 |
} |
| 182 |
|
| 183 |
public void refresh(){ |
| 184 |
if(!(eObject instanceof SimpleMatchPattern)) |
| 185 |
return; |
| 186 |
refresh = true; |
| 187 |
if(((SimpleMatchPattern) eObject).getCreationTime() != null){ |
| 188 |
DateFormat dateFormat = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss"); |
| 189 |
Date date = new Date(getSymptomDescriptionCreationTime(((SimpleMatchPattern) eObject).getCreationTime().toString())); |
| 190 |
creationTime.setText(dateFormat.format(date)); |
| 191 |
} |
| 192 |
refresh = false; |
| 193 |
super.refresh(); |
| 194 |
} |
| 195 |
} |