use of org.talend.componentdesigner.model.ILibEntry in project tdi-studio-se by Talend.
the class LibListViewer method setEntries.
/*
* (non-Javadoc)
*
* @see org.eclipse.jdt.internal.debug.ui.launcher.IClasspathViewer#setEntries(org.eclipse.jdt.launching.IRuntimeClasspathEntry[])
*/
public void setEntries(ILibEntry[] entries) {
if (entries == null) {
return;
}
// this.existingEntries = Arrays.asList(entries);
this.existingEntries.clear();
for (ILibEntry entry : entries) {
if (entry != null) {
existingEntries.add(entry);
}
}
notifyChanged();
}
use of org.talend.componentdesigner.model.ILibEntry in project tdi-studio-se by Talend.
the class JavaXMLConfigWizardPage method fillImportItems.
/*
* (non-Javadoc)
*
* @see org.talend.componentdesigner.ui.wizard.creatcomponent.AbstractXMLConfigPage#fillImportItems()
*/
protected void fillImportItems() {
for (int i = 0; i < availableXmlTree.getItems().length; i++) {
TreeItem item = availableXmlTree.getItem(i);
if (item.getText().equals(CODEGENERATION)) {
Node codeGenNode = ((TreeNodeData) item.getData()).getXMLNode();
TreeItem importsItem = new TreeItem(item, SWT.CASCADE);
importsItem.setText(IMPORTS);
Element importsEle = codeGenNode.getOwnerDocument().createElement(IMPORTS);
codeGenNode.appendChild(importsEle);
TreeNodeData importsData = new TreeNodeData();
importsData.setXMLNode(importsEle);
importsData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(IMPORTSITEMPATH));
importsItem.setData(importsData);
List<Node> jarImportNodes = new ArrayList<Node>();
List<Node> pmImportNodes = new ArrayList<Node>();
for (ILibEntry libEntry : componentPref.getLibEntries()) {
TreeItem importItem = new TreeItem(importsItem, SWT.CASCADE);
importItem.setText(IMPORT);
Element importEle = importsEle.getOwnerDocument().createElement(IMPORT);
importsEle.appendChild(importEle);
importEle.setAttribute(NAME, libEntry.getNamePrefix());
importEle.setAttribute(MODULE, libEntry.getName());
//$NON-NLS-1$
importEle.setAttribute(REQUIRED, "true");
TreeNodeData nodeData = new TreeNodeData();
nodeData.putAttrValue(NAME, libEntry.getNamePrefix());
nodeData.putAttrValue(MODULE, libEntry.getName());
//$NON-NLS-1$
nodeData.putAttrValue(REQUIRED, "true");
nodeData.setXMLNode(importEle);
nodeData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(IMPORTITEMPATH));
importItem.setData(nodeData);
if (libEntry instanceof JarLibEntry) {
jarImportNodes.add(importEle);
} else {
pmImportNodes.add(importEle);
}
}
this.componentPref.setJavaImportNodes(jarImportNodes.toArray(new Node[jarImportNodes.size()]));
}
}
}
use of org.talend.componentdesigner.model.ILibEntry in project tdi-studio-se by Talend.
the class PerlXMLConfigWizardPage method fillImportItems.
/*
* (non-Javadoc)
*
* @see org.talend.componentdesigner.ui.wizard.creatcomponent.AbstractXMLConfigPage#fillImportItems()
*/
protected void fillImportItems() {
for (int i = 0; i < availableXmlTree.getItems().length; i++) {
TreeItem item = availableXmlTree.getItem(i);
if (item.getText().equals(CODEGENERATION)) {
Node codeGenNode = ((TreeNodeData) item.getData()).getXMLNode();
TreeItem importsItem = new TreeItem(item, SWT.CASCADE);
importsItem.setText(IMPORTS);
Element importsEle = codeGenNode.getOwnerDocument().createElement(IMPORTS);
codeGenNode.appendChild(importsEle);
TreeNodeData importsData = new TreeNodeData();
importsData.setXMLNode(importsEle);
importsData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(IMPORTSITEMPATH));
importsItem.setData(importsData);
List<Node> jarImportNodes = new ArrayList<Node>();
List<Node> pmImportNodes = new ArrayList<Node>();
for (ILibEntry libEntry : componentPref.getLibEntries()) {
TreeItem importItem = new TreeItem(importsItem, SWT.CASCADE);
importItem.setText(IMPORT);
Element importEle = importsEle.getOwnerDocument().createElement(IMPORT);
importsEle.appendChild(importEle);
importEle.setAttribute(NAME, libEntry.getNamePrefix());
importEle.setAttribute(MODULE, libEntry.getName());
//$NON-NLS-1$
importEle.setAttribute(REQUIRED, "true");
TreeNodeData nodeData = new TreeNodeData();
nodeData.putAttrValue(NAME, libEntry.getNamePrefix());
nodeData.putAttrValue(MODULE, libEntry.getName());
//$NON-NLS-1$
nodeData.putAttrValue(REQUIRED, "true");
nodeData.setXMLNode(importEle);
nodeData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(IMPORTITEMPATH));
importItem.setData(nodeData);
if (libEntry instanceof JarLibEntry) {
jarImportNodes.add(importEle);
} else {
pmImportNodes.add(importEle);
}
}
this.componentPref.setPerlImportNodes(pmImportNodes.toArray(new Node[pmImportNodes.size()]));
}
}
}
use of org.talend.componentdesigner.model.ILibEntry in project tdi-studio-se by Talend.
the class AddResourceAction method run.
/**
* Prompts for a jar to add.
*
* @see IAction#run()
*/
@Override
public void run() {
// ViewerFilter filter = new ArchiveFilter(getSelectedJars());
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setValidator(validator);
//$NON-NLS-1$
dialog.setTitle(Messages.getString("AddResourceAction.JARSecection"));
//$NON-NLS-1$
dialog.setMessage(Messages.getString("AddResourceAction.ChooseResource"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot().getProject(PluginConstant.COMPONENT_PROJECT));
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
List<ILibEntry> res = new ArrayList<ILibEntry>();
for (int i = 0; i < elements.length; i++) {
IResource elem = (IResource) elements[i];
String name = elem.getName();
if (name.matches("(?i).*\\.(jar)\\b")) {
//$NON-NLS-1$
res.add(new JarLibEntry(elem));
}
if (name.matches("(?i).*\\.(pm)\\b")) {
//$NON-NLS-1$
res.add(new PmLibEntry(elem));
}
}
if (res.size() > 0) {
ILibEntry[] entries = new ILibEntry[res.size()];
getViewer().addEntries(res.toArray(entries));
}
}
}
use of org.talend.componentdesigner.model.ILibEntry in project tdi-studio-se by Talend.
the class LibListViewer method getSelectedEntries.
/*
* (non-Javadoc)
*
* @see org.eclipse.jdt.internal.debug.ui.launcher.IClasspathViewer#getSelectedEntries()
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public ILibEntry[] getSelectedEntries() {
IStructuredSelection selection = (IStructuredSelection) getSelection();
List<ILibEntry> entries = new ArrayList<ILibEntry>(selection.size() * 2);
Iterator<ILibEntry> itr = selection.iterator();
while (itr.hasNext()) {
ILibEntry element = (ILibEntry) itr.next();
entries.add(element);
}
ILibEntry[] array = new ILibEntry[entries.size()];
return entries.toArray(array);
}
Aggregations