use of org.talend.core.model.properties.LinkDocumentationItem in project tdi-studio-se by Talend.
the class ImportItemUtil method resetItemReference.
/**
*
* cLi Comment method "resetItemReference".
*
* resolve the encode some special character(bug 6252), maybe, It's not better to resolve this by manually.
*
* such as, "[" is "%5B", "]" is "%5D", etc.
*/
@SuppressWarnings("unchecked")
private void resetItemReference(ItemRecord itemRecord, Resource resource) {
Item item = itemRecord.getItem();
EList<EObject> contents = resource.getContents();
/*
* ignore job. no need, because it can't be allowed input special char for name.
*/
if (item instanceof ProcessItem) {
// ((ProcessItem) item).setProcess((ProcessType) EcoreUtil.getObjectByType(contents,
// TalendFilePackage.eINSTANCE
// .getProcessType()));
} else /*
* ignore joblet. no need, because it can't be allowed input special char for name.
*/
if (item instanceof JobletProcessItem) {
// JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
//
// jobletProcessItem.setJobletProcess((JobletProcess) EcoreUtil.getObjectByType(contents,
// JobletPackage.eINSTANCE
// .getJobletProcess()));
// jobletProcessItem
// .setIcon((ByteArray) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getByteArray()));
} else // connectionItem
if (item instanceof ConnectionItem) {
((ConnectionItem) item).setConnection((Connection) EcoreUtil.getObjectByType(contents, ConnectionPackage.eINSTANCE.getConnection()));
} else // context
if (item instanceof ContextItem) {
EList contexts = ((ContextItem) item).getContext();
contexts.clear();
contexts.addAll(EcoreUtil.getObjectsByType(contents, TalendFilePackage.eINSTANCE.getContextType()));
} else // file
if (item instanceof FileItem) {
/*
* ignore routine, no need, because it can't be allowed input special char for name.
*/
if (item instanceof RoutineItem) {
return;
}
FileItem fileItem = (FileItem) item;
fileItem.setContent((ByteArray) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getByteArray()));
} else // snippet
if (item instanceof SnippetItem) {
EList variables = ((SnippetItem) item).getVariables();
variables.clear();
variables.addAll(EcoreUtil.getObjectsByType(contents, PropertiesPackage.eINSTANCE.getSnippetVariable()));
} else // link doc
if (item instanceof LinkDocumentationItem) {
((LinkDocumentationItem) item).setLink((LinkType) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getLinkType()));
} else // business
if (item instanceof BusinessProcessItem) {
BusinessProcessItem businessProcessItem = (BusinessProcessItem) item;
businessProcessItem.setSemantic((BusinessProcess) EcoreUtil.getObjectByType(contents, BusinessPackage.eINSTANCE.getBusinessProcess()));
businessProcessItem.setNotationHolder((NotationHolder) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getNotationHolder()));
}
}
use of org.talend.core.model.properties.LinkDocumentationItem in project tdi-studio-se by Talend.
the class OpenDocumentationAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
protected void doRun() {
RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
Item item = node.getObject().getProperty().getItem();
if (item == null) {
return;
}
URL url = null;
// String extension = null;
if (item instanceof DocumentationItem) {
DocumentationItem documentationItem = (DocumentationItem) item;
// if (documentationItem.getExtension() != null) {
// extension = documentationItem.getExtension();
// }
IFile file = LinkDocumentationHelper.getTempFile(documentationItem.getName(), documentationItem.getExtension());
try {
documentationItem.getContent().setInnerContentToFile(file.getLocation().toFile());
url = file.getLocationURI().toURL();
} catch (Exception e) {
showErrorMessage();
return;
}
} else if (item instanceof LinkDocumentationItem) {
// link documenation
LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
if (!LinkUtils.validateLink(linkDocItem.getLink())) {
showErrorMessage();
return;
}
// if (linkDocItem.getExtension() != null) {
// extension = linkDocItem.getExtension();
// }
String uri = linkDocItem.getLink().getURI();
if (LinkUtils.isRemoteFile(uri)) {
try {
url = new URL(uri);
} catch (MalformedURLException e) {
//
}
} else if (LinkUtils.existedFile(uri)) {
try {
url = new File(uri).toURL();
} catch (MalformedURLException e) {
//
}
}
}
openedByBrowser(item, url);
// progress(item, extension);
}
use of org.talend.core.model.properties.LinkDocumentationItem in project tdi-studio-se by Talend.
the class ExtractDocumentationAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
final Item item = node.getObject().getProperty().getItem();
if (item == null) {
return;
}
String initialFileName = null;
String initialExtension = null;
if (item instanceof DocumentationItem) {
DocumentationItem documentationItem = (DocumentationItem) item;
initialFileName = documentationItem.getName();
if (documentationItem.getExtension() != null) {
initialExtension = documentationItem.getExtension();
}
} else if (item instanceof LinkDocumentationItem) {
// link documenation
LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
if (!LinkUtils.validateLink(linkDocItem.getLink())) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.getString(//$NON-NLS-1$
"ExtractDocumentationAction.fileErrorTitle"), //$NON-NLS-1$
Messages.getString("ExtractDocumentationAction.fileErrorMessages"));
return;
}
initialFileName = linkDocItem.getName();
if (linkDocItem.getExtension() != null) {
initialExtension = linkDocItem.getExtension();
}
}
if (initialFileName != null) {
FileDialog fileDlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
if (initialExtension != null) {
//$NON-NLS-1$
initialFileName = initialFileName + LinkUtils.DOT + initialExtension;
//$NON-NLS-1$ //$NON-NLS-2$
fileDlg.setFilterExtensions(new String[] { "*." + initialExtension, "*.*" });
}
fileDlg.setFileName(initialFileName);
String filename = fileDlg.open();
if (filename != null) {
final File file = new File(filename);
ProgressDialog progressDialog = new ProgressDialog(Display.getCurrent().getActiveShell()) {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
if (item instanceof DocumentationItem) {
DocumentationItem documentationItem = (DocumentationItem) item;
documentationItem.getContent().setInnerContentToFile(file);
} else if (item instanceof LinkDocumentationItem) {
// link documenation
LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
ByteArray byteArray = LinkDocumentationHelper.getLinkItemContent(linkDocItem);
if (byteArray != null) {
byteArray.setInnerContentToFile(file);
}
}
} catch (IOException ioe) {
MessageBoxExceptionHandler.process(ioe);
}
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
// Nothing to do
}
}
}
}
Aggregations