Example usage for org.eclipse.jface.databinding.viewers ObservableListContentProvider ObservableListContentProvider

List of usage examples for org.eclipse.jface.databinding.viewers ObservableListContentProvider ObservableListContentProvider

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.viewers ObservableListContentProvider ObservableListContentProvider.

Prototype

public ObservableListContentProvider() 

Source Link

Document

Constructs an ObservableListContentProvider.

Usage

From source file:org.yafra.rcp.admin.YafraBusRoleTable.java

License:Apache License

/**
 * @wbp.parser.entryPoint/*w ww  .j a  va  2  s. c  o  m*/
 */
public void createTable(TableViewer viewerBRoles, List<MGYafraBusRole> broles) {
    // business role table viewer
    this.fillTable(broles);
    this.tableCreateCols(viewerBRoles);
    viewerBRoles.setContentProvider(new ObservableListContentProvider());
    // viewerUser.setContentProvider(new YafraUserContentProvider());
    viewerBRoles.setLabelProvider(new YafraBusRoleLabelProvider());
}

From source file:org.yafra.rcp.admin.YafraTechRoleTable.java

License:Apache License

/**
 * @wbp.parser.entryPoint/*  w w  w  . java2  s . c  o m*/
 */
public void createTable(TableViewer viewerRoles, List<MGYafraTechRole> troles) {
    // business role table viewer
    this.fillTable(troles, null);
    tableCreateCols(viewerRoles);
    viewerRoles.setContentProvider(new ObservableListContentProvider());
    viewerRoles.setLabelProvider(new YafraTechRoleLabelProvider());
}

From source file:org.yafra.rcp.admin.YafraUserAddBusRoleDialog.java

License:Apache License

/**
 * Create contents of the dialog./*w  w  w .  j a va2  s. c  o  m*/
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);

    Label lblAddNewBusRole = new Label(container, SWT.NONE);
    lblAddNewBusRole.setText("Add new business role - select one or more roles below");

    ScrolledComposite scrolledComposite = new ScrolledComposite(container,
            SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gridData.heightHint = 95;
    scrolledComposite.setLayoutData(gridData);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);

    fillList();
    inputRoles = new WritableList(roles, MGYafraBusRole.class);
    viewerRoles = new ListViewer(scrolledComposite, SWT.BORDER | SWT.MULTI);
    viewerRoles.setContentProvider(new ObservableListContentProvider());
    viewerRoles.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            MGYafraBusRole user = (MGYafraBusRole) element;
            return (user.getName() + " - " + user.getDescription());
        }
    });
    viewerRoles.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            if (event.getSelection().isEmpty()) {
                // if the selection is empty clear list
                selectedroles.clear();
                glob.setDebugmessage(" - selection change is empty");
                return;
            }
            if (event.getSelection() instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
                glob.setDebugmessage(
                        " - selection on dialog business roles no of selections: " + selection.size());
                for (Iterator<MGYafraBusRole> iterator = selection.iterator(); iterator.hasNext();) {
                    selectedroles.add(iterator.next());
                }
            }
        }
    });
    viewerRoles.setInput(inputRoles);

    scrolledComposite.setContent(viewerRoles.getList());
    scrolledComposite.setMinSize(viewerRoles.getList().computeSize(SWT.DEFAULT, SWT.DEFAULT));

    return container;
}

From source file:org.yafra.rcp.admin.YafraUserTable.java

License:Apache License

/**
 * @wbp.parser.entryPoint/*from ww  w  . ja  va 2s.  co m*/
 */
public void createTable(TableViewer viewerUsers, List<MGYafraUser> users) {
    // business role table viewer
    this.fillTable(users, null);
    tableCreateCols(viewerUsers);
    viewerUsers.setContentProvider(new ObservableListContentProvider());
    // viewerUser.setContentProvider(new YafraUserContentProvider());
    viewerUsers.setLabelProvider(new YafraUserLabelProvider());
}

From source file:org.yafra.rcp.person.PersonTable.java

License:Apache License

/**
 * @wbp.parser.entryPoint/*w w  w  . jav  a 2s  .c  o m*/
 */
public void createTable(TableViewer viewerPersons, List<MGPerson> persons) {
    // business role table viewer
    this.fillTable(persons, null);
    tableCreateCols(viewerPersons);
    viewerPersons.setContentProvider(new ObservableListContentProvider());
    // viewerUser.setContentProvider(new YafraUserContentProvider());
    viewerPersons.setLabelProvider(new PersonLabelProvider());
}

From source file:ramo.klevis.openrental.forms.FormAvaibleCar.java

protected DataBindingContext initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    ///*from  w ww.j  ava2  s  .  c om*/
    fillClassAndLocation();
    //
    IObservableValue comboViewerObserveSingleSelection = ViewersObservables.observeSingleSelection(comboViewer);
    IObservableValue beanAvaibleCarClazzObserveValue = PojoObservables.observeValue(beanAvaibleCar, "clazz");
    bindingContext.bindValue(comboViewerObserveSingleSelection, beanAvaibleCarClazzObserveValue, null, null);
    //
    IObservableValue comboViewer_1ObserveSingleSelection = ViewersObservables
            .observeSingleSelection(comboViewer_1);
    IObservableValue beanAvaibleCarLocationObserveValue = PojoObservables.observeValue(beanAvaibleCar,
            "location");
    bindingContext.bindValue(comboViewer_1ObserveSingleSelection, beanAvaibleCarLocationObserveValue, null,
            null);
    //
    IObservableValue fromDateTextObserveSelectionObserveWidget = SWTObservables.observeSelection(fromDateText);
    IObservableValue beanAvaibleCarFromDateObserveValue = PojoObservables.observeValue(beanAvaibleCar,
            "fromDate");
    bindingContext.bindValue(fromDateTextObserveSelectionObserveWidget, beanAvaibleCarFromDateObserveValue,
            null, null);
    //
    IObservableValue toDateTextObserveSelectionObserveWidget = SWTObservables.observeSelection(toDateText);
    IObservableValue beanAvaibleCarToDateObserveValue = PojoObservables.observeValue(beanAvaibleCar, "toDate");
    bindingContext.bindValue(toDateTextObserveSelectionObserveWidget, beanAvaibleCarToDateObserveValue, null,
            null);
    //
    ObservableListContentProvider listContentProvider_2 = new ObservableListContentProvider();
    tableViewer.setContentProvider(listContentProvider_2);
    //
    IObservableMap[] observeMaps = PojoObservables.observeMaps(listContentProvider_2.getKnownElements(),
            Car.class, new String[] { "id", "license", "make", "model", "rate", "year", "classes.class_" });
    tableViewer.setLabelProvider(new ObservableMapLabelProvider(observeMaps));
    //
    WritableList writableList_2 = new WritableList(getListCarsAvaible(), Car.class);
    tableViewer.setInput(writableList_2);
    //
    return bindingContext;
}

From source file:ramo.klevis.openrental.forms.FormAvaibleCar.java

private void fillClassAndLocation() {
    ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
    comboViewer.setContentProvider(listContentProvider);
    ////from ww w  . j a  v  a  2 s.  c o  m
    IObservableMap observeMap = PojoObservables.observeMap(listContentProvider.getKnownElements(), Class.class,
            "class_");
    comboViewer.setLabelProvider(new ObservableMapLabelProvider(observeMap));
    //
    WritableList writableList = new WritableList(itemClass, Class.class);
    comboViewer.setInput(writableList);
    //
    ObservableListContentProvider listContentProvider_1 = new ObservableListContentProvider();
    comboViewer_1.setContentProvider(listContentProvider_1);
    //
    IObservableMap observeMap_1 = PojoObservables.observeMap(listContentProvider_1.getKnownElements(),
            Location.class, "loc");
    comboViewer_1.setLabelProvider(new ObservableMapLabelProvider(observeMap_1));
    //
    WritableList writableList_1 = new WritableList(itemLocation, Location.class);
    comboViewer_1.setInput(writableList_1);
}

From source file:ts.eclipse.ide.json.ui.internal.tsconfig.FilesPage.java

License:Open Source License

/**
 * Create Files section./*from  ww w. ja v  a  2  s. co m*/
 * 
 * @param parent
 */
private void createFilesSection(Composite parent) {
    final IFile tsconfigFile = getTsconfigFile();
    FormToolkit toolkit = super.getToolkit();
    Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
    section.setDescription(TsconfigEditorMessages.FilesPage_FilesSection_desc);
    section.setText(TsconfigEditorMessages.FilesPage_FilesSection_title);

    Composite client = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 2;
    layout.marginHeight = 2;
    client.setLayout(layout);

    Table table = toolkit.createTable(client, SWT.MULTI);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.minimumHeight = 100;
    gd.widthHint = 100;
    table.setLayoutData(gd);

    // Buttons
    Composite buttonsComposite = toolkit.createComposite(client);
    buttonsComposite.setLayout(new GridLayout());
    buttonsComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    if (tsconfigFile != null) {
        final Button addButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_add,
                SWT.PUSH);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        addButton.setLayoutData(gd);
        addButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                // Get existing ts files
                Collection<IResource> existingFiles = getExistingFiles(tsconfigFile.getParent());
                Object[] resources = DialogUtils.openTypeScriptResourcesDialog(tsconfigFile.getProject(),
                        existingFiles, addButton.getShell());
                if (resources != null && resources.length > 0) {
                    IPath path = null;
                    Collection<String> elements = new ArrayList<String>(resources.length);
                    for (int i = 0; i < resources.length; i++) {
                        path = WorkbenchResourceUtil.getRelativePath((IResource) resources[i],
                                tsconfigFile.getParent());
                        elements.add(path.toString());
                    }
                    IObservableList list = ((IObservableList) filesViewer.getInput());
                    list.addAll(elements);
                    filesViewer.refresh();
                }
            }

            private Collection<IResource> getExistingFiles(IContainer parent) {
                if (filesViewer.getSelection().isEmpty()) {
                    return null;
                }
                Collection<IResource> resources = new ArrayList<IResource>();
                Object[] files = filesViewer.getStructuredSelection().toArray();
                for (int i = 0; i < files.length; i++) {
                    IResource f = parent.getFile(new Path((String) files[i]));
                    if (f.exists()) {
                        resources.add(f);
                    }
                }
                return resources;
            }
        });
    }

    filesRemoveButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_remove, SWT.PUSH);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    filesRemoveButton.setLayoutData(gd);
    filesRemoveButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            removeSelectedItems(filesViewer);
        }
    });

    if (tsconfigFile != null) {
        filesOpenButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_open, SWT.PUSH);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        filesOpenButton.setLayoutData(gd);
        filesOpenButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                openFile(filesViewer.getSelection());
            }
        });
    }

    // Files table
    filesViewer = new TableViewer(table);
    filesViewer.setLabelProvider(new DecoratingLabelProvider(filesLabelProvider, filesLabelProvider));
    // open file when row is double clicked
    filesViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent e) {
            openFile(filesViewer.getSelection());
        }
    });
    // update enable/disable of buttons when selection changed
    filesViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateFilesOpenButton(event.getSelection());
            filesRemoveButton.setEnabled(!event.getSelection().isEmpty());
        }
    });
    filesViewer.getTable().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                removeSelectedItems(filesViewer);
            }
        }
    });
    toolkit.paintBordersFor(client);
    section.setClient(client);
    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    section.setLayoutData(new GridData(GridData.FILL_BOTH));

    IObservableList files = JSONProperties.list(new ExtendedJSONPath("files[*]"))
            .observe(getEditor().getDocument());
    filesViewer.setContentProvider(new ObservableListContentProvider());
    filesViewer.setInput(files);

}

From source file:ts.eclipse.ide.json.ui.internal.tsconfig.FilesPage.java

License:Open Source License

private void createExcludeSection(Composite parent) {
    final IFile tsconfigFile = getTsconfigFile();
    FormToolkit toolkit = super.getToolkit();
    Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
    section.setDescription(TsconfigEditorMessages.FilesPage_ExcludeSection_desc);
    section.setText(TsconfigEditorMessages.FilesPage_ExcludeSection_title);

    Composite client = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;/*from   w w  w  .  jav  a 2 s .  c o m*/
    layout.marginWidth = 2;
    layout.marginHeight = 2;
    client.setLayout(layout);

    Table table = toolkit.createTable(client, SWT.MULTI);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 20;
    gd.widthHint = 100;
    table.setLayoutData(gd);

    Composite buttonsComposite = toolkit.createComposite(client);
    buttonsComposite.setLayout(new GridLayout());
    buttonsComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    if (tsconfigFile != null) {
        final Button addButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_add,
                SWT.PUSH);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        addButton.setLayoutData(gd);
        addButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                Object[] resources = DialogUtils.openResourcesDialog(tsconfigFile.getProject(),
                        addButton.getShell());
                if (resources != null && resources.length > 0) {
                    IPath path = null;
                    Collection<String> elements = new ArrayList<String>(resources.length);
                    for (int i = 0; i < resources.length; i++) {
                        path = WorkbenchResourceUtil.getRelativePath((IResource) resources[i],
                                tsconfigFile.getParent());
                        elements.add(path.toString());
                    }
                    IObservableList list = ((IObservableList) excludeViewer.getInput());
                    list.addAll(elements);
                }
            }
        });
    }

    final Button addGlobButton = toolkit.createButton(buttonsComposite,
            TsconfigEditorMessages.Button_add_pattern, SWT.PUSH);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    addGlobButton.setLayoutData(gd);
    addGlobButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            InputDialog dialog = new InputDialog(addGlobButton.getShell(),
                    TsconfigEditorMessages.AddPatternDialog_title,
                    TsconfigEditorMessages.AddPatternDialog_message, "**/*.spec.ts", null);
            if (dialog.open() == Window.OK) {
                IObservableList list = ((IObservableList) excludeViewer.getInput());
                list.add(dialog.getValue());
            }
        }
    });

    excludeRemoveButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_remove,
            SWT.PUSH);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    excludeRemoveButton.setLayoutData(gd);
    excludeRemoveButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            removeSelectedItems(excludeViewer);
        }
    });

    excludeViewer = new TableViewer(table);
    excludeViewer.setLabelProvider(new DecoratingLabelProvider(filesLabelProvider, filesLabelProvider));
    // update enable/disable of buttons when selection changed
    excludeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            excludeRemoveButton.setEnabled(!event.getSelection().isEmpty());
        }
    });
    excludeViewer.getTable().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                removeSelectedItems(excludeViewer);
            }
        }
    });

    toolkit.paintBordersFor(client);
    section.setClient(client);
    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    section.setLayoutData(new GridData(GridData.FILL_BOTH));

    IObservableList exclude = JSONProperties.list(new ExtendedJSONPath("exclude[*]"))
            .observe(getEditor().getDocument());
    excludeViewer.setContentProvider(new ObservableListContentProvider());
    excludeViewer.setInput(exclude);

}

From source file:ts.eclipse.ide.json.ui.internal.tsconfig.FilesPage.java

License:Open Source License

private void createIncludeSection(Composite parent) {
    final IFile tsconfigFile = getTsconfigFile();
    FormToolkit toolkit = super.getToolkit();
    Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
    section.setDescription(TsconfigEditorMessages.FilesPage_IncludeSection_desc);
    section.setText(TsconfigEditorMessages.FilesPage_IncludeSection_title);

    Composite client = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;/*from   www . ja v a2  s  . c om*/
    layout.marginWidth = 2;
    layout.marginHeight = 2;
    client.setLayout(layout);

    Table table = toolkit.createTable(client, SWT.MULTI);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 20;
    gd.widthHint = 100;
    table.setLayoutData(gd);

    Composite buttonsComposite = toolkit.createComposite(client);
    buttonsComposite.setLayout(new GridLayout());
    buttonsComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    if (tsconfigFile != null) {
        final Button addButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_add,
                SWT.PUSH);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        addButton.setLayoutData(gd);
        addButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                Object[] resources = DialogUtils.openResourcesDialog(tsconfigFile.getProject(),
                        addButton.getShell());
                if (resources != null && resources.length > 0) {
                    IPath path = null;
                    Collection<String> elements = new ArrayList<String>(resources.length);
                    for (int i = 0; i < resources.length; i++) {
                        path = WorkbenchResourceUtil.getRelativePath((IResource) resources[i],
                                tsconfigFile.getParent());
                        elements.add(path.toString());
                    }
                    IObservableList list = ((IObservableList) includeViewer.getInput());
                    list.addAll(elements);
                }

            }
        });
    }

    final Button addGlobButton = toolkit.createButton(buttonsComposite,
            TsconfigEditorMessages.Button_add_pattern, SWT.PUSH);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    addGlobButton.setLayoutData(gd);
    addGlobButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            InputDialog dialog = new InputDialog(addGlobButton.getShell(),
                    TsconfigEditorMessages.AddPatternDialog_title,
                    TsconfigEditorMessages.AddPatternDialog_message, "src/**/*", null);
            if (dialog.open() == Window.OK) {
                IObservableList list = ((IObservableList) includeViewer.getInput());
                list.add(dialog.getValue());
            }
        }
    });

    includeRemoveButton = toolkit.createButton(buttonsComposite, TsconfigEditorMessages.Button_remove,
            SWT.PUSH);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    includeRemoveButton.setLayoutData(gd);
    includeRemoveButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            removeSelectedItems(includeViewer);
        }
    });

    includeViewer = new TableViewer(table);
    includeViewer.setLabelProvider(new DecoratingLabelProvider(filesLabelProvider, filesLabelProvider));
    // update enable/disable of buttons when selection changed
    includeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            includeRemoveButton.setEnabled(!event.getSelection().isEmpty());
        }
    });
    includeViewer.getTable().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                removeSelectedItems(includeViewer);
            }
        }
    });
    toolkit.paintBordersFor(client);
    section.setClient(client);
    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    section.setLayoutData(new GridData(GridData.FILL_BOTH));

    IObservableList include = JSONProperties.list(new ExtendedJSONPath("include[*]"))
            .observe(getEditor().getDocument());
    includeViewer.setContentProvider(new ObservableListContentProvider());
    includeViewer.setInput(include);

}