use of org.eclipse.jface.bindings.keys.ParseException in project translationstudio8 by heartsome.
the class DBManagement method openDBMgmgDialog.
// 以下为非完整步骤
/**
* @param from
* 入口,请使用 TSUIConstants 类中提供的枚举。
* @return 打开的库管理对话框;
*/
public DatabaseManagementDialog openDBMgmgDialog(Entry from) {
if (from.equals(TsUIConstants.Entry.MENU)) {
ts.menuDBManagement().click();
} else if (from.equals(TsUIConstants.Entry.SHORTCUT)) {
try {
ts.pressShortcut(SWTBotUtils.getCtrlOrCmdKey(), Keystrokes.SHIFT, KeyStroke.getInstance("D"));
} catch (ParseException e) {
e.printStackTrace();
assertTrue("快捷键解析错误。", false);
}
} else {
assertTrue("参数错误,该功能无此入口:" + from, false);
}
dialog = new DatabaseManagementDialog(DatabaseManagementDialog.MANAGEMENT);
return dialog;
}
use of org.eclipse.jface.bindings.keys.ParseException in project translationstudio8 by heartsome.
the class MemoryDBManagement method openDBMgmgDialog.
// 以下为非完整步骤
/**
* @param from
* 入口,请使用 TSUIConstants 类中提供的枚举。
* @return 打开的库管理对话框;
*/
public MemoryDatabaseManagementDialog openDBMgmgDialog(Entry from) {
if (from.equals(TsUIConstants.Entry.MENU)) {
if (isMemory) {
ts.menuDBManagement().click();
} else {
ts.menuTeriDBManagement().click();
}
} else if (from.equals(TsUIConstants.Entry.SHORTCUT)) {
try {
ts.pressShortcut(SWTBotUtils.getCtrlOrCmdKey(), Keystrokes.SHIFT, KeyStroke.getInstance("D"));
} catch (ParseException e) {
e.printStackTrace();
assertTrue("快捷键解析错误。", false);
}
} else {
assertTrue("参数错误,该功能无此入口:" + from, false);
}
dialog = new MemoryDatabaseManagementDialog(MemoryDatabaseManagementDialog.MANAGEMENT, isMemory ? "dlgTitleMemoryManagement" : "dlgTitletreiTbManagement");
return dialog;
}
use of org.eclipse.jface.bindings.keys.ParseException in project bndtools by bndtools.
the class GeneralInfoPart method createSection.
private void createSection(Section section, FormToolkit toolkit) {
section.setText("Basic Information");
KeyStroke assistKeyStroke = null;
try {
assistKeyStroke = KeyStroke.getInstance("Ctrl+Space");
} catch (ParseException x) {
// Ignore
}
FieldDecoration contentAssistDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
Composite composite = toolkit.createComposite(section);
section.setClient(composite);
toolkit.createLabel(composite, "Version:");
txtVersion = toolkit.createText(composite, "", SWT.BORDER);
ToolTips.setupMessageAndToolTipFromSyntax(txtVersion, Constants.BUNDLE_VERSION);
Hyperlink linkActivator = toolkit.createHyperlink(composite, "Activator:", SWT.NONE);
txtActivator = toolkit.createText(composite, "", SWT.BORDER);
ToolTips.setupMessageAndToolTipFromSyntax(txtActivator, Constants.BUNDLE_ACTIVATOR);
toolkit.createLabel(composite, "Declarative Services:");
cmbComponents = new Combo(composite, SWT.READ_ONLY);
// Content Proposal for the Activator field
ContentProposalAdapter activatorProposalAdapter = null;
ActivatorClassProposalProvider proposalProvider = new ActivatorClassProposalProvider();
activatorProposalAdapter = new ContentProposalAdapter(txtActivator, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters());
activatorProposalAdapter.addContentProposalListener(proposalProvider);
activatorProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
activatorProposalAdapter.setLabelProvider(new JavaContentProposalLabelProvider());
activatorProposalAdapter.setAutoActivationDelay(1000);
// Decorator for the Activator field
ControlDecoration decorActivator = new ControlDecoration(txtActivator, SWT.LEFT | SWT.CENTER, composite);
decorActivator.setImage(contentAssistDecoration.getImage());
decorActivator.setMarginWidth(3);
if (assistKeyStroke == null) {
decorActivator.setDescriptionText("Content Assist is available. Start typing to activate");
} else {
decorActivator.setDescriptionText(MessageFormat.format("Content Assist is available. Press {0} or start typing to activate", assistKeyStroke.format()));
}
decorActivator.setShowOnlyOnFocus(true);
decorActivator.setShowHover(true);
// Decorator for the Components combo
ControlDecoration decorComponents = new ControlDecoration(cmbComponents, SWT.LEFT | SWT.CENTER, composite);
decorComponents.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
decorComponents.setMarginWidth(3);
decorComponents.setDescriptionText("Use Java annotations to detect Declarative Service Components.");
decorComponents.setShowOnlyOnFocus(false);
decorComponents.setShowHover(true);
// Listeners
txtVersion.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
addDirtyProperty(Constants.BUNDLE_VERSION);
}
});
}
});
cmbComponents.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
ComponentChoice old = componentChoice;
int index = cmbComponents.getSelectionIndex();
if (index >= 0 && index < ComponentChoice.values().length) {
componentChoice = ComponentChoice.values()[cmbComponents.getSelectionIndex()];
if (old != componentChoice) {
addDirtyProperty(aQute.bnd.osgi.Constants.SERVICE_COMPONENT);
addDirtyProperty(aQute.bnd.osgi.Constants.DSANNOTATIONS);
if (old == null) {
cmbComponents.remove(ComponentChoice.values().length);
}
}
}
}
});
}
});
txtActivator.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent ev) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
addDirtyProperty(Constants.BUNDLE_ACTIVATOR);
}
});
}
});
linkActivator.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent ev) {
String activatorClassName = txtActivator.getText();
if (activatorClassName != null && activatorClassName.length() > 0) {
try {
IJavaProject javaProject = getJavaProject();
if (javaProject == null)
return;
IType activatorType = javaProject.findType(activatorClassName);
if (activatorType != null) {
JavaUI.openInEditor(activatorType, true, true);
}
} catch (PartInitException e) {
ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error opening an editor for activator class '{0}'.", activatorClassName), e));
} catch (JavaModelException e) {
ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error searching for activator class '{0}'.", activatorClassName), e));
}
}
}
});
activatorProposalAdapter.addContentProposalListener(new IContentProposalListener() {
@Override
public void proposalAccepted(IContentProposal proposal) {
if (proposal instanceof JavaContentProposal) {
String selectedPackageName = ((JavaContentProposal) proposal).getPackageName();
if (!model.isIncludedPackage(selectedPackageName)) {
model.addPrivatePackage(selectedPackageName);
}
}
}
});
// Layout
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 15;
composite.setLayout(layout);
GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
txtVersion.setLayoutData(gd);
txtActivator.setLayoutData(gd);
cmbComponents.setLayoutData(gd);
}
use of org.eclipse.jface.bindings.keys.ParseException in project mechanoid by robotoworks.
the class PackageBrowserField method attachProposalProvider.
private void attachProposalProvider() {
try {
mProposalProvider = new PackageProposalProvider();
mPackageProposalAdapter = new ContentProposalAdapter(getTextField(), new TextContentAdapter(), mProposalProvider, KeyStroke.getInstance("Ctrl+Space"), new char[] { '.' });
mPackageProposalAdapter.setLabelProvider(new LabelProvider() {
@Override
public Image getImage(Object element) {
return mPackageImage;
}
@Override
public String getText(Object element) {
PackageProposal p = (PackageProposal) element;
return p.getContent();
}
});
mPackageProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
} catch (ParseException e) {
e.printStackTrace();
}
}
use of org.eclipse.jface.bindings.keys.ParseException in project dbeaver by serge-rider.
the class UIUtils method installContentProposal.
public static void installContentProposal(Control control, IControlContentAdapter contentAdapter, IContentProposalProvider provider, boolean autoActivation) {
try {
KeyStroke keyStroke = autoActivation ? null : KeyStroke.getInstance("Ctrl+Space");
final ContentProposalAdapter proposalAdapter = new ContentProposalAdapter(control, contentAdapter, provider, keyStroke, autoActivation ? ".abcdefghijklmnopqrstuvwxyz_$(".toCharArray() : ".(".toCharArray());
proposalAdapter.setPopupSize(new Point(300, 200));
} catch (ParseException e) {
log.error("Error installing filters content assistant");
}
}
Aggregations