Search in sources :

Example 51 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project hale by halestudio.

the class WorkspaceConfigurationPage method createContent.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void createContent(Composite page) {
    Composite main = new Composite(page, SWT.NONE);
    main.setLayout(new GridLayout(3, false));
    Composite tableParent = new Composite(main, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    tableParent.setLayout(layout);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 2);
    gridData.minimumHeight = 150;
    tableParent.setLayoutData(gridData);
    workspaceTableViewer = new TableViewer(tableParent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    workspaceTableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 2));
    workspaceTableViewer.setContentProvider(ArrayContentProvider.getInstance());
    workspaceTableViewer.getTable().setHeaderVisible(true);
    workspaceTableViewer.getTable().setLinesVisible(true);
    // disable selection on table viewer
    workspaceTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            // prevent selection
            if (!event.getSelection().isEmpty()) {
                workspaceTableViewer.setSelection(StructuredSelection.EMPTY);
            }
        }
    });
    TableViewerColumn nameColumn = new TableViewerColumn(workspaceTableViewer, SWT.NONE);
    layout.setColumnData(nameColumn.getColumn(), new ColumnWeightData(2, true));
    nameColumn.setLabelProvider(new WorkspaceNameLabelProvider());
    nameColumn.getColumn().setText("Name");
    nameColumn.setEditingSupport(new WorkspaceNameEditingSupport(workspaceTableViewer));
    TableViewerColumn isolatedColumn = new TableViewerColumn(workspaceTableViewer, SWT.NONE);
    layout.setColumnData(isolatedColumn.getColumn(), new ColumnWeightData(1, true));
    isolatedColumn.setLabelProvider(new WorkspaceIsolatedLabelProvider());
    isolatedColumn.getColumn().setText("Isolated");
    isolatedColumn.setEditingSupport(new WorkspaceIsolatedEditingSupport(workspaceTableViewer));
    TableViewerColumn namespaceColumn = new TableViewerColumn(workspaceTableViewer, SWT.NONE);
    layout.setColumnData(namespaceColumn.getColumn(), new ColumnWeightData(3, true));
    namespaceColumn.setLabelProvider(new WorkspaceNamespaceLabelProvider());
    namespaceColumn.getColumn().setText("Namespace");
    TableViewerColumn featuresColumn = new TableViewerColumn(workspaceTableViewer, SWT.NONE);
    layout.setColumnData(featuresColumn.getColumn(), new ColumnWeightData(3, true));
    featuresColumn.setLabelProvider(new WorkspaceFeaturesLabelProvider());
    featuresColumn.getColumn().setText("Features");
    IWizardContainer container = getContainer();
    if (container instanceof WizardDialog) {
        changeListener = new IPageChangingListener() {

            @Override
            public void handlePageChanging(PageChangingEvent event) {
                Object currentPage = event.getCurrentPage();
                Object targetPage = event.getTargetPage();
                if ((currentPage instanceof FeatureChainingConfigurationPage || currentPage instanceof ChainPage) && targetPage instanceof WorkspaceConfigurationPage) {
                    goingBack = false;
                } else if (currentPage instanceof AppSchemaDataStoreConfigurationPage && targetPage instanceof WorkspaceConfigurationPage) {
                    goingBack = true;
                }
            }
        };
        WizardDialog dialog = (WizardDialog) container;
        dialog.addPageChangingListener(changeListener);
    } else {
        changeListener = null;
    }
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IPageChangingListener(org.eclipse.jface.dialogs.IPageChangingListener) IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) ChainPage(eu.esdihumboldt.hale.io.appschema.ui.FeatureChainingConfigurationPage.ChainPage) GridLayout(org.eclipse.swt.layout.GridLayout) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) PageChangingEvent(org.eclipse.jface.dialogs.PageChangingEvent) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 52 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project eclipse.platform.text by eclipse.

the class HyperlinkDetectorsConfigurationBlock method createControl.

@Override
public Control createControl(Composite parent) {
    PixelConverter pixelConverter = new PixelConverter(parent);
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    addFiller(composite, 2);
    String label = TextEditorMessages.HyperlinksEnabled_label;
    fHyperlinksEnabledCheckBox = addCheckBox(composite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED, 0);
    fHyperlinksEnabledCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean state = fHyperlinksEnabledCheckBox.getSelection();
            fHyperlinkDefaultKeyModifierText.setEnabled(state);
            fHyperlinkKeyModifierText.setEnabled(state && getSelectedItem() != null);
            fHyperlinkDetectorsViewer.getTable().setEnabled(state);
            handleHyperlinkKeyModifierModified();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    // Text field for default modifier string
    label = TextEditorMessages.HyperlinkDefaultKeyModifier_label;
    fHyperlinkDefaultKeyModifierText = (Text) addTextField(composite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER, 15, 20, pixelConverter)[1];
    fHyperlinkDefaultKeyModifierText.addKeyListener(new KeyListener() {

        private boolean isModifierCandidate;

        @Override
        public void keyPressed(KeyEvent e) {
            isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {
                // && e.time -time < 1000) {
                String modifierString = fHyperlinkDefaultKeyModifierText.getText();
                Point selection = fHyperlinkDefaultKeyModifierText.getSelection();
                int i = selection.x - 1;
                while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
                    i--;
                }
                boolean needsPrefixDelimiter = i > -1 && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
                i = selection.y;
                while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) {
                    i++;
                }
                boolean needsPostfixDelimiter = i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
                String insertString;
                if (needsPrefixDelimiter && needsPostfixDelimiter)
                    insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifierAndDelimiter, Action.findModifierString(e.stateMask));
                else if (needsPrefixDelimiter)
                    insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifier, Action.findModifierString(e.stateMask));
                else if (needsPostfixDelimiter)
                    insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertModifierAndDelimiter, Action.findModifierString(e.stateMask));
                else
                    insertString = Action.findModifierString(e.stateMask);
                fHyperlinkDefaultKeyModifierText.insert(insertString);
            }
        }
    });
    fHyperlinkDefaultKeyModifierText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            handleHyperlinkDefaultKeyModifierModified();
        }
    });
    addFiller(composite, 2);
    Composite editorComposite = new Composite(composite, SWT.NONE);
    GridData gd;
    gd = new GridData(SWT.FILL, SWT.TOP, true, false);
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 20;
    editorComposite.setLayoutData(gd);
    TableColumnLayout tableColumnlayout = new TableColumnLayout();
    editorComposite.setLayout(tableColumnlayout);
    // Hyperlink detector table
    Table hyperlinkDetectorTable = new Table(editorComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
    hyperlinkDetectorTable.setHeaderVisible(true);
    hyperlinkDetectorTable.setLinesVisible(true);
    hyperlinkDetectorTable.setFont(parent.getFont());
    hyperlinkDetectorTable.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleListSelection();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    ColumnLayoutData columnLayoutData = new ColumnWeightData(1);
    TableColumn nameColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 0);
    nameColumn.setText(TextEditorMessages.HyperlinkDetectorTable_nameColumn);
    tableColumnlayout.setColumnData(nameColumn, columnLayoutData);
    TableColumn modifierKeysColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 1);
    modifierKeysColumn.setText(TextEditorMessages.HyperlinkDetectorTable_modifierKeysColumn);
    tableColumnlayout.setColumnData(modifierKeysColumn, columnLayoutData);
    TableColumn targetNameColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 2);
    targetNameColumn.setText(TextEditorMessages.HyperlinkDetectorTable_targetNameColumn);
    tableColumnlayout.setColumnData(targetNameColumn, columnLayoutData);
    fHyperlinkDetectorsViewer = new CheckboxTableViewer(hyperlinkDetectorTable);
    fHyperlinkDetectorsViewer.setUseHashlookup(true);
    fHyperlinkDetectorsViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            String id = ((ListItem) event.getElement()).id;
            if (id == null)
                return;
            fStore.setValue(id, !event.getChecked());
        }
    });
    fHyperlinkDetectorsViewer.setLabelProvider(new ItemLabelProvider());
    fHyperlinkDetectorsViewer.setContentProvider(new ItemContentProvider());
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.heightHint = pixelConverter.convertHeightInCharsToPixels(10);
    fHyperlinkDetectorsViewer.getControl().setLayoutData(gd);
    // addFiller(composite, 2);
    // Text field for modifier string
    label = TextEditorMessages.HyperlinkKeyModifier_label;
    fHyperlinkKeyModifierText = (Text) addTextField(composite, label, null, 15, 20, pixelConverter)[1];
    fHyperlinkKeyModifierText.addKeyListener(new KeyListener() {

        private boolean isModifierCandidate;

        @Override
        public void keyPressed(KeyEvent e) {
            isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {
                // && e.time -time < 1000) {
                String modifierString = fHyperlinkKeyModifierText.getText();
                Point selection = fHyperlinkKeyModifierText.getSelection();
                int i = selection.x - 1;
                while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
                    i--;
                }
                boolean needsPrefixDelimiter = i > -1 && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
                i = selection.y;
                while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) {
                    i++;
                }
                boolean needsPostfixDelimiter = i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
                String insertString;
                if (needsPrefixDelimiter && needsPostfixDelimiter)
                    insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifierAndDelimiter, Action.findModifierString(e.stateMask));
                else if (needsPrefixDelimiter)
                    insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifier, Action.findModifierString(e.stateMask));
                else if (needsPostfixDelimiter)
                    insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertModifierAndDelimiter, Action.findModifierString(e.stateMask));
                else
                    insertString = Action.findModifierString(e.stateMask);
                fHyperlinkKeyModifierText.insert(insertString);
            }
        }
    });
    fHyperlinkKeyModifierText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            handleHyperlinkKeyModifierModified();
        }
    });
    return composite;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Point(org.eclipse.swt.graphics.Point) TableColumn(org.eclipse.swt.widgets.TableColumn) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) PixelConverter(org.eclipse.jface.layout.PixelConverter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) ColumnLayoutData(org.eclipse.jface.viewers.ColumnLayoutData) KeyListener(org.eclipse.swt.events.KeyListener) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 53 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project linuxtools by eclipse.

the class VagrantVMView method createTableViewer.

private void createTableViewer(final Composite container) {
    search = new Text(container, SWT.SEARCH | SWT.ICON_SEARCH);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(search);
    search.addModifyListener(onSearch());
    Composite tableArea = new Composite(container, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).applyTo(tableArea);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableArea);
    final TableColumnLayout tableLayout = new TableColumnLayout();
    tableArea.setLayout(tableLayout);
    this.viewer = new TableViewer(tableArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    this.viewer.setContentProvider(new VagrantVMContentProvider());
    final Table table = viewer.getTable();
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).applyTo(table);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(table);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    // 'Name' column
    // $NON-NLS-1$
    final TableViewerColumn nameColumn = createColumn(DVMessages.getString("NAME"));
    setLayout(nameColumn, tableLayout, 150);
    nameColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IVagrantVM) {
                return ((IVagrantVM) element).name();
            }
            return super.getText(element);
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof IVagrantVM) {
                final IVagrantVM container = (IVagrantVM) element;
                final String state = container.state();
                if (EnumVMStatus.RUNNING.equals(EnumVMStatus.fromStatusMessage(state))) {
                    return SWTImagesFactory.DESC_CONTAINER_STARTED.createImage();
                } else {
                    return SWTImagesFactory.DESC_CONTAINER_STOPPED.createImage();
                }
            }
            return super.getImage(element);
        }
    });
    // 'Provider' column
    // $NON-NLS-1$
    final TableViewerColumn imageColumn = createColumn(DVMessages.getString("PROVIDER"));
    setLayout(imageColumn, tableLayout, 150);
    imageColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IVagrantVM) {
                return ((IVagrantVM) element).provider();
            }
            return super.getText(element);
        }
    });
    // 'State' column
    // $NON-NLS-1$
    final TableViewerColumn creationDateColumn = createColumn(DVMessages.getString("STATE"));
    setLayout(creationDateColumn, tableLayout, 150);
    creationDateColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IVagrantVM) {
                return ((IVagrantVM) element).state();
            }
            return super.getText(element);
        }
    });
    // 'State Description' column
    // $NON-NLS-1$
    final TableViewerColumn commandColumn = createColumn(DVMessages.getString("STATE_DESC"));
    setLayout(commandColumn, tableLayout, 150);
    commandColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IVagrantVM) {
                return ((IVagrantVM) element).state_desc();
            }
            return super.getText(element);
        }
    });
    // comparator
    final VagrantVMComparator comparator = new VagrantVMComparator(this.viewer);
    viewer.setComparator(comparator);
    // apply search filter
    this.viewer.addFilter(getContainersFilter());
    setConnection(VagrantService.getInstance());
    connection.addVMListener(this);
    // get the current selection in the tableviewer
    getSite().setSelectionProvider(viewer);
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) IVagrantVM(org.eclipse.linuxtools.vagrant.core.IVagrantVM) Image(org.eclipse.swt.graphics.Image) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 54 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project linuxtools by eclipse.

the class DockerImagesView method createTableViewer.

private void createTableViewer(final Composite container) {
    search = new Text(container, SWT.SEARCH | SWT.ICON_SEARCH);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(search);
    search.addModifyListener(onSearch());
    Composite tableArea = new Composite(container, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).applyTo(tableArea);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableArea);
    final TableColumnLayout tableLayout = new TableColumnLayout();
    tableArea.setLayout(tableLayout);
    this.viewer = new TableViewer(tableArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    this.viewer.setContentProvider(new DockerImagesContentProvider());
    final Table table = viewer.getTable();
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).applyTo(table);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(table);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    // 'Image' column
    final TableViewerColumn idColumn = createColumn(DVMessages.getString(// $NON-NLS-1$
    "ID"));
    setLayout(idColumn, tableLayout, 150);
    idColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IDockerImage) {
                // for image id, remove any sha256 digest prefix
                // and truncate to max of 12 characters
                String imageId = ((IDockerImage) element).id();
                if (// $NON-NLS-1$
                imageId.startsWith("sha256:"))
                    imageId = imageId.substring(7);
                if (imageId.length() > 12) {
                    return imageId.substring(0, 12);
                }
                return imageId;
            }
            return super.getText(element);
        }
    });
    // 'Repo/Tags' column
    final TableViewerColumn tagsColumn = createColumn(DVMessages.getString(// $NON-NLS-1$
    "TAGS"));
    setLayout(tagsColumn, tableLayout, 150);
    tagsColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IDockerImage) {
                final IDockerImage image = (IDockerImage) element;
                final StringBuilder messageBuilder = new StringBuilder();
                for (Iterator<String> iterator = image.repoTags().iterator(); iterator.hasNext(); ) {
                    final String repoTag = iterator.next();
                    messageBuilder.append(repoTag);
                    if (iterator.hasNext()) {
                        messageBuilder.append('\n');
                    }
                }
                return messageBuilder.toString();
            }
            return super.getText(element);
        }
    });
    // 'Creation Date' column
    final TableViewerColumn creationDateColumn = createColumn(DVMessages.getString(// $NON-NLS-1$
    "CREATED"));
    setLayout(creationDateColumn, tableLayout, 150);
    creationDateColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IDockerImage) {
                return LabelProviderUtils.toCreatedDate(Long.parseLong(((IDockerImage) element).created()));
            }
            return super.getText(element);
        }
    });
    // 'Virtual Size' column
    final TableViewerColumn virtsizeColumn = createColumn(DVMessages.getString(// $NON-NLS-1$
    "VIRTSIZE"));
    setLayout(virtsizeColumn, tableLayout, 150);
    virtsizeColumn.setLabelProvider(new SpecialColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IDockerImage) {
                Long size = ((IDockerImage) element).virtualSize();
                if (size <= 0)
                    // $NON-NLS-1$
                    return "0";
                final String[] units = new String[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                "B", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                "kB", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                "MB", "GB", // $NON-NLS-1$ //$NON-NLS-2$
                "TB" };
                int digitGroups = (int) (Math.log10(size) / Math.log10(1000));
                return new DecimalFormat("#,##0.#").format(// $NON-NLS-1$
                size / Math.pow(1000, digitGroups)) + " " + units[digitGroups];
            }
            return super.getText(element);
        }

        @Override
        public String getCompareText(final Object element) {
            // and not the shortened value with units appended.
            if (element instanceof IDockerImage) {
                return // $NON-NLS-1$
                new DecimalFormat("000000000000000000000000").format((((IDockerImage) element).virtualSize()));
            }
            return super.getText(element);
        }
    });
    // comparator
    final DockerImagesComparator comparator = new DockerImagesComparator(this.viewer);
    comparator.setColumn(creationDateColumn.getColumn());
    // Set column a second time so we reverse the order and default to most
    // currently created containers first
    comparator.setColumn(creationDateColumn.getColumn());
    viewer.setComparator(comparator);
    // apply search filter
    this.viewer.addFilter(getImagesFilter());
    setConnection(CommandUtils.getCurrentConnection(null));
    // get the current selection in the tableviewer
    getSite().setSelectionProvider(viewer);
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) DecimalFormat(java.text.DecimalFormat) Text(org.eclipse.swt.widgets.Text) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) Iterator(java.util.Iterator) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 55 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project yamcs-studio by yamcs.

the class CommandQueueView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    // Build the tables
    FillLayout fl = new FillLayout();
    fl.marginHeight = 0;
    fl.marginWidth = 0;
    parent.setLayout(fl);
    SashForm sash = new SashForm(parent, SWT.VERTICAL);
    Composite tableWrapper = new Composite(sash, SWT.NONE);
    tableWrapper.setLayoutData(new GridData(GridData.FILL_BOTH));
    TableColumnLayout tcl = new TableColumnLayout();
    tableWrapper.setLayout(tcl);
    commandQueuesTableViewer = new CommandQueuesTableViewer(this, tableWrapper, tcl);
    commandQueuesContentProvider = new CommandQueuesTableContentProvider(commandQueuesTableViewer);
    commandQueuesTableViewer.setContentProvider(commandQueuesContentProvider);
    commandQueuesTableViewer.setInput(commandQueuesContentProvider);
    commandQueuesTableViewer.addSelectionChangedListener(evt -> {
        currentQueuesModel.reloadCommandsTable((IStructuredSelection) evt.getSelection());
    });
    if (getViewSite() != null)
        getViewSite().setSelectionProvider(commandQueuesTableViewer);
    Composite tableWrapper2 = new Composite(sash, SWT.NONE);
    tableWrapper2.setLayoutData(new GridData(GridData.FILL_BOTH));
    TableColumnLayout tcl2 = new TableColumnLayout();
    tableWrapper2.setLayout(tcl2);
    commandQueuedTableViewer = new CommandQueuedTableViewer(this, tableWrapper2, tcl2);
    commandQueuedContentProvider = new CommandQueuedTableContentProvider(commandQueuedTableViewer);
    commandQueuedTableViewer.setContentProvider(commandQueuedContentProvider);
    commandQueuedTableViewer.setInput(commandQueuedContentProvider);
    // Set initial state
    refreshState();
    CommandingCatalogue.getInstance().addCommandQueueListener(this);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) Composite(org.eclipse.swt.widgets.Composite) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout)

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