本文整理匯總了Java中org.eclipse.swt.widgets.List.getSelectionCount方法的典型用法代碼示例。如果您正苦於以下問題:Java List.getSelectionCount方法的具體用法?Java List.getSelectionCount怎麽用?Java List.getSelectionCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.List
的用法示例。
在下文中一共展示了List.getSelectionCount方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: copy
import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
/**
* Copies the current selection to the clipboard.
*
* @param list the data source
*/
protected void copy(final List list) {
if (canCopy(list)) {
final StringBuilder data = new StringBuilder();
for (int row = 0; row < list.getSelectionCount(); row++) {
data.append(list.getSelection()[row]);
if (row != list.getSelectionCount() - 1) {
data.append(NewLine.SYSTEM_LINE_SEPARATOR);
}
}
final Clipboard clipboard = new Clipboard(list.getDisplay());
clipboard.setContents(new String[] { data.toString() }, new TextTransfer[] { TextTransfer.getInstance() });
clipboard.dispose();
}
}
示例2: applyChanges
import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
private static final void applyChanges(Shell shell, List list, Control control, int position,
InsertTextInterface insertTextInterface) {
String extra = "${" + list.getSelection()[0] + "}";
if (insertTextInterface != null) {
insertTextInterface.insertText(extra, position);
} else {
if (control.isDisposed())
return;
if (list.getSelectionCount() <= 0)
return;
if (control instanceof Text) {
((Text)control).insert(extra);
} else if (control instanceof CCombo) {
CCombo combo = (CCombo)control;
combo.setText(extra); // We can't know the location of the cursor yet. All we can do is overwrite.
}
}
if (!shell.isDisposed())
shell.dispose();
if (!control.isDisposed()) control.setData(Boolean.FALSE);
}
示例3: copy
import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
private void copy(final List list) {
if (list.getSelectionIndex() != -1) {
final StringBuilder text = new StringBuilder();
for (int i = 0; i < list.getSelectionCount(); i++) {
text.append(list.getSelection()[i]);
if (i != list.getSelectionCount() - 1) {
text.append(newLine);
}
}
final Clipboard clipboard = new Clipboard(list.getDisplay());
clipboard.setContents(new String[] { text.toString() }, new TextTransfer[] { TextTransfer.getInstance() });
clipboard.dispose();
}
}
示例4: applyChanges
import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
private static final void applyChanges(Shell shell, List list, Control control, int position,
InsertTextInterface insertTextInterface) {
String extra = "${" + list.getSelection()[0] + "}";
if (insertTextInterface != null) {
insertTextInterface.insertText(extra, position);
} else {
if (control.isDisposed())
return;
if (list.getSelectionCount() <= 0)
return;
if (control instanceof Text) {
((Text)control).insert(extra);
} else if (control instanceof CCombo) {
CCombo combo = (CCombo)control;
combo.setText(extra); // We can't know the location of the cursor yet. All we can do is overwrite.
} else if (control instanceof StyledTextComp) {
((StyledTextComp)control).insert(extra);
}
else if (control instanceof StyledText) {
((StyledText)control).insert(extra);
}
}
if (!shell.isDisposed())
shell.dispose();
if (!control.isDisposed()) control.setData(Boolean.FALSE);
}
示例5: canCopy
import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
protected boolean canCopy(final List list) {
return !list.isDisposed() && list.getSelectionCount() > 0;
}