// Left and right tool bar
private final ToolBar bar1, bar2, bar3;
- private final Button assign;
-
- //private final StyledText text;
-
// Control to change brush size
private final BrushControl brushControl;
public static Combo comboLabel;
+ private static Button assign;
+
// Current segmentation tool
private Segmenter segmenter;
bar1 = new ToolBar(this, SWT.RIGHT | SWT.FLAT);
bar2 = new ToolBar(this, SWT.RIGHT | SWT.FLAT);
bar3 = new ToolBar(this, SWT.RIGHT | SWT.FLAT);
- assign = new Button(bar3, SWT.PUSH);
view = new AnnotatedImageControl(this, SWT.BORDER);
brushControl = new BrushControl(getShell(), SWT.BORDER);
eventHandler = new EventHandler();
SwtUtils.addLabel(bar3, getAction(Tool.SetLabel).getText());
comboLabel = SwtUtils.addCombo(bar3, 150, SWT.SIMPLE);
comboLabel.setToolTipText( getAction(Tool.SetLabel).getToolTipText());
- comboLabel.addKeyListener(new KeyListener() {
- @Override
+ comboLabel.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
- ArrayList<String> listElements = new ArrayList<String>();
- //For the down arrow functionality
- if(e.keyCode == 16777218)
- {
- comboLabel.setListVisible(true);
- }
- // If key pressed is only a number of charecter or space.
- else if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 97 && e.keyCode <= 122) || e.keyCode == 32)
- {
- //For removing all previously assigned labels
- comboLabel.remove(0,comboLabel.getItemCount()-1);
- listElements = labels.getLabels(comboLabel.getText());
- assign.setEnabled(!(comboLabel.getText().isEmpty()));
-
- }
- for (int i=0; i<listElements.size();i++)
- {
- comboLabel.add(listElements.get(i),i);
- }
- }
- @Override
- public void keyPressed(KeyEvent arg0) {
- // TODO Auto-generated method stub
+ dropdownLabels(e);
}
});
- ToolItem item = new ToolItem(bar3, SWT.SEPARATOR);
- assign.setText("Assign");
- item.setWidth(50);
- item.setControl(assign);
- assign.addSelectionListener(new SelectionListener() {
+ assign = SwtUtils.addButton(bar3, 50, "Assign");
+ assign.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
if(view.getContext().isEnabled())
{
view.getContext().getEnabledMask().segmentName = comboLabel.getText();
}
}
- System.out.println("selected"+view.getContext().getEnabledMask().segmentName);
execute(Tool.AssignButton, null);
}
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- // TODO Auto-generated method stub
- }
});
bar3.pack();
}
-
+ /**
+ * For dropping down the labels on pressing the down arrow key just like "Google suggests" functionality.
+ * @param e
+ */
+ public void dropdownLabels(KeyEvent e)
+ {
+ ArrayList<String> listElements = new ArrayList<String>();
+ //For the down arrow functionality
+ if(e.keyCode == 16777218)
+ {
+ comboLabel.setListVisible(true);
+ }
+ // If key pressed is only a number of charecter or space.
+ else if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 97 && e.keyCode <= 122) || e.keyCode == 32)
+ {
+ //For removing all previously assigned labels
+ comboLabel.remove(0,comboLabel.getItemCount()-1);
+ listElements = labels.getLabels(comboLabel.getText());
+ assign.setEnabled(!(comboLabel.getText().isEmpty()));
+
+ }
+ for (int i=0; i<listElements.size();i++)
+ {
+ comboLabel.add(listElements.get(i),i);
+ }
+ }
+
private void layoutControls() {
GridLayout layout = new GridLayout(3, false);
layout.marginHeight = 1;
return segmenter;
}
-
public void setContext(SegmentationContext ctx) {
// context change handler handles initialization etc.