Search in sources :

Example 6 with ILibEntry

use of org.talend.componentdesigner.model.ILibEntry in project tdi-studio-se by Talend.

the class ComponentPref method readToString.

/**
     * Parse fields of current class to string.
     * 
     * @return
     */
public String readToString() {
    StringBuffer fields = new StringBuffer(getName() + FIELDS_SEPARATOR + getLanguageType().getNameSuffix() + FIELDS_SEPARATOR);
    // 1. append jetFileTypes
    if (this.getJetFileStamps().size() > 0) {
        for (JetFileStamp fileStamp : getJetFileStamps()) {
            fields.append(fileStamp.getFileStampName());
            fields.append(INTERNAL_FIELDS_SEPARATOR);
        }
    }
    fields.append(FIELDS_SEPARATOR);
    // 2. append resourceFileTypes.
    if (this.resourceLanguageTypes.size() > 0) {
        for (ResourceLanguageType resourceType : resourceLanguageTypes) {
            fields.append(resourceType.getLang());
            fields.append(INTERNAL_FIELDS_SEPARATOR);
        }
    }
    fields.append(FIELDS_SEPARATOR);
    // 3. append imageUrl String.
    if (this.imageURL == null) {
        fields.append(PluginConstant.EMPTY_STRING);
    } else {
        fields.append(imageURL);
    }
    fields.append(FIELDS_SEPARATOR);
    // 4. append library entries string.
    if (libEntries != null && this.libEntries.length > 0) {
        for (ILibEntry entry : this.libEntries) {
            fields.append(entry.getName());
            fields.append(EQUEL_FIELDS_SEPARATOR);
            fields.append(entry.isExternal());
            fields.append(EQUEL_FIELDS_SEPARATOR);
            fields.append(entry.getLocation());
            fields.append(INTERNAL_FIELDS_SEPARATOR);
        }
    }
    return fields.toString();
}
Also used : ILibEntry(org.talend.componentdesigner.model.ILibEntry) JetFileStamp(org.talend.componentdesigner.model.enumtype.JetFileStamp) ResourceLanguageType(org.talend.componentdesigner.model.enumtype.ResourceLanguageType)

Example 7 with ILibEntry

use of org.talend.componentdesigner.model.ILibEntry 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);
}
Also used : ILibEntry(org.talend.componentdesigner.model.ILibEntry) Path(org.eclipse.core.runtime.Path) JarLibEntry(org.talend.componentdesigner.model.libentry.JarLibEntry) PmLibEntry(org.talend.componentdesigner.model.libentry.PmLibEntry)

Example 8 with ILibEntry

use of org.talend.componentdesigner.model.ILibEntry 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()]));
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ILibEntry(org.talend.componentdesigner.model.ILibEntry) JarLibEntry(org.talend.componentdesigner.model.libentry.JarLibEntry) PmLibEntry(org.talend.componentdesigner.model.libentry.PmLibEntry) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) FileDialog(org.eclipse.swt.widgets.FileDialog)

Aggregations

ILibEntry (org.talend.componentdesigner.model.ILibEntry)8 ArrayList (java.util.ArrayList)5 JarLibEntry (org.talend.componentdesigner.model.libentry.JarLibEntry)5 PmLibEntry (org.talend.componentdesigner.model.libentry.PmLibEntry)3 Path (org.eclipse.core.runtime.Path)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 TreeNodeData (org.talend.componentdesigner.ui.composite.xmltree.TreeNodeData)2 Element (org.w3c.dom.Element)2 Node (org.w3c.dom.Node)2 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 ElementTreeSelectionDialog (org.eclipse.ui.dialogs.ElementTreeSelectionDialog)1 WorkbenchContentProvider (org.eclipse.ui.model.WorkbenchContentProvider)1 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)1 ResourceComparator (org.eclipse.ui.views.navigator.ResourceComparator)1 JetFileStamp (org.talend.componentdesigner.model.enumtype.JetFileStamp)1