Example usage for org.eclipse.jface.viewers TableViewer TableViewer

List of usage examples for org.eclipse.jface.viewers TableViewer TableViewer

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers TableViewer TableViewer.

Prototype

public TableViewer(Composite parent, int style) 

Source Link

Document

Creates a table viewer on a newly-created table control under the given parent.

Usage

From source file:au.gov.ga.earthsci.intent.IntentSelectionDialog.java

License:Apache License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    getShell().setText("Select action");

    viewer = new TableViewer(composite, SWT.BORDER);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    viewer.getTable().setLayoutData(gridData);

    text = new Text(composite, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
    gridData = new GridData(SWT.FILL, SWT.NONE, true, false);
    GC gc = new GC(text);
    try {/*www  .j  a  va2 s .c o  m*/
        gc.setFont(text.getFont());
        FontMetrics fm = gc.getFontMetrics();
        textHeight = 4 * fm.getHeight();
        gridData.heightHint = textHeight;
    } finally {
        gc.dispose();
    }
    text.setLayoutData(gridData);

    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new IntentSelectionDialogTableLabelProvider());
    viewer.getTable().addListener(SWT.MeasureItem, new Listener() {
        @Override
        public void handleEvent(Event event) {
            event.height = ROW_HEIGHT;
        }
    });
    viewer.setInput(filters);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateSelection();
        }
    });
    viewer.getTable().select(0);
    updateSelection();

    return composite;
}

From source file:au.gov.ga.earthsci.retrieve.part.RetrievePart.java

License:Apache License

@Inject
public void init(Composite parent, MPart part) {
    retrievalService.addListener(this);

    viewer = new TableViewer(parent, SWT.V_SCROLL);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setInput(retrievals);//from  w  w w . j  a  v a  2s  .c  o m
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);
    /*viewer.setSorter(new ViewerSorter()
    {
       @Override
       public int category(Object element)
       {
    return ((JobInfo) element).job.getState();
       }
            
       @Override
       public int compare(Viewer viewer, Object e1, Object e2)
       {
    return ((JobInfo) e1).job.getPriority() - ((JobInfo) e2).job.getPriority();
       }
    });
    viewer.addFilter(new ViewerFilter()
    {
       @Override
       public boolean select(Viewer viewer, Object parentElement, Object element)
       {
    return ((JobInfo) element).job.getState() != Job.SLEEPING;
       }
            
    });*/

    createColumns();
}

From source file:br.com.dimag.safetycar.gui.views.AutomovelListView.java

License:Open Source License

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it./*from   w ww . j a  v a  2  s .c om*/
 */
public void createPartControl(Composite parent) {

    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER_SOLID);
    viewer.setColumnProperties(new String[] { "Placa", "Marca" });
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    viewer.setInput(createModel());
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            // TODO Auto-generated method stub
            StructuredSelection sl = (StructuredSelection) event.getSelection();
            closeView();
            openView(AutomovelView.ID);
            AutomovelView view = (AutomovelView) findView(AutomovelView.ID);
            view.loadAutomovel((Automovel) sl.getFirstElement());
        }

    });
}

From source file:br.com.dimag.safetycar.gui.views.ClienteListView.java

License:Open Source License

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.//from   ww  w .j ava  2  s .  c o m
 */
public void createPartControl(Composite parent) {

    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER_SOLID);
    viewer.setColumnProperties(new String[] { "Nome", "Endereo" });
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    viewer.setInput(createModel());
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            // TODO Auto-generated method stub
            StructuredSelection sl = (StructuredSelection) event.getSelection();
            closeView();
            openView(ClienteView.ID);
            ClienteView view = (ClienteView) findView(ClienteView.ID);
            view.loadCliente((Cliente) sl.getFirstElement());
        }

    });
}

From source file:br.com.dimag.safetycar.gui.views.OSListView.java

License:Open Source License

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.//from w  w  w .j a  v  a  2s  .com
 */
public void createPartControl(Composite composite) {

    {

        composite.setSize(484, 418);
        GridLayout mainLayout = new GridLayout();
        mainLayout.numColumns = 1;
        composite.setLayout(mainLayout);
        {
            groupDadosServico = new Group(composite, SWT.NONE);
            GridLayout dadosServicoLayout = new GridLayout();
            dadosServicoLayout.numColumns = 2;

            GridData dadosServicoLData = new GridData();
            dadosServicoLData.verticalAlignment = SWT.FILL;
            dadosServicoLData.horizontalAlignment = SWT.FILL;
            groupDadosServico.setLayoutData(dadosServicoLData);

            groupDadosServico.setLayout(dadosServicoLayout);
            groupDadosServico.setText("Dados da Consulta OS");
            groupDadosServico.setSize(243, 215);

            // PLACA ORDEM SERVIO

            {
                labelPlaca = new Label(groupDadosServico, SWT.NONE);
                labelPlaca.setText("Placa:");
            }
            {
                textPlaca = new Text(groupDadosServico, SWT.NONE);
                GridData descricaoProdutoLData = new GridData();
                descricaoProdutoLData.heightHint = 13;
                descricaoProdutoLData.horizontalAlignment = GridData.FILL;
                descricaoProdutoLData.grabExcessHorizontalSpace = true;
                textPlaca.setLayoutData(descricaoProdutoLData);
            }

            // view BOTO PESQUISAR
            {
                buttonPesquisar = new Button(groupDadosServico, SWT.PUSH | SWT.CENTER);
                GridData buttonConfirmaLData = new GridData();
                buttonConfirmaLData.verticalAlignment = GridData.BEGINNING;
                buttonConfirmaLData.horizontalAlignment = GridData.BEGINNING;
                buttonPesquisar.setLayoutData(buttonConfirmaLData);
                buttonPesquisar.setText("Pesquisar");

                buttonPesquisar.addSelectionListener(new SelectionListener() {

                    @Override
                    public void widgetSelected(SelectionEvent event) {
                        pesquisar();
                    }

                    @Override
                    public void widgetDefaultSelected(SelectionEvent arg0) {
                        // TODO Auto-generated method stub
                    }

                });
            }

            viewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER_SOLID);
            viewer.getTable().setLinesVisible(true);
            viewer.getTable().setHeaderVisible(true);

            viewer.setContentProvider(new ViewContentProvider());
            GridData viewerLData = new GridData();
            viewerLData.grabExcessHorizontalSpace = true;
            viewerLData.grabExcessVerticalSpace = true;
            viewerLData.horizontalAlignment = SWT.FILL;
            viewerLData.verticalAlignment = SWT.FILL;
            viewer.getControl().setLayoutData(viewerLData);
            viewer.setLabelProvider(new ViewLabelProvider());

            for (ColumnProperty columnProperty : ColumnProperty.values()) {
                TableColumn coluna = new TableColumn(viewer.getTable(), SWT.NONE);
                coluna.setText(columnProperty.getName());
                coluna.setWidth(columnProperty.getWidth());
            }

            viewer.addDoubleClickListener(new IDoubleClickListener() {

                @Override
                public void doubleClick(DoubleClickEvent event) {
                    // TODO Auto-generated method stub
                    StructuredSelection sl = (StructuredSelection) event.getSelection();
                    closeView();
                    openView(OSView.ID);
                    OSView view = (OSView) findView(OSView.ID);
                    view.loadOS((OrdemServico) sl.getFirstElement());
                }

            });
            loadData();
        }
    }
}

From source file:br.com.dimag.safetycar.gui.views.OSView.java

License:Open Source License

@Override
public void createPartControl(Composite composite) {

    {//  w  ww .j ava  2  s . com
        composite.setSize(399, 309);
        {
            groupDadosOS = new Group(composite, SWT.NONE);
            GridLayout dadosPessoaisLayout = new GridLayout();
            dadosPessoaisLayout.numColumns = 2;
            groupDadosOS.setLayout(dadosPessoaisLayout);
            groupDadosOS.setText("Dados OS");
            groupDadosOS.setSize(243, 215);
            {
                labelPlacaVeiculo = new Label(groupDadosOS, SWT.NONE);
                GridData labelPlacaVeiculoLData = new GridData();
                labelPlacaVeiculoLData.verticalAlignment = GridData.BEGINNING;
                labelPlacaVeiculoLData.horizontalAlignment = GridData.FILL;
                labelPlacaVeiculo.setLayoutData(labelPlacaVeiculoLData);
                labelPlacaVeiculo.setText("Placa");
            }
            {
                GridData cComboPlacaLData = new GridData();
                cComboPlacaLData.verticalAlignment = GridData.BEGINNING;
                cComboPlacaLData.horizontalAlignment = GridData.FILL;
                cComboPlacaLData.grabExcessHorizontalSpace = true;
                cComboAutomovel = new CCombo(groupDadosOS, SWT.NONE);
                cComboAutomovel.setLayoutData(cComboPlacaLData);
            }
            {
                labelCliente = new Label(groupDadosOS, SWT.NONE);
                labelCliente.setText("Cliente:");
            }
            {
                GridData cComboClienteLData = new GridData();
                cComboClienteLData.verticalAlignment = GridData.BEGINNING;
                cComboClienteLData.horizontalAlignment = GridData.FILL;
                cComboClienteLData.grabExcessHorizontalSpace = true;
                cComboCliente = new CCombo(groupDadosOS, SWT.NONE);
                cComboCliente.setLayoutData(cComboClienteLData);
            }
            {
                labelAtendente = new Label(groupDadosOS, SWT.NONE);
                GridData labelAtendenteLData = new GridData();
                labelAtendenteLData.verticalAlignment = GridData.BEGINNING;
                labelAtendenteLData.horizontalAlignment = GridData.FILL;
                labelAtendente.setLayoutData(labelAtendenteLData);
                labelAtendente.setText("Atendente");
            }
            {
                GridData cComboAtendenteLData = new GridData();
                cComboAtendenteLData.verticalAlignment = GridData.BEGINNING;
                cComboAtendenteLData.horizontalAlignment = GridData.FILL;
                cComboAtendenteLData.grabExcessHorizontalSpace = true;
                cComboAtendente = new CCombo(groupDadosOS, SWT.NONE);
                cComboAtendente.setLayoutData(cComboAtendenteLData);
            }
            {
                labelMecanico = new Label(groupDadosOS, SWT.NONE);
                GridData labelMecanicoLData = new GridData();
                labelMecanicoLData.verticalAlignment = GridData.BEGINNING;
                labelMecanicoLData.horizontalAlignment = GridData.FILL;
                labelMecanico.setLayoutData(labelMecanicoLData);
                labelMecanico.setText("Mecnico");
            }
            {
                GridData cComboMecanicoLData = new GridData();
                cComboMecanicoLData.grabExcessHorizontalSpace = true;
                cComboMecanicoLData.verticalAlignment = GridData.BEGINNING;
                cComboMecanicoLData.horizontalAlignment = GridData.FILL;
                cComboMecanico = new CCombo(groupDadosOS, SWT.NONE);
                cComboMecanico.setLayoutData(cComboMecanicoLData);
            }
            {
                labelDefeitoReclamado = new Label(groupDadosOS, SWT.NONE);
                GridData labelDefeitoReclamadoLData = new GridData();
                labelDefeitoReclamadoLData.horizontalAlignment = GridData.FILL;
                labelDefeitoReclamado.setLayoutData(labelDefeitoReclamadoLData);
                labelDefeitoReclamado.setText("Defeito Reclamado:");
            }
            {
                textDefeitoReclamado = new Text(groupDadosOS, SWT.NONE);
                GridData DefeitoReclamadoLData = new GridData();
                DefeitoReclamadoLData.heightHint = 13;
                DefeitoReclamadoLData.horizontalAlignment = GridData.FILL;
                DefeitoReclamadoLData.grabExcessHorizontalSpace = true;
                textDefeitoReclamado.setLayoutData(DefeitoReclamadoLData);
            }
            {
                labelStatusOrdemServico = new Label(groupDadosOS, SWT.NONE);
                GridData labelStatusOrdemServicoLData = new GridData();
                labelStatusOrdemServicoLData.verticalAlignment = GridData.BEGINNING;
                labelStatusOrdemServicoLData.horizontalAlignment = GridData.FILL;
                labelStatusOrdemServico.setLayoutData(labelStatusOrdemServicoLData);
                labelStatusOrdemServico.setText("Status Ordem Servico");
            }
            {
                GridData cComboStatusOrdemServicoLData = new GridData();
                cComboStatusOrdemServicoLData.grabExcessHorizontalSpace = true;
                cComboStatusOrdemServicoLData.verticalAlignment = GridData.BEGINNING;
                cComboStatusOrdemServicoLData.horizontalAlignment = GridData.FILL;
                cComboStatusOrdemServico = new CCombo(groupDadosOS, SWT.NONE);
                cComboStatusOrdemServico.setLayoutData(cComboStatusOrdemServicoLData);
            }
            {
                groupServiico = new Group(groupDadosOS, SWT.NONE);
                GridLayout group1Layout = new GridLayout();
                groupServiico.setLayout(group1Layout);
                GridData group1LData = new GridData();
                group1LData.verticalAlignment = GridData.FILL;
                group1LData.horizontalAlignment = GridData.FILL;
                group1LData.horizontalSpan = 2;
                group1Layout.numColumns = 2;
                group1LData.grabExcessHorizontalSpace = true;
                group1LData.grabExcessVerticalSpace = true;
                group1LData.widthHint = 314;
                group1LData.heightHint = 64;
                groupServiico.setLayoutData(group1LData);
                groupServiico.setText("Servio:");
                {
                    GridData cComboServicosLData = new GridData();
                    cComboServicosLData.grabExcessHorizontalSpace = true;
                    cComboServicosLData.horizontalAlignment = SWT.FILL;
                    cComboServicos = new CCombo(groupServiico, SWT.NONE);
                    cComboServicos.setLayoutData(cComboServicosLData);
                }
                {
                    buttonAddServico = new Button(groupServiico, SWT.PUSH | SWT.CENTER);
                    buttonAddServico.setText("Adicionar");
                    buttonAddServico.addSelectionListener(new SelectionListener() {

                        @Override
                        public void widgetDefaultSelected(SelectionEvent event) {
                            // TODO Auto-generated method stub
                        }

                        @Override
                        public void widgetSelected(SelectionEvent event) {
                            adicionarServico();

                        }

                    });
                }
                {
                    GridData tableViewerServicoLData = new GridData();
                    tableViewerServicoLData.verticalAlignment = GridData.FILL;
                    tableViewerServicoLData.horizontalAlignment = GridData.FILL;
                    tableViewerServicoLData.horizontalSpan = 2;
                    tableViewerServicoLData.grabExcessHorizontalSpace = true;
                    tableViewerServicoLData.grabExcessVerticalSpace = true;
                    tableViewerServico = new TableViewer(groupServiico, SWT.NONE);
                    tableViewerServico.getControl().setLayoutData(tableViewerServicoLData);
                    tableViewerServico.setContentProvider(new ViewContentProviderServico());
                    tableViewerServico.setLabelProvider(new ViewLabelProviderServico());
                    tableViewerServico.setColumnProperties(new String[] { "Descrio", "Valor" });
                }
            }
            {
                groupProduto = new Group(groupDadosOS, SWT.NONE);
                groupProduto.setText("Produtos:");
                GridLayout groupProdutoLayout = new GridLayout();
                groupProdutoLayout.makeColumnsEqualWidth = false;
                groupProdutoLayout.numColumns = 2;
                GridData groupProdutoLData = new GridData();
                groupProdutoLData.grabExcessHorizontalSpace = true;
                groupProdutoLData.grabExcessVerticalSpace = true;
                groupProdutoLData.horizontalSpan = 2;
                groupProdutoLData.verticalAlignment = SWT.FILL;
                groupProdutoLData.horizontalAlignment = SWT.FILL;
                groupProduto.setLayoutData(groupProdutoLData);
                groupProduto.setLayout(groupProdutoLayout);
                {
                    GridData cComboProdutosLData = new GridData();
                    cComboProdutosLData.grabExcessHorizontalSpace = true;
                    cComboProdutosLData.horizontalAlignment = SWT.FILL;
                    cComboProdutos = new CCombo(groupProduto, SWT.NONE);
                    cComboProdutos.setLayoutData(cComboProdutosLData);
                }
                {
                    buttonAddProduto = new Button(groupProduto, SWT.PUSH | SWT.CENTER);
                    buttonAddProduto.setText("Adicionar");
                    buttonAddProduto.addSelectionListener(new SelectionListener() {

                        @Override
                        public void widgetDefaultSelected(SelectionEvent event) {
                            // TODO Auto-generated method stub
                        }

                        @Override
                        public void widgetSelected(SelectionEvent event) {
                            adicionarProduto();
                        }

                    });
                }
                {
                    GridData tableViewerProdutoLData = new GridData();
                    tableViewerProdutoLData.grabExcessHorizontalSpace = true;
                    tableViewerProdutoLData.grabExcessVerticalSpace = true;
                    tableViewerProdutoLData.horizontalSpan = 2;
                    tableViewerProdutoLData.verticalAlignment = SWT.FILL;
                    tableViewerProdutoLData.horizontalAlignment = SWT.FILL;
                    tableViewerProduto = new TableViewer(groupProduto, SWT.NONE);
                    tableViewerProduto.getControl().setLayoutData(tableViewerProdutoLData);
                    tableViewerProduto.setContentProvider(new ViewContentProviderProduto());
                    tableViewerProduto.setLabelProvider(new ViewLabelProviderProduto());
                    tableViewerProduto.setColumnProperties(new String[] { "Descrio", "Valor" });
                }
            }

            {
                buttonConfirma = new Button(groupDadosOS, SWT.PUSH | SWT.CENTER);
                GridData buttonConfirmaLData = new GridData();
                buttonConfirmaLData.verticalAlignment = GridData.BEGINNING;
                buttonConfirmaLData.horizontalAlignment = GridData.BEGINNING;
                buttonConfirma.setLayoutData(buttonConfirmaLData);
                buttonConfirma.setText("Confirmar");

                buttonConfirma.addSelectionListener(new SelectionListener() {

                    @Override
                    public void widgetSelected(SelectionEvent event) {
                        performFinish();
                    }

                    @Override
                    public void widgetDefaultSelected(SelectionEvent arg0) {
                        // TODO Auto-generated method stub
                    }

                });
            }
            {
                buttonCancelar = new Button(groupDadosOS, SWT.PUSH | SWT.CENTER);
                GridData buttonCancelarLData = new GridData();
                buttonCancelarLData.verticalAlignment = GridData.BEGINNING;
                buttonCancelarLData.horizontalAlignment = GridData.BEGINNING;
                buttonCancelar.setLayoutData(buttonCancelarLData);
                buttonCancelar.setText("Cancelar");

                buttonCancelar.addSelectionListener(new SelectionListener() {

                    @Override
                    public void widgetSelected(SelectionEvent event) {
                        if (isUpdate) {
                            openView(OSListView.ID);
                        }
                        closeView();
                    }

                    @Override
                    public void widgetDefaultSelected(SelectionEvent arg0) {
                        // TODO Auto-generated method stub
                    }

                });
            }
            {
                labelErro = new Label(groupDadosOS, SWT.NONE);
                GridData labelErroLData = new GridData();
                labelErroLData.verticalAlignment = GridData.FILL;
                labelErroLData.horizontalAlignment = GridData.FILL;
                labelErroLData.horizontalSpan = 2;
                labelErroLData.grabExcessHorizontalSpace = true;
                labelErroLData.widthHint = 319;
                labelErroLData.heightHint = 26;
                labelErro.setLayoutData(labelErroLData);
                labelErro.setText("");
            }
        }
    }

}

From source file:br.com.dimag.safetycar.gui.views.ProdutoListView.java

License:Open Source License

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.//from www .  ja va  2  s  . c  om
 */
public void createPartControl(Composite parent) {

    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER_SOLID);
    viewer.setColumnProperties(new String[] { "EAN", "Descrio" });
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    viewer.setInput(createModel());
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            // TODO Auto-generated method stub
            StructuredSelection sl = (StructuredSelection) event.getSelection();
            closeView();
            openView(ProdutoView.ID);
            ProdutoView view = (ProdutoView) findView(ProdutoView.ID);
            view.loadProduto((Produto) sl.getFirstElement());
        }

    });
}

From source file:br.com.dimag.safetycar.gui.views.ServicoListView.java

License:Open Source License

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.//ww  w. j a va2s .  c  om
 */
public void createPartControl(Composite composite) {
    {

        composite.setSize(484, 418);
        GridLayout mainLayout = new GridLayout();
        mainLayout.numColumns = 1;
        composite.setLayout(mainLayout);
        {
            groupDadosServico = new Group(composite, SWT.NONE);
            GridLayout dadosServicoLayout = new GridLayout();
            dadosServicoLayout.numColumns = 2;

            GridData dadosServicoLData = new GridData();
            dadosServicoLData.verticalAlignment = SWT.FILL;
            dadosServicoLData.horizontalAlignment = SWT.FILL;
            groupDadosServico.setLayoutData(dadosServicoLData);

            groupDadosServico.setLayout(dadosServicoLayout);
            groupDadosServico.setText("Dados da Consulta Servio");
            groupDadosServico.setSize(243, 215);

            // DESCRIO SERVIO

            {
                labelDescricao = new Label(groupDadosServico, SWT.NONE);
                labelDescricao.setText("Descrio:");
            }
            {
                textDescricao = new Text(groupDadosServico, SWT.NONE);
                GridData descricaoProdutoLData = new GridData();
                descricaoProdutoLData.heightHint = 13;
                descricaoProdutoLData.horizontalAlignment = GridData.FILL;
                descricaoProdutoLData.grabExcessHorizontalSpace = true;
                textDescricao.setLayoutData(descricaoProdutoLData);
            }

            // view BOTO CONFIRMA
            {
                buttonPesquisar = new Button(groupDadosServico, SWT.PUSH | SWT.CENTER);
                GridData buttonConfirmaLData = new GridData();
                buttonConfirmaLData.verticalAlignment = GridData.BEGINNING;
                buttonConfirmaLData.horizontalAlignment = GridData.BEGINNING;
                buttonPesquisar.setLayoutData(buttonConfirmaLData);
                buttonPesquisar.setText("Pesquisar");

                buttonPesquisar.addSelectionListener(new SelectionListener() {

                    @Override
                    public void widgetSelected(SelectionEvent event) {
                        pesquisar();
                    }

                    @Override
                    public void widgetDefaultSelected(SelectionEvent arg0) {
                        // TODO Auto-generated method stub
                    }

                });
            }

            // PRA BAIXO JA ESTAVA

            viewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER_SOLID);
            viewer.getTable().setLinesVisible(true);
            viewer.getTable().setHeaderVisible(true);

            viewer.setContentProvider(new ViewContentProvider());
            GridData viewerLData = new GridData();
            viewerLData.grabExcessHorizontalSpace = true;
            viewerLData.grabExcessVerticalSpace = true;
            viewerLData.horizontalAlignment = SWT.FILL;
            viewerLData.verticalAlignment = SWT.FILL;
            viewer.getControl().setLayoutData(viewerLData);
            viewer.setLabelProvider(new ViewLabelProvider());

            for (ColumnProperty columnProperty : ColumnProperty.values()) {
                TableColumn coluna = new TableColumn(viewer.getTable(), SWT.NONE);
                coluna.setText(columnProperty.getName());
                coluna.setWidth(columnProperty.getWidth());
            }

            viewer.addDoubleClickListener(new IDoubleClickListener() {

                @Override
                public void doubleClick(DoubleClickEvent event) {
                    // TODO Auto-generated method stub
                    StructuredSelection sl = (StructuredSelection) event.getSelection();
                    closeView();
                    openView(ServicoView.ID);
                    ServicoView view = (ServicoView) findView(ServicoView.ID);
                    view.loadServico((Servico) sl.getFirstElement());
                }

            });
            loadData();
        }
    }
}

From source file:br.com.dimag.safetycar.gui.views.UsuarioListView.java

License:Open Source License

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.//ww  w  .j  a v  a 2  s.  c o m
 */
public void createPartControl(Composite composite) {
    {

        composite.setSize(484, 418);
        GridLayout mainLayout = new GridLayout();
        mainLayout.numColumns = 1;
        composite.setLayout(mainLayout);
        {
            groupDadosUsuario = new Group(composite, SWT.NONE);
            GridLayout dadosUsuarioLayout = new GridLayout();
            dadosUsuarioLayout.numColumns = 1;

            GridData dadosServicoLData = new GridData();
            dadosServicoLData.verticalAlignment = SWT.FILL;
            dadosServicoLData.horizontalAlignment = SWT.FILL;
            groupDadosUsuario.setLayoutData(dadosServicoLData);

            groupDadosUsuario.setLayout(dadosUsuarioLayout);
            groupDadosUsuario.setText("Dados da Consulta Usurios");
            groupDadosUsuario.setSize(243, 215);

            // LOGIN

            {
                labelLogin = new Label(groupDadosUsuario, SWT.NONE);
                labelLogin.setText("Login:");
            }
            {
                textLogin = new Text(groupDadosUsuario, SWT.NONE);
                GridData loginUsuarioLData = new GridData();
                loginUsuarioLData.heightHint = 13;
                loginUsuarioLData.horizontalAlignment = GridData.FILL;
                loginUsuarioLData.grabExcessHorizontalSpace = true;
                textLogin.setLayoutData(loginUsuarioLData);
            }

            // view BOTO CONFIRMA
            {
                buttonPesquisar = new Button(groupDadosUsuario, SWT.PUSH | SWT.CENTER);
                GridData buttonConfirmaLData = new GridData();
                buttonConfirmaLData.verticalAlignment = GridData.BEGINNING;
                buttonConfirmaLData.horizontalAlignment = GridData.BEGINNING;
                buttonPesquisar.setLayoutData(buttonConfirmaLData);
                buttonPesquisar.setText("Pesquisar");

                buttonPesquisar.addSelectionListener(new SelectionListener() {

                    @Override
                    public void widgetSelected(SelectionEvent event) {
                        pesquisar();
                    }

                    @Override
                    public void widgetDefaultSelected(SelectionEvent arg0) {
                        // TODO Auto-generated method stub
                    }

                });
            }

            // PRA BAIXO JA ESTAVA

            viewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER_SOLID);
            viewer.getTable().setLinesVisible(true);
            viewer.getTable().setHeaderVisible(true);

            viewer.setContentProvider(new ViewContentProvider());
            GridData viewerLData = new GridData();
            viewerLData.grabExcessHorizontalSpace = true;
            viewerLData.grabExcessVerticalSpace = true;
            viewerLData.horizontalAlignment = SWT.FILL;
            viewerLData.verticalAlignment = SWT.FILL;
            viewer.getControl().setLayoutData(viewerLData);
            viewer.setLabelProvider(new ViewLabelProvider());

            for (ColumnProperty columnProperty : ColumnProperty.values()) {
                TableColumn coluna = new TableColumn(viewer.getTable(), SWT.NONE);
                coluna.setText(columnProperty.getName());
                coluna.setWidth(columnProperty.getWidth());
            }

            viewer.addDoubleClickListener(new IDoubleClickListener() {

                @Override
                public void doubleClick(DoubleClickEvent event) {
                    // TODO Auto-generated method stub
                    StructuredSelection sl = (StructuredSelection) event.getSelection();
                    closeView();
                    openView(UsuarioView.ID);
                    UsuarioView view = (UsuarioView) findView(UsuarioView.ID);
                    view.loadUsuario((Usuario) sl.getFirstElement());
                }

            });
            loadData();
        }
    }
}

From source file:br.gov.frameworkdemoiselle.tools.nimble.eclipse.views.NimbleView.java

License:Open Source License

/**
 * This is a callback that will allow us
 * to create the viewer and initialize it.
 *///from w  ww  .j  a  v  a 2s.co m
public void createPartControl(Composite parent) {
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    viewer.setSorter(new NameSorter());
    viewer.setInput(getViewSite());

    // Create the help context id for the viewer's control
    PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "demoiselle-nimble-eclipse.viewer");
    makeActions();
    hookContextMenu();
    hookDoubleClickAction();
    contributeToActionBars();
}