Search in sources :

Example 26 with IClientAreaProvider

use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.

the class ColumnGroupsCommandHandlerTest method setUp.

@Before
public void setUp() {
    this.gridLayer = new GridLayerFixture();
    this.selectionLayer = (SelectionLayer) this.gridLayer.getBodyLayer().getViewportLayer().getScrollableLayer();
    this.model = new ColumnGroupModel();
    this.handler = new ColumnGroupsCommandHandler(this.model, this.selectionLayer, new ColumnGroupHeaderLayer(this.gridLayer.getColumnHeaderLayer(), this.gridLayer.getBodyLayer().getSelectionLayer(), new ColumnGroupModel()));
    this.gridLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 1050, 250);
        }
    });
    this.gridLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
}
Also used : ColumnGroupHeaderLayer(org.eclipse.nebula.widgets.nattable.group.ColumnGroupHeaderLayer) Shell(org.eclipse.swt.widgets.Shell) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) GridLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture) ColumnGroupModel(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel) Before(org.junit.Before)

Example 27 with IClientAreaProvider

use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.

the class AutoResizeColumnsTest method setClientAreaProvider.

private void setClientAreaProvider(ILayer layer) {
    layer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 1050, 250);
        }
    });
    layer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 28 with IClientAreaProvider

use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.

the class MultiColumnResizeCommandTest method setClientAreaProvider.

private void setClientAreaProvider(ILayer layer) {
    layer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 1050, 250);
        }
    });
    layer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 29 with IClientAreaProvider

use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.

the class DefaultBodyLayerStackTest method setup.

@Before
public void setup() {
    this.layerStack = new DefaultBodyLayerStack(new DataLayerFixture(10, 5, 100, 20));
    this.layerStack.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 2000, 250);
        }
    });
    this.layerStack.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) Before(org.junit.Before)

Example 30 with IClientAreaProvider

use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.

the class NatExporter method exportLayer.

/**
 * Exports the given {@link ILayer} to the given {@link OutputStream} using
 * the provided {@link ITableExporter}.
 *
 * @param exporter
 *            The {@link ITableExporter} that should be used for exporting.
 * @param outputStream
 *            The {@link OutputStream} that should be used to write the
 *            export to.
 * @param layer
 *            The {@link ILayer} that should be exported.
 * @param configRegistry
 *            The {@link IConfigRegistry} needed to retrieve the export
 *            configurations.
 *
 * @since 1.5
 */
protected void exportLayer(final ITableExporter exporter, final OutputStream outputStream, final ILayer layer, final IConfigRegistry configRegistry) {
    if (this.preRender) {
        AutoResizeHelper.autoResize(layer, configRegistry);
    }
    IClientAreaProvider originalClientAreaProvider = layer.getClientAreaProvider();
    // This needs to be done so that the layer can return all the cells
    // not just the ones visible in the viewport
    layer.doCommand(new TurnViewportOffCommand());
    setClientAreaToMaximum(layer);
    // if a SummaryRowLayer is in the layer stack, we need to ensure that
    // the values are calculated
    layer.doCommand(new CalculateSummaryRowValuesCommand());
    // if a FormulaDataProvider is involved, we need to ensure that the
    // formula evaluation is disabled so the formula itself is exported
    // instead of the calculated value
    layer.doCommand(new DisableFormulaEvaluationCommand());
    ProgressBar progressBar = null;
    if (this.shell != null) {
        Shell childShell = new Shell(this.shell.getDisplay(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
        // $NON-NLS-1$
        childShell.setText(Messages.getString("NatExporter.exporting"));
        int endRow = layer.getRowCount() - 1;
        progressBar = new ProgressBar(childShell, SWT.SMOOTH);
        progressBar.setMinimum(0);
        progressBar.setMaximum(endRow);
        progressBar.setBounds(0, 0, 400, 25);
        progressBar.setFocus();
        childShell.pack();
        childShell.open();
    }
    try {
        exporter.exportTable(this.shell, progressBar, outputStream, layer, configRegistry);
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        // These must be fired at the end of the thread execution
        layer.setClientAreaProvider(originalClientAreaProvider);
        layer.doCommand(new TurnViewportOnCommand());
        layer.doCommand(new EnableFormulaEvaluationCommand());
        if (progressBar != null) {
            Shell childShell = progressBar.getShell();
            progressBar.dispose();
            childShell.dispose();
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CalculateSummaryRowValuesCommand(org.eclipse.nebula.widgets.nattable.summaryrow.command.CalculateSummaryRowValuesCommand) TurnViewportOnCommand(org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOnCommand) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) DisableFormulaEvaluationCommand(org.eclipse.nebula.widgets.nattable.formula.command.DisableFormulaEvaluationCommand) EnableFormulaEvaluationCommand(org.eclipse.nebula.widgets.nattable.formula.command.EnableFormulaEvaluationCommand) TurnViewportOffCommand(org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOffCommand) ProgressBar(org.eclipse.swt.widgets.ProgressBar) IOException(java.io.IOException)

Aggregations

IClientAreaProvider (org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider)31 Rectangle (org.eclipse.swt.graphics.Rectangle)30 Shell (org.eclipse.swt.widgets.Shell)18 ClientAreaResizeCommand (org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand)17 Before (org.junit.Before)17 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)8 Test (org.junit.Test)7 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)5 GridLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture)5 DefaultGridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer)4 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)3 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)3 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)3 TestLayer (org.eclipse.nebula.widgets.nattable.test.fixture.TestLayer)3 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)2 CompositeFreezeLayer (org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer)2 FreezeLayer (org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer)2 RowHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer)2 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)2