Search in sources :

Example 91 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.

the class HistoricalQuoteProviderPage method createSampleArea.

@Override
protected void createSampleArea(Composite container) {
    Composite composite = new Composite(container, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    composite.setLayout(layout);
    tableSampleData = new QuotesTableViewer(composite);
}
Also used : QuotesTableViewer(name.abuchen.portfolio.ui.util.QuotesTableViewer) Composite(org.eclipse.swt.widgets.Composite) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout)

Example 92 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.

the class NewAccountPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(container);
    Label lblAcc = new Label(container, SWT.NULL);
    lblAcc.setText(Messages.ColumnAccount);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(lblAcc);
    final Text accountName = new Text(container, SWT.BORDER | SWT.SINGLE);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(accountName);
    Button button = new Button(container, SWT.PUSH);
    button.setText(Messages.NewFileWizardButtonAdd);
    GridDataFactory.fillDefaults().applyTo(button);
    Composite tableContainer = new Composite(container, SWT.NONE);
    GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(tableContainer);
    TableColumnLayout layout = new TableColumnLayout();
    tableContainer.setLayout(layout);
    tViewer = new TableViewer(tableContainer);
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String acnName = accountName.getText();
            if (acnName.length() > 0) {
                Account currentAccount = new Account();
                currentAccount.setName(acnName);
                currentAccount.setCurrencyCode(client.getBaseCurrency());
                client.addAccount(currentAccount);
                tViewer.refresh();
                // $NON-NLS-1$
                accountName.setText("");
                accountName.setFocus();
            }
        }
    });
    Table table = tViewer.getTable();
    table.setHeaderVisible(true);
    table.setEnabled(false);
    tViewer.setContentProvider(ArrayContentProvider.getInstance());
    tViewer.setInput(client.getAccounts());
    TableViewerColumn aCol = new TableViewerColumn(tViewer, SWT.NONE);
    layout.setColumnData(aCol.getColumn(), new ColumnWeightData(50));
    aCol.getColumn().setText(Messages.ColumnAccount);
    aCol.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((Account) element).getName();
        }

        @Override
        public Image getImage(Object element) {
            return Images.ACCOUNT.image();
        }
    });
    container.pack();
    setPageComplete(true);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Account(name.abuchen.portfolio.model.Account) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Image(org.eclipse.swt.graphics.Image) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 93 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project azure-tools-for-java by Microsoft.

the class WindowsAzureActivityLogView method createTable.

private Table createTable(Composite parent) {
    table = new Table(parent, SWT.BORDER);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    for (int i = 0; i < 4; i++) {
        new TableColumn(table, SWT.NONE);
    }
    TableColumnLayout layout = new TableColumnLayout();
    parent.setLayout(layout);
    table.getColumn(0).setText(Messages.desc);
    table.getColumn(1).setText(Messages.progress);
    table.getColumn(2).setText(Messages.status);
    table.getColumn(3).setText(Messages.startTime);
    layout.setColumnData(table.getColumn(0), new ColumnWeightData(95));
    layout.setColumnData(table.getColumn(1), new ColumnWeightData(25));
    layout.setColumnData(table.getColumn(2), new ColumnWeightData(65));
    layout.setColumnData(table.getColumn(3), new ColumnWeightData(15));
    return table;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 94 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project archi by archimatetool.

the class ImageManagerDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    setTitle(Messages.ImageManagerDialog_1);
    setMessage(Messages.ImageManagerDialog_2);
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite client = new Composite(composite, SWT.NULL);
    GridLayout layout = new GridLayout(2, false);
    client.setLayout(layout);
    client.setLayoutData(new GridData(GridData.FILL_BOTH));
    SashForm sash = new SashForm(client, SWT.HORIZONTAL);
    sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 580;
    gd.heightHint = 300;
    sash.setLayoutData(gd);
    // Table
    Composite tableComp = new Composite(sash, SWT.BORDER);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    tableComp.setLayout(layout);
    CLabel label = new CLabel(tableComp, SWT.NULL);
    label.setText(Messages.ImageManagerDialog_3);
    Composite tableComp2 = new Composite(tableComp, SWT.NULL);
    tableComp2.setLayout(new TableColumnLayout());
    tableComp2.setLayoutData(new GridData(GridData.FILL_BOTH));
    fModelsViewer = new ModelsViewer(tableComp2);
    fModelsViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    // $NON-NLS-1$
    fModelsViewer.setInput("");
    fModelsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (o instanceof IArchimateModel) {
                fScale.setEnabled(true);
                clearGallery();
                updateGallery((IArchimateModel) o);
            }
        }
    });
    // Mouse Up action...
    fModelsViewer.getControl().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            Object o = ((IStructuredSelection) fModelsViewer.getSelection()).getFirstElement();
            // Open...
            if (o == OPEN) {
                handleOpenAction();
            }
        }
    });
    Composite galleryComposite = new Composite(sash, SWT.NULL);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    galleryComposite.setLayout(layout);
    fGallery = new Gallery(galleryComposite, SWT.V_SCROLL | SWT.BORDER);
    fGallery.setLayoutData(new GridData(GridData.FILL_BOTH));
    // Renderers
    final NoGroupRenderer groupRenderer = new NoGroupRenderer();
    groupRenderer.setItemSize(DEFAULT_GALLERY_ITEM_SIZE, DEFAULT_GALLERY_ITEM_SIZE);
    groupRenderer.setAutoMargin(true);
    groupRenderer.setMinMargin(10);
    fGallery.setGroupRenderer(groupRenderer);
    final DefaultGalleryItemRenderer itemRenderer = new DefaultGalleryItemRenderer();
    // itemRenderer.setDropShadows(true);
    // itemRenderer.setDropShadowsSize(7);
    itemRenderer.setShowRoundedSelectionCorners(true);
    fGallery.setItemRenderer(itemRenderer);
    // Root Group
    fGalleryRoot = new GalleryItem(fGallery, SWT.NONE);
    // Slider
    fScale = new Scale(galleryComposite, SWT.HORIZONTAL);
    gd = new GridData(SWT.END, SWT.NONE, false, false);
    gd.widthHint = 120;
    fScale.setLayoutData(gd);
    fScale.setMinimum(MIN_GALLERY_ITEM_SIZE);
    fScale.setMaximum(MAX_GALLERY_ITEM_SIZE);
    fScale.setIncrement(8);
    fScale.setPageIncrement(32);
    fScale.setSelection(DEFAULT_GALLERY_ITEM_SIZE);
    fScale.setEnabled(false);
    fScale.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int inc = fScale.getSelection();
            itemRenderer.setDropShadows(inc >= 96);
            groupRenderer.setItemSize(inc, inc);
        }
    });
    // Gallery selections
    fGallery.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (e.item instanceof GalleryItem) {
                // $NON-NLS-1$
                fUserSelectedImagePath = (String) ((GalleryItem) e.item).getData("imagepath");
                // $NON-NLS-1$
                fUserSelectedModel = (IArchimateModel) ((GalleryItem) e.item).getData("model");
            } else {
                fUserSelectedImagePath = null;
                fUserSelectedModel = null;
            }
        }
    });
    // Double-clicks
    fGallery.addListener(SWT.MouseDoubleClick, new Listener() {

        @Override
        public void handleEvent(Event event) {
            GalleryItem item = fGallery.getItem(new Point(event.x, event.y));
            if (item != null) {
                okPressed();
            }
        }
    });
    // Dispose of the images here not in the main dispose() method because if the help system is showing then
    // the TrayDialog is resized and this control is asked to relayout.
    fGallery.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            disposeImages();
        }
    });
    sash.setWeights(new int[] { 30, 70 });
    // If we have this model in the table, select it
    if (fUserSelectedModel != null && ((ModelsViewerContentProvider) fModelsViewer.getContentProvider()).getModels().contains(fUserSelectedModel)) {
        fModelsViewer.setSelection(new StructuredSelection(fUserSelectedModel));
        // Make selection of image path if it's set
        if (fUserSelectedImagePath != null) {
            for (GalleryItem item : fGalleryRoot.getItems()) {
                // $NON-NLS-1$
                String imagePath = (String) item.getData("imagepath");
                if (imagePath != null && fUserSelectedImagePath.equals(imagePath)) {
                    fGallery.setSelection(new GalleryItem[] { item });
                    break;
                }
            }
        }
    } else // Else select the first model in the table, if there is one
    {
        Object element = fModelsViewer.getElementAt(0);
        if (element != null) {
            fModelsViewer.setSelection(new StructuredSelection(element), true);
        }
    }
    return composite;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) DisposeListener(org.eclipse.swt.events.DisposeListener) DisposeListener(org.eclipse.swt.events.DisposeListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IArchimateModel(com.archimatetool.model.IArchimateModel) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Scale(org.eclipse.swt.widgets.Scale) DefaultGalleryItemRenderer(org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRenderer) Point(org.eclipse.swt.graphics.Point) GalleryItem(org.eclipse.nebula.widgets.gallery.GalleryItem) SashForm(org.eclipse.swt.custom.SashForm) Gallery(org.eclipse.nebula.widgets.gallery.Gallery) GridData(org.eclipse.swt.layout.GridData) DisposeEvent(org.eclipse.swt.events.DisposeEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NoGroupRenderer(org.eclipse.nebula.widgets.gallery.NoGroupRenderer)

Example 95 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project archi by archimatetool.

the class DropinsPluginDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    setTitle(Messages.DropinsPluginDialog_1);
    setMessage(Messages.DropinsPluginDialog_2);
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    container.setLayout(new GridLayout(1, false));
    Composite tableComp = new Composite(container, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    tableComp.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    tableComp.setLayoutData(gd);
    viewer = new TableViewer(tableComp, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    // Mac Silicon Item height
    UIUtils.fixMacSiliconItemHeight(viewer.getTable());
    viewer.getTable().setHeaderVisible(true);
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
    column.getColumn().setText(Messages.DropinsPluginDialog_3);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(8, false));
    column.getColumn().setText(Messages.DropinsPluginDialog_4);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
    column.getColumn().setText(Messages.DropinsPluginDialog_5);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
    column.getColumn().setText(Messages.DropinsPluginDialog_6);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
    column.getColumn().setText(Messages.DropinsPluginDialog_14);
    DropinsPluginHandler handler = new DropinsPluginHandler();
    viewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            try {
                return handler.getInstalledPlugins().toArray();
            } catch (IOException ex) {
                // $NON-NLS-1$
                Logger.logError("Error getting installed plug-in", ex);
            }
            return new Object[0];
        }
    });
    class LabelCellProvider extends LabelProvider implements ITableLabelProvider {

        @Override
        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }

        @Override
        public String getColumnText(Object element, int columnIndex) {
            if (element instanceof Bundle) {
                Bundle bundle = (Bundle) element;
                switch(columnIndex) {
                    case 0:
                        // $NON-NLS-1$
                        return bundle.getHeaders().get("Bundle-Name");
                    case 1:
                        return bundle.getVersion().toString();
                    case 2:
                        return bundle.getSymbolicName();
                    case 3:
                        // $NON-NLS-1$
                        return bundle.getHeaders().get("Bundle-Vendor");
                    case 4:
                        try {
                            File file = handler.getDropinsBundleFile(bundle);
                            return file == null ? Messages.DropinsPluginDialog_13 : file.getParentFile().getPath();
                        } catch (IOException ex) {
                            return Messages.DropinsPluginDialog_13;
                        }
                    default:
                        break;
                }
            }
            return element.toString();
        }
    }
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            Bundle b1 = (Bundle) e1;
            Bundle b2 = (Bundle) e2;
            // $NON-NLS-1$ //$NON-NLS-2$
            return b1.getHeaders().get("Bundle-Name").compareToIgnoreCase(b2.getHeaders().get("Bundle-Name"));
        }
    });
    viewer.setLabelProvider(new LabelCellProvider());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            getButton(UNINSTALL).setEnabled(!event.getSelection().isEmpty());
        }
    });
    // anything will do //$NON-NLS-1$
    viewer.setInput("");
    return area;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Composite(org.eclipse.swt.widgets.Composite) Bundle(org.osgi.framework.Bundle) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IOException(java.io.IOException) GridLayout(org.eclipse.swt.layout.GridLayout) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) File(java.io.File) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)105 Composite (org.eclipse.swt.widgets.Composite)94 TableViewer (org.eclipse.jface.viewers.TableViewer)78 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)62 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)51 GridData (org.eclipse.swt.layout.GridData)46 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)44 Table (org.eclipse.swt.widgets.Table)38 GridLayout (org.eclipse.swt.layout.GridLayout)34 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)31 Image (org.eclipse.swt.graphics.Image)28 Label (org.eclipse.swt.widgets.Label)27 Viewer (org.eclipse.jface.viewers.Viewer)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)23 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)22 SelectionEvent (org.eclipse.swt.events.SelectionEvent)22 Button (org.eclipse.swt.widgets.Button)21 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)18 TableColumn (org.eclipse.swt.widgets.TableColumn)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)17