List of usage examples for org.eclipse.jface.viewers TableViewer TableViewer
public TableViewer(Table table)
From source file:com.amitinside.e4.rcp.todo.parts.FormsUIPart.java
License:Apache License
@PostConstruct public void createControls(Composite parent) { final FormToolkit toolkit = new FormToolkit(parent.getDisplay()); final ScrolledForm form = toolkit.createScrolledForm(parent); form.setText("Eclipse Forms API Example"); final TableWrapLayout layout = new TableWrapLayout(); form.getBody().setLayout(layout);/* www. j av a 2s . c o m*/ toolkit.createLabel(form.getBody(), "Snippet2"); final ExpandableComposite composite = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT); composite.setText("Expand Me"); final String text = "Lots of text, Lots of text,"; final Label label = toolkit.createLabel(composite, text, SWT.WRAP); composite.setClient(label); final TableWrapData td = new TableWrapData(); td.colspan = 1; composite.setLayoutData(td); composite.addExpansionListener(new ExpansionAdapter() { @Override public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); // Creating the Screen final Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR); section.setText("Section 1 for demonstration"); //$NON-NLS-1$ section.setDescription("This demonstrates the usage of section"); // Composite for storing the data final Composite client = toolkit.createComposite(section, SWT.WRAP); GridLayoutUtil.applyGridLayout(client).numColumns(2).marginHeight(2).marginWidth(2); final Table t = toolkit.createTable(client, SWT.NONE); GridDataUtil.applyGridData(t).withFill().heightHint(20).widthHint(100); toolkit.paintBordersFor(client); final Button b = toolkit.createButton(client, "Do something", SWT.PUSH); //$NON-NLS-1$ GridDataUtil.applyGridData(b).verticalAlignment(GridData.VERTICAL_ALIGN_BEGINNING); section.setClient(client); viewer = new TableViewer(t); viewer.setContentProvider(ArrayContentProvider.getInstance()); final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE); viewerColumn.getColumn().setWidth(100); viewerColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return element.toString(); }; }); }
From source file:com.android.ddmuilib.AllocationPanel.java
License:Apache License
/** * Create our control(s).//from w ww.j a va 2 s. co m */ @Override protected Control createControl(Composite parent) { final IPreferenceStore store = DdmUiPreferences.getStore(); Display display = parent.getDisplay(); // get some images mSortUpImg = ImageLoader.getDdmUiLibLoader().loadImage("sort_up.png", display); mSortDownImg = ImageLoader.getDdmUiLibLoader().loadImage("sort_down.png", display); // base composite for selected client with enabled thread update. mAllocationBase = new Composite(parent, SWT.NONE); mAllocationBase.setLayout(new FormLayout()); // table above the sash Composite topParent = new Composite(mAllocationBase, SWT.NONE); topParent.setLayout(new GridLayout(6, false)); mEnableButton = new Button(topParent, SWT.PUSH); mEnableButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Client current = getCurrentClient(); AllocationTrackingStatus status = current.getClientData().getAllocationStatus(); if (status == AllocationTrackingStatus.ON) { current.enableAllocationTracker(false); } else { current.enableAllocationTracker(true); } current.requestAllocationStatus(); } }); mRequestButton = new Button(topParent, SWT.PUSH); mRequestButton.setText("Get Allocations"); mRequestButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getCurrentClient().requestAllocationDetails(); } }); setUpButtons(false /* enabled */, AllocationTrackingStatus.OFF); GridData gridData; Composite spacer = new Composite(topParent, SWT.NONE); spacer.setLayoutData(gridData = new GridData(GridData.FILL_HORIZONTAL)); new Label(topParent, SWT.NONE).setText("Filter:"); final Text filterText = new Text(topParent, SWT.BORDER); filterText.setLayoutData(gridData = new GridData(GridData.FILL_HORIZONTAL)); gridData.widthHint = 200; filterText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { mFilterText = filterText.getText().trim(); mAllocationViewer.refresh(); } }); mTraceFilterCheck = new Button(topParent, SWT.CHECK); mTraceFilterCheck.setText("Inc. trace"); mTraceFilterCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { mAllocationViewer.refresh(); } }); mAllocationTable = new Table(topParent, SWT.MULTI | SWT.FULL_SELECTION); mAllocationTable.setLayoutData(gridData = new GridData(GridData.FILL_BOTH)); gridData.horizontalSpan = 6; mAllocationTable.setHeaderVisible(true); mAllocationTable.setLinesVisible(true); final TableColumn numberCol = TableHelper.createTableColumn(mAllocationTable, "Alloc Order", SWT.RIGHT, "Alloc Order", //$NON-NLS-1$ PREFS_ALLOC_COL_NUMBER, store); numberCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(numberCol, SortMode.NUMBER); } }); final TableColumn sizeCol = TableHelper.createTableColumn(mAllocationTable, "Allocation Size", SWT.RIGHT, "888", //$NON-NLS-1$ PREFS_ALLOC_COL_SIZE, store); sizeCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(sizeCol, SortMode.SIZE); } }); final TableColumn classCol = TableHelper.createTableColumn(mAllocationTable, "Allocated Class", SWT.LEFT, "Allocated Class", //$NON-NLS-1$ PREFS_ALLOC_COL_CLASS, store); classCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(classCol, SortMode.CLASS); } }); final TableColumn threadCol = TableHelper.createTableColumn(mAllocationTable, "Thread Id", SWT.LEFT, "999", //$NON-NLS-2$ PREFS_ALLOC_COL_THREAD, store); threadCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(threadCol, SortMode.THREAD); } }); final TableColumn inClassCol = TableHelper.createTableColumn(mAllocationTable, "Allocated in", SWT.LEFT, "utime", //$NON-NLS-1$ PREFS_ALLOC_COL_TRACE_CLASS, store); inClassCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(inClassCol, SortMode.IN_CLASS); } }); final TableColumn inMethodCol = TableHelper.createTableColumn(mAllocationTable, "Allocated in", SWT.LEFT, "utime", //$NON-NLS-1$ PREFS_ALLOC_COL_TRACE_METHOD, store); inMethodCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(inMethodCol, SortMode.IN_METHOD); } }); // init the default sort colum switch (mSorter.getSortMode()) { case SIZE: mSortColumn = sizeCol; break; case CLASS: mSortColumn = classCol; break; case THREAD: mSortColumn = threadCol; break; case IN_CLASS: mSortColumn = inClassCol; break; case IN_METHOD: mSortColumn = inMethodCol; break; } mSortColumn.setImage(mSorter.isDescending() ? mSortDownImg : mSortUpImg); mAllocationViewer = new TableViewer(mAllocationTable); mAllocationViewer.setContentProvider(new AllocationContentProvider()); mAllocationViewer.setLabelProvider(new AllocationLabelProvider()); mAllocationViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { AllocationInfo selectedAlloc = getAllocationSelection(event.getSelection()); updateAllocationStackTrace(selectedAlloc); } }); // the separating sash final Sash sash = new Sash(mAllocationBase, SWT.HORIZONTAL); Color darkGray = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); sash.setBackground(darkGray); // the UI below the sash mStackTracePanel = new StackTracePanel(); mStackTraceTable = mStackTracePanel.createPanel(mAllocationBase, PREFS_STACK_COLUMN, store); // now setup the sash. // form layout data FormData data = new FormData(); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(sash, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); topParent.setLayoutData(data); final FormData sashData = new FormData(); if (store != null && store.contains(PREFS_ALLOC_SASH)) { sashData.top = new FormAttachment(0, store.getInt(PREFS_ALLOC_SASH)); } else { sashData.top = new FormAttachment(50, 0); // 50% across } sashData.left = new FormAttachment(0, 0); sashData.right = new FormAttachment(100, 0); sash.setLayoutData(sashData); data = new FormData(); data.top = new FormAttachment(sash, 0); data.bottom = new FormAttachment(100, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); mStackTraceTable.setLayoutData(data); // allow resizes, but cap at minPanelWidth sash.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { Rectangle sashRect = sash.getBounds(); Rectangle panelRect = mAllocationBase.getClientArea(); int bottom = panelRect.height - sashRect.height - 100; e.y = Math.max(Math.min(e.y, bottom), 100); if (e.y != sashRect.y) { sashData.top = new FormAttachment(0, e.y); store.setValue(PREFS_ALLOC_SASH, e.y); mAllocationBase.layout(); } } }); return mAllocationBase; }
From source file:com.android.ddmuilib.EmulatorControlPanel.java
License:Apache License
private void createGpxLocationControl(Composite gpxLocationComp) { GridData gd;//from ww w . j a va 2 s. c o m IPreferenceStore store = DdmUiPreferences.getStore(); gpxLocationComp.setLayout(new GridLayout(1, false)); mGpxUploadButton = new Button(gpxLocationComp, SWT.PUSH); mGpxUploadButton.setText("Load GPX..."); // Table for way point mGpxWayPointTable = new Table(gpxLocationComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION); mGpxWayPointTable.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL)); gd.heightHint = 100; mGpxWayPointTable.setHeaderVisible(true); mGpxWayPointTable.setLinesVisible(true); TableHelper.createTableColumn(mGpxWayPointTable, "Name", SWT.LEFT, "Some Name", PREFS_WAYPOINT_COL_NAME, store); TableHelper.createTableColumn(mGpxWayPointTable, "Longitude", SWT.LEFT, "-199.999999", PREFS_WAYPOINT_COL_LONGITUDE, store); TableHelper.createTableColumn(mGpxWayPointTable, "Latitude", SWT.LEFT, "-199.999999", PREFS_WAYPOINT_COL_LATITUDE, store); TableHelper.createTableColumn(mGpxWayPointTable, "Elevation", SWT.LEFT, "99999.9", PREFS_WAYPOINT_COL_ELEVATION, store); TableHelper.createTableColumn(mGpxWayPointTable, "Description", SWT.LEFT, "Some Description", PREFS_WAYPOINT_COL_DESCRIPTION, store); final TableViewer gpxWayPointViewer = new TableViewer(mGpxWayPointTable); gpxWayPointViewer.setContentProvider(new WayPointContentProvider()); gpxWayPointViewer.setLabelProvider(new WayPointLabelProvider()); gpxWayPointViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object selectedObject = structuredSelection.getFirstElement(); if (selectedObject instanceof WayPoint) { WayPoint wayPoint = (WayPoint) selectedObject; if (mEmulatorConsole != null && mPlayingTrack == false) { processCommandResult(mEmulatorConsole.sendLocation(wayPoint.getLongitude(), wayPoint.getLatitude(), wayPoint.getElevation())); } } } } }); // table for tracks. mGpxTrackTable = new Table(gpxLocationComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION); mGpxTrackTable.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL)); gd.heightHint = 100; mGpxTrackTable.setHeaderVisible(true); mGpxTrackTable.setLinesVisible(true); TableHelper.createTableColumn(mGpxTrackTable, "Name", SWT.LEFT, "Some very long name", PREFS_TRACK_COL_NAME, store); TableHelper.createTableColumn(mGpxTrackTable, "Point Count", SWT.RIGHT, "9999", PREFS_TRACK_COL_COUNT, store); TableHelper.createTableColumn(mGpxTrackTable, "First Point Time", SWT.LEFT, "999-99-99T99:99:99Z", PREFS_TRACK_COL_FIRST, store); TableHelper.createTableColumn(mGpxTrackTable, "Last Point Time", SWT.LEFT, "999-99-99T99:99:99Z", PREFS_TRACK_COL_LAST, store); TableHelper.createTableColumn(mGpxTrackTable, "Comment", SWT.LEFT, "-199.999999", PREFS_TRACK_COL_COMMENT, store); final TableViewer gpxTrackViewer = new TableViewer(mGpxTrackTable); gpxTrackViewer.setContentProvider(new TrackContentProvider()); gpxTrackViewer.setLabelProvider(new TrackLabelProvider()); gpxTrackViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object selectedObject = structuredSelection.getFirstElement(); if (selectedObject instanceof Track) { Track track = (Track) selectedObject; if (mEmulatorConsole != null && mPlayingTrack == false) { TrackPoint[] points = track.getPoints(); processCommandResult(mEmulatorConsole.sendLocation(points[0].getLongitude(), points[0].getLatitude(), points[0].getElevation())); } mPlayGpxButton.setEnabled(true); mGpxBackwardButton.setEnabled(true); mGpxForwardButton.setEnabled(true); mGpxSpeedButton.setEnabled(true); return; } } mPlayGpxButton.setEnabled(false); mGpxBackwardButton.setEnabled(false); mGpxForwardButton.setEnabled(false); mGpxSpeedButton.setEnabled(false); } }); mGpxUploadButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(mParent.getShell(), SWT.OPEN); fileDialog.setText("Load GPX File"); fileDialog.setFilterExtensions(new String[] { "*.gpx" }); String fileName = fileDialog.open(); if (fileName != null) { GpxParser parser = new GpxParser(fileName); if (parser.parse()) { gpxWayPointViewer.setInput(parser.getWayPoints()); gpxTrackViewer.setInput(parser.getTracks()); } } } }); mGpxPlayControls = new Composite(gpxLocationComp, SWT.NONE); GridLayout gl; mGpxPlayControls.setLayout(gl = new GridLayout(5, false)); gl.marginHeight = gl.marginWidth = 0; mGpxPlayControls.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mPlayGpxButton = new Button(mGpxPlayControls, SWT.PUSH | SWT.FLAT); mPlayGpxButton.setImage(mPlayImage); mPlayGpxButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (mPlayingTrack == false) { ISelection selection = gpxTrackViewer.getSelection(); if (selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object selectedObject = structuredSelection.getFirstElement(); if (selectedObject instanceof Track) { Track track = (Track) selectedObject; playTrack(track); } } } else { // if we're playing, then we pause mPlayingTrack = false; if (mPlayingThread != null) { mPlayingThread.interrupt(); } } } }); Label separator = new Label(mGpxPlayControls, SWT.SEPARATOR | SWT.VERTICAL); separator.setLayoutData(gd = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); gd.heightHint = 0; ImageLoader loader = ImageLoader.getDdmUiLibLoader(); mGpxBackwardButton = new Button(mGpxPlayControls, SWT.TOGGLE | SWT.FLAT); mGpxBackwardButton.setImage(loader.loadImage("backward.png", mParent.getDisplay())); //$NON-NLS-1$ mGpxBackwardButton.setSelection(false); mGpxBackwardButton.addSelectionListener(mDirectionButtonAdapter); mGpxForwardButton = new Button(mGpxPlayControls, SWT.TOGGLE | SWT.FLAT); mGpxForwardButton.setImage(loader.loadImage("forward.png", mParent.getDisplay())); //$NON-NLS-1$ mGpxForwardButton.setSelection(true); mGpxForwardButton.addSelectionListener(mDirectionButtonAdapter); mGpxSpeedButton = new Button(mGpxPlayControls, SWT.PUSH | SWT.FLAT); mSpeedIndex = 0; mSpeed = PLAY_SPEEDS[mSpeedIndex]; mGpxSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed)); mGpxSpeedButton.addSelectionListener(mSpeedButtonAdapter); mPlayGpxButton.setEnabled(false); mGpxBackwardButton.setEnabled(false); mGpxForwardButton.setEnabled(false); mGpxSpeedButton.setEnabled(false); }
From source file:com.android.ddmuilib.EmulatorControlPanel.java
License:Apache License
private void createKmlLocationControl(Composite kmlLocationComp) { GridData gd;//from w ww .j a v a 2s. co m IPreferenceStore store = DdmUiPreferences.getStore(); kmlLocationComp.setLayout(new GridLayout(1, false)); mKmlUploadButton = new Button(kmlLocationComp, SWT.PUSH); mKmlUploadButton.setText("Load KML..."); // Table for way point mKmlWayPointTable = new Table(kmlLocationComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION); mKmlWayPointTable.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL)); gd.heightHint = 200; mKmlWayPointTable.setHeaderVisible(true); mKmlWayPointTable.setLinesVisible(true); TableHelper.createTableColumn(mKmlWayPointTable, "Name", SWT.LEFT, "Some Name", PREFS_WAYPOINT_COL_NAME, store); TableHelper.createTableColumn(mKmlWayPointTable, "Longitude", SWT.LEFT, "-199.999999", PREFS_WAYPOINT_COL_LONGITUDE, store); TableHelper.createTableColumn(mKmlWayPointTable, "Latitude", SWT.LEFT, "-199.999999", PREFS_WAYPOINT_COL_LATITUDE, store); TableHelper.createTableColumn(mKmlWayPointTable, "Elevation", SWT.LEFT, "99999.9", PREFS_WAYPOINT_COL_ELEVATION, store); TableHelper.createTableColumn(mKmlWayPointTable, "Description", SWT.LEFT, "Some Description", PREFS_WAYPOINT_COL_DESCRIPTION, store); final TableViewer kmlWayPointViewer = new TableViewer(mKmlWayPointTable); kmlWayPointViewer.setContentProvider(new WayPointContentProvider()); kmlWayPointViewer.setLabelProvider(new WayPointLabelProvider()); mKmlUploadButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(mParent.getShell(), SWT.OPEN); fileDialog.setText("Load KML File"); fileDialog.setFilterExtensions(new String[] { "*.kml" }); String fileName = fileDialog.open(); if (fileName != null) { KmlParser parser = new KmlParser(fileName); if (parser.parse()) { kmlWayPointViewer.setInput(parser.getWayPoints()); mPlayKmlButton.setEnabled(true); mKmlBackwardButton.setEnabled(true); mKmlForwardButton.setEnabled(true); mKmlSpeedButton.setEnabled(true); } } } }); kmlWayPointViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object selectedObject = structuredSelection.getFirstElement(); if (selectedObject instanceof WayPoint) { WayPoint wayPoint = (WayPoint) selectedObject; if (mEmulatorConsole != null && mPlayingTrack == false) { processCommandResult(mEmulatorConsole.sendLocation(wayPoint.getLongitude(), wayPoint.getLatitude(), wayPoint.getElevation())); } } } } }); mKmlPlayControls = new Composite(kmlLocationComp, SWT.NONE); GridLayout gl; mKmlPlayControls.setLayout(gl = new GridLayout(5, false)); gl.marginHeight = gl.marginWidth = 0; mKmlPlayControls.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mPlayKmlButton = new Button(mKmlPlayControls, SWT.PUSH | SWT.FLAT); mPlayKmlButton.setImage(mPlayImage); mPlayKmlButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (mPlayingTrack == false) { Object input = kmlWayPointViewer.getInput(); if (input instanceof WayPoint[]) { playKml((WayPoint[]) input); } } else { // if we're playing, then we pause mPlayingTrack = false; if (mPlayingThread != null) { mPlayingThread.interrupt(); } } } }); Label separator = new Label(mKmlPlayControls, SWT.SEPARATOR | SWT.VERTICAL); separator.setLayoutData(gd = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL)); gd.heightHint = 0; ImageLoader loader = ImageLoader.getDdmUiLibLoader(); mKmlBackwardButton = new Button(mKmlPlayControls, SWT.TOGGLE | SWT.FLAT); mKmlBackwardButton.setImage(loader.loadImage("backward.png", mParent.getDisplay())); //$NON-NLS-1$ mKmlBackwardButton.setSelection(false); mKmlBackwardButton.addSelectionListener(mDirectionButtonAdapter); mKmlForwardButton = new Button(mKmlPlayControls, SWT.TOGGLE | SWT.FLAT); mKmlForwardButton.setImage(loader.loadImage("forward.png", mParent.getDisplay())); //$NON-NLS-1$ mKmlForwardButton.setSelection(true); mKmlForwardButton.addSelectionListener(mDirectionButtonAdapter); mKmlSpeedButton = new Button(mKmlPlayControls, SWT.PUSH | SWT.FLAT); mSpeedIndex = 0; mSpeed = PLAY_SPEEDS[mSpeedIndex]; mKmlSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed)); mKmlSpeedButton.addSelectionListener(mSpeedButtonAdapter); mPlayKmlButton.setEnabled(false); mKmlBackwardButton.setEnabled(false); mKmlForwardButton.setEnabled(false); mKmlSpeedButton.setEnabled(false); }
From source file:com.android.ddmuilib.logcat.LogCatPanel.java
License:Apache License
private void createFiltersTable(Composite parent) { final Table table = new Table(parent, SWT.FULL_SELECTION); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2;//w ww . ja va2s . c om table.setLayoutData(gd); mFiltersTableViewer = new TableViewer(table); mFiltersTableViewer.setContentProvider(new LogCatFilterContentProvider()); mFiltersTableViewer.setLabelProvider(new LogCatFilterLabelProvider(mLogCatFilterData)); mFiltersTableViewer.setInput(mLogCatFilters); mFiltersTableViewer.getTable().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { filterSelectionChanged(); } @Override public void widgetDefaultSelected(SelectionEvent arg0) { editSelectedFilter(); } }); }
From source file:com.android.ddmuilib.net.NetworkPanel.java
License:Apache License
/** * Create table showing summary of network activity. *//*from w ww . j av a 2 s . c o m*/ private void createTable() { mTable = new Table(mPanel, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); final FormData data = new FormData(); data.top = new FormAttachment(mChartComposite); data.left = new FormAttachment(mChartComposite, 0, SWT.CENTER); data.bottom = new FormAttachment(100); mTable.setLayoutData(data); mTable.setHeaderVisible(true); mTable.setLinesVisible(true); final IPreferenceStore store = DdmUiPreferences.getStore(); TableHelper.createTableColumn(mTable, "", SWT.CENTER, buildSampleText(2), null, null); TableHelper.createTableColumn(mTable, "Tag", SWT.LEFT, buildSampleText(32), PREFS_NETWORK_COL_TITLE, store); TableHelper.createTableColumn(mTable, "RX bytes", SWT.RIGHT, buildSampleText(12), PREFS_NETWORK_COL_RX_BYTES, store); TableHelper.createTableColumn(mTable, "RX packets", SWT.RIGHT, buildSampleText(12), PREFS_NETWORK_COL_RX_PACKETS, store); TableHelper.createTableColumn(mTable, "TX bytes", SWT.RIGHT, buildSampleText(12), PREFS_NETWORK_COL_TX_BYTES, store); TableHelper.createTableColumn(mTable, "TX packets", SWT.RIGHT, buildSampleText(12), PREFS_NETWORK_COL_TX_PACKETS, store); mTableViewer = new TableViewer(mTable); mTableViewer.setContentProvider(new ContentProvider()); mTableViewer.setLabelProvider(new LabelProvider()); }
From source file:com.android.ddmuilib.StackTracePanel.java
License:Apache License
/** * Creates the controls for the StrackTrace display. * <p/>This method will set the parent {@link Composite} to use a {@link GridLayout} with * 2 columns./*from w ww .j a v a2 s. co m*/ * @param parent the parent composite. * @param prefs_stack_column * @param store */ public Table createPanel(Composite parent, String prefs_stack_column, IPreferenceStore store) { mStackTraceTable = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION); mStackTraceTable.setHeaderVisible(false); mStackTraceTable.setLinesVisible(false); TableHelper.createTableColumn(mStackTraceTable, "Info", SWT.LEFT, "SomeLongClassName.method(android/somepackage/someotherpackage/somefile.java:99999)", //$NON-NLS-1$ prefs_stack_column, store); mStackTraceViewer = new TableViewer(mStackTraceTable); mStackTraceViewer.setContentProvider(new StackTraceContentProvider()); mStackTraceViewer.setLabelProvider(new StackTraceLabelProvider()); mStackTraceViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { if (sSourceRevealer != null && mCurrentClient != null) { // get the selected stack trace element ISelection selection = mStackTraceViewer.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object object = structuredSelection.getFirstElement(); if (object instanceof StackTraceElement) { StackTraceElement traceElement = (StackTraceElement) object; if (traceElement.isNativeMethod() == false) { sSourceRevealer.reveal(mCurrentClient.getClientData().getClientDescription(), traceElement.getClassName(), traceElement.getLineNumber()); } } } } } }); return mStackTraceTable; }
From source file:com.android.ddmuilib.ThreadPanel.java
License:Apache License
/** * Create our control(s).// w ww.jav a2 s . c om */ @Override protected Control createControl(Composite parent) { mDisplay = parent.getDisplay(); final IPreferenceStore store = DdmUiPreferences.getStore(); mBase = new Composite(parent, SWT.NONE); mBase.setLayout(new StackLayout()); // UI for thread not enabled mNotEnabled = new Label(mBase, SWT.CENTER | SWT.WRAP); mNotEnabled.setText("Thread updates not enabled for selected client\n" + "(use toolbar button to enable)"); // UI for not client selected mNotSelected = new Label(mBase, SWT.CENTER | SWT.WRAP); mNotSelected.setText("no client is selected"); // base composite for selected client with enabled thread update. mThreadBase = new Composite(mBase, SWT.NONE); mThreadBase.setLayout(new FormLayout()); // table above the sash mThreadTable = new Table(mThreadBase, SWT.MULTI | SWT.FULL_SELECTION); mThreadTable.setHeaderVisible(true); mThreadTable.setLinesVisible(true); TableHelper.createTableColumn(mThreadTable, "ID", SWT.RIGHT, "888", //$NON-NLS-2$ PREFS_THREAD_COL_ID, store); TableHelper.createTableColumn(mThreadTable, "Tid", SWT.RIGHT, "88888", //$NON-NLS-2$ PREFS_THREAD_COL_TID, store); TableHelper.createTableColumn(mThreadTable, "Status", SWT.LEFT, "timed-wait", //$NON-NLS-2$ PREFS_THREAD_COL_STATUS, store); TableHelper.createTableColumn(mThreadTable, "utime", SWT.RIGHT, "utime", //$NON-NLS-2$ PREFS_THREAD_COL_UTIME, store); TableHelper.createTableColumn(mThreadTable, "stime", SWT.RIGHT, "utime", //$NON-NLS-2$ PREFS_THREAD_COL_STIME, store); TableHelper.createTableColumn(mThreadTable, "Name", SWT.LEFT, "android.class.ReallyLongClassName.MethodName", //$NON-NLS-1$ PREFS_THREAD_COL_NAME, store); mThreadViewer = new TableViewer(mThreadTable); mThreadViewer.setContentProvider(new ThreadContentProvider()); mThreadViewer.setLabelProvider(new ThreadLabelProvider()); mThreadViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { requestThreadStackTrace(getThreadSelection(event.getSelection())); } }); mThreadViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { requestThreadStackTrace(getThreadSelection(event.getSelection())); } }); // the separating sash final Sash sash = new Sash(mThreadBase, SWT.HORIZONTAL); Color darkGray = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); sash.setBackground(darkGray); // the UI below the sash mStackTraceBase = new Composite(mThreadBase, SWT.NONE); mStackTraceBase.setLayout(new GridLayout(2, false)); mRefreshStackTraceButton = new Button(mStackTraceBase, SWT.PUSH); mRefreshStackTraceButton.setText("Refresh"); mRefreshStackTraceButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { requestThreadStackTrace(getThreadSelection(null)); } }); mStackTraceTimeLabel = new Label(mStackTraceBase, SWT.NONE); mStackTraceTimeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mStackTracePanel = new StackTracePanel(); mStackTraceTable = mStackTracePanel.createPanel(mStackTraceBase, PREFS_STACK_COLUMN, store); GridData gd; mStackTraceTable.setLayoutData(gd = new GridData(GridData.FILL_BOTH)); gd.horizontalSpan = 2; // now setup the sash. // form layout data FormData data = new FormData(); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(sash, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); mThreadTable.setLayoutData(data); final FormData sashData = new FormData(); if (store != null && store.contains(PREFS_THREAD_SASH)) { sashData.top = new FormAttachment(0, store.getInt(PREFS_THREAD_SASH)); } else { sashData.top = new FormAttachment(50, 0); // 50% across } sashData.left = new FormAttachment(0, 0); sashData.right = new FormAttachment(100, 0); sash.setLayoutData(sashData); data = new FormData(); data.top = new FormAttachment(sash, 0); data.bottom = new FormAttachment(100, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); mStackTraceBase.setLayoutData(data); // allow resizes, but cap at minPanelWidth sash.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { Rectangle sashRect = sash.getBounds(); Rectangle panelRect = mThreadBase.getClientArea(); int bottom = panelRect.height - sashRect.height - 100; e.y = Math.max(Math.min(e.y, bottom), 100); if (e.y != sashRect.y) { sashData.top = new FormAttachment(0, e.y); store.setValue(PREFS_THREAD_SASH, e.y); mThreadBase.layout(); } } }); ((StackLayout) mBase.getLayout()).topControl = mNotSelected; return mBase; }
From source file:com.android.ide.eclipse.adt.internal.launch.DeviceChooserDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { // set dialog title getShell().setText("Android Device Chooser"); Composite top = new Composite(parent, SWT.NONE); top.setLayout(new GridLayout(1, true)); String msg;//from ww w. jav a 2s . c o m if (mProjectTarget.isPlatform()) { msg = String.format("Select a device with min API level %s.", mMinApiVersion.getApiString()); } else { msg = String.format("Select a device compatible with target %s.", mProjectTarget.getFullName()); } Label label = new Label(top, SWT.NONE); label.setText(msg); mDeviceRadioButton = new Button(top, SWT.RADIO); mDeviceRadioButton.setText("Choose a running Android device"); mDeviceRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean deviceMode = mDeviceRadioButton.getSelection(); mDeviceTable.setEnabled(deviceMode); mPreferredAvdSelector.setEnabled(!deviceMode); if (deviceMode) { handleDeviceSelection(); } else { mResponse.setAvdToLaunch(mPreferredAvdSelector.getSelected()); } enableOkButton(); } }); mDeviceRadioButton.setSelection(true); // offset the selector from the radio button Composite offsetComp = new Composite(top, SWT.NONE); offsetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(1, false); layout.marginRight = layout.marginHeight = 0; layout.marginLeft = 30; offsetComp.setLayout(layout); mDeviceTable = new Table(offsetComp, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER); GridData gd; mDeviceTable.setLayoutData(gd = new GridData(GridData.FILL_BOTH)); gd.heightHint = 100; mDeviceTable.setHeaderVisible(true); mDeviceTable.setLinesVisible(true); TableHelper.createTableColumn(mDeviceTable, "Serial Number", SWT.LEFT, "AAA+AAAAAAAAAAAAAAAAAAA", //$NON-NLS-2$ null /* prefs name */, null /* prefs store */); TableHelper.createTableColumn(mDeviceTable, "AVD Name", SWT.LEFT, "AAAAAAAAAAAAAAAAAAA", //$NON-NLS-2$ null /* prefs name */, null /* prefs store */); TableHelper.createTableColumn(mDeviceTable, "Target", SWT.LEFT, "AAA+Android 9.9.9", //$NON-NLS-2$ null /* prefs name */, null /* prefs store */); TableHelper.createTableColumn(mDeviceTable, "Debug", SWT.LEFT, "Debug", //$NON-NLS-2$ null /* prefs name */, null /* prefs store */); TableHelper.createTableColumn(mDeviceTable, "State", SWT.LEFT, "bootloader", //$NON-NLS-2$ null /* prefs name */, null /* prefs store */); // create the viewer for it mViewer = new TableViewer(mDeviceTable); mViewer.setContentProvider(new ContentProvider()); mViewer.setLabelProvider(new LabelProvider()); mViewer.setInput(AndroidDebugBridge.getBridge()); mDeviceTable.addSelectionListener(new SelectionAdapter() { /** * Handles single-click selection on the device selector. * {@inheritDoc} */ @Override public void widgetSelected(SelectionEvent e) { handleDeviceSelection(); } /** * Handles double-click selection on the device selector. * Note that the single-click handler will probably already have been called. * {@inheritDoc} */ @Override public void widgetDefaultSelected(SelectionEvent e) { handleDeviceSelection(); if (isOkButtonEnabled()) { okPressed(); } } }); Button radio2 = new Button(top, SWT.RADIO); radio2.setText("Launch a new Android Virtual Device"); // offset the selector from the radio button offsetComp = new Composite(top, SWT.NONE); offsetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout = new GridLayout(1, false); layout.marginRight = layout.marginHeight = 0; layout.marginLeft = 30; offsetComp.setLayout(layout); mPreferredAvdSelector = new AvdSelector(offsetComp, mSdk.getSdkOsLocation(), mSdk.getAvdManager(), new NonRunningAvdFilter(), DisplayMode.SIMPLE_SELECTION, new AdtConsoleSdkLog()); mPreferredAvdSelector.setTableHeightHint(100); mPreferredAvdSelector.setEnabled(false); mPreferredAvdSelector.setSelectionListener(new SelectionAdapter() { /** * Handles single-click selection on the AVD selector. * {@inheritDoc} */ @Override public void widgetSelected(SelectionEvent e) { if (mDisableAvdSelectionChange == false) { mResponse.setAvdToLaunch(mPreferredAvdSelector.getSelected()); enableOkButton(); } } /** * Handles double-click selection on the AVD selector. * * Note that the single-click handler will probably already have been called * but the selected item can have changed in between. * * {@inheritDoc} */ @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); if (isOkButtonEnabled()) { okPressed(); } } }); return top; }
From source file:com.android.ide.eclipse.adt.internal.ui.ConfigurationSelector.java
License:Open Source License
/** * Creates the selector.//w w w . j ava2s.c om * <p/> * The {@link SelectorMode} changes the behavior of the selector depending on what is being * edited (a device config, a resource config, a given configuration). * * @param parent the composite parent. * @param mode the mode for the selector. */ public ConfigurationSelector(Composite parent, SelectorMode mode) { super(parent, SWT.NONE); mMode = mode; mBaseConfiguration.createDefault(); GridLayout gl = new GridLayout(4, false); gl.marginWidth = gl.marginHeight = 0; setLayout(gl); // first column is the first table final Table fullTable = new Table(this, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER); fullTable.setLayoutData(new GridData(GridData.FILL_BOTH)); fullTable.setHeaderVisible(true); fullTable.setLinesVisible(true); // create the column final TableColumn fullTableColumn = new TableColumn(fullTable, SWT.LEFT); // set the header fullTableColumn.setText("Available Qualifiers"); fullTable.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle r = fullTable.getClientArea(); fullTableColumn.setWidth(r.width); } }); mFullTableViewer = new TableViewer(fullTable); mFullTableViewer.setContentProvider(new QualifierContentProvider()); // the label provider must return the value of the label only if the mode is // CONFIG_ONLY mFullTableViewer.setLabelProvider(new QualifierLabelProvider(mMode == SelectorMode.CONFIG_ONLY)); mFullTableViewer.setInput(mBaseConfiguration); mFullTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structSelection = (IStructuredSelection) selection; Object first = structSelection.getFirstElement(); if (first instanceof ResourceQualifier) { mAddButton.setEnabled(true); return; } } mAddButton.setEnabled(false); } }); // 2nd column is the left/right arrow button Composite buttonComposite = new Composite(this, SWT.NONE); gl = new GridLayout(1, false); gl.marginWidth = gl.marginHeight = 0; buttonComposite.setLayout(gl); buttonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL)); new Composite(buttonComposite, SWT.NONE); mAddButton = new Button(buttonComposite, SWT.BORDER | SWT.PUSH); mAddButton.setText("->"); mAddButton.setEnabled(false); mAddButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) mFullTableViewer.getSelection(); Object first = selection.getFirstElement(); if (first instanceof ResourceQualifier) { ResourceQualifier qualifier = (ResourceQualifier) first; mBaseConfiguration.removeQualifier(qualifier); mSelectedConfiguration.addQualifier(qualifier); mFullTableViewer.refresh(); mSelectionTableViewer.refresh(); mSelectionTableViewer.setSelection(new StructuredSelection(qualifier), true); onChange(false /* keepSelection */); } } }); mRemoveButton = new Button(buttonComposite, SWT.BORDER | SWT.PUSH); mRemoveButton.setText("<-"); mRemoveButton.setEnabled(false); mRemoveButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) mSelectionTableViewer.getSelection(); Object first = selection.getFirstElement(); if (first instanceof ResourceQualifier) { ResourceQualifier qualifier = (ResourceQualifier) first; mSelectedConfiguration.removeQualifier(qualifier); mBaseConfiguration.addQualifier(qualifier); mFullTableViewer.refresh(); mSelectionTableViewer.refresh(); onChange(false /* keepSelection */); } } }); // 3rd column is the selected config table final Table selectionTable = new Table(this, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER); selectionTable.setLayoutData(new GridData(GridData.FILL_BOTH)); selectionTable.setHeaderVisible(true); selectionTable.setLinesVisible(true); // create the column final TableColumn selectionTableColumn = new TableColumn(selectionTable, SWT.LEFT); // set the header selectionTableColumn.setText("Chosen Qualifiers"); selectionTable.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle r = selectionTable.getClientArea(); selectionTableColumn.setWidth(r.width); } }); mSelectionTableViewer = new TableViewer(selectionTable); mSelectionTableViewer.setContentProvider(new QualifierContentProvider()); // always show the qualifier value in this case. mSelectionTableViewer.setLabelProvider(new QualifierLabelProvider(true /* showQualifierValue */)); mSelectionTableViewer.setInput(mSelectedConfiguration); mSelectionTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { // ignore selection changes during resfreshes in some cases. if (mOnRefresh) { return; } ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structSelection = (IStructuredSelection) selection; if (structSelection.isEmpty() == false) { Object first = structSelection.getFirstElement(); if (first instanceof ResourceQualifier) { mRemoveButton.setEnabled(true); if (mMode != SelectorMode.CONFIG_ONLY) { QualifierEditBase composite = mUiMap.get(first.getClass()); if (composite != null) { composite.setQualifier((ResourceQualifier) first); } mStackLayout.topControl = composite; mQualifierEditParent.layout(); } return; } } else { if (mMode != SelectorMode.CONFIG_ONLY) { mStackLayout.topControl = null; mQualifierEditParent.layout(); } } } mRemoveButton.setEnabled(false); } }); if (mMode != SelectorMode.CONFIG_ONLY) { // 4th column is the detail of the selected qualifier mQualifierEditParent = new Composite(this, SWT.NONE); mQualifierEditParent.setLayout(mStackLayout = new StackLayout()); mQualifierEditParent.setLayoutData(new GridData(GridData.FILL_VERTICAL)); // create the UI for all the qualifiers, and associate them to the // ResourceQualifer class. mUiMap.put(CountryCodeQualifier.class, new MCCEdit(mQualifierEditParent)); mUiMap.put(NetworkCodeQualifier.class, new MNCEdit(mQualifierEditParent)); mUiMap.put(LocaleQualifier.class, new LocaleEdit(mQualifierEditParent)); mUiMap.put(LayoutDirectionQualifier.class, new LayoutDirectionEdit(mQualifierEditParent)); mUiMap.put(SmallestScreenWidthQualifier.class, new SmallestScreenWidthEdit(mQualifierEditParent)); mUiMap.put(ScreenWidthQualifier.class, new ScreenWidthEdit(mQualifierEditParent)); mUiMap.put(ScreenHeightQualifier.class, new ScreenHeightEdit(mQualifierEditParent)); mUiMap.put(ScreenSizeQualifier.class, new ScreenSizeEdit(mQualifierEditParent)); mUiMap.put(ScreenRatioQualifier.class, new ScreenRatioEdit(mQualifierEditParent)); mUiMap.put(ScreenOrientationQualifier.class, new OrientationEdit(mQualifierEditParent)); mUiMap.put(UiModeQualifier.class, new UiModeEdit(mQualifierEditParent)); mUiMap.put(NightModeQualifier.class, new NightModeEdit(mQualifierEditParent)); mUiMap.put(DensityQualifier.class, new DensityEdit(mQualifierEditParent)); mUiMap.put(TouchScreenQualifier.class, new TouchEdit(mQualifierEditParent)); mUiMap.put(KeyboardStateQualifier.class, new KeyboardEdit(mQualifierEditParent)); mUiMap.put(TextInputMethodQualifier.class, new TextInputEdit(mQualifierEditParent)); mUiMap.put(NavigationStateQualifier.class, new NavigationStateEdit(mQualifierEditParent)); mUiMap.put(NavigationMethodQualifier.class, new NavigationEdit(mQualifierEditParent)); mUiMap.put(ScreenDimensionQualifier.class, new ScreenDimensionEdit(mQualifierEditParent)); mUiMap.put(VersionQualifier.class, new VersionEdit(mQualifierEditParent)); } }