use of org.eclipse.swt.events.KeyEvent in project bndtools by bndtools.
the class TestSuiteLabelProvider method createSection.
private void createSection(Section section, FormToolkit toolkit) {
section.setText(Messages.TestSuitesPart_section_junit_tests);
Composite composite = toolkit.createComposite(section);
section.setClient(composite);
// Section toolbar buttons
ToolBar toolbar = new ToolBar(section, SWT.FLAT);
section.setTextClient(toolbar);
final ToolItem addItem = new ToolItem(toolbar, SWT.PUSH);
addItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
addItem.setToolTipText(Messages.TestSuitesPart_add);
final ToolItem removeItem = new ToolItem(toolbar, SWT.PUSH);
removeItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
removeItem.setDisabledImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE_DISABLED));
removeItem.setToolTipText(Messages.TestSuitesPart_remove);
removeItem.setEnabled(false);
Table table = toolkit.createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
viewer = new TableViewer(table);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new TestSuiteLabelProvider());
toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
final ToolItem btnMoveUp = new ToolItem(toolbar, SWT.PUSH);
btnMoveUp.setText("Up");
btnMoveUp.setImage(imgUp);
btnMoveUp.setEnabled(false);
final ToolItem btnMoveDown = new ToolItem(toolbar, SWT.PUSH);
btnMoveDown.setText("Down");
btnMoveDown.setImage(imgDown);
btnMoveDown.setEnabled(false);
// LISTENERS
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
boolean enabled = selection != null && !selection.isEmpty();
removeItem.setEnabled(enabled);
btnMoveUp.setEnabled(enabled);
btnMoveDown.setEnabled(enabled);
getManagedForm().fireSelectionChanged(TestSuitesPart.this, selection);
}
});
viewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
String name = (String) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (name != null)
doOpenSource(name);
}
});
viewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { ResourceTransfer.getInstance() }, new TestSuiteListDropAdapter());
addItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doAdd();
}
});
removeItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doRemove();
}
});
table.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.character == SWT.DEL) {
doRemove();
} else if (e.character == '+') {
doAdd();
}
}
});
btnMoveUp.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doMoveUp();
}
});
btnMoveDown.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doMoveDown();
}
});
// Layout
GridLayout layout;
layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
composite.setLayout(layout);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
// gd.widthHint = 75;
gd.heightHint = 75;
table.setLayoutData(gd);
toolbar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
}
use of org.eclipse.swt.events.KeyEvent in project bndtools by bndtools.
the class MapValuesContentProvider method createAvailableBundlesPanel.
Control createAvailableBundlesPanel(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
new Label(panel, SWT.NONE).setText("Available Bundles:");
selectionSearchTxt = new Text(panel, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
selectionSearchTxt.setMessage("filter bundle name");
final Tree availableTree = new Tree(panel, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
availableViewer = new TreeViewer(availableTree);
availableViewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
availableViewer.setContentProvider(new RepositoryTreeContentProvider());
availableViewer.setAutoExpandLevel(2);
availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
// Load data
try {
refreshBundleList();
} catch (Exception e) {
setErrorMessage("Error querying repositories: " + e.getMessage());
logger.logError("Error querying repository configuration.", e);
}
// Listeners
selectionSearchTxt.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.ARROW_DOWN)
availableTree.setFocus();
}
});
selectionSearchTxt.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
}
});
availableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
// Enable add button when a bundle or bundle version is selected on
// the left
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) availableViewer.getSelection();
for (Iterator<?> iter = sel.iterator(); iter.hasNext(); ) {
Object element = iter.next();
if (element instanceof RepositoryBundle || element instanceof RepositoryBundleVersion || element instanceof ProjectBundle) {
addButton.setEnabled(true);
return;
}
}
addButton.setEnabled(false);
}
});
availableViewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
doAdd();
}
});
GridLayout layout;
GridData gd;
layout = new GridLayout(1, false);
panel.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
selectionSearchTxt.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 300;
gd.widthHint = 250;
availableTree.setLayoutData(gd);
return panel;
}
use of org.eclipse.swt.events.KeyEvent in project bndtools by bndtools.
the class PluginPathPart method createClient.
/**
* Fill the section.
*/
private void createClient(Section section, FormToolkit toolkit) {
section.setText("Plugin Path");
createToolBar(section);
Table table = new Table(section, SWT.BORDER | SWT.FULL_SELECTION);
toolkit.adapt(table);
toolkit.paintBordersFor(table);
section.setClient(table);
viewer = new TableViewer(table);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new PluginPathLabelProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
boolean enable = !viewer.getSelection().isEmpty();
removeItem.setEnabled(enable);
}
});
table.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.character == SWT.DEL) {
doRemove();
} else if (e.character == '+') {
doAdd();
}
}
});
}
use of org.eclipse.swt.events.KeyEvent in project cogtool by cogtool.
the class WidgetPropertiesPane method createWidgets.
protected void createWidgets() {
// set up widgets, set disabled for launch
widgetName = new DisplayLabel(this, SWT.NONE);
widgetName.setText(L10N.get("FE.WidgetNameCaption", "Widget Name") + ":");
widgetNameText = new WidgetChangeText(this, SWT.SINGLE | SWT.BORDER, FrameEditorLID.ChangeNameProperty, view);
widgetTitle = new DisplayLabel(this, SWT.NONE);
widgetTitle.setText(DISPLAYED_LABEL);
widgetTitleText = new WidgetChangeText(this, SWT.SINGLE | SWT.BORDER, FrameEditorLID.ChangeTitleProperty, view);
widgetAux = new DisplayLabel(this, SWT.NONE);
widgetAux.setText(AUX_TEXT_LABEL);
widgetAuxText = new WidgetChangeText(this, SWT.SINGLE | SWT.BORDER, FrameEditorLID.ChangeAuxTextProperty, view);
widgetType = new DisplayLabel(this, SWT.NONE);
widgetType.setText(L10N.get("FE.WidgetTypeCaption", "Type") + ":");
widgetTypeLabel = new Label(this, SWT.NONE);
widgetMode = new DisplayLabel(this, SWT.NONE);
widgetMode.setText(L10N.get("FE.WidgetModeCaption", "Mode") + ":");
widgetModeValue = new Label(this, SWT.NONE);
widgetRender = new Button(this, SWT.CHECK);
widgetRender.setText(L10N.get("FE.WidgetRenderedCaption", "Render Widget Skin"));
// Add listener to the rendered widget property
widgetRender.addSelectionListener(view.createWidgetChgHandler(FrameEditorLID.SetRenderSkin));
remoteLabel = new DisplayLabel(this, SWT.NONE);
remoteLabel.setText(L10N.get("FE.RemoteLabelCaption", "Remote Label") + ":");
remoteLabelFind = new Link(this, SWT.NONE);
remoteLabelFind.setText(L10N.get("FE.RemoteLabelFind", "<a>Find</a>"));
remoteLabelFind.setFont(FontUtils.getAdjustedFont(remoteLabelFind.getFont(), 8, SWT.BOLD));
remoteLabelText = new WidgetChangeText(this, SWT.SINGLE | SWT.BORDER, FrameEditorLID.SetRemoteLabelText, view);
remoteLabelOwner = new DisplayLabel(this, SWT.NONE);
remoteLabelOwner.setText(L10N.get("FE.RemoteLabelOwnerCaption", "Remote Label Owner") + ":");
remoteLabelOwnerName = new Link(this, SWT.NONE);
remoteLabelType = new DisplayLabel(this, SWT.NONE);
remoteLabelType.setText(L10N.get("FE.RemoteLabelTypeCaption", "Remote Label Type") + ":");
remoteLabelTypeCombo = new View.PerformActionCombo(this, SWT.DROP_DOWN | SWT.READ_ONLY) {
@Override
protected boolean doChangeAction() {
int selectedType = remoteLabelTypeCombo.getSelectionIndex();
FrameEditorUI.SetRemoteLabelTypeParms setTypeParms = new FrameEditorUI.SetRemoteLabelTypeParms(widgetTypeChoices[selectedType], view.selection.getSelectedIWidgets()[0]);
return view.performAction(FrameEditorLID.SetRemoteLabelType, setTypeParms, true);
}
};
for (WidgetType widgetTypeChoice : widgetTypeChoices) {
remoteLabelTypeCombo.add(widgetTypeChoice.toString());
}
imagePath = new DisplayLabel(this, SWT.NONE);
imagePath.setText(IMAGE_PATH);
imagePathText = new TextWithEnableFix(this, SWT.SINGLE | SWT.READ_ONLY);
isInitiallySelected = new Button(this, SWT.CHECK);
isInitiallySelected.setText(L10N.get("FE.InitiallySelected", "Initially Selected"));
WidgetAttributeListener listener = new WidgetAttributeListener(WidgetAttributes.IS_SELECTED_ATTR) {
@Override
public Object getValue() {
return new Boolean(isInitiallySelected.getSelection());
}
};
isInitiallySelected.addSelectionListener(listener);
isButtonSelected = new Button(this, SWT.CHECK);
isButtonSelected.setText(L10N.get("FE.InitiallySelected", "Initially Selected"));
isButtonSelected.setEnabled(false);
listener = new WidgetAttributeListener(WidgetAttributes.IS_SELECTED_ATTR) {
@Override
public Object getValue() {
return new Boolean(isButtonSelected.getSelection());
}
};
isButtonSelected.addSelectionListener(listener);
isToggleable = new Button(this, SWT.CHECK);
isToggleable.setText(L10N.get("FE.Togglable", "Can be toggled"));
listener = new WidgetAttributeListener(WidgetAttributes.IS_TOGGLEABLE_ATTR) {
@Override
public Object getValue() {
boolean sel = isToggleable.getSelection();
isButtonSelected.setEnabled(sel);
return new Boolean(sel);
}
};
isToggleable.addSelectionListener(listener);
/*this.isMultiLine = new Button(parent, SWT.CHECK);
this.isMultiLine.setText(L10N.get("FE.MultiLine", "Multiple Lined"));
listener = new WidgetAttributeListener(WidgetType.IS_MULTILINE_ATTR) {
@Override
public Object getValue() {
return new Boolean(isMultiLine.getSelection());
}
};
this.isMultiLine.addSelectionListener(listener);*/
selectLabel = new DisplayLabel(this, SWT.NONE);
selectLabel.setText(L10N.get("FE.ComboSelectCaption", "Initially Selected Item") + ":");
initiallySelected = new ComboWithEnableFix(this, SWT.DROP_DOWN | SWT.READ_ONLY);
initiallySelected.setVisibleItemCount(8);
initiallySelected.addSelectionListener(selectionAttrListener);
isSeparator = new Button(this, SWT.CHECK);
isSeparator.setText(L10N.get("FE.Separator", "Separator"));
listener = new WidgetAttributeListener(WidgetAttributes.IS_SEPARATOR_ATTR) {
@Override
public Object getValue() {
return (isSeparator.getSelection()) ? WidgetAttributes.IS_SEPARATOR : WidgetAttributes.NON_SEPARATOR;
}
};
isSeparator.addSelectionListener(listener);
isSeparator.moveAbove(widgetTypeLabel);
submenuActionLabel = new DisplayLabel(this, SWT.NONE);
submenuActionLabel.setText(L10N.get("FE.SubmenuActionLabel", "Submenu transition action") + ":");
submenuAction = new ComboWithEnableFix(this, SWT.DROP_DOWN | SWT.READ_ONLY);
// Maximize the possible set of values.
submenuActions = new Integer[] { WidgetAttributes.HOVER_SUBMENU_ACTION, null, null };
submenuAction.add(L10N.get("FE.HoverSubmenuAction", "Hover"));
listener = new WidgetAttributeListener(WidgetAttributes.SUBMENU_ACTION_ATTR) {
@Override
public Object getValue() {
Object a = submenuActions[submenuAction.getSelectionIndex()];
submenuDelay.setEnabled(a == WidgetAttributes.HOVER_SUBMENU_ACTION);
return a;
}
};
submenuAction.addSelectionListener(listener);
submenuDelayLabel = new DisplayLabel(this, SWT.NONE);
submenuDelayLabel.setText(L10N.get("FE.SubmenuDelay", "Submenu transition delay") + ":");
// TODO: remove READ_ONLY when editing allowed (check exception in setSubmenuDelayAttr)
submenuDelay = new ComboWithEnableFix(this, SWT.DROP_DOWN | SWT.READ_ONLY);
submenuDelay.add("0.0 s (" + L10N.get("FE.TypicalForMac", "typical for a Mac") + ")");
submenuDelay.add("0.5 s (" + L10N.get("FE.TypicalForPC", "typical for a PC") + ")");
listener = new WidgetAttributeListener(WidgetAttributes.SUBMENU_DELAY_ATTR) {
@Override
public Object getValue() {
switch(submenuDelay.getSelectionIndex()) {
case 0:
{
return WidgetAttributes.NO_SUBMENU_DELAY;
}
case 1:
{
return WidgetAttributes.PC_SUBMENU_DELAY;
}
}
// should be the current value!
return null;
}
@Override
public void widgetDefaultSelected(SelectionEvent evt) {
view.setSubmenuDelayAttr(view.selection.getSelectedIWidgets()[0], submenuDelay.getText());
}
};
submenuDelay.addSelectionListener(listener);
submenuDelay.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent evt) {
/*
* We can allow certain types of characters here:
* Control characters (arrow keys, etc): Character.CONTROL
* Numerics: Character.DECIMAL_DIGIT_NUMBER
* Decimal Point: keycodes 46 and 16777262
*
* Disallow anything else
*/
int characterType = Character.getType(evt.character);
if ((characterType == Character.CONTROL) || (characterType == Character.DECIMAL_DIGIT_NUMBER) || (evt.keyCode == 46) || (evt.keyCode == 16777262)) {
evt.doit = true;
} else {
evt.doit = false;
}
}
// listen for the enter key on the number pad for OS X
public void keyReleased(KeyEvent evt) {
if (OSUtils.MACOSX) {
if (evt.keyCode == SWT.KEYPAD_CR) {
view.setSubmenuDelayAttr(view.selection.getSelectedIWidgets()[0], submenuDelay.getText());
}
}
}
});
contextMenuActionLabel = new DisplayLabel(this, SWT.NONE);
contextMenuActionLabel.setText(L10N.get("FE.ContextMenuAction", "Context Menu Action") + ":");
// Maximize the possible set of values.
contextMenuActions = new Integer[] { null, null, null };
contextMenuAction = new ComboWithEnableFix(this, SWT.DROP_DOWN | SWT.READ_ONLY);
//TODO: this.contextMenuAction.add(L10N.get("FE.MenuKeyPress", "Menu Key Press"));
listener = new WidgetAttributeListener(WidgetAttributes.CONTEXT_MENU_ACTION_ATTR) {
@Override
public Object getValue() {
return contextMenuActions[contextMenuAction.getSelectionIndex()];
}
};
contextMenuAction.addSelectionListener(listener);
// Set initial selection
//widgetShapeCombo.select(0);
widgetTypeLabel.setText(N_A);
widgetModeValue.setText(N_A);
}
use of org.eclipse.swt.events.KeyEvent in project cogtool by cogtool.
the class Keypad method makeEntry.
/**
* Creates and lays out the elements for the keypad's enter/cancel box.
*
* @author Paul Rubritz (ptr@andrew.cmu.edu)
*/
protected void makeEntry() {
GridLayout grid = new GridLayout();
grid.numColumns = 3;
GridData gridKeysOption = new GridData();
gridKeysOption.horizontalSpan = 2;
Composite entry = new Composite(dialog, SWT.NONE);
entry.setLayoutData(gridKeysOption);
entry.setLayout(grid);
int width = (keypadType == FULL_KEYPAD) ? FULL_WIDTH : NUMPAD_WIDTH;
/* text input box */
enteredText = new Text(entry, SWT.NONE);
enteredText.setFont(FontUtils.DEFAULT_FONT);
gridKeysOption = new GridData();
gridKeysOption.horizontalSpan = 3;
gridKeysOption.widthHint = width;
gridKeysOption.heightHint = 100;
enteredText.setLayoutData(gridKeysOption);
enteredText.setBackground(getDefaultBGColor());
enteredText.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent evt) {
if (evt.keyCode == SWT.ESC) {
userResponse = null;
dialog.close();
}
}
});
/* enter button */
gridKeysOption = new GridData();
gridKeysOption.verticalIndent = 10;
gridKeysOption.horizontalSpan = 2;
gridKeysOption.widthHint = width / 2;
gridKeysOption.heightHint = 75;
gridKeysOption.horizontalAlignment = SWT.RIGHT;
SelectionListener listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
userResponse = enteredText.getText();
dialog.close();
}
};
makeButton(entry, ENTER_KEY, gridKeysOption, listener);
/* cancel button */
gridKeysOption = new GridData();
gridKeysOption.verticalIndent = 10;
gridKeysOption.horizontalSpan = 1;
gridKeysOption.widthHint = width / 2;
gridKeysOption.heightHint = 75;
gridKeysOption.horizontalAlignment = SWT.RIGHT;
listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
userResponse = null;
dialog.close();
}
};
makeButton(entry, CANCEL_KEY, gridKeysOption, listener);
}
Aggregations