use of net.heartsome.cat.ts.ui.extensionpoint.AbstractNewProjectWizardPage in project translationstudio8 by heartsome.
the class NewProjectWizardLanguagePage method getNextPage.
/**
* 处理扩展页面中需要获取项目源语言问题 (non-Javadoc)
* @see org.eclipse.jface.wizard.WizardPage#getNextPage()
*/
public IWizardPage getNextPage() {
if (getWizard() == null) {
return null;
}
IWizardPage[] pages = getWizard().getPages();
for (int i = 0; i < pages.length; i++) {
if (pages[i] instanceof AbstractNewProjectWizardPage) {
AbstractNewProjectWizardPage extensoinPage = (AbstractNewProjectWizardPage) pages[i];
extensoinPage.setProjSourceLang(getSrcLanguage());
}
}
return getWizard().getNextPage(this);
}
use of net.heartsome.cat.ts.ui.extensionpoint.AbstractNewProjectWizardPage in project translationstudio8 by heartsome.
the class NewProjectWizard method addPages.
@Override
public void addPages() {
firstPage = new NewProjectWizardProjInfoPage();
addPage(firstPage);
secondPage = new NewProjectWizardLanguagePage();
addPage(secondPage);
AbstractNewProjectWizardPage pageTm = getPageByType("TM");
if (pageTm != null) {
addPage(pageTm);
}
AbstractNewProjectWizardPage pageTb = getPageByType("TB");
if (pageTb != null) {
addPage(pageTb);
}
srcFilesPage = new NewProjectWizardSourceFilePage();
srcFilesPage.setConvertInfo(convertImpl);
addPage(srcFilesPage);
}
use of net.heartsome.cat.ts.ui.extensionpoint.AbstractNewProjectWizardPage in project translationstudio8 by heartsome.
the class NewProjectWizard method runWizardPageExtension.
/**
* 加载扩展向导页 ;
*/
private void runWizardPageExtension() {
// 加载向导扩展
IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(PAGE_EXTENSION_ID);
try {
for (IConfigurationElement e : config) {
final Object o = e.createExecutableExtension("class");
if (o instanceof AbstractNewProjectWizardPage) {
ISafeRunnable runnable = new ISafeRunnable() {
public void handleException(Throwable exception) {
logger.error(Messages.getString("wizard.NewProjectWizard.logger1"), exception);
}
public void run() throws Exception {
extensionPages.add((AbstractNewProjectWizardPage) o);
}
};
SafeRunner.run(runnable);
}
}
} catch (CoreException ex) {
logger.error(Messages.getString("wizard.NewProjectWizard.logger1"), ex);
}
// 加载转换器扩展
IConfigurationElement[] config2 = Platform.getExtensionRegistry().getConfigurationElementsFor("net.heartsome.cat.ts.ui.extension.converter");
try {
for (IConfigurationElement e : config2) {
final Object o = e.createExecutableExtension("class");
if (o instanceof IConverterCaller) {
ISafeRunnable runnable = new ISafeRunnable() {
public void handleException(Throwable exception) {
logger.error(Messages.getString("wizard.NewProjectWizard.logger2"), exception);
}
public void run() throws Exception {
convertImpl = (IConverterCaller) o;
}
};
SafeRunner.run(runnable);
}
}
} catch (CoreException ex) {
logger.error(Messages.getString("wizard.NewProjectWizard.logger2"), ex);
}
}
use of net.heartsome.cat.ts.ui.extensionpoint.AbstractNewProjectWizardPage in project translationstudio8 by heartsome.
the class NewProjectHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
NewProjectWizard wizard = new NewProjectWizard();
TSWizardDialog dialog = new NewProjectWizardDialog(window.getShell(), wizard) {
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
getButton(IDialogConstants.FINISH_ID).setText(Messages.getString("handlers.NewProjectHandler.finishLbl"));
}
// robert help 2012-09-06
@Override
protected Control createHelpControl(Composite parent) {
Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
((GridLayout) parent.getLayout()).numColumns++;
toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
toolBar.setCursor(cursor);
toolBar.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
cursor.dispose();
}
});
ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
helpItem.setImage(helpImage);
//$NON-NLS-1$
helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
helpItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String language = CommonFunction.getSystemLanguage();
String helpUrl = "";
if (getCurrentPage() instanceof NewProjectWizardProjInfoPage) {
// ROBERTHELP 新建项目-项目信息
helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s02.html#create-project-wizard-project-info", language);
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
} else if (getCurrentPage() instanceof NewProjectWizardLanguagePage) {
// ROBERTHELP 新建项目-语言信息
helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s02.html#create-project-wizard-languages", language);
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
} else if (getCurrentPage() instanceof AbstractNewProjectWizardPage) {
if ("TM".equals(((AbstractNewProjectWizardPage) getCurrentPage()).getPageType())) {
// ROBERTHELP 新建项目-记忆库
helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s02.html#create-project-wizard-tm", language);
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
} else {
// ROBERTHELP 新建项目-术语库
helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s02.html#create-project-wizard-tb", language);
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
}
} else if (getCurrentPage() instanceof NewProjectWizardSourceFilePage) {
// ROBERTHELP 新建项目-源文件
helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s02.html#create-project-wizard-source-file", language);
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
}
}
});
return toolBar;
}
};
dialog.setHelpAvailable(true);
dialog.open();
return null;
}
use of net.heartsome.cat.ts.ui.extensionpoint.AbstractNewProjectWizardPage in project translationstudio8 by heartsome.
the class NewProjectWizard method initProjectConfig.
/**
* 构建项目配置信息
* @param project
* ;
* @throws CoreException
*/
private void initProjectConfig(final IProject project, IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
final IProgressMonitor sMonitor = monitor;
sMonitor.beginTask(Messages.getString("wizard.NewProjectWizard.task2"), 3);
sMonitor.worked(1);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
ProjectInfoBean bean = new ProjectInfoBean();
bean.setProjectName(project.getName());
bean.setMapField(firstPage.getFieldMap());
bean.setMapAttr(firstPage.getAttributeMap());
bean.setSourceLang(secondPage.getSrcLanguage());
bean.setTargetLang(secondPage.getTargetlanguage());
for (AbstractNewProjectWizardPage extensionPage : extensionPages) {
if (extensionPage.getPageType().equals("TM")) {
bean.setTmDb(extensionPage.getSelectedDatabase());
} else if (extensionPage.getPageType().equals("TB")) {
bean.setTbDb(extensionPage.getSelectedDatabase());
}
}
sMonitor.worked(1);
ProjectConfiger projCfg = ProjectConfigerFactory.getProjectConfiger(project);
sMonitor.worked(1);
projCfg.updateProjectConfig(bean);
// 记住当前语言信息
IPreferenceStore ps = Activator.getDefault().getPreferenceStore();
ps.setValue(IPreferenceConstants.NEW_PROJECT_SRC_LANG, bean.getSourceLang().getCode());
List<Language> targetLangList = bean.getTargetLang();
StringBuffer bf = new StringBuffer();
for (Language lang : targetLangList) {
bf.append(lang.getCode());
bf.append(",");
}
ps.setValue(IPreferenceConstants.NEW_PROJECT_TGT_LANG, bf.substring(0, bf.lastIndexOf(",")));
if (sMonitor.isCanceled()) {
try {
project.delete(true, sMonitor);
} catch (CoreException e) {
logger.error("", e);
}
throw new OperationCanceledException();
}
}
});
sMonitor.done();
}
Aggregations