use of org.talend.componentdesigner.model.libentry.JarLibEntry 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.libentry.JarLibEntry in project tdi-studio-se by Talend.
the class ComponentPref method handleLibEntries.
private static void handleLibEntries(String[] internalFields, ComponentPref componentBean) {
ILibEntry[] libArrays = new ILibEntry[internalFields.length];
for (int j = 0; j < internalFields.length; j++) {
String[] entryStrings = internalFields[j].split(EQUEL_FIELDS_SEPARATOR);
int k = 0;
String libName = entryStrings[k++];
String isExternal = entryStrings[k++];
String location = entryStrings[k++];
Object obj = null;
if (Boolean.valueOf(isExternal)) {
obj = new Path(location);
} else {
obj = ResourcesPlugin.getWorkspace().getRoot().getProject(PluginConstant.COMPONENT_PROJECT).findMember(location);
}
if (libName.matches("(?i).*\\.(jar)\\b")) {
//$NON-NLS-1$
libArrays[j] = new JarLibEntry(obj);
} else if (libName.matches("(?i).*\\.(pm)\\b")) {
//$NON-NLS-1$
libArrays[j] = new PmLibEntry(obj);
} else {
// Nothing
}
}
componentBean.setLibEntries(libArrays);
}
use of org.talend.componentdesigner.model.libentry.JarLibEntry in project tdi-studio-se by Talend.
the class AddExternalResourceAction method run.
/**
* Prompts for a project to add.
*
* @see IAction#run()
*/
@Override
public void run() {
// String lastUsedPath = getDialogSetting(LAST_PATH_SETTING);
String lastUsedPath = null;
if (lastUsedPath == null) {
//$NON-NLS-1$
lastUsedPath = "";
}
FileDialog dialog = new FileDialog(getShell(), SWT.MULTI);
//$NON-NLS-1$
dialog.setText(Messages.getString("AddExternalResourceAction.JarSelection"));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
dialog.setFilterExtensions(new String[] { "*.*", "*.jar", "*.zip", "*.pm" });
dialog.setFilterPath(lastUsedPath);
String res = dialog.open();
if (res == null) {
return;
}
String[] fileNames = dialog.getFileNames();
int nChosen = fileNames.length;
IPath filterPath = new Path(dialog.getFilterPath());
List<ILibEntry> list = new ArrayList<ILibEntry>();
IPath path = null;
for (int i = 0; i < nChosen; i++) {
path = filterPath.append(fileNames[i]).makeAbsolute();
if (path.toFile().exists()) {
if (path.lastSegment().matches("(?i).*\\.(jar)\\b")) {
//$NON-NLS-1$
list.add(new JarLibEntry(path));
}
if (path.lastSegment().matches("(?i).*\\.(pm)\\b")) {
//$NON-NLS-1$
list.add(new PmLibEntry(path));
}
} else {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("AddExternalResourceAction.ErrorTitle"), //$NON-NLS-1$
Messages.getString("AddExternalResourceAction.ErrorMsg"));
}
}
if (list.size() > 0) {
setDialogSetting(LAST_PATH_SETTING, filterPath.toOSString());
getViewer().addEntries(list.toArray(new ILibEntry[list.size()]));
}
}
use of org.talend.componentdesigner.model.libentry.JarLibEntry 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.libentry.JarLibEntry 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()]));
}
}
}
Aggregations