Search in sources :

Example 51 with TableViewerColumn

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

the class ImportBndWorkspaceWizardPageOne method createControl.

@Override
public void createControl(final Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    Label lblFolder = new Label(container, SWT.NONE);
    lblFolder.setText("Root Directory:");
    txtFolder = new Text(container, SWT.BORDER | SWT.SINGLE);
    txtFolder.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent event) {
            getWizard().getContainer().updateButtons();
        }
    });
    //Adding the decorator
    txtFolderErrorDecorator = new ControlDecoration(txtFolder, SWT.TOP | SWT.RIGHT);
    FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
    Image img = fieldDecoration.getImage();
    txtFolderErrorDecorator.setImage(img);
    txtFolderErrorDecorator.setDescriptionText("Selected folder must contain valid Bnd Workspace configuration project.");
    // hiding it initially
    txtFolderErrorDecorator.hide();
    Button btnOpenDialog = new Button(container, SWT.PUSH);
    btnOpenDialog.setText("Browse...");
    btnOpenDialog.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dirDialog = new DirectoryDialog(container.getShell());
            dirDialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
            dirDialog.setText("Select the folder containing the project.");
            txtFolder.setText(dirDialog.open());
            getWizard().getContainer().updateButtons();
        }
    });
    Label lblProjects = new Label(container, SWT.NONE);
    lblProjects.setText("Projects:");
    tableViewer = new TableViewer(container, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    tableViewer.setContentProvider(ArrayContentProvider.getInstance());
    tableViewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            // configuration project always first
            if (e1 instanceof File && e2 instanceof Project) {
                return -1;
            } else if (e1 instanceof Project && e2 instanceof File) {
                return 1;
            }
            Project p1 = (Project) e1;
            Project p2 = (Project) e2;
            return super.compare(viewer, p1.getName(), p2.getName());
        }
    });
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            // Disable selection since the tableviewer should be readonly, but not disabled
            if (!event.getSelection().isEmpty()) {
                tableViewer.setSelection(StructuredSelection.EMPTY);
            }
        }
    });
    TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE);
    column.setLabelProvider(new ProjectsColumnLabelProvider());
    Button refreshButton = new Button(container, SWT.PUSH);
    refreshButton.setText("Refresh");
    refreshButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            getWizard().getContainer().updateButtons();
        }
    });
    deleteButton = new Button(container, SWT.CHECK);
    deleteButton.setText("Delete existing settings");
    inferExecutionEnvironmentButton = new Button(container, SWT.CHECK);
    inferExecutionEnvironmentButton.setSelection(true);
    inferExecutionEnvironmentButton.setText("Infer execution-environment (J2SE and JavaSE).");
    inferExecutionEnvironmentButton.setToolTipText("Uses the 'javac.target' from the Bnd Workspace to infer a Execution Environment to the JRE container. If nothing matches, the default JRE will be used.\nExisting containers will be removed.");
    FormLayout layout = new FormLayout();
    container.setLayout(layout);
    FormData fd_lblFolder = new FormData();
    fd_lblFolder.top = new FormAttachment(0, 10);
    fd_lblFolder.left = new FormAttachment(0, 10);
    lblFolder.setLayoutData(fd_lblFolder);
    FormData fd_txtFolder = new FormData();
    fd_txtFolder.top = new FormAttachment(lblFolder, 0, SWT.CENTER);
    fd_txtFolder.left = new FormAttachment(lblFolder, 10);
    fd_txtFolder.right = new FormAttachment(100, -100);
    txtFolder.setLayoutData(fd_txtFolder);
    FormData fd_btnDialog = new FormData();
    fd_btnDialog.top = new FormAttachment(lblFolder, 0, SWT.CENTER);
    fd_btnDialog.left = new FormAttachment(txtFolder, 10);
    fd_btnDialog.right = new FormAttachment(100, -10);
    btnOpenDialog.setLayoutData(fd_btnDialog);
    FormData fd_lblProjects = new FormData();
    fd_lblProjects.top = new FormAttachment(lblFolder, 20);
    fd_lblProjects.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
    lblProjects.setLayoutData(fd_lblProjects);
    FormData fd_table = new FormData();
    fd_table.top = new FormAttachment(lblProjects, 5);
    fd_table.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
    fd_table.right = new FormAttachment(100, -100);
    fd_table.bottom = new FormAttachment(100, -55);
    tableViewer.getTable().setLayoutData(fd_table);
    FormData fd_btnRefresh = new FormData();
    fd_btnRefresh.top = new FormAttachment(tableViewer.getTable(), 0, SWT.TOP);
    fd_btnRefresh.left = new FormAttachment(btnOpenDialog, 0, SWT.LEFT);
    fd_btnRefresh.right = new FormAttachment(100, -10);
    refreshButton.setLayoutData(fd_btnRefresh);
    FormData fd_btnDelete = new FormData();
    fd_btnDelete.top = new FormAttachment(tableViewer.getTable(), 10);
    fd_btnDelete.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
    deleteButton.setLayoutData(fd_btnDelete);
    FormData fd_btnInfer = new FormData();
    fd_btnInfer.top = new FormAttachment(deleteButton, 10);
    fd_btnInfer.left = new FormAttachment(lblFolder, 0, SWT.LEFT);
    inferExecutionEnvironmentButton.setLayoutData(fd_btnInfer);
    getShell().setMinimumSize(470, 450);
    // required to avoid an error in the system
    setControl(parent);
    setPageComplete(false);
    txtFolder.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Image(org.eclipse.swt.graphics.Image) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) FormAttachment(org.eclipse.swt.layout.FormAttachment) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) IProject(org.eclipse.core.resources.IProject) Project(aQute.bnd.build.Project) TableViewer(org.eclipse.jface.viewers.TableViewer) File(java.io.File)

Example 52 with TableViewerColumn

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

the class ProjectListControl method createTableLayout.

private void createTableLayout(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    // Add TableColumnLayout
    TableColumnLayout layout = new TableColumnLayout();
    composite.setLayout(layout);
    // Instantiate TableViewer
    projects = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    projects.setHeaderVisible(true);
    projects.setLinesVisible(true);
    projects.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            selectionListener.widgetSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            selectionListener.widgetDefaultSelected(e);
        }
    });
    tableViewer = new CheckboxTableViewer(projects);
    tableViewer.setUseHashlookup(true);
    // Project
    TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
    TableColumn tableCol = tableViewerColumn.getColumn();
    layout.setColumnData(tableCol, new ColumnWeightData(60, 100, true));
    tableCol.setText(Messages.project1);
    // Repository
    tableViewerColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
    tableCol = tableViewerColumn.getColumn();
    layout.setColumnData(tableCol, new ColumnWeightData(26, 80, true));
    tableCol.setText(Messages.repository);
    tableViewerColumn.setEditingSupport(new InlineComboEditingSupport(tableViewer));
    // Bundles
    tableViewerColumn = new TableViewerColumn(tableViewer, SWT.CENTER);
    tableCol = tableViewerColumn.getColumn();
    layout.setColumnData(tableCol, new ColumnWeightData(14, 35, true));
    tableCol.setText(Messages.bundles);
    contentProvider = new ContentProvider();
    tableViewer.setContentProvider(contentProvider);
    tableViewer.setLabelProvider(new TableLabelProvider());
    tableViewer.setColumnProperties(columnNames);
    tableViewer.setCheckStateProvider(new ICheckStateProvider() {

        public boolean isGrayed(Object element) {
            return false;
        }

        public boolean isChecked(Object element) {
            ProjectDiff diff = (ProjectDiff) element;
            return diff.isRelease();
        }
    });
    projects.pack();
    TableSortingEnabler.applyTableColumnSorting(tableViewer);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) ProjectDiff(bndtools.release.ProjectDiff) Composite(org.eclipse.swt.widgets.Composite) ICheckStateProvider(org.eclipse.jface.viewers.ICheckStateProvider) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IColumnContentProvider(bndtools.release.ui.TableSortingEnabler.IColumnContentProvider) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 53 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project uiautomatorviewer by yangzaiCN.

the class UiAutomatorViewer method createContents.

/**
 * Create contents of the application window.
 *
 * @param parent
 */
@Override
protected Control createContents(Composite parent) {
    UiAutomatorModel.createInstance(this);
    Composite basePane = new Composite(parent, SWT.NONE);
    basePane.setLayout(new GridLayout(2, false));
    mScreenshotCanvas = new Canvas(basePane, SWT.NONE);
    mScreenshotCanvas.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            UiAutomatorModel.getModel().toggleExploreMode();
        }
    });
    mScreenshotCanvas.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK));
    mScreenshotCanvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
    mScreenshotCanvas.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            if (mCachedScaleImage != null) {
                // shifting the image here, so that there's a border around screen shot
                // this makes highlighting red rectangles on the screen shot edges more visible
                e.gc.drawImage(mCachedScaleImage, IMG_BORDER, IMG_BORDER);
                Rectangle rect = UiAutomatorModel.getModel().getCurrentDrawingRect();
                if (rect != null) {
                    e.gc.setForeground(e.gc.getDevice().getSystemColor(SWT.COLOR_RED));
                    if (UiAutomatorModel.getModel().isExploreMode()) {
                        // when we highlight nodes dynamically on mouse move,
                        // use dashed borders
                        e.gc.setLineStyle(SWT.LINE_DASH);
                        e.gc.setLineWidth(1);
                    } else {
                        // when highlighting nodes on tree node selection,
                        // use solid borders
                        e.gc.setLineStyle(SWT.LINE_SOLID);
                        e.gc.setLineWidth(2);
                    }
                    e.gc.drawRectangle(IMG_BORDER + getScaledSize(rect.x), IMG_BORDER + getScaledSize(rect.y), getScaledSize(rect.width), getScaledSize(rect.height));
                }
            }
        }
    });
    mScreenshotCanvas.addMouseMoveListener(new MouseMoveListener() {

        @Override
        public void mouseMove(MouseEvent e) {
            if (UiAutomatorModel.getModel().isExploreMode()) {
                UiAutomatorModel.getModel().updateSelectionForCoordinates(getInverseScaledSize(e.x - IMG_BORDER), getInverseScaledSize(e.y - IMG_BORDER));
            }
        }
    });
    mScreenshotCanvas.setBackgroundImage(ImageHelper.loadImageDescriptorFromResource("images/logo.png").createImage());
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    toolBarManager.add(mOpenFilesAction);
    toolBarManager.add(mExpandAllAction);
    toolBarManager.add(mScreenshotAction);
    toolBarManager.createControl(basePane);
    mTreeViewer = new TreeViewer(basePane, SWT.BORDER);
    Tree tree = mTreeViewer.getTree();
    GridData gd_Tree = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
    gd_Tree.widthHint = 350;
    tree.setLayoutData(gd_Tree);
    mTreeViewer.setContentProvider(new BasicTreeNodeContentProvider());
    // default LabelProvider uses toString() to generate text to display
    mTreeViewer.setLabelProvider(new LabelProvider());
    mTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            if (event.getSelection().isEmpty()) {
                UiAutomatorModel.getModel().setSelectedNode(null);
            } else if (event.getSelection() instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
                Object o = selection.toArray()[0];
                if (o instanceof BasicTreeNode) {
                    UiAutomatorModel.getModel().setSelectedNode((BasicTreeNode) o);
                }
            }
        }
    });
    // move focus so that it's not on tool bar (looks weird)
    tree.setFocus();
    Group grpNodeDetail = new Group(basePane, SWT.NONE);
    grpNodeDetail.setLayout(new FillLayout(SWT.HORIZONTAL));
    GridData gd_grpNodeDetail = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_grpNodeDetail.heightHint = FIXED_DETAIL_VIEW_HEIGHT;
    gd_grpNodeDetail.minimumHeight = FIXED_DETAIL_VIEW_HEIGHT;
    gd_grpNodeDetail.widthHint = FIXED_RHS_WIDTH;
    gd_grpNodeDetail.minimumWidth = FIXED_RHS_WIDTH;
    grpNodeDetail.setLayoutData(gd_grpNodeDetail);
    grpNodeDetail.setText("Node Detail");
    Composite tableContainer = new Composite(grpNodeDetail, SWT.NONE);
    tableContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    TableColumnLayout columnLayout = new TableColumnLayout();
    tableContainer.setLayout(columnLayout);
    mTableViewer = new TableViewer(tableContainer, SWT.BORDER | SWT.FULL_SELECTION);
    Table table = mTableViewer.getTable();
    table.setLinesVisible(true);
    // use ArrayContentProvider here, it assumes the input to the TableViewer
    // is an array, where each element represents a row in the table
    mTableViewer.setContentProvider(new ArrayContentProvider());
    TableViewerColumn tableViewerColumnKey = new TableViewerColumn(mTableViewer, SWT.NONE);
    TableColumn tblclmnKey = tableViewerColumnKey.getColumn();
    tableViewerColumnKey.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof AttributePair) {
                // first column, shows the attribute name
                return ((AttributePair) element).key;
            }
            return super.getText(element);
        }
    });
    columnLayout.setColumnData(tblclmnKey, new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
    TableViewerColumn tableViewerColumnValue = new TableViewerColumn(mTableViewer, SWT.NONE);
    tableViewerColumnValue.setEditingSupport(new AttributeTableEditingSupport(mTableViewer));
    TableColumn tblclmnValue = tableViewerColumnValue.getColumn();
    columnLayout.setColumnData(tblclmnValue, new ColumnWeightData(2, ColumnWeightData.MINIMUM_WIDTH, true));
    tableViewerColumnValue.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof AttributePair) {
                // second column, shows the attribute value
                return ((AttributePair) element).value;
            }
            return super.getText(element);
        }
    });
    return basePane;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Group(org.eclipse.swt.widgets.Group) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Rectangle(org.eclipse.swt.graphics.Rectangle) AttributePair(com.android.uiautomator.tree.AttributePair) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ToolBarManager(org.eclipse.jface.action.ToolBarManager) BasicTreeNode(com.android.uiautomator.tree.BasicTreeNode) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) BasicTreeNodeContentProvider(com.android.uiautomator.tree.BasicTreeNodeContentProvider) Tree(org.eclipse.swt.widgets.Tree) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) MouseAdapter(org.eclipse.swt.events.MouseAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 54 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project linuxtools by eclipse.

the class RunImageLabelsTab method addTableViewerColumn.

private TableViewerColumn addTableViewerColumn(final TableViewer tableViewer, final String title, final int width) {
    final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    final TableColumn column = viewerColumn.getColumn();
    if (title != null) {
        column.setText(title);
    }
    column.setWidth(width);
    return viewerColumn;
}
Also used : TableColumn(org.eclipse.swt.widgets.TableColumn) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 55 with TableViewerColumn

use of org.eclipse.jface.viewers.TableViewerColumn in project linuxtools by eclipse.

the class RunImageLinksTab method createTableViewerColumn.

private TableViewerColumn createTableViewerColumn(final TableViewer tableViewer, final String title, final int width) {
    final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    final TableColumn column = viewerColumn.getColumn();
    if (title != null) {
        column.setText(title);
    }
    column.setWidth(width);
    return viewerColumn;
}
Also used : TableColumn(org.eclipse.swt.widgets.TableColumn) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)134 TableViewer (org.eclipse.jface.viewers.TableViewer)72 Composite (org.eclipse.swt.widgets.Composite)53 GridData (org.eclipse.swt.layout.GridData)52 SelectionEvent (org.eclipse.swt.events.SelectionEvent)45 TableColumn (org.eclipse.swt.widgets.TableColumn)41 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)36 GridLayout (org.eclipse.swt.layout.GridLayout)32 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)28 Table (org.eclipse.swt.widgets.Table)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)16 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)16 Point (org.eclipse.swt.graphics.Point)15 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)14 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)14 FillLayout (org.eclipse.swt.layout.FillLayout)14 Button (org.eclipse.swt.widgets.Button)14 Image (org.eclipse.swt.graphics.Image)13 Text (org.eclipse.swt.widgets.Text)11