hint.append( "</p></form>" );
formText.setText( hint.toString(), true, true );
Composite bottomPanel = toolkit.createComposite( knowPanel );
TableWrapLayout tableLayout = new TableWrapLayout();
tableLayout.verticalSpacing = 0;
tableLayout.leftMargin = 10;
bottomPanel.setLayout( tableLayout );
Composite btnPanel = toolkit.createComposite( bottomPanel );
RowLayout layout = new RowLayout();
layout.spacing = 1;
layout.wrap = true;
layout.marginTop = 5;
layout.marginBottom = 0;
btnPanel.setLayout( layout );
String resourceID = hash.get( "ID" );
ImageHyperlink btn;
btn = toolkit.createImageHyperlink( btnPanel, SWT.WRAP );
btn.setImage( positiveImg );
btn.setToolTipText( "Vote the note as helpful" );
btn.setHref( resourceID );
btn.addHyperlinkListener( new HyperlinkAdapter() {
@Override
public void linkActivated( HyperlinkEvent e )
{
getEmbetClient().vote( (String) e.getHref(), "Good", userID );
reloadContent();
}
});
btn = toolkit.createImageHyperlink( btnPanel, SWT.WRAP );
btn.setImage( negativeImg );
btn.setToolTipText( "Vote the note as NOT helpful" );
btn.setHref( resourceID );
btn.addHyperlinkListener( new HyperlinkAdapter() {
@Override
public void linkActivated( HyperlinkEvent e )
{
getEmbetClient().vote( (String) e.getHref(), "Bad", userID );
reloadContent();
}
});
btn = toolkit.createImageHyperlink( btnPanel, SWT.WRAP );
btn.setImage( removeImg );
btn.setToolTipText( "Don't show the note in this context" );
btn.setHref( resourceID );
btn.addHyperlinkListener( new HyperlinkAdapter() {
@Override
public void linkActivated( HyperlinkEvent e )
{
getEmbetClient().vote( (String) e.getHref(), "Close", userID );
reloadContent();
}
});
if( hash.containsKey( "Author") ) {
Composite userPanel = toolkit.createComposite( btnPanel );
RowLayout aLayout = new RowLayout();
aLayout.center = true;
aLayout.marginTop = 0;
aLayout.marginBottom = 0;
aLayout.marginLeft = 10;
userPanel.setLayout( aLayout );
Label lbl = toolkit.createLabel( userPanel, null, SWT.NONE );
lbl.setImage( userImg );
lbl = toolkit.createLabel( userPanel, hash.get("Author"), SWT.NONE );
lbl.setToolTipText( "Author of the note" );
lbl.setForeground( colorDarkGray );
}
Composite timePanel = toolkit.createComposite( bottomPanel );
layout = new RowLayout();
layout.spacing = 40;
layout.wrap = true;
layout.marginTop = 0;
layout.marginBottom = 0;
timePanel.setLayout( layout );
String vote, relevance, total;
DecimalFormat formatter = new DecimalFormat( "0.00" );
relevance = Integer.toString( (int)( Float.parseFloat( hash.get("Relevance") ) * 100 ) );
vote = formatter.format( Float.parseFloat( hash.get("Vote") ) );
total = formatter.format( Float.parseFloat( hash.get("Total") ) ) ;
Label lbl;
lbl = toolkit.createLabel( timePanel, total + " (r: " + relevance + "%, v: " + vote + ")" );
lbl.setToolTipText( "Total score (context relevance, cumulative vote)" );
// lbl.setForeground( colorDarkGray );
lbl = toolkit.createLabel( timePanel, hash.get("Time") );
lbl.setForeground( colorGray );
// separator line
lbl = toolkit.createSeparator( knowPanel, SWT.HORIZONTAL | SWT.SHADOW_IN );
lbl.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
// create space for next note
Composite sep = toolkit.createComposite( knowPanel );
TableWrapLayout layout2 = new TableWrapLayout();
layout2.topMargin = 0;
layout2.bottomMargin = 0;
sep.setLayout( layout2 );
toolkit.createLabel( sep, "" );
}