List of usage examples for org.eclipse.jface.viewers TreeViewer TreeViewer
public TreeViewer(Composite parent, int style)
From source file:com.netxforge.netxstudio.screens.f3.Networks.java
License:Open Source License
private void buildUI() { setLayout(new FillLayout(SWT.HORIZONTAL)); // Readonlyness. boolean readonly = ScreenUtil.isReadOnlyOperation(this.getOperation()); int widgetStyle = readonly ? SWT.READ_ONLY : SWT.NONE; frmNetworks = toolkit.createForm(this); frmNetworks.setSeparatorVisible(true); toolkit.paintBordersFor(frmNetworks); frmNetworks.setText(getOperationText() + "Network"); frmNetworks.getBody().setLayout(new FillLayout(SWT.HORIZONTAL)); frmNetworks.addMessageHyperlinkListener(new HyperlinkAdapter()); sashForm = new SashForm(frmNetworks.getBody(), SWT.VERTICAL); sashForm.setOrientation(SWT.HORIZONTAL); toolkit.adapt(sashForm);/*from w ww.j a v a 2 s.c o m*/ toolkit.paintBordersFor(sashForm); Composite composite = toolkit.createComposite(sashForm, SWT.NONE); toolkit.paintBordersFor(composite); composite.setLayout(new GridLayout(3, false)); Label lblFilterLabel = toolkit.createLabel(composite, "Filter:", SWT.NONE); lblFilterLabel.setSize(64, 81); txtFilterText = toolkit.createText(composite, "New Text", SWT.H_SCROLL | SWT.SEARCH | SWT.CANCEL); GridData gd_txtFilterText = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); // gd_txtFilterText.widthHint = 200; txtFilterText.setLayoutData(gd_txtFilterText); txtFilterText.setSize(64, 81); txtFilterText.setText(""); txtFilterText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { ViewerFilter[] filters = networkTreeViewer.getFilters(); for (ViewerFilter viewerFilter : filters) { if (viewerFilter instanceof TreeSearchFilter) { ((TreeSearchFilter) viewerFilter).setSearchText(txtFilterText.getText()); } } networkTreeViewer.refresh(); networkTreeViewer.expandAll(); } }); if (!readonly) { mghprlnkNewImagehyperlink = toolkit.createImageHyperlink(composite, SWT.NONE); mghprlnkNewImagehyperlink.addHyperlinkListener(new IHyperlinkListener() { public void linkActivated(HyperlinkEvent e) { OperatorFilterDialog dialog = new OperatorFilterDialog(Networks.this.getShell(), operatorsResource); int result = dialog.open(); if (result == Window.OK) { Operator operator = (Operator) dialog.getFirstResult(); Network newNetwork = OperatorsFactory.eINSTANCE.createNetwork(); newNetwork.setName("<new network>"); Command add = AddCommand.create(editingService.getEditingDomain(), operator, null, newNetwork); editingService.getEditingDomain().getCommandStack().execute(add); } } public void linkEntered(HyperlinkEvent e) { } public void linkExited(HyperlinkEvent e) { } }); mghprlnkNewImagehyperlink.setImage(ResourceManager .getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/ctool16/Network_E.png")); mghprlnkNewImagehyperlink.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); toolkit.paintBordersFor(mghprlnkNewImagehyperlink); mghprlnkNewImagehyperlink.setText("New"); } networkTreeViewer = new TreeViewer(composite, SWT.BORDER | SWT.VIRTUAL | SWT.MULTI | widgetStyle); // networkTreeViewer.setUseHashlookup(true); // networkTreeViewer.setComparer(new CDOElementComparer()); networkTreeViewer.addFilter(new TreeSearchFilter()); // CB http://work.netxforge.com/issues/290 networkTreeViewer.setComparator(new NetworkViewerComparator()); networkTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ISelection s = event.getSelection(); if (s instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) s; final Object o = ss.getFirstElement(); Networks.this.getDisplay().asyncExec(new Runnable() { public void run() { try { handleDetailsSelection(o); } catch (Exception e) { e.printStackTrace(); } } }); } } }); Tree tree = networkTreeViewer.getTree(); GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 2); gd_tree.widthHint = 396; tree.setLayoutData(gd_tree); tree.setSize(74, 81); toolkit.paintBordersFor(tree); cmpDetails = toolkit.createComposite(sashForm, SWT.NONE); toolkit.paintBordersFor(cmpDetails); cmpDetails.setLayout(new FillLayout()); sashForm.setWeights(new int[] { 3, 7 }); }
From source file:com.netxforge.netxstudio.screens.f3.RoomsTree.java
License:Open Source License
private void buildUI() { // Readonlyness. boolean readonly = ScreenUtil.isReadOnlyOperation(this.getOperation()); setLayout(new FillLayout(SWT.HORIZONTAL)); frmSites = toolkit.createForm(this); frmSites.setSeparatorVisible(true);//ww w . ja va 2s .co m toolkit.paintBordersFor(frmSites); frmSites.setText(this.getOperationText() + "Rooms"); frmSites.getBody().setLayout(new GridLayout(3, false)); Label lblFilterLabel = toolkit.createLabel(frmSites.getBody(), "Filter:", SWT.NONE); lblFilterLabel.setAlignment(SWT.RIGHT); GridData gd_lblFilterLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblFilterLabel.widthHint = 36; lblFilterLabel.setLayoutData(gd_lblFilterLabel); txtFilterText = toolkit.createText(frmSites.getBody(), "New Text", SWT.H_SCROLL | SWT.SEARCH | SWT.CANCEL); txtFilterText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { ViewerFilter[] filters = roomsTreeViewer.getFilters(); for (ViewerFilter viewerFilter : filters) { if (viewerFilter instanceof ISearchFilter) { ((ISearchFilter) viewerFilter).setSearchText(txtFilterText.getText()); } } roomsTreeViewer.refresh(); } }); txtFilterText.setText(""); GridData gd_txtFilterText = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); gd_txtFilterText.widthHint = 200; txtFilterText.setLayoutData(gd_txtFilterText); if (!readonly) { ImageHyperlink mghprlnkNewMetric = toolkit.createImageHyperlink(frmSites.getBody(), SWT.NONE); mghprlnkNewMetric.addHyperlinkListener(new IHyperlinkListener() { public void linkActivated(HyperlinkEvent e) { ISelection sel = getViewer().getSelection(); if (sel instanceof IStructuredSelection) { Object o = ((IStructuredSelection) sel).getFirstElement(); if (o instanceof Site) { NewEditRoom roomScreen = new NewEditRoom(screenService.getScreenContainer(), SWT.NONE); roomScreen.setScreenService(screenService); roomScreen.setOperation(ScreenUtil.OPERATION_NEW); roomScreen.injectData(o, GeoFactory.eINSTANCE.createRoom()); screenService.setActiveScreen(roomScreen); } } } public void linkEntered(HyperlinkEvent e) { } public void linkExited(HyperlinkEvent e) { } }); mghprlnkNewMetric.setImage(ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/ctool16/Room_E.png")); toolkit.paintBordersFor(mghprlnkNewMetric); mghprlnkNewMetric.setText("New"); } roomsTreeViewer = new TreeViewer(frmSites.getBody(), SWT.BORDER | SWT.VIRTUAL); roomsTreeViewer.setUseHashlookup(true); roomsTreeViewer.setComparer(new CDOElementComparer()); Tree tree = roomsTreeViewer.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); toolkit.paintBordersFor(tree); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(roomsTreeViewer, SWT.NONE); TreeColumn trclmnCountry = treeViewerColumn.getColumn(); trclmnCountry.setWidth(100); trclmnCountry.setText("Country"); TreeViewerColumn treeViewerColumn_2 = new TreeViewerColumn(roomsTreeViewer, SWT.NONE); TreeColumn trclmnSite = treeViewerColumn_2.getColumn(); trclmnSite.setWidth(100); trclmnSite.setText("Site"); TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(roomsTreeViewer, SWT.NONE); TreeColumn trclmnName = treeViewerColumn_1.getColumn(); trclmnName.setWidth(129); trclmnName.setText("Name"); roomsTreeViewer.addFilter(new CDOSearchFilter()); }
From source file:com.netxforge.netxstudio.screens.f3.SitesTree.java
License:Open Source License
private void buildUI() { // Readonlyness. boolean readonly = ScreenUtil.isReadOnlyOperation(this.getOperation()); setLayout(new FillLayout(SWT.HORIZONTAL)); frmSites = toolkit.createForm(this); frmSites.setSeparatorVisible(true);//from w w w . ja v a 2 s . c o m toolkit.paintBordersFor(frmSites); frmSites.setText(this.getOperationText() + "Sites"); frmSites.getBody().setLayout(new GridLayout(3, false)); Label lblFilterLabel = toolkit.createLabel(frmSites.getBody(), "Filter:", SWT.NONE); lblFilterLabel.setAlignment(SWT.RIGHT); GridData gd_lblFilterLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblFilterLabel.widthHint = 36; lblFilterLabel.setLayoutData(gd_lblFilterLabel); txtFilterText = toolkit.createText(frmSites.getBody(), "New Text", SWT.H_SCROLL | SWT.SEARCH | SWT.CANCEL); txtFilterText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { sitesTreeViewer.refresh(); ViewerFilter[] filters = sitesTreeViewer.getFilters(); for (ViewerFilter viewerFilter : filters) { if (viewerFilter instanceof ISearchFilter) { ((ISearchFilter) viewerFilter).setSearchText(txtFilterText.getText()); } } } }); txtFilterText.setText(""); GridData gd_txtFilterText = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); gd_txtFilterText.widthHint = 200; txtFilterText.setLayoutData(gd_txtFilterText); if (!readonly) { ImageHyperlink mghprlnkNewMetric = toolkit.createImageHyperlink(frmSites.getBody(), SWT.NONE); mghprlnkNewMetric.addHyperlinkListener(new IHyperlinkListener() { public void linkActivated(HyperlinkEvent e) { if (screenService != null) { ISelection selection = getViewer().getSelection(); if (selection instanceof IStructuredSelection) { Object o = ((IStructuredSelection) selection).getFirstElement(); if (o instanceof Country) { NewEditSite siteScreen = new NewEditSite(screenService.getScreenContainer(), SWT.NONE); siteScreen.setScreenService(screenService); siteScreen.setOperation(ScreenUtil.OPERATION_NEW); siteScreen.injectData(o, GeoFactory.eINSTANCE.createSite()); screenService.setActiveScreen(siteScreen); } } } } public void linkEntered(HyperlinkEvent e) { } public void linkExited(HyperlinkEvent e) { } }); mghprlnkNewMetric.setImage(ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/ctool16/Site_E.png")); toolkit.paintBordersFor(mghprlnkNewMetric); mghprlnkNewMetric.setText("New"); } sitesTreeViewer = new TreeViewer(frmSites.getBody(), SWT.BORDER | SWT.VIRTUAL | SWT.MULTI); sitesTreeViewer.setUseHashlookup(true); sitesTreeViewer.setComparer(new CDOElementComparer()); Tree tree = sitesTreeViewer.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); toolkit.paintBordersFor(tree); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(sitesTreeViewer, SWT.NONE); TreeColumn trclmnCountry = treeViewerColumn.getColumn(); trclmnCountry.setWidth(100); trclmnCountry.setText("Country"); TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(sitesTreeViewer, SWT.NONE); TreeColumn trclmnName = treeViewerColumn_1.getColumn(); trclmnName.setWidth(129); trclmnName.setText("Name"); TreeViewerColumn treeViewerColumn_2 = new TreeViewerColumn(sitesTreeViewer, SWT.NONE); TreeColumn trclmnCity = treeViewerColumn_2.getColumn(); trclmnCity.setWidth(105); trclmnCity.setText("City"); TreeViewerColumn treeViewerColumn_3 = new TreeViewerColumn(sitesTreeViewer, SWT.NONE); TreeColumn trclmnStreet = treeViewerColumn_3.getColumn(); trclmnStreet.setWidth(100); trclmnStreet.setText("Street"); TreeViewerColumn treeViewerColumn_4 = new TreeViewerColumn(sitesTreeViewer, SWT.NONE); TreeColumn trclmnNr = treeViewerColumn_4.getColumn(); trclmnNr.setWidth(100); trclmnNr.setText("Nr"); sitesTreeViewer.addFilter(new CDOSearchFilter()); }
From source file:com.netxforge.netxstudio.screens.f3.Warehouses.java
License:Open Source License
private void buildUI() { setLayout(new FillLayout(SWT.HORIZONTAL)); // Readonlyness. boolean readonly = ScreenUtil.isReadOnlyOperation(this.getOperation()); int widgetStyle = readonly ? SWT.READ_ONLY : SWT.NONE; frmNodeTypes = toolkit.createForm(this); frmNodeTypes.setSeparatorVisible(true); toolkit.paintBordersFor(frmNodeTypes); frmNodeTypes.setText(getOperationText() + "Warehouse"); frmNodeTypes.getBody().setLayout(new FillLayout(SWT.HORIZONTAL)); sashForm = new SashForm(frmNodeTypes.getBody(), SWT.VERTICAL); sashForm.setOrientation(SWT.HORIZONTAL); toolkit.adapt(sashForm);/*from w w w .j a va 2 s . co m*/ toolkit.paintBordersFor(sashForm); Composite composite = toolkit.createComposite(sashForm, SWT.NONE); toolkit.paintBordersFor(composite); composite.setLayout(new GridLayout(3, false)); Label lblFilterLabel = toolkit.createLabel(composite, "Filter:", SWT.NONE); lblFilterLabel.setSize(64, 81); txtFilterText = toolkit.createText(composite, "New Text", SWT.H_SCROLL | SWT.SEARCH | SWT.CANCEL); GridData gd_txtFilterText = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_txtFilterText.widthHint = 200; txtFilterText.setLayoutData(gd_txtFilterText); txtFilterText.setSize(64, 81); txtFilterText.setText(""); txtFilterText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { warehouseTreeViewer.refresh(); ViewerFilter[] filters = warehouseTreeViewer.getFilters(); for (ViewerFilter viewerFilter : filters) { if (viewerFilter instanceof ISearchFilter) { ((ISearchFilter) viewerFilter).setSearchText(txtFilterText.getText()); } } } }); mghprlnkNewImagehyperlink = toolkit.createImageHyperlink(composite, SWT.NONE); mghprlnkNewImagehyperlink.addHyperlinkListener(new IHyperlinkListener() { public void linkActivated(HyperlinkEvent e) { // Create a new top level network, for this operator. Network newNetwork = OperatorsFactory.eINSTANCE.createNetwork(); newNetwork.setName("<new network>"); Command add = AddCommand.create(editingService.getEditingDomain(), operator, null, newNetwork); editingService.getEditingDomain().getCommandStack().execute(add); } public void linkEntered(HyperlinkEvent e) { } public void linkExited(HyperlinkEvent e) { } }); mghprlnkNewImagehyperlink.setImage(ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/ctool16/Network_E.png")); mghprlnkNewImagehyperlink.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); toolkit.paintBordersFor(mghprlnkNewImagehyperlink); mghprlnkNewImagehyperlink.setText("New"); warehouseTreeViewer = new TreeViewer(composite, SWT.BORDER | widgetStyle); warehouseTreeViewer.setUseHashlookup(true); warehouseTreeViewer.setComparer(new CDOElementComparer()); warehouseTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ISelection s = event.getSelection(); if (s instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) s; Object o = ss.getFirstElement(); handleDetailsSelection(o); } } }); Tree tree = warehouseTreeViewer.getTree(); GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 2); gd_tree.widthHint = 396; tree.setLayoutData(gd_tree); tree.setSize(74, 81); toolkit.paintBordersFor(tree); cmpDetails = toolkit.createComposite(sashForm, SWT.NONE); toolkit.paintBordersFor(cmpDetails); cmpDetails.setLayout(new FillLayout()); sashForm.setWeights(new int[] { 1, 1 }); }
From source file:com.netxforge.netxstudio.screens.f3.WarehouseTree.java
License:Open Source License
private void buildUI() { // Readonlyness. boolean readonly = ScreenUtil.isReadOnlyOperation(this.getOperation()); setLayout(new FillLayout(SWT.HORIZONTAL)); frmWarehouseTree = toolkit.createForm(this); frmWarehouseTree.setSeparatorVisible(true); toolkit.paintBordersFor(frmWarehouseTree); frmWarehouseTree.setText(getOperationText() + "Warehouses"); frmWarehouseTree.getBody().setLayout(new GridLayout(4, false)); Label lblFilterLabel = toolkit.createLabel(frmWarehouseTree.getBody(), "Filter:", SWT.NONE); lblFilterLabel.setAlignment(SWT.RIGHT); GridData gd_lblFilterLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblFilterLabel.widthHint = 36;//from w w w .j a va2s . c o m lblFilterLabel.setLayoutData(gd_lblFilterLabel); txtFilterText = toolkit.createText(frmWarehouseTree.getBody(), "New Text", SWT.H_SCROLL | SWT.SEARCH | SWT.CANCEL); txtFilterText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { ViewerFilter[] filters = warehouseTreeViewer.getFilters(); for (ViewerFilter viewerFilter : filters) { if (viewerFilter instanceof ISearchFilter) { ((ISearchFilter) viewerFilter).setSearchText(txtFilterText.getText()); } } warehouseTreeViewer.refresh(); } }); txtFilterText.setText(""); GridData gd_txtFilterText = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); gd_txtFilterText.widthHint = 200; txtFilterText.setLayoutData(gd_txtFilterText); if (!readonly) { ImageHyperlink hypLnkNewWarehouse = toolkit.createImageHyperlink(frmWarehouseTree.getBody(), SWT.NONE); hypLnkNewWarehouse.addHyperlinkListener(new IHyperlinkListener() { public void linkActivated(HyperlinkEvent e) { NewEditWarehouse warehouseScreen = new NewEditWarehouse(screenService.getScreenContainer(), SWT.NONE); warehouseScreen.setOperation(ScreenUtil.OPERATION_NEW); warehouseScreen.setScreenService(screenService); Warehouse newWarehouse = OperatorsFactory.eINSTANCE.createWarehouse(); warehouseScreen.injectData(warehouseResource, newWarehouse); screenService.setActiveScreen(warehouseScreen); } public void linkEntered(HyperlinkEvent e) { } public void linkExited(HyperlinkEvent e) { } }); hypLnkNewWarehouse.setImage(ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/ctool16/Warehouse_E.png")); toolkit.paintBordersFor(hypLnkNewWarehouse); hypLnkNewWarehouse.setText("New"); new Label(frmWarehouseTree.getBody(), SWT.NONE); } warehouseTreeViewer = new TreeViewer(frmWarehouseTree.getBody(), SWT.BORDER | SWT.VIRTUAL); warehouseTreeViewer.setUseHashlookup(true); warehouseTreeViewer.setComparer(new CDOElementComparer()); Tree tree = warehouseTreeViewer.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); toolkit.paintBordersFor(tree); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(warehouseTreeViewer, SWT.NONE); TreeColumn trclmnCountry = treeViewerColumn.getColumn(); trclmnCountry.setWidth(100); trclmnCountry.setText("Warehouse"); TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(warehouseTreeViewer, SWT.NONE); TreeColumn trclmnName = treeViewerColumn_1.getColumn(); trclmnName.setWidth(129); trclmnName.setText("Item name"); warehouseTreeViewer.addFilter(new CDOSearchFilter()); }
From source file:com.netxforge.netxstudio.screens.f4.MappingStatistics.java
License:Open Source License
private void buildUI() { setLayout(new FillLayout(SWT.HORIZONTAL)); frmMappingStatistics = toolkit.createForm(this); frmMappingStatistics.setSeparatorVisible(true); toolkit.paintBordersFor(frmMappingStatistics); frmMappingStatistics.setText("Mapping Statistics: " + metricSource.getName()); frmMappingStatistics.getBody().setLayout(new FormLayout()); cleanStatsAction = new CleanStatsAction("Clean up..."); frmMappingStatistics.getMenuManager().add(cleanStatsAction); SashForm sashForm = new SashForm(frmMappingStatistics.getBody(), SWT.NONE); FormData fd_sashForm = new FormData(); fd_sashForm.bottom = new FormAttachment(100, -12); fd_sashForm.right = new FormAttachment(100, -12); fd_sashForm.top = new FormAttachment(0, 12); fd_sashForm.left = new FormAttachment(0, 12); sashForm.setLayoutData(fd_sashForm); toolkit.adapt(sashForm);//w w w.j a va2s. c om toolkit.paintBordersFor(sashForm); Section sctnStatistics = toolkit.createSection(sashForm, Section.EXPANDED | Section.TITLE_BAR); toolkit.paintBordersFor(sctnStatistics); sctnStatistics.setText("Statistics"); Composite cmpSelector = toolkit.createComposite(sctnStatistics, SWT.NONE); toolkit.paintBordersFor(cmpSelector); sctnStatistics.setClient(cmpSelector); cmpSelector.setLayout(new FillLayout(SWT.HORIZONTAL)); statisticsTreeViewer = new TreeViewer(cmpSelector, SWT.BORDER | SWT.MULTI); statisticsTreeViewer.setUseHashlookup(true); statisticsTreeViewer.setComparer(new CDOElementComparer()); statisticsTree = statisticsTreeViewer.getTree(); toolkit.paintBordersFor(statisticsTree); // statisticsListViewer = new ListViewer(cmpSelector, SWT.BORDER // | SWT.V_SCROLL); // TODO, convert to an action. Menu menu = new Menu(statisticsTreeViewer.getTree()); statisticsTreeViewer.getTree().setMenu(menu); MenuItem mntmMore = new MenuItem(menu, SWT.NONE); mntmMore.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Show the period etc.. ISelection selection = statisticsTreeViewer.getSelection(); if (selection instanceof IStructuredSelection) { Object o = ((IStructuredSelection) selection).getFirstElement(); if (o instanceof MappingStatistic) { // Create a predicate for filtering the values within a // range. MappingStatistic mappingStatistics = (MappingStatistic) o; final int targetIntervalHint = mappingStatistics.getIntervalEstimate(); Resource metricResource = editingService.getData(MetricsPackage.Literals.METRIC); List<NetXResource> resourcesInMetricSource = StudioUtils .resourcesInMetricSource(metricResource.getContents(), metricSource); if (resourcesInMetricSource.isEmpty()) { System.out.println("No resources for this metricsource"); return; } DateTimeRange dtr = mappingStatistics.getPeriodEstimate(); System.out.println("VALUES FOR PERIOD:"); System.out.println("FROM=" + NonModelUtils.dateAndTime(dtr.getBegin())); System.out.println("TO=" + NonModelUtils.dateAndTime(dtr.getEnd())); int valueCount = 0; for (NetXResource res : resourcesInMetricSource) { System.out.println("values for resource: " + res.getShortName() + "on Component" + res.getComponentRef().getName()); List<Value> values = StudioUtils.valuesForIntervalKindAndPeriod(res, targetIntervalHint, null, dtr); if (values.size() > 0) { valueCount += values.size(); System.out.println("number of values " + Iterables.size(values)); for (Value v : values) { System.out.println( NonModelUtils.fromXMLDate(v.getTimeStamp()) + ":" + v.getValue()); } } } System.out.println("total values for this import = " + valueCount); } } } }); mntmMore.setText("Values..."); MenuItem mntmDelete = new MenuItem(menu, SWT.NONE); mntmDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Show the period etc.. ISelection selection = statisticsTreeViewer.getSelection(); if (selection instanceof IStructuredSelection) { Object o = ((IStructuredSelection) selection).getFirstElement(); if (o instanceof MappingStatistic) { MappingStatistic mappingStatistics = (MappingStatistic) o; final int targetIntervalHint = mappingStatistics.getIntervalEstimate(); Resource metricResource = editingService.getData(MetricsPackage.Literals.METRIC); List<NetXResource> resourcesInMetricSource = StudioUtils .resourcesInMetricSource(metricResource.getContents(), metricSource); DateTimeRange dtr = mappingStatistics.getPeriodEstimate(); for (NetXResource res : resourcesInMetricSource) { List<Value> values = StudioUtils.valuesForIntervalKindAndPeriod(res, targetIntervalHint, null, dtr); if (values.size() > 0) { WarningDeleteCommand dc = new WarningDeleteCommand( editingService.getEditingDomain(), values); editingService.getEditingDomain().getCommandStack().execute(dc); } } } } } }); mntmDelete.setText("Purge import..."); Section sctnSummary = toolkit.createSection(sashForm, Section.EXPANDED | Section.TITLE_BAR); toolkit.paintBordersFor(sctnSummary); sctnSummary.setText("Summary"); Composite composite = toolkit.createComposite(sctnSummary, SWT.NONE); toolkit.paintBordersFor(composite); sctnSummary.setClient(composite); composite.setLayout(new GridLayout(2, false)); Label lblStatus = toolkit.createLabel(composite, "Status:", SWT.NONE); lblStatus.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); txtMessage = toolkit.createText(composite, "New Text", SWT.READ_ONLY | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL); txtMessage.setText(""); GridData gd_txtMessage = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1); gd_txtMessage.heightHint = 93; txtMessage.setLayoutData(gd_txtMessage); // RUN PERIOD Label lblStartDatetime = toolkit.createLabel(composite, "Start Date/Time:", SWT.NONE); lblStartDatetime.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtStartDateTime = toolkit.createText(composite, "New Text", SWT.READ_ONLY); txtStartDateTime.setText(""); txtStartDateTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblEndDatetime = toolkit.createLabel(composite, "End Date/Time:", SWT.NONE); lblEndDatetime.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtEndDateTime = toolkit.createText(composite, "New Text", SWT.READ_ONLY); txtEndDateTime.setText(""); txtEndDateTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); // METRIC PERIOD ESTIMATE. Label lblStartMetricDatetime = toolkit.createLabel(composite, "Metrics start:", SWT.NONE); lblStartMetricDatetime.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtMetricStartDateTime = toolkit.createText(composite, "New Text", SWT.READ_ONLY); txtMetricStartDateTime.setText(""); txtMetricStartDateTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblEndMetricDatetime = toolkit.createLabel(composite, "Metrics end:", SWT.NONE); lblEndMetricDatetime.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtMetricEndDateTime = toolkit.createText(composite, "New Text", SWT.READ_ONLY); txtMetricEndDateTime.setText(""); txtMetricEndDateTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); // RECORDS Label lblTotalRecordsProcessed = toolkit.createLabel(composite, "Total rows processed: ", SWT.NONE); lblTotalRecordsProcessed.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtTotalRecords = toolkit.createText(composite, "New Text", SWT.READ_ONLY); txtTotalRecords.setText(""); txtTotalRecords.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblTotalExpectedValues = toolkit.createLabel(composite, "Total values:", SWT.NONE); lblTotalExpectedValues.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtTotalValues = toolkit.createText(composite, "New Text", SWT.READ_ONLY); txtTotalValues.setText(""); txtTotalValues.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtTotalValues.setToolTipText("Total values is the # of metrics * the number of rows"); Label lblTotalFailedValues = toolkit.createLabel(composite, "Total Failed Values", SWT.NONE); lblTotalFailedValues.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtTotalFailedValues = toolkit.createText(composite, "New Text", SWT.READ_ONLY); txtTotalFailedValues.setText(""); txtTotalFailedValues.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); // Composite filler = toolkit.createComposite(composite, SWT.NONE); // GridData gd_filler = new GridData(SWT.LEFT, SWT.CENTER, false, false, // 2, 1); // gd_filler.heightHint = 30; // filler.setLayoutData(gd_filler); // toolkit.paintBordersFor(filler); tblViewerRecords = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); recordsTable = tblViewerRecords.getTable(); recordsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1)); recordsTable.setLinesVisible(true); recordsTable.setHeaderVisible(true); toolkit.paintBordersFor(recordsTable); MappingRecordErrorToolTipSupport.enableFor(tblViewerRecords, ToolTip.NO_RECREATE); TableViewerColumn tableViewerColumn = new TableViewerColumn(tblViewerRecords, SWT.NONE); TableColumn tblclmnNewColumn = tableViewerColumn.getColumn(); tblclmnNewColumn.setWidth(40); tblclmnNewColumn.setText("Count"); TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tblViewerRecords, SWT.NONE); TableColumn tblclmnColumn = tableViewerColumn_1.getColumn(); tblclmnColumn.setWidth(40); tblclmnColumn.setText("Column"); TableViewerColumn tableViewerColumn_2 = new TableViewerColumn(tblViewerRecords, SWT.NONE); TableColumn tblclmnMessage = tableViewerColumn_2.getColumn(); tblclmnMessage.setWidth(400); tblclmnMessage.setText("Message"); sashForm.setWeights(new int[] { 3, 7 }); }
From source file:com.netxforge.netxstudio.screens.f4.Metrics.java
License:Open Source License
private void buildUI() { // Readonlyness. boolean readonly = ScreenUtil.isReadOnlyOperation(this.getOperation()); String actionText = readonly ? "View: " : "Edit: "; setLayout(new FillLayout(SWT.HORIZONTAL)); frmMetrics = toolkit.createForm(this); frmMetrics.setSeparatorVisible(true); toolkit.paintBordersFor(frmMetrics); frmMetrics.setText(actionText + "Metrics"); frmMetrics.getBody().setLayout(new GridLayout(3, false)); Label lblFilterLabel = toolkit.createLabel(frmMetrics.getBody(), "Filter:", SWT.NONE); lblFilterLabel.setAlignment(SWT.RIGHT); GridData gd_lblFilterLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblFilterLabel.widthHint = 36;/*from w ww . j a va 2 s. c om*/ lblFilterLabel.setLayoutData(gd_lblFilterLabel); txtFilterText = toolkit.createText(frmMetrics.getBody(), "New Text", SWT.H_SCROLL | SWT.SEARCH | SWT.CANCEL); txtFilterText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { ViewerFilter[] filters = metricsTreeViewer.getFilters(); for (ViewerFilter viewerFilter : filters) { if (viewerFilter instanceof ISearchFilter) { ((ISearchFilter) viewerFilter).setSearchText(txtFilterText.getText()); } } metricsTreeViewer.refresh(); } }); txtFilterText.setText(""); GridData gd_txtFilterText = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); gd_txtFilterText.widthHint = 200; txtFilterText.setLayoutData(gd_txtFilterText); if (!readonly) { ImageHyperlink mghprlnkNewMetric = toolkit.createImageHyperlink(frmMetrics.getBody(), SWT.NONE); mghprlnkNewMetric.addHyperlinkListener(new IHyperlinkListener() { public void linkActivated(HyperlinkEvent e) { if (screenService != null) { ISelection selection = getViewer().getSelection(); if (selection instanceof IStructuredSelection) { Object subowner = ((IStructuredSelection) selection).getFirstElement(); NewEditMetric metricScreen = new NewEditMetric(screenService.getScreenContainer(), SWT.NONE); metricScreen.setOperation(ScreenUtil.OPERATION_NEW); metricScreen.setScreenService(screenService); Metric metric = MetricsFactory.eINSTANCE.createMetric(); // metricScreen.injectData(metricResource, metric); metricScreen.injectData(metricResource, subowner, metric); screenService.setActiveScreen(metricScreen); } } } public void linkEntered(HyperlinkEvent e) { } public void linkExited(HyperlinkEvent e) { } }); mghprlnkNewMetric.setImage(ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit", "icons/full/ctool16/Metric_E.png")); toolkit.paintBordersFor(mghprlnkNewMetric); mghprlnkNewMetric.setText("New"); } metricsTreeViewer = new TreeViewer(frmMetrics.getBody(), SWT.BORDER | SWT.VIRTUAL | SWT.MULTI | SWT.FULL_SELECTION); metricsTreeViewer.setUseHashlookup(true); metricsTreeViewer.setComparer(new CDOElementComparer()); Tree tree = metricsTreeViewer.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); toolkit.paintBordersFor(tree); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(metricsTreeViewer, SWT.NONE); TreeColumn trclmnName = treeViewerColumn.getColumn(); trclmnName.setWidth(300); trclmnName.setText("Name"); TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(metricsTreeViewer, SWT.NONE); TreeColumn trclmnDescription = treeViewerColumn_1.getColumn(); trclmnDescription.setWidth(270); trclmnDescription.setText("Description"); TreeViewerColumn treeViewerColumn_2 = new TreeViewerColumn(metricsTreeViewer, SWT.NONE); TreeColumn trclmnUnit = treeViewerColumn_2.getColumn(); trclmnUnit.setWidth(84); trclmnUnit.setText("Unit"); metricsTreeViewer.addFilter(new CDOSearchFilter()); }
From source file:com.nokia.carbide.cpp.debug.kernelaware.ui.OverviewTab.java
License:Open Source License
public TreeViewer createControl(TabFolder tabFolder, TabItem tabItem) { final Composite composite = new Composite(tabFolder, SWT.NONE); final GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 0;// w w w .j a v a 2 s . co m gridLayout.marginTop = 5; gridLayout.marginHeight = 0; gridLayout.numColumns = 3; composite.setLayout(gridLayout); tabItem.setControl(composite); final Label filterLabel = new Label(composite, SWT.NONE); final GridData gridData = new GridData(SWT.RIGHT, SWT.CENTER, false, false); gridData.horizontalIndent = 5; filterLabel.setLayoutData(gridData); filterLabel.setText(Messages.getString("SymbianOSView.NameFilterLabel")); //$NON-NLS-1$ filterText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); filterText.setText(Messages.getString("SymbianOSView.NameFilterInitialText")); //$NON-NLS-1$ filterText.setToolTipText(Messages.getString("SymbianOSView.NameFilterToolTip")); //$NON-NLS-1$ final GridData gd_filterText = new GridData(SWT.LEFT, SWT.CENTER, false, false); gd_filterText.widthHint = 200; filterText.setLayoutData(gd_filterText); clearFilterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); clearFilterToolBar.createControl(composite); IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$ public void run() { filterText.setText(""); //$NON-NLS-1$ FilterItems(); } }; clearTextAction.setToolTipText(Messages.getString("SymbianOSView.ClearToolTip")); //$NON-NLS-1$ clearTextAction.setImageDescriptor(SymbianOSView.clearImageDesc); clearTextAction.setDisabledImageDescriptor(SymbianOSView.clearImageDesc); clearFilterToolBar.add(clearTextAction); clearFilterToolBar.update(false); // initially there is no text to clear clearFilterToolBar.getControl().setVisible(false); filterText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { FilterItems(); clearFilterToolBar.getControl().setVisible(filterText.getText().length() > 0); } }); filterText.addFocusListener(new FocusAdapter() { /* * (non-Javadoc) * * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent) */ public void focusGained(FocusEvent e) { /* * Running in an asyncExec because the selectAll() does not * appear to work when using mouse to give focus to text. */ Display display = filterText.getDisplay(); display.asyncExec(new Runnable() { public void run() { if (!filterText.isDisposed()) { filterText.selectAll(); } } }); } }); viewer = new TreeViewer(composite, SWT.BORDER); viewer.setContentProvider(new OverviewDataProvider()); viewer.setLabelProvider(new OSViewLabelProvider(viewer)); viewer.setInput(new Object()); viewer.addFilter(nameFilter); Tree tree = viewer.getTree(); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); viewer.setData("controller", this); //$NON-NLS-1$ return viewer; }
From source file:com.nokia.carbide.cpp.internal.pi.save.SaveSamplesPage.java
License:Open Source License
/** * This method initializes projectComposite * *//*from w w w. j a va 2 s. c o m*/ private void createProjectComposite(Composite container) { GridLayout gridLayout2 = new GridLayout(); gridLayout2.numColumns = 2; Composite projectComposite = new Composite(container, SWT.NONE); projectComposite.setLayout(gridLayout2); projectComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); outputChooserTreeViewer = new TreeViewer(projectComposite, SWT.BORDER); outputChooserTreeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); outputChooserTreeViewer.setContentProvider(new ProjectContentProvider()); outputChooserTreeViewer.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())); outputChooserTreeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); outputChooserTreeViewer.getTree().addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { dialogChanged(); } }); createButtonComposite(projectComposite); }
From source file:com.nokia.carbide.cpp.internal.pi.wizards.ui.NewPIWizardPageOutputTask.java
License:Open Source License
/** * This method initializes projectComposite * *//*w w w. j ava2s. c om*/ private void createProjectComposite() { GridLayout gridLayout2 = new GridLayout(); gridLayout2.numColumns = 2; projectComposite = new Composite(composite, SWT.NONE); projectComposite.setLayout(gridLayout2); projectComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); outputChooserTreeViewer = new TreeViewer(projectComposite, SWT.BORDER); outputChooserTreeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); outputChooserTreeViewer.setContentProvider(new ProjectContentProvider()); outputChooserTreeViewer.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())); outputChooserTreeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); outputChooserTreeViewer.getTree().addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { validatePage(); } }); outputChooserTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent arg0) { TreeSelection selection = (TreeSelection) outputChooserTreeViewer.getSelection(); if (selection != null) { Object selected = selection.getFirstElement(); if (selected != null) { if (selected instanceof IContainer) { NewPIWizardSettings.getInstance().outputContainer = (IContainer) selected; } } } } }); createButtonComposite(); }