Search in sources :

Example 1 with ManifestItem

use of org.talend.designer.camel.dependencies.core.model.ManifestItem in project tesb-studio-se by Talend.

the class CamelDependenciesPanel method moveUp.

private void moveUp() {
    ManifestItem selected = (ManifestItem) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
    List input = (List) tableViewer.getInput();
    int index = input.indexOf(selected);
    int size = input.size();
    int targetIndex = index - 1;
    if (targetIndex < 0 || ((ManifestItem) input.get(targetIndex)).isBuiltIn()) {
        targetIndex = size - 1;
    }
    input.remove(selected);
    input.add(targetIndex, selected);
    tableViewer.refresh();
    tableViewer.setSelection(new StructuredSelection(selected));
    tableViewer.getTable().showSelection();
    fireDependenciesChangedListener();
}
Also used : ManifestItem(org.talend.designer.camel.dependencies.core.model.ManifestItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) List(java.util.List)

Example 2 with ManifestItem

use of org.talend.designer.camel.dependencies.core.model.ManifestItem in project tesb-studio-se by Talend.

the class DependenciesCoreUtil method getManifestItems.

private static Collection<? extends ManifestItem> getManifestItems(Map<?, ?> map, String header) {
    final Object data = map.get(header);
    if (null != data) {
        final Collection<ManifestItem> list = new ArrayList<ManifestItem>();
        final String s = data.toString();
        if (!s.isEmpty()) {
            try {
                for (ManifestElement me : ManifestElement.parseHeader(header, data.toString())) {
                    final ManifestItem item = ManifestItem.newItem(header);
                    item.setName(me.getValue());
                    item.setVersion(me.getAttribute(item.getVersionAttribute()));
                    item.setOptional(Constants.RESOLUTION_OPTIONAL.equals(me.getDirective(Constants.RESOLUTION_DIRECTIVE)));
                    item.setDescription(MessageFormat.format(Messages.DependenciesCoreUtil_userDefined, header));
                    list.add(item);
                }
            } catch (BundleException e) {
                ExceptionHandler.process(e);
            }
        }
        return list;
    }
    return null;
}
Also used : ManifestElement(org.eclipse.osgi.util.ManifestElement) ManifestItem(org.talend.designer.camel.dependencies.core.model.ManifestItem) ArrayList(java.util.ArrayList) BundleException(org.osgi.framework.BundleException)

Example 3 with ManifestItem

use of org.talend.designer.camel.dependencies.core.model.ManifestItem in project tesb-studio-se by Talend.

the class CamelDependenciesPanel method moveDown.

private void moveDown() {
    ManifestItem selected = (ManifestItem) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
    List input = (List) tableViewer.getInput();
    int index = input.indexOf(selected);
    int size = input.size();
    int targetIndex = index + 1;
    if (targetIndex >= size) {
        for (targetIndex = 0; targetIndex < size && ((ManifestItem) input.get(targetIndex)).isBuiltIn(); ++targetIndex) {
        }
    }
    input.remove(selected);
    input.add(targetIndex, selected);
    tableViewer.refresh();
    tableViewer.setSelection(new StructuredSelection(selected));
    tableViewer.getTable().showSelection();
    fireDependenciesChangedListener();
}
Also used : ManifestItem(org.talend.designer.camel.dependencies.core.model.ManifestItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) List(java.util.List)

Example 4 with ManifestItem

use of org.talend.designer.camel.dependencies.core.model.ManifestItem in project tesb-studio-se by Talend.

the class CamelDependenciesPanel method editSelected.

private void editSelected() {
    final ManifestItem selected = (ManifestItem) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
    final NewOrEditDependencyDialog dialog = new NewOrEditDependencyDialog(getInput(), selected, getShell(), type);
    if (dialog.open() == Dialog.OK) {
        ManifestItem item = dialog.getManifestItem();
        selected.setName(item.getName());
        selected.setOptional(item.isOptional());
        selected.setVersion(item.getVersion());
        tableViewer.update(selected, null);
        fireDependenciesChangedListener();
    }
}
Also used : ManifestItem(org.talend.designer.camel.dependencies.core.model.ManifestItem) NewOrEditDependencyDialog(org.talend.camel.designer.ui.editor.dependencies.dialog.NewOrEditDependencyDialog)

Example 5 with ManifestItem

use of org.talend.designer.camel.dependencies.core.model.ManifestItem in project tesb-studio-se by Talend.

the class CamelDependenciesPanel method addNewItem.

private void addNewItem() {
    final Collection<ManifestItem> input = (Collection<ManifestItem>) getInput();
    NewOrEditDependencyDialog dialog = new NewOrEditDependencyDialog(input, getShell(), type);
    if (dialog.open() == Dialog.OK) {
        final ManifestItem addedItem = dialog.getManifestItem();
        input.add(addedItem);
        tableViewer.refresh();
        tableViewer.setSelection(new StructuredSelection(addedItem));
        tableViewer.getTable().showSelection();
        tableViewer.getTable().setFocus();
        fireDependenciesChangedListener();
    }
}
Also used : ManifestItem(org.talend.designer.camel.dependencies.core.model.ManifestItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Collection(java.util.Collection) NewOrEditDependencyDialog(org.talend.camel.designer.ui.editor.dependencies.dialog.NewOrEditDependencyDialog)

Aggregations

ManifestItem (org.talend.designer.camel.dependencies.core.model.ManifestItem)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 List (java.util.List)2 NewOrEditDependencyDialog (org.talend.camel.designer.ui.editor.dependencies.dialog.NewOrEditDependencyDialog)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)1 ManifestElement (org.eclipse.osgi.util.ManifestElement)1 BundleException (org.osgi.framework.BundleException)1