use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class CodeView method createPartControl.
@Override
public void createPartControl(Composite parent) {
this.parent = parent;
parent.setLayout(new FillLayout());
ECodeLanguage language = LanguageManager.getCurrentLanguage();
ISourceViewer viewer = null;
final StyledText text;
int styles = SWT.H_SCROLL | SWT.V_SCROLL;
document = new Document();
switch(language) {
case JAVA:
IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
viewer = new JavaSourceViewer(parent, null, null, false, styles, store);
viewer.setDocument(document);
JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools();
tools.setupJavaDocumentPartitioner(viewer.getDocument(), IJavaPartitions.JAVA_PARTITIONING);
SimpleJavaSourceViewerConfiguration config = new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, true);
viewer.configure(config);
viewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
document = viewer.getDocument();
break;
// empty since only have java
default:
}
viewer.setEditable(false);
text = viewer.getTextWidget();
// getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
IAction wrapAction = new Action() {
@Override
public void run() {
text.setWordWrap(isChecked());
}
};
//$NON-NLS-1$
wrapAction.setToolTipText("wrap");
wrapAction.setChecked(false);
//$NON-NLS-1$
wrapAction.setImageDescriptor(ImageDescriptor.createFromFile(DesignerPlugin.class, "/icons/wrap.gif"));
tbm.add(wrapAction);
createMenu();
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class TestComponentsAction method initialize.
public void initialize() {
Job job = new //$NON-NLS-1$
Job(//$NON-NLS-1$
"Component Test") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
// IProgressMonitor monitorWrap = new CodeGeneratorProgressMonitor(monitor);
//$NON-NLS-1$
monitor.beginTask("Component Test Running", 1100);
IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
Set<IComponent> components = componentsFactory.getComponents();
monitor.worked(100);
RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
ECodeLanguage codeLanguage = repositoryContext.getProject().getLanguage();
String path = getPath();
// TODO
int taskTotal = components.size();
for (IComponent component : components) {
String templateURI = path + File.separatorChar + component.getName() + File.separatorChar + TestParameter.GENERATE_TEST;
File templateFile = new File(templateURI);
// System.out.println(templateFile + " " + templateFile.exists());
if (templateFile.exists()) {
File[] fileArray = getFile(templateFile, codeLanguage);
//$NON-NLS-1$ //$NON-NLS-2$
generateCode(fileArray, templateURI.replace("\\", "/"));
}
monitor.worked(1 * 1000 / taskTotal);
}
} catch (Exception e) {
//$NON-NLS-1$
log.error("Exception during test Initialization", e);
}
monitor.done();
return Status.OK_STATUS;
}
};
job.schedule();
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class ContextParameterExtractor method buildParameterFrom.
private static IContextParameter buildParameterFrom(final Control text, final IContextManager manager, final String parameterName) {
//$NON-NLS-1$
String nameProposal = "";
if (text instanceof Text) {
nameProposal = ((Text) text).getSelectionText();
if (nameProposal.length() == 0) {
nameProposal = ((Text) text).getText();
}
} else {
if (text instanceof StyledText) {
nameProposal = ((StyledText) text).getSelectionText();
if (nameProposal.length() == 0) {
nameProposal = ((StyledText) text).getText();
}
}
}
if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
nameProposal = TalendTextUtils.removeQuotes(nameProposal);
}
String value = nameProposal;
if (ContextParameterUtils.containContextVariables(value)) {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
new Shell(), //$NON-NLS-1$
Messages.getString("ContextParameterExtractor.ExistedTitle"), //$NON-NLS-1$
Messages.getString("ContextParameterExtractor.ExistedMessages"));
return null;
}
//$NON-NLS-1$ //$NON-NLS-2$
nameProposal = nameProposal.replace(" ", "_");
IContextParameter parameter = new JobContextParameter();
if (manager.checkValidParameterName(null, parameterName)) {
parameter.setName(parameterName);
} else if (manager.checkValidParameterName(null, nameProposal)) {
parameter.setName(nameProposal);
} else {
//$NON-NLS-1$
parameter.setName("");
}
ECodeLanguage curLanguage = LanguageManager.getCurrentLanguage();
if (curLanguage == ECodeLanguage.PERL) {
parameter.setType(MetadataTalendType.getDefaultTalendType());
} else {
parameter.setType(JavaTypesManager.getDefaultJavaType().getId());
}
//$NON-NLS-1$
parameter.setPrompt(parameterName + "?");
//$NON-NLS-1$
parameter.setComment("");
parameter.setValue(value);
return parameter;
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class SynchronizeSchemaOnlyForPerlDemoMigrationTask method execute.
/*
* (non-Javadoc)
*
* @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
* ProcessItem)
*/
@Override
public ExecutionResult execute(Item item) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
boolean modified = false;
ECodeLanguage language = LanguageManager.getCurrentLanguage();
if (language == ECodeLanguage.PERL) {
Project project = ProjectManager.getInstance().getProject(item);
if (project != null && project.getTechnicalLabel().equalsIgnoreCase("TALENDDEMOSPERL")) {
//$NON-NLS-1$
IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getProcessFromItem(item);
modified = synchronizeSchema(process);
if (modified) {
ProcessType processType = process.saveXmlFile();
if (item instanceof ProcessItem) {
((ProcessItem) item).setProcess(processType);
} else if (item instanceof JobletProcessItem) {
((JobletProcessItem) item).setJobletProcess((JobletProcess) processType);
}
factory.save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class LanguageProvider method getCurrentLanguage.
public static ILanguage getCurrentLanguage() {
ECodeLanguage codeLanguage = null;
if (!MapperMain.isStandAloneMode()) {
RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
codeLanguage = repositoryContext.getProject().getLanguage();
} else {
codeLanguage = ECodeLanguage.PERL;
}
switch(codeLanguage) {
case JAVA:
if (!(language instanceof JavaLanguage) || LanguageProvider.language == null) {
LanguageProvider.language = getJavaLanguage();
}
break;
default:
if (!(language instanceof PerlLanguage) || LanguageProvider.language == null) {
LanguageProvider.language = getPerlLanguage();
}
}
return LanguageProvider.language;
}
Aggregations