use of org.eclipse.jface.bindings.keys.KeySequence in project translationstudio8 by heartsome.
the class PluginConfigManageDialog method createShortcutKeyGoup.
/**
* 创建快捷键面板
* @param tparent
* ;
*/
private void createShortcutKeyGoup(Composite tparent) {
Group group = new Group(tparent, SWT.None);
group.setText(Messages.getString("dialog.PluginConfigManageDialog.group"));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(group);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(group);
Label keyLbl = new Label(group, SWT.NONE);
keyLbl.setText(Messages.getString("dialog.PluginConfigManageDialog.keyLbl"));
keyTxt = new Text(group, SWT.BORDER);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(keyTxt);
fKeySequenceText = new KeySequenceText(keyTxt);
fKeySequenceText.setKeyStrokeLimit(4);
fKeySequenceText.addPropertyChangeListener(new IPropertyChangeListener() {
public final void propertyChange(final PropertyChangeEvent event) {
if (!event.getOldValue().equals(event.getNewValue())) {
final KeySequence keySequence = fKeySequenceText.getKeySequence();
if (!keySequence.isComplete()) {
return;
}
keyTxt.setSelection(keyTxt.getTextLimit());
}
}
});
}
use of org.eclipse.jface.bindings.keys.KeySequence in project eclipse.platform.text by eclipse.
the class CompletionProposalPopup method addCommandSupport.
/**
* Adds command support to the given control.
*
* @param control the control to watch for focus
* @since 3.2
*/
private void addCommandSupport(final Control control) {
final KeySequence commandSequence = fContentAssistant.getRepeatedInvocationKeySequence();
if (commandSequence != null && !commandSequence.isEmpty() && fContentAssistant.isRepeatedInvocationMode()) {
control.addFocusListener(new FocusListener() {
private CommandKeyListener fCommandKeyListener;
@Override
public void focusGained(FocusEvent e) {
if (Helper.okToUse(control)) {
if (fCommandKeyListener == null) {
fCommandKeyListener = new CommandKeyListener(commandSequence);
fProposalTable.addKeyListener(fCommandKeyListener);
}
}
}
@Override
public void focusLost(FocusEvent e) {
if (fCommandKeyListener != null) {
control.removeKeyListener(fCommandKeyListener);
fCommandKeyListener = null;
}
}
});
}
if (fAdditionalInfoController != null) {
control.addFocusListener(new FocusListener() {
private TraverseListener fTraverseListener;
@Override
public void focusGained(FocusEvent e) {
if (Helper.okToUse(control)) {
if (fTraverseListener == null) {
fTraverseListener = new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent event) {
if (event.detail == SWT.TRAVERSE_TAB_NEXT) {
IInformationControl iControl = fAdditionalInfoController.getCurrentInformationControl2();
if (fAdditionalInfoController.getInternalAccessor().canReplace(iControl)) {
fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true);
event.doit = false;
}
}
}
};
fProposalTable.addTraverseListener(fTraverseListener);
}
}
}
@Override
public void focusLost(FocusEvent e) {
if (fTraverseListener != null) {
control.removeTraverseListener(fTraverseListener);
fTraverseListener = null;
}
}
});
}
}
use of org.eclipse.jface.bindings.keys.KeySequence in project archi by archimatetool.
the class FullScreenAction method addKeyBinding.
/**
* Add a Key binding mapped to an Action
*/
private void addKeyBinding(ActionRegistry registry, IBindingService service, ActionFactory actionFactory) {
KeySequence seq = (KeySequence) service.getBestActiveBindingFor(actionFactory.getCommandId());
if (seq != null && seq.getKeyStrokes().length > 0) {
KeyStroke ks = seq.getKeyStrokes()[0];
keyBindings.add(new KeyBinding(ks.getModifierKeys(), Character.toLowerCase(ks.getNaturalKey()), registry.getAction(actionFactory.getId())));
}
}
use of org.eclipse.jface.bindings.keys.KeySequence in project n4js by eclipse.
the class WorkspaceWizardPage method getActiveContentAssistBinding.
/**
* Returns the active key binding for content assist.
*
* If no binding is set null is returned.
*/
private KeyStroke getActiveContentAssistBinding() {
IBindingService bindingService = PlatformUI.getWorkbench().getService(IBindingService.class);
TriggerSequence[] activeBindingsFor = bindingService.getActiveBindingsFor(CONTENT_ASSIST_ECLIPSE_COMMAND_ID);
if (activeBindingsFor.length > 0 && activeBindingsFor[0] instanceof KeySequence) {
KeyStroke[] strokes = ((KeySequence) activeBindingsFor[0]).getKeyStrokes();
if (strokes.length == 1) {
return strokes[0];
}
}
return null;
}
use of org.eclipse.jface.bindings.keys.KeySequence in project webtools.sourceediting by eclipse.
the class StructuredContentAssistProcessor method getIterationBinding.
/**
* @return {@link KeySequence} used by user to iterate to the next page
*/
private KeySequence getIterationBinding() {
final IBindingService bindingSvc = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
TriggerSequence binding = bindingSvc.getBestActiveBindingFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
if (binding instanceof KeySequence)
return (KeySequence) binding;
return null;
}
Aggregations