// Text field for default modifier string
label= TextEditorMessages.HyperlinkDefaultKeyModifier_label;
fHyperlinkDefaultKeyModifierText= (Text)addTextField(composite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER, 15, 20, pixelConverter)[1];
fHyperlinkDefaultKeyModifierText.addKeyListener(new KeyListener() {
private boolean isModifierCandidate;
public void keyPressed(KeyEvent e) {
isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
}
public void keyReleased(KeyEvent e) {
if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {// && e.time -time < 1000) {
String modifierString= fHyperlinkDefaultKeyModifierText.getText();
Point selection= fHyperlinkDefaultKeyModifierText.getSelection();
int i= selection.x - 1;
while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
i--;
}
boolean needsPrefixDelimiter= i > -1 && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
i= selection.y;
while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) {
i++;
}
boolean needsPostfixDelimiter= i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
String insertString;
if (needsPrefixDelimiter && needsPostfixDelimiter)
insertString= NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifierAndDelimiter, Action.findModifierString(e.stateMask));
else if (needsPrefixDelimiter)
insertString= NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifier, Action.findModifierString(e.stateMask));
else if (needsPostfixDelimiter)
insertString= NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertModifierAndDelimiter, Action.findModifierString(e.stateMask));
else
insertString= Action.findModifierString(e.stateMask);
fHyperlinkDefaultKeyModifierText.insert(insertString);
}
}
});
fHyperlinkDefaultKeyModifierText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
handleHyperlinkDefaultKeyModifierModified();
}
});
addFiller(composite, 2);
Composite editorComposite= new Composite(composite, SWT.NONE);
GridData gd;
// XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=178097
if ("gtk".equals(SWT.getPlatform())) //$NON-NLS-1$
gd= new GridData(SWT.FILL, SWT.FILL, true, true);
else
gd= new GridData(SWT.FILL, SWT.TOP, true, false);
gd.horizontalSpan= 2;
gd.horizontalIndent= 20;
editorComposite.setLayoutData(gd);
TableColumnLayout tableColumnlayout= new TableColumnLayout();
editorComposite.setLayout(tableColumnlayout);
// Hyperlink detector table
Table hyperlinkDetectorTable= new Table(editorComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
hyperlinkDetectorTable.setHeaderVisible(true);
hyperlinkDetectorTable.setLinesVisible(true);
hyperlinkDetectorTable.setFont(parent.getFont());
hyperlinkDetectorTable.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
handleListSelection();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
ColumnLayoutData columnLayoutData= new ColumnWeightData(1);
TableColumn nameColumn= new TableColumn(hyperlinkDetectorTable, SWT.NONE, 0);
nameColumn.setText(TextEditorMessages.HyperlinkDetectorTable_nameColumn);
tableColumnlayout.setColumnData(nameColumn, columnLayoutData);
TableColumn modifierKeysColumn= new TableColumn(hyperlinkDetectorTable, SWT.NONE, 1);
modifierKeysColumn.setText(TextEditorMessages.HyperlinkDetectorTable_modifierKeysColumn);
tableColumnlayout.setColumnData(modifierKeysColumn, columnLayoutData);
TableColumn targetNameColumn= new TableColumn(hyperlinkDetectorTable, SWT.NONE, 2);
targetNameColumn.setText(TextEditorMessages.HyperlinkDetectorTable_targetNameColumn);
tableColumnlayout.setColumnData(targetNameColumn, columnLayoutData);
fHyperlinkDetectorsViewer= new CheckboxTableViewer(hyperlinkDetectorTable);
fHyperlinkDetectorsViewer.setUseHashlookup(true);
fHyperlinkDetectorsViewer.addCheckStateListener(new ICheckStateListener() {
/*
* @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
*/
public void checkStateChanged(CheckStateChangedEvent event) {
String id= ((ListItem)event.getElement()).id;
if (id == null)
return;
fStore.setValue(id, !event.getChecked());
}
});
fHyperlinkDetectorsViewer.setLabelProvider(new ItemLabelProvider());
fHyperlinkDetectorsViewer.setContentProvider(new ItemContentProvider());
gd= new GridData(SWT.FILL, SWT.FILL, true , false);
gd.heightHint= pixelConverter.convertHeightInCharsToPixels(10);
fHyperlinkDetectorsViewer.getControl().setLayoutData(gd);
// addFiller(composite, 2);
// Text field for modifier string
label= TextEditorMessages.HyperlinkKeyModifier_label;
fHyperlinkKeyModifierText= (Text)addTextField(composite, label, null, 15, 20, pixelConverter)[1];
fHyperlinkKeyModifierText.addKeyListener(new KeyListener() {
private boolean isModifierCandidate;
public void keyPressed(KeyEvent e) {
isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
}