Search in sources :

Example 66 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project webtools.sourceediting by eclipse.

the class PropertyPreferencePage method openProjectSettings.

void openProjectSettings() {
    ListDialog dialog = new ListDialog(getShell()) {

        @Override
        protected Control createDialogArea(Composite container) {
            Control area = super.createDialogArea(container);
            getTableViewer().setSorter(new ResourceSorter(ResourceSorter.NAME));
            return area;
        }
    };
    dialog.setMessage(SSEUIMessages.PropertyPreferencePage_02);
    dialog.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

        public Object[] getElements(Object inputElement) {
            return ((IWorkspace) inputElement).getRoot().getProjects();
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    dialog.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), SSEUIPlugin.getDefault().getWorkbench().getDecoratorManager().getLabelDecorator()));
    dialog.setInput(ResourcesPlugin.getWorkspace());
    dialog.setTitle(SSEUIMessages.PropertyPreferencePage_01);
    if (dialog.open() == Window.OK) {
        Object[] result = dialog.getResult();
        if (result.length > 0) {
            IProject project = (IProject) dialog.getResult()[0];
            Map data = new HashMap();
            data.put(DISABLE_LINK, Boolean.TRUE);
            PreferencesUtil.createPropertyDialogOn(getShell(), project, getPropertyPageID(), new String[] { getPropertyPageID() }, data).open();
        }
    }
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ResourceSorter(org.eclipse.ui.views.navigator.ResourceSorter) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) Viewer(org.eclipse.jface.viewers.Viewer) DecoratingLabelProvider(org.eclipse.jface.viewers.DecoratingLabelProvider) IProject(org.eclipse.core.resources.IProject) Control(org.eclipse.swt.widgets.Control) IWorkspace(org.eclipse.core.resources.IWorkspace) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) HashMap(java.util.HashMap) Map(java.util.Map) ListDialog(org.eclipse.ui.dialogs.ListDialog)

Example 67 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project webtools.sourceediting by eclipse.

the class AttributesBlock method createControl.

public void createControl(Composite parent) {
    TabItem item = new TabItem((TabFolder) parent, SWT.NONE);
    // $NON-NLS-1$
    item.setText(Messages.getString("AttributesBlock.0"));
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginBottom = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    item.setControl(composite);
    table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.MULTI);
    table.setHeaderVisible(true);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if (event.character == SWT.DEL && event.stateMask == 0) {
                performRemove();
            }
        }
    });
    TableColumn tc1 = new TableColumn(table, SWT.NONE);
    // $NON-NLS-1$
    tc1.setText(Messages.getString("AttributesBlock.2"));
    tc1.setWidth(350);
    tc1.setResizable(true);
    TableColumn tc2 = new TableColumn(table, SWT.NONE);
    // $NON-NLS-1$
    tc2.setText(Messages.getString("AttributesBlock.7"));
    tc2.setWidth(50);
    tc2.setResizable(true);
    Composite buttonComp = new Composite(composite, SWT.FILL);
    buttonComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    GridLayout gl = new GridLayout();
    gl.marginWidth = 0;
    buttonComp.setLayout(gl);
    Button addButton = new Button(buttonComp, SWT.PUSH);
    // $NON-NLS-1$
    addButton.setText(Messages.getString("AttributesBlock.8"));
    addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    addButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            AttributeDialog dialog = new AttributeDialog(getShell(), attributes);
            if (dialog.open() == Window.OK) {
                List<IAttribute> newAttributes = dialog.getAttributes();
                LaunchAttribute first = null;
                for (IAttribute attribute : newAttributes) {
                    // $NON-NLS-1$
                    LaunchAttribute att = new LaunchAttribute(attribute.getURI(), "string", null);
                    if (first == null)
                        first = att;
                    attributes.addAttribute(att);
                }
                if (newAttributes.size() > 0) {
                    tViewer.refresh();
                    tViewer.setSelection(new StructuredSelection(first), true);
                    tViewer.editElement(first, 1);
                    updateLaunchConfigurationDialog();
                }
            }
        }
    });
    removeButton = new Button(buttonComp, SWT.PUSH);
    // $NON-NLS-1$
    removeButton.setText(Messages.getString("AttributesBlock.14"));
    removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    removeButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            performRemove();
        }
    });
    setControl(table);
    tViewer = new TableViewer(table);
    tViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            return attributes.getAttributes().toArray(new LaunchAttribute[0]);
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            attributes = (LaunchAttributes) newInput;
        }
    });
    tViewer.setSorter(new ViewerSorter() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            LaunchAttribute a1 = (LaunchAttribute) e1;
            LaunchAttribute a2 = (LaunchAttribute) e2;
            return a1.uri.compareTo(a2.uri);
        }
    });
    tViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            updateRemoveButton();
        }
    });
    TableViewerColumn tvc1 = new TableViewerColumn(tViewer, tc1);
    tvc1.setLabelProvider(new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            LaunchAttribute tv = (LaunchAttribute) cell.getElement();
            cell.setText(tv.uri);
        }

        @Override
        public int getToolTipTimeDisplayed(Object object) {
            return 5000;
        }

        @Override
        public String getToolTipText(Object element) {
            LaunchAttribute tv = (LaunchAttribute) element;
            return attributeUris.get(tv.uri).getDescription();
        }
    });
    // ColumnViewerToolTipSupport.enableFor(tViewer);
    TableViewerColumn tvc2 = new TableViewerColumn(tViewer, tc2);
    tvc2.setLabelProvider(new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            LaunchAttribute tv = (LaunchAttribute) cell.getElement();
            cell.setText(tv.value);
        }
    });
    tvc2.setEditingSupport(new EditingSupport(tViewer) {

        @Override
        protected boolean canEdit(Object element) {
            return true;
        }

        @Override
        protected CellEditor getCellEditor(Object element) {
            return new TextCellEditor(table);
        }

        @Override
        protected Object getValue(Object element) {
            LaunchAttribute tv = (LaunchAttribute) element;
            // $NON-NLS-1$
            return tv.value == null ? "" : tv.value;
        }

        @Override
        protected void setValue(Object element, Object value) {
            LaunchAttribute tv = (LaunchAttribute) element;
            tv.setValue((String) value);
            updateLaunchConfigurationDialog();
            tViewer.update(tv, null);
        }
    });
    restoreColumnSettings();
}
Also used : CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) KeyAdapter(org.eclipse.swt.events.KeyAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) EditingSupport(org.eclipse.jface.viewers.EditingSupport) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TableColumn(org.eclipse.swt.widgets.TableColumn) LaunchAttribute(org.eclipse.wst.xsl.launching.config.LaunchAttribute) ViewerCell(org.eclipse.jface.viewers.ViewerCell) TabItem(org.eclipse.swt.widgets.TabItem) GridData(org.eclipse.swt.layout.GridData) IAttribute(org.eclipse.wst.xsl.jaxp.launching.IAttribute) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) LaunchAttributes(org.eclipse.wst.xsl.jaxp.launching.LaunchAttributes) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 68 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project epp.mpc by eclipse.

the class MarketplaceWizard method notifyNonInstallableItems.

protected void notifyNonInstallableItems(final List<CatalogItem> noninstallableItems) {
    MessageDialog dialog = new MessageDialog(getShell(), Messages.MarketplaceWizard_UnableToInstallSolutions, null, Messages.MarketplaceWizard_IncompatibleSolutionsMessage, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) {

        @Override
        protected Control createCustomArea(Composite parent) {
            parent.setLayout(new GridLayout());
            TableViewer tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
            tableViewer.setLabelProvider(createLabelProvider());
            tableViewer.setContentProvider(createContentProvider());
            tableViewer.setInput(noninstallableItems);
            Control tableControl = tableViewer.getControl();
            GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, Math.max(40, Math.min(120, tableControl.computeSize(SWT.DEFAULT, SWT.DEFAULT).y))).applyTo(tableControl);
            return tableControl;
        }

        private LabelProvider createLabelProvider() {
            return new LabelProvider() {

                @Override
                public String getText(Object element) {
                    // we could show that with an IStyledLabelProvider behind the name
                    return ((CatalogItem) element).getName();
                }

                @Override
                public Image getImage(Object element) {
                    return MarketplaceClientUiPlugin.getInstance().getImageRegistry().get(MarketplaceClientUiPlugin.IU_ICON_ERROR);
                }
            };
        }

        private IStructuredContentProvider createContentProvider() {
            return new IStructuredContentProvider() {

                public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
                }

                public void dispose() {
                }

                public Object[] getElements(Object inputElement) {
                    return ((List<?>) inputElement).toArray();
                }
            };
        }
    };
    dialog.open();
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) List(java.util.List) ArrayList(java.util.ArrayList) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 69 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project epp.mpc by eclipse.

the class ShowNatureProposalsDialog method createDialogArea.

@Override
public Control createDialogArea(Composite parent) {
    setTitle(Messages.MissingNatureDetector_Title);
    setMessage(Messages.MissingNatureDetector_Desc);
    wizban = DiscoveryImages.BANNER_DISOVERY.createImage();
    setTitleImage(wizban);
    Composite res = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, SWT.DEFAULT).applyTo(res);
    GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins()).equalWidth(false).applyTo(res);
    Label label = new Label(res, SWT.WRAP);
    label.setText(Messages.MissingNatureDetector_Message);
    naturesCheckList = CheckboxTableViewer.newCheckList(res, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    naturesCheckList.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            return ((Set<?>) inputElement).toArray();
        }
    });
    naturesCheckList.setComparator(new ViewerComparator());
    naturesCheckList.setInput(candidates.keySet());
    naturesCheckList.setAllChecked(true);
    GridDataFactory.fillDefaults().applyTo(naturesCheckList.getControl());
    naturesCheckList.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            Button okButton = getButton(IDialogConstants.OK_ID);
            if (okButton != null) {
                okButton.setEnabled(canComplete());
            }
            updateSelectedNatures();
        }
    });
    Link preferencesLink = new Link(res, SWT.NONE);
    preferencesLink.setText(Messages.MissingNatureDetector_linkToPreferences);
    preferencesLink.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(getShell(), ProjectNaturesPreferencePage.ID, null, null);
            pref.setBlockOnOpen(false);
            pref.open();
        }
    });
    return res;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) Button(org.eclipse.swt.widgets.Button) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Link(org.eclipse.swt.widgets.Link)

Example 70 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project liferay-ide by liferay.

the class PropertyPreferencePage method _openProjectSettings.

private void _openProjectSettings() {
    ListDialog dialog = new ListDialog(getShell()) {

        @Override
        protected Control createDialogArea(Composite container) {
            Control area = super.createDialogArea(container);
            getTableViewer().setSorter(new ResourceSorter(ResourceSorter.NAME));
            return area;
        }
    };
    dialog.setMessage(SSEUIMessages.PropertyPreferencePage_02);
    dialog.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

        public Object[] getElements(Object inputElement) {
            return ((IWorkspace) inputElement).getRoot().getProjects();
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    IWorkbench workbench = SSEUIPlugin.getDefault().getWorkbench();
    dialog.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), workbench.getDecoratorManager().getLabelDecorator()));
    dialog.setInput(ResourcesPlugin.getWorkspace());
    dialog.setTitle(SSEUIMessages.PropertyPreferencePage_01);
    if (dialog.open() == Window.OK) {
        Object[] result = dialog.getResult();
        if (ListUtil.isNotEmpty(result)) {
            IProject project = (IProject) dialog.getResult()[0];
            Map data = new HashMap();
            data.put(_disableLink, Boolean.TRUE);
            PreferencesUtil.createPropertyDialogOn(getShell(), project, getPropertyPageID(), new String[] { getPropertyPageID() }, data).open();
        }
    }
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ResourceSorter(org.eclipse.ui.views.navigator.ResourceSorter) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) Viewer(org.eclipse.jface.viewers.Viewer) DecoratingLabelProvider(org.eclipse.jface.viewers.DecoratingLabelProvider) IProject(org.eclipse.core.resources.IProject) IWorkbench(org.eclipse.ui.IWorkbench) Control(org.eclipse.swt.widgets.Control) IWorkspace(org.eclipse.core.resources.IWorkspace) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) HashMap(java.util.HashMap) Map(java.util.Map) ListDialog(org.eclipse.ui.dialogs.ListDialog)

Aggregations

IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)99 Viewer (org.eclipse.jface.viewers.Viewer)77 Composite (org.eclipse.swt.widgets.Composite)58 GridData (org.eclipse.swt.layout.GridData)54 TableViewer (org.eclipse.jface.viewers.TableViewer)45 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)43 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)42 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)40 GridLayout (org.eclipse.swt.layout.GridLayout)40 LabelProvider (org.eclipse.jface.viewers.LabelProvider)32 Image (org.eclipse.swt.graphics.Image)29 Button (org.eclipse.swt.widgets.Button)28 Label (org.eclipse.swt.widgets.Label)28 SelectionEvent (org.eclipse.swt.events.SelectionEvent)26 Table (org.eclipse.swt.widgets.Table)24 ArrayList (java.util.ArrayList)23 ComboViewer (org.eclipse.jface.viewers.ComboViewer)19 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)19 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)18 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)18