Search in sources :

Example 1 with ILabelProviderListener

use of org.eclipse.jface.viewers.ILabelProviderListener in project tdi-studio-se by Talend.

the class StatusConfirmSettingDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    TableViewer viewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.minimumHeight = 200;
    data.heightHint = 200;
    data.minimumWidth = 350;
    data.widthHint = 350;
    viewer.getControl().setLayoutData(data);
    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn column = new TableColumn(table, SWT.NONE);
    //$NON-NLS-1$
    column.setText(Messages.getString("VersionManagementDialog.Items"));
    column.setWidth(140);
    column = new TableColumn(table, SWT.NONE);
    //$NON-NLS-1$
    column.setText(Messages.getString("StatusManagementDialog.Status"));
    column.setWidth(120);
    column = new TableColumn(table, SWT.NONE);
    //$NON-NLS-1$
    column.setText(Messages.getString("StatusManagementDialog.NewStatus"));
    column.setWidth(90);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new ITableLabelProvider() {

        public Image getColumnImage(Object element, int columnIndex) {
            RepositoryObject object = (RepositoryObject) element;
            if (columnIndex == 0) {
                ERepositoryObjectType itemType = object.getRepositoryObjectType();
                return getItemsImage(CoreImageProvider.getIcon(itemType));
            }
            return null;
        }

        public String getColumnText(Object element, int columnIndex) {
            RepositoryObject object = (RepositoryObject) element;
            switch(columnIndex) {
                case 0:
                    return object.getLabel();
                case 1:
                    return statusHelper.getStatusLabel(object.getProperty().getOldStatusCode());
                case 2:
                    if (object.getStatusCode().equals(object.getProperty().getOldStatusCode())) {
                        //$NON-NLS-1$
                        return "-";
                    }
                    return statusHelper.getStatusLabel(object.getStatusCode());
                default:
            }
            return null;
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    viewer.setInput(modifiedVersionItems);
    for (TableItem item : table.getItems()) {
        RepositoryObject object = (RepositoryObject) item.getData();
        // if (!object.getOldVersion().equals(object.getNewVersion())) {
        item.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_RED));
    // }
    }
    return composite;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) RepositoryObject(org.talend.core.model.repository.RepositoryObject) TableItem(org.eclipse.swt.widgets.TableItem) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) TableColumn(org.eclipse.swt.widgets.TableColumn) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 2 with ILabelProviderListener

use of org.eclipse.jface.viewers.ILabelProviderListener in project tdi-studio-se by Talend.

the class ImportDemoProjectItemsPage method initializeViewer.

/**
     * initializeViewer.
     */
private void initializeViewer() {
    wizardSelectionViewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        // TODO Auto-generated method stub
        }

        @Override
        public void dispose() {
        // TODO Auto-generated method stub
        }

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof List) {
                return ((List) inputElement).toArray();
            }
            return null;
        }
    });
    wizardSelectionViewer.setLabelProvider(new ITableLabelProvider() {

        @Override
        public void removeListener(ILabelProviderListener listener) {
        }

        @Override
        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        @Override
        public void dispose() {
        }

        @Override
        public void addListener(ILabelProviderListener listener) {
        }

        @Override
        public String getColumnText(Object element, int columnIndex) {
            if (element instanceof DemoProjectBean) {
                DemoProjectBean field = (DemoProjectBean) element;
                return field.getDemoDesc();
            }
            return "";
        }

        @Override
        public Image getColumnImage(Object element, int columnIndex) {
            if (element instanceof DemoProjectBean) {
                return getFullImagePath((DemoProjectBean) element);
            }
            return null;
        }
    });
    wizardSelectionViewer.setInput(this.demoProjectList);
}
Also used : ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) Viewer(org.eclipse.jface.viewers.Viewer) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) List(java.util.List) ArrayList(java.util.ArrayList) Image(org.eclipse.swt.graphics.Image)

Example 3 with ILabelProviderListener

use of org.eclipse.jface.viewers.ILabelProviderListener in project tdi-studio-se by Talend.

the class VersionSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    composite = getWidgetFactory().createFlatFormComposite(parent);
    tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final String[] columnProperties = new String[] { //$NON-NLS-1$
    Messages.getString("VersionSection.Version"), //$NON-NLS-1$
    Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$ 
    Messages.getString("VersionSection.Status") };
    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column1.setText(columnProperties[0]);
    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column2.setText(columnProperties[1]);
    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column3.setText(columnProperties[2]);
    final TableColumn column4 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
    column4.setText(columnProperties[3]);
    tableViewer.setColumnProperties(columnProperties);
    Object layoutData = parent.getLayoutData();
    if (layoutData instanceof GridData) {
        GridData gridData = (GridData) layoutData;
        gridData.grabExcessVerticalSpace = true;
        gridData.verticalAlignment = SWT.FILL;
    }
    FormData formData = new FormData();
    formData.left = new FormAttachment(0);
    formData.top = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    formData.bottom = new FormAttachment(100);
    table.setLayoutData(formData);
    tableViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
            if (repositoryObject.getProperty() == null) {
                return null;
            }
            RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
            try {
                List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
                Collections.sort(allVersion, new IRepositoryObjectComparator());
                Object[] objects = new Object[allVersion.size()];
                for (int i = 0; i < objects.length; i++) {
                    IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
                    RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
                    objects[i] = repositoryNode;
                }
                return objects;
            } catch (PersistenceException e) {
                return null;
            }
        }

        private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
            ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
            RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
            repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
            repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
            return repositoryNode;
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    tableViewer.setLabelProvider(new ITableLabelProvider() {

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

        public String getColumnText(Object element, int columnIndex) {
            RepositoryNode repositoryNode = (RepositoryNode) element;
            switch(columnIndex) {
                case 0:
                    return repositoryNode.getObject().getVersion();
                case 1:
                    if (repositoryNode.getObject().getCreationDate() != null) {
                        return FORMATTER.format(repositoryNode.getObject().getCreationDate());
                    } else {
                        return null;
                    }
                case 2:
                    if (repositoryNode.getObject().getModificationDate() != null) {
                        return FORMATTER.format(repositoryNode.getObject().getModificationDate());
                    } else {
                        return null;
                    }
                case 3:
                    if (repositoryNode.getObject().getStatusCode() != null) {
                        return repositoryNode.getObject().getStatusCode();
                    } else {
                        return null;
                    }
                default:
                    return null;
            }
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopUp");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager mgr) {
            ISelection selection = tableViewer.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
                for (ITreeContextualAction action : contextualsActions) {
                    if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
                        action.init(null, structuredSelection);
                        if (action.isVisible()) {
                            mgr.add(action);
                        }
                    }
                }
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
    Listener sortListener = new Listener() {

        private int direction = 1;

        public void handleEvent(Event e) {
            final TableColumn column = (TableColumn) e.widget;
            if (column == table.getSortColumn()) {
                direction = -direction;
            }
            if (direction == 1) {
                table.setSortDirection(SWT.DOWN);
            } else {
                table.setSortDirection(SWT.UP);
            }
            table.setSortColumn(column);
            tableViewer.setSorter(new ViewerSorter() {

                int index = 0;

                @Override
                public void sort(Viewer viewer, Object[] elements) {
                    while (index < table.getColumns().length && table.getColumn(index) != column) {
                        index++;
                    }
                    super.sort(viewer, elements);
                }

                @Override
                public int compare(Viewer viewer, Object e1, Object e2) {
                    ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
                    String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
                    "";
                    String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
                    "";
                    return getComparator().compare(columnText, columnText2) * direction;
                }
            });
        }
    };
    column1.addListener(SWT.Selection, sortListener);
    column2.addListener(SWT.Selection, sortListener);
    column3.addListener(SWT.Selection, sortListener);
    column4.addListener(SWT.Selection, sortListener);
    table.setSortColumn(column1);
    table.setSortDirection(SWT.DOWN);
    aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) IMenuListener(org.eclipse.jface.action.IMenuListener) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeContextualAction(org.talend.commons.ui.swt.actions.ITreeContextualAction) Image(org.eclipse.swt.graphics.Image) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ISelection(org.eclipse.jface.viewers.ISelection) List(java.util.List) Menu(org.eclipse.swt.widgets.Menu) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) TableLayout(org.eclipse.jface.viewers.TableLayout) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormData(org.eclipse.swt.layout.FormData) Table(org.eclipse.swt.widgets.Table) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) RepositoryNode(org.talend.repository.model.RepositoryNode) TableColumn(org.eclipse.swt.widgets.TableColumn) IMenuListener(org.eclipse.jface.action.IMenuListener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Event(org.eclipse.swt.widgets.Event) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IMenuManager(org.eclipse.jface.action.IMenuManager) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 4 with ILabelProviderListener

use of org.eclipse.jface.viewers.ILabelProviderListener in project bndtools by bndtools.

the class BndContainerPage method createControl.

/*
     * (non-Javadoc)
     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets .Composite)
     */
@Override
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new FormLayout());
    composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
    composite.setFont(parent.getFont());
    setControl(composite);
    final Button wCreate = new Button(composite, SWT.NONE);
    wCreate.setEnabled(model == null);
    final FormData fd_wCreate = new FormData();
    fd_wCreate.bottom = new FormAttachment(100, -5);
    fd_wCreate.right = new FormAttachment(100, -4);
    wCreate.setLayoutData(fd_wCreate);
    wCreate.setText("Create bnd.bnd");
    final TableViewer tableViewer = new TableViewer(composite, SWT.BORDER);
    table = tableViewer.getTable();
    final FormData fd_table = new FormData();
    fd_table.top = new FormAttachment(0, 3);
    fd_table.left = new FormAttachment(0, 3);
    fd_table.right = new FormAttachment(100, -4);
    fd_table.bottom = new FormAttachment(100, -37);
    table.setLayoutData(fd_table);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    final TableColumn wBsn = new TableColumn(table, SWT.NONE);
    wBsn.setWidth(200);
    wBsn.setText("Bundle Symbolic Name");
    final TableColumn wVersion = new TableColumn(table, SWT.NONE);
    wVersion.setWidth(100);
    wVersion.setText("Version");
    final TableColumn wOptions = new TableColumn(table, SWT.NONE);
    wOptions.setWidth(200);
    wOptions.setText("Options");
    final TableColumn wFile = new TableColumn(table, SWT.NONE);
    wFile.setWidth(100);
    wFile.setText("File");
    tableViewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            if (model != null)
                try {
                    return model.getBuildpath().toArray();
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            return new Object[0];
        }

        @Override
        public void dispose() {
        // TODO Auto-generated method stub
        }

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    tableViewer.setLabelProvider(new ITableLabelProvider() {

        @Override
        public Image getColumnImage(Object element, int columnIndex) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public String getColumnText(Object element, int columnIndex) {
            Container c = (Container) element;
            switch(columnIndex) {
                case 0:
                    return c.getBundleSymbolicName();
                case 1:
                    return c.getVersion();
                case 2:
                    return c.getError();
                case 3:
                    return c.getFile() + " (" + (c.getFile() != null && c.getFile().exists() ? "exists" : "?") + ")";
                default:
                    break;
            }
            return null;
        }

        @Override
        public void addListener(ILabelProviderListener listener) {
        // TODO Auto-generated method stub
        }

        @Override
        public void dispose() {
        // TODO Auto-generated method stub
        }

        @Override
        public boolean isLabelProperty(Object element, String property) {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public void removeListener(ILabelProviderListener listener) {
        // TODO Auto-generated method stub
        }
    });
    tableViewer.setInput(model);
    wCreate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            System.out.println("defw selected");
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            wCreate.setEnabled(!createBnd());
            tableViewer.setInput(model);
        }
    });
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) Image(org.eclipse.swt.graphics.Image) TableColumn(org.eclipse.swt.widgets.TableColumn) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) Container(aQute.bnd.build.Container) Button(org.eclipse.swt.widgets.Button) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 5 with ILabelProviderListener

use of org.eclipse.jface.viewers.ILabelProviderListener in project azure-tools-for-java by Microsoft.

the class ApplicationInsightsPreferencePage method createApplicationInsightsResourceTable.

public void createApplicationInsightsResourceTable(Composite parent) {
    table = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    GridData gridData = new GridData();
    gridData.heightHint = 360;
    gridData.verticalIndent = 15;
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessHorizontalSpace = false;
    table.setLayoutData(gridData);
    TableColumn strNameCol = new TableColumn(table, SWT.FILL);
    strNameCol.setText(Messages.resrcName);
    strNameCol.setWidth(150);
    TableColumn strUrlDisCol = new TableColumn(table, SWT.FILL);
    strUrlDisCol.setText(Messages.instrKey);
    strUrlDisCol.setWidth(190);
    tableViewer = new TableViewer(table);
    tableViewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object obj, Object obj1) {
        }

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(Object obj) {
            return getTableContent();
        }
    });
    tableViewer.setLabelProvider(new ITableLabelProvider() {

        @Override
        public void removeListener(ILabelProviderListener ilabelproviderlistener) {
        }

        @Override
        public boolean isLabelProperty(Object element, String s) {
            return false;
        }

        @Override
        public void dispose() {
        }

        @Override
        public void addListener(ILabelProviderListener ilabelproviderlistener) {
        }

        @Override
        public String getColumnText(Object element, int i) {
            ApplicationInsightsPageTableElement rowElement = (ApplicationInsightsPageTableElement) element;
            String result = "";
            switch(i) {
                case 0:
                    result = rowElement.getResourceName();
                    break;
                case 1:
                    result = rowElement.getInstrumentationKey();
                    break;
                default:
                    break;
            }
            return result;
        }

        @Override
        public Image getColumnImage(Object element, int i) {
            return null;
        }
    });
    tableViewer.setInput(getTableContent());
    Composite containerButtons = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.END;
    gridData.verticalAlignment = GridData.BEGINNING;
    gridData.verticalIndent = 15;
    containerButtons.setLayout(gridLayout);
    containerButtons.setLayoutData(gridData);
    btnNew = new Button(containerButtons, SWT.PUSH);
    btnNew.setText(Messages.btnNewLbl);
    gridData = new GridData();
    gridData.widthHint = 70;
    btnNew.setLayoutData(gridData);
    btnNew.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            newButtonListener();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    btnAdd = new Button(containerButtons, SWT.PUSH);
    btnAdd.setText(Messages.btnAddLbl);
    gridData = new GridData();
    gridData.widthHint = 70;
    btnAdd.setLayoutData(gridData);
    btnAdd.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            addButtonListener();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    btnDetails = new Button(containerButtons, SWT.PUSH);
    btnDetails.setEnabled(false);
    btnDetails.setText(Messages.btnDtlsLbl);
    gridData = new GridData();
    gridData.widthHint = 70;
    btnDetails.setLayoutData(gridData);
    btnDetails.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            detailsButtonListener();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    btnRemove = new Button(containerButtons, SWT.PUSH);
    btnRemove.setEnabled(false);
    btnRemove.setText(Messages.btnRmvLbl);
    gridData = new GridData();
    gridData.widthHint = 70;
    btnRemove.setLayoutData(gridData);
    btnRemove.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            removeButtonListener();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    table.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            selIndex = tableViewer.getTable().getSelectionIndex();
            btnDetails.setEnabled(true);
            btnRemove.setEnabled(true);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent event) {
        }
    });
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent selectionchangedevent) {
            if (selectionchangedevent.getSelection().isEmpty()) {
                btnDetails.setEnabled(false);
                btnRemove.setEnabled(false);
            }
        }
    });
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Image(org.eclipse.swt.graphics.Image) TableColumn(org.eclipse.swt.widgets.TableColumn) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)7 Image (org.eclipse.swt.graphics.Image)7 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)6 GridData (org.eclipse.swt.layout.GridData)6 TableViewer (org.eclipse.jface.viewers.TableViewer)5 Composite (org.eclipse.swt.widgets.Composite)5 TableColumn (org.eclipse.swt.widgets.TableColumn)5 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)4 Viewer (org.eclipse.jface.viewers.Viewer)4 Table (org.eclipse.swt.widgets.Table)4 FormAttachment (org.eclipse.swt.layout.FormAttachment)3 FormData (org.eclipse.swt.layout.FormData)3 List (java.util.List)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 ViewerSorter (org.eclipse.jface.viewers.ViewerSorter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 FormLayout (org.eclipse.swt.layout.FormLayout)2 Button (org.eclipse.swt.widgets.Button)2 TableItem (org.eclipse.swt.widgets.TableItem)2