Java Examples for org.eclipse.jface.viewers.ArrayContentProvider

The following java examples will help you to understand the usage of org.eclipse.jface.viewers.ArrayContentProvider. These source code samples are taken from different open source projects.

Example 1
Project: tern.java-master  File: ReorgQueries.java View source code
private Runnable createQueryRunnable(final String question, final Object[] elements, final int[] result) {
    return new Runnable() {

        public void run() {
            ListDialog dialog = new YesNoListDialog(fShell, true);
            dialog.setAddCancelButton(false);
            dialog.setBlockOnOpen(true);
            dialog.setContentProvider(new ArrayContentProvider());
            dialog.setLabelProvider(new JavaScriptElementLabelProvider());
            dialog.setTitle(fDialogTitle);
            dialog.setMessage(question);
            dialog.setInput(elements);
            dialog.open();
            result[0] = dialog.getReturnCode();
        }
    };
}
Example 2
Project: codemap-master  File: SelectionView.java View source code
@Override
public void createPartControl(Composite parent) {
    // the PageBook allows simple switching between two viewers
    pagebook = new PageBook(parent, SWT.NONE);
    tableviewer = new TableViewer(pagebook, SWT.NONE);
    tableviewer.setLabelProvider(new WorkbenchLabelProvider());
    tableviewer.setContentProvider(new ArrayContentProvider());
    tableviewer.setSelection(null);
    // we're cooperative and also provide our selection
    // at least for the tableviewer
    getSite().setSelectionProvider(tableviewer);
    textviewer = new TextViewer(pagebook, SWT.H_SCROLL | SWT.V_SCROLL);
    textviewer.setEditable(false);
    getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(PACKAGE_EXPLORER.id, listener);
}
Example 3
Project: extFM-Tooling-master  File: SatisfiabilityDialog.java View source code
@Override
protected Control createCustomArea(Composite parent) {
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    createColumns(parent, viewer);
    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    viewer.setContentProvider(new ArrayContentProvider());
    // Get the content for the viewer, setInput will call getElements in the
    // contentProvider
    viewer.setInput(getFileList());
    // Layout the viewer
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.horizontalSpan = 2;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    viewer.getControl().setLayoutData(gridData);
    return viewer.getControl();
}
Example 4
Project: aws-toolkit-eclipse-master  File: DeployWizardRoleSelectionPage.java View source code
private ComboViewer newRoleComboView(Composite composite, List<String> roles) {
    ComboViewer roleComboViewer = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
    roleComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    roleComboViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    roleComboViewer.setInput(roles);
    // Custom Label provider to clearly indicate the default role in the ComboViewer
    roleComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (isDefaultRoleName(element)) {
                return "(Default) " + element;
            }
            return super.getText(element);
        }

        private boolean isDefaultRoleName(Object element) {
            return element instanceof String && defaultRole.equals(element);
        }
    });
    return roleComboViewer;
}
Example 5
Project: cdo-master  File: AbstractDetailsPage.java View source code
protected ComboViewer combo(Composite parent, FormToolkit toolkit, String label, EAttribute attribute) {
    toolkit.createLabel(parent, label);
    ComboViewer result = new ComboViewer(createDecorationComposite(parent, toolkit, layoutData(parent, SWT.LEFT, false, 1)), SWT.READ_ONLY | SWT.DROP_DOWN);
    result.setLabelProvider(new AdapterFactoryLabelProvider(getAdapterFactory()));
    result.setContentProvider(new ArrayContentProvider());
    result.setInput(attribute.getEAttributeType().getInstanceClass().getEnumConstants());
    getContext().bindValue(ViewersObservables.observeSingleSelection(result), EMFEditObservables.observeDetailValue(getRealm(), getEditingDomain(), getValue(), attribute));
    getContext().bindValue(WidgetProperties.enabled().observe(result.getControl()), getValue(), null, ObjectWritableConverter.createUpdateValueStrategy(attribute));
    addRevertDecoration(result.getControl(), attribute);
    return result;
}
Example 6
Project: tcf-master  File: FilteredCheckedListDialog.java View source code
/**
	 * Create the checked list and add check action changed listener to monitor events.
	 *
	 * @param composite The parent composite.
	 */
private void createTable(Composite composite) {
    tableViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    tableViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            tableCheckStateChanged(event);
        }
    });
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.heightHint = 120;
    data.widthHint = 200;
    tableViewer.getTable().setLayoutData(data);
    tableViewer.setContentProvider(ArrayContentProvider.getInstance());
    tableViewer.setLabelProvider(labelProvider);
    patternFilter = new TablePatternFilter(labelProvider);
    tableViewer.addFilter(patternFilter);
    tableViewer.addSelectionChangedListener(this);
}
Example 7
Project: streamline-master  File: DataViewer.java View source code
private void createViewer(Composite parent, IPersistentMap<String, DataType<?>> inData) {
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    createColumns(parent, viewer, inData);
    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
// Get the content for the viewer, setInput will call getElements in the
// contentProvider
//	    viewer.setInput(ModelProvider.INSTANCE.getPersons());
// Make the selection available to other views
// Set the sorter for the table
// Layout the viewer
//	    GridData gridData = new GridData();
//	    gridData.verticalAlignment = GridData.FILL;
//	    gridData.horizontalSpan = 2;
//	    gridData.grabExcessHorizontalSpace = true;
//	    gridData.grabExcessVerticalSpace = true;
//	    gridData.horizontalAlignment = GridData.FILL;
//	    viewer.getControl().setLayoutData(gridData);
}
Example 8
Project: geotools-old-master  File: JDataChoosePage.java View source code
public void createControl(Composite parent) {
    Composite mainComposite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(1, false);
    mainComposite.setLayout(gridLayout);
    List<DataStoreFactorySpi> factoryList = new ArrayList<DataStoreFactorySpi>();
    for (Iterator<DataStoreFactorySpi> iter = DataStoreFinder.getAvailableDataStores(); iter.hasNext(); ) {
        factoryList.add(iter.next());
    }
    TableViewer viewer = new TableViewer(mainComposite);
    GridData viewerGD = new GridData(SWT.FILL, SWT.FILL, true, false);
    viewer.getTable().setLayoutData(viewerGD);
    viewer.addSelectionChangedListener(this);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider() {

        public String getText(Object element) {
            if (element instanceof DataStoreFactorySpi) {
                DataStoreFactorySpi factory = (DataStoreFactorySpi) element;
                return factory.getDisplayName();
            }
            return super.getText(element);
        }
    });
    viewer.setInput(factoryList.toArray());
    setControl(mainComposite);
    canFlip = false;
}
Example 9
Project: xmind-master  File: EditorStatePersistance.java View source code
/**
     * @throws WorkbenchException
     */
private void recoverLastSession() throws WorkbenchException {
    File sessionFile = getSessionFile();
    if (sessionFile == null || !sessionFile.exists())
        return;
    XMLMemento root;
    try {
        Reader reader = new BufferedReader(new FileReader(sessionFile));
        root = XMLMemento.createReadRoot(reader);
    } catch (IOException e) {
        logger.logError(null, e);
        return;
    } finally {
        sessionFile.delete();
    }
    IMemento[] states = root.getChildren(IWorkbenchConstants.TAG_EDITOR);
    if (states.length == 0)
        return;
    ListSelectionDialog dialog = new ListSelectionDialog(null, states, new ArrayContentProvider(), new EditorStateLabelProvider(), WorkbenchMessages.appWindow_ListSelectionDialog_Text);
    dialog.setTitle(WorkbenchMessages.appWindow_ListSelectionDialog_Title);
    dialog.setInitialSelections(states);
    int ret = dialog.open();
    if (ret == ListSelectionDialog.CANCEL)
        return;
    Object[] result = dialog.getResult();
    if (result == null)
        return;
    states = new IMemento[result.length];
    System.arraycopy(result, 0, states, 0, result.length);
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window == null) {
        window = workbench.openWorkbenchWindow(null);
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        page = window.openPage(null);
    }
    page.openEditors(null, null, states, 0, 0);
}
Example 10
Project: CodingSpectator-master  File: RefactoringSaveHelper.java View source code
private boolean askSaveAllDirtyEditors(Shell shell, IEditorPart[] dirtyEditors) {
    final boolean canSaveAutomatically = fSaveMode != SAVE_ALL_ALWAYS_ASK;
    if (//must save everything
    canSaveAutomatically && RefactoringSavePreferences.getSaveAllEditors())
        return true;
    ListDialog dialog = new ListDialog(shell) {

        {
            setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL);
        }

        protected Control createDialogArea(Composite parent) {
            Composite result = (Composite) super.createDialogArea(parent);
            if (canSaveAutomatically) {
                final Button check = new Button(result, SWT.CHECK);
                check.setText(RefactoringMessages.RefactoringStarter_always_save);
                check.setSelection(RefactoringSavePreferences.getSaveAllEditors());
                check.addSelectionListener(new SelectionAdapter() {

                    public void widgetSelected(SelectionEvent e) {
                        RefactoringSavePreferences.setSaveAllEditors(check.getSelection());
                    }
                });
                applyDialogFont(result);
            }
            return result;
        }
    };
    dialog.setTitle(RefactoringMessages.RefactoringStarter_save_all_resources);
    dialog.setAddCancelButton(true);
    dialog.setLabelProvider(createDialogLabelProvider());
    dialog.setMessage(RefactoringMessages.RefactoringStarter_must_save);
    dialog.setContentProvider(new ArrayContentProvider());
    dialog.setInput(Arrays.asList(dirtyEditors));
    return dialog.open() == Window.OK;
}