List of usage examples for org.eclipse.jface.viewers TreeViewer TreeViewer
public TreeViewer(Composite parent, int style)
From source file:com.hangum.tadpole.mongodb.core.dialogs.collection.index.NewIndexDialog.java
License:Open Source License
/** * Create contents of the dialog./* w w w.j ava2s .c o m*/ * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout gridLayout = (GridLayout) container.getLayout(); gridLayout.verticalSpacing = 4; gridLayout.horizontalSpacing = 4; gridLayout.marginHeight = 4; gridLayout.marginWidth = 4; gridLayout.numColumns = 2; Label lblName = new Label(container, SWT.NONE); lblName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblName.setText("Collection Name"); comboColName = new Combo(container, SWT.READ_ONLY); comboColName.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { selectCollection(); } }); comboColName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblIndexName = new Label(container, SWT.NONE); lblIndexName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblIndexName.setText("Index Name"); textIndexName = new Text(container, SWT.BORDER); textIndexName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); tabFolder = new CTabFolder(container, SWT.NONE); tabFolder.setBorderVisible(false); tabFolder.setSelectionBackground(TadpoleWidgetUtils.getTabFolderBackgroundColor(), TadpoleWidgetUtils.getTabFolderPercents()); tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); CTabItem tbtmUi = new CTabItem(tabFolder, SWT.NONE); tbtmUi.setText("UI"); Composite compositeUI = new Composite(tabFolder, SWT.NONE); tbtmUi.setControl(compositeUI); compositeUI.setLayout(new GridLayout(1, false)); treeColumnViewer = new TreeViewer(compositeUI, SWT.NONE | SWT.FULL_SELECTION); Tree tree = treeColumnViewer.getTree(); tree.setHeaderVisible(true); tree.setLinesVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); createTableMongoColumne(); treeColumnViewer.setContentProvider(new MongoDBCollectionFieldsContentProvider()); treeColumnViewer.setLabelProvider(new MongoDBCollectionFieldsLabelProvider()); btnUnique = new Button(compositeUI, SWT.CHECK); btnUnique.setText("Unique"); initUI(); comboColName.setFocus(); return container; }
From source file:com.hangum.tadpole.mongodb.core.dialogs.resultview.FindOneDetailComposite.java
License:Open Source License
/** * Create the composite./*from www. jav a 2 s .c o m*/ * * @param parent * @param collectionName * @param dbResultObject */ public FindOneDetailComposite(Composite parent, String collectionName, DBObject dbResultObject, boolean isTypeShowing) { super(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(1, false); gridLayout.verticalSpacing = 1; gridLayout.horizontalSpacing = 1; gridLayout.marginHeight = 1; gridLayout.marginWidth = 1; setLayout(gridLayout); this.collectionName = collectionName; this.dbResultObject = dbResultObject; this.isTypeShowing = isTypeShowing; treeViewerMongo = new TreeViewer(this, SWT.BORDER | SWT.VIRTUAL | SWT.FULL_SELECTION); Tree tree = treeViewerMongo.getTree(); tree.setHeaderVisible(true); tree.setLinesVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Button btnViewSource = new Button(this, SWT.NONE); btnViewSource.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnViewSource.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { showViewSource(); } }); btnViewSource.setText("View Source"); createTreeColumn(); treeViewerMongo.setContentProvider(new TreeMongoContentProvider()); treeViewerMongo.setLabelProvider(new TreeMongoLabelProvider()); initData(); // google analytic AnalyticCaller.track(this.getClass().getName()); }
From source file:com.hangum.tadpole.mongodb.core.editors.dbInfos.comosites.CollectionInformationComposite.java
License:Open Source License
/** * Create the composite./*from ww w.java 2s . c o m*/ * @param parent * @param style */ public CollectionInformationComposite(Composite parent, int style) { super(parent, style); GridLayout gridLayout = new GridLayout(1, false); gridLayout.verticalSpacing = 1; gridLayout.horizontalSpacing = 1; gridLayout.marginHeight = 1; gridLayout.marginWidth = 1; setLayout(gridLayout); Composite compositeToolbar = new Composite(this, SWT.NONE); compositeToolbar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); GridLayout gl_compositeToolbar = new GridLayout(1, false); gl_compositeToolbar.verticalSpacing = 1; gl_compositeToolbar.horizontalSpacing = 1; gl_compositeToolbar.marginHeight = 1; gl_compositeToolbar.marginWidth = 1; compositeToolbar.setLayout(gl_compositeToolbar); ToolBar toolBar = new ToolBar(compositeToolbar, SWT.FLAT | SWT.RIGHT); ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE); tltmRefresh.setImage(ImageUtils.getRefresh()); tltmRefresh.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { initData(userDB); } }); tltmRefresh.setToolTipText(Messages.CollectionInformationComposite_tltmRefresh_text); Composite compositeHead = new Composite(this, SWT.NONE); compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); GridLayout gl_compositeHead = new GridLayout(2, false); gl_compositeHead.verticalSpacing = 2; gl_compositeHead.horizontalSpacing = 2; gl_compositeHead.marginHeight = 2; gl_compositeHead.marginWidth = 2; compositeHead.setLayout(gl_compositeHead); Label lblName = new Label(compositeHead, SWT.NONE); lblName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblName.setText(Messages.CollectionInformationComposite_0); textFilter = new Text(compositeHead, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textFilter.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { filter.setSearchString(textFilter.getText()); treeViewerCollections.refresh(); } }); Composite compositeBody = new Composite(this, SWT.NONE); compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); compositeBody.setSize(590, 199); GridLayout gl_compositeBody = new GridLayout(1, false); gl_compositeBody.verticalSpacing = 2; gl_compositeBody.horizontalSpacing = 2; gl_compositeBody.marginHeight = 2; gl_compositeBody.marginWidth = 2; compositeBody.setLayout(gl_compositeBody); treeViewerCollections = new TreeViewer(compositeBody, SWT.BORDER | SWT.VIRTUAL | SWT.FULL_SELECTION); treeViewerCollections.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { try { IStructuredSelection is = (IStructuredSelection) event.getSelection(); Object selElement = is.getFirstElement(); if (selElement instanceof MongoDBCollectionInfoDTO) { MongoDBCollectionInfoDTO dto = (MongoDBCollectionInfoDTO) selElement; dto.setChild(MongoDBQuery.collectionColumn(userDB, dto.getName())); treeViewerCollections.refresh(dto, true); treeViewerCollections.expandToLevel(dto, 1); } } catch (Exception e) { logger.error("mongodb treeview refresh", e); //$NON-NLS-1$ } } }); treeViewerCollections.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection is = (IStructuredSelection) event.getSelection(); Object selElement = is.getFirstElement(); if (selElement instanceof MongoDBCollectionInfoDTO) { MongoDBCollectionInfoDTO dto = (MongoDBCollectionInfoDTO) selElement; MongoDBEditorInput input = new MongoDBEditorInput(dto.getName(), userDB, dto.getChild()); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { page.openEditor(input, MongoDBTableEditor.ID); } catch (PartInitException e) { logger.error("Load the table data", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(null, "Error", "An error has occurred.", errStatus); //$NON-NLS-1$ //$NON-NLS-2$ } } } }); Tree tree = treeViewerCollections.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); treeViewerCollections.setUseHashlookup(true); createTableColumn(); treeViewerCollections.setContentProvider(new MongoInfoContentProvider()); treeViewerCollections.setLabelProvider(new MongoInfoLabelProvider()); treeViewerCollections.setInput(collectionList); collectionSorter = new MongoDBCollectionComparator(); treeViewerCollections.setSorter(collectionSorter); filter = new MongoInfoFilter(); treeViewerCollections.addFilter(filter); Group grpSummary = new Group(this, SWT.NONE); grpSummary.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); grpSummary.setSize(590, 45); grpSummary.setText(Messages.CollectionInformationComposite_2); GridLayout gl_grpSummary = new GridLayout(4, false); gl_grpSummary.verticalSpacing = 2; gl_grpSummary.horizontalSpacing = 2; gl_grpSummary.marginHeight = 2; gl_grpSummary.marginWidth = 2; grpSummary.setLayout(gl_grpSummary); lblCollection = new Label(grpSummary, SWT.BORDER); lblCollection.setText("Collection"); //$NON-NLS-1$ lblSizes = new Label(grpSummary, SWT.BORDER); lblSizes.setText("Sizes"); //$NON-NLS-1$ lblStorages = new Label(grpSummary, SWT.BORDER); lblStorages.setText("Storages"); //$NON-NLS-1$ lblIndex = new Label(grpSummary, SWT.BORDER); lblIndex.setText("Index"); //$NON-NLS-1$ }
From source file:com.hangum.tadpole.mongodb.core.editors.dbInfos.MongoDBInfosEditor.java
License:Open Source License
@Override public void createPartControl(Composite parent) { GridLayout gl_parent = new GridLayout(1, false); gl_parent.marginHeight = 2;/* w w w . j a v a 2 s .c om*/ gl_parent.verticalSpacing = 2; gl_parent.horizontalSpacing = 2; gl_parent.marginWidth = 2; parent.setLayout(gl_parent); Composite compositeHead = new Composite(parent, SWT.NONE); compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); compositeHead.setLayout(new GridLayout(3, false)); // Composite composite = new Composite(compositeHead, SWT.NONE); // composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); // composite.setLayout(new GridLayout(1, false)); // // lblServerInfo = new Label(composite, SWT.NONE); // lblServerInfo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); // lblServerInfo.setText(userDB.getHost() + ":" + userDB.getPort()); Label lblName = new Label(compositeHead, SWT.NONE); lblName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblName.setText("Name Filter"); //$NON-NLS-1$ textFilter = new Text(compositeHead, SWT.BORDER); textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textFilter.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { filter.setSearchString(textFilter.getText()); treeViewerCollections.refresh(); } }); Button btnRefresh = new Button(compositeHead, SWT.NONE); btnRefresh.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { initData(); } }); btnRefresh.setText("Refresh"); //$NON-NLS-1$ Composite compositeBody = new Composite(parent, SWT.NONE); compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); compositeBody.setLayout(new GridLayout(1, false)); treeViewerCollections = new TreeViewer(compositeBody, SWT.BORDER); treeViewerCollections.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { try { IStructuredSelection is = (IStructuredSelection) event.getSelection(); Object selElement = is.getFirstElement(); if (selElement instanceof MongoDBCollectionInfoDTO) { MongoDBCollectionInfoDTO dto = (MongoDBCollectionInfoDTO) selElement; dto.setChild(MongoDBQuery.collectionColumn(userDB, dto.getName())); treeViewerCollections.refresh(dto, true); treeViewerCollections.expandToLevel(dto, 1); } } catch (Exception e) { logger.error("mongodb treeview refresh", e); //$NON-NLS-1$ } } }); treeViewerCollections.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection is = (IStructuredSelection) event.getSelection(); Object selElement = is.getFirstElement(); if (selElement instanceof MongoDBCollectionInfoDTO) { MongoDBCollectionInfoDTO dto = (MongoDBCollectionInfoDTO) selElement; MongoDBEditorInput input = new MongoDBEditorInput(dto.getName(), userDB, dto.getChild()); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { page.openEditor(input, MongoDBTableEditor.ID); } catch (PartInitException e) { logger.error("Load the table data", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getSite().getShell(), "Error", //$NON-NLS-1$ "An error has occurred.", errStatus); //$NON-NLS-1$ } } } }); Tree tree = treeViewerCollections.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); collectionSorter = new MongoDBCollectionComparator(); treeViewerCollections.setSorter(collectionSorter); createTableColumn(); treeViewerCollections.setContentProvider(new MongoInfoContentProvider()); treeViewerCollections.setLabelProvider(new MongoInfoLabelProvider()); treeViewerCollections.setInput(collectionList); filter = new MongoInfoFilter(); treeViewerCollections.addFilter(filter); Group grpSummary = new Group(parent, SWT.NONE); grpSummary.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); grpSummary.setText("Summary"); //$NON-NLS-1$ grpSummary.setLayout(new GridLayout(4, false)); lblCollection = new Label(grpSummary, SWT.BORDER); lblCollection.setText("Collection"); //$NON-NLS-1$ lblSizes = new Label(grpSummary, SWT.BORDER); lblSizes.setText("Sizes"); //$NON-NLS-1$ lblStorages = new Label(grpSummary, SWT.BORDER); lblStorages.setText("Storages"); //$NON-NLS-1$ lblIndex = new Label(grpSummary, SWT.BORDER); lblIndex.setText("Index"); //$NON-NLS-1$ initData(); }
From source file:com.hangum.tadpole.rdb.core.editors.main.composite.plandetail.OraclePlanComposite.java
License:Open Source License
/** * Create the composite.//from w ww .ja va 2 s . c o m * @param parent * @param style */ public OraclePlanComposite(Composite parent, int style) { super(parent, style); setLayout(new GridLayout(1, false)); Composite compositeBody = new Composite(this, SWT.NONE); GridLayout gl_compositeHead = new GridLayout(2, false); gl_compositeHead.verticalSpacing = 2; gl_compositeHead.horizontalSpacing = 2; gl_compositeHead.marginHeight = 0; gl_compositeHead.marginWidth = 2; compositeBody.setLayout(gl_compositeHead); compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); compositeBody.setLayout(new GridLayout(1, false)); tvQueryPlan = new TreeViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION); Tree tree = tvQueryPlan.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tree.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { if (event.keyCode == SWT.F4) { IStructuredSelection is = (IStructuredSelection) tvQueryPlan.getSelection(); OraclePlanDAO selElement = (OraclePlanDAO) is.getFirstElement(); openInformationDialog(selElement); } } }); tvQueryPlan.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection is = (IStructuredSelection) event.getSelection(); OraclePlanDAO selElement = (OraclePlanDAO) is.getFirstElement(); openInformationDialog(selElement); } }); Composite compositeBtn = new Composite(compositeBody, SWT.NONE); compositeBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); GridLayout gl_compositeBtn = new GridLayout(4, false); gl_compositeBtn.verticalSpacing = 2; gl_compositeBtn.horizontalSpacing = 2; gl_compositeBtn.marginWidth = 0; gl_compositeBtn.marginHeight = 2; compositeBtn.setLayout(gl_compositeBtn); compositeTail = new PlanTailComposite(this, compositeBtn, SWT.NONE); compositeTail.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2)); GridLayout gl_compositeResult = new GridLayout(1, false); gl_compositeResult.verticalSpacing = 2; gl_compositeResult.horizontalSpacing = 2; gl_compositeResult.marginHeight = 0; gl_compositeResult.marginWidth = 2; compositeTail.setLayout(gl_compositeResult); }
From source file:com.hangum.tadpole.rdb.core.viewers.connections.ManagerViewer.java
License:Open Source License
@Override public void createPartControl(Composite parent) { setPartName(Messages.ManagerViewer_0); compositeMainComposite = new Composite(parent, SWT.NONE); GridLayout gl_composite = new GridLayout(1, false); gl_composite.verticalSpacing = 0;//from w w w . j a va 2 s. c o m gl_composite.horizontalSpacing = 0; gl_composite.marginHeight = 0; gl_composite.marginWidth = 0; compositeMainComposite.setLayout(gl_composite); managerTV = new TreeViewer(compositeMainComposite, SWT.NONE); managerTV.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection is = (IStructuredSelection) event.getSelection(); if (is.getFirstElement() instanceof UserDBDAO) { UserDBDAO userDB = (UserDBDAO) is.getFirstElement(); addUserResouceData(userDB); AnalyticCaller.track(ManagerViewer.ID, userDB.getDbms_types()); } // // (managerTV.getControl().setFocus();) , ? ?? event listener ? . // ? . // managerTV.getControl().setFocus(); } }); managerTV.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection is = (IStructuredSelection) event.getSelection(); Object selElement = is.getFirstElement(); // db object ? ? ??. if (selElement instanceof UserDBDAO) { QueryEditorAction qea = new QueryEditorAction(); qea.run((UserDBDAO) selElement); // erd ? erd ??? . } else if (selElement instanceof UserDBResourceDAO) { UserDBResourceDAO dao = (UserDBResourceDAO) selElement; if (PublicTadpoleDefine.RESOURCE_TYPE.ERD.toString().equals(dao.getResource_types())) { UserDBDAO userDB = dao.getParent(); if (userDB != null && DBDefine.MONGODB_DEFAULT == DBDefine.getDBDefine(userDB)) { MongoDBERDViewAction ea = new MongoDBERDViewAction(); ea.run(dao); } else { RDBERDViewAction ea = new RDBERDViewAction(); ea.run(dao); } } else { QueryEditorAction qea = new QueryEditorAction(); qea.run(dao); } // manager } else if (selElement instanceof ManagerListDTO) { ConnectDatabaseAction cda = new ConnectDatabaseAction(getSite().getWorkbenchWindow()); cda.runConnectionDialog(is); } } }); Tree tree = managerTV.getTree(); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tree.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); managerTV.setContentProvider(new ManagerContentProvider()); managerTV.setLabelProvider(new ManagerLabelProvider()); managerTV.setInput(treeList); getSite().setSelectionProvider(managerTV); createPopupMenu(); registerServiceHandler(); init(); // db? erd ?? PlatformUI.getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty() == PublicTadpoleDefine.SAVE_FILE) { addResource(Integer.parseInt(event.getNewValue().toString().split(":")[0])); //$NON-NLS-1$ } else if (event.getProperty() == PublicTadpoleDefine.ADD_DB) { init(); } } }); }
From source file:com.hangum.tadpole.rdb.core.viewers.object.sub.mongodb.collections.TadpoleMongoDBCollectionComposite.java
License:Open Source License
private void createWidget(final CTabFolder tabFolderObject) { CTabItem tbtmTable = new CTabItem(tabFolderObject, SWT.NONE); tbtmTable.setText("Collections"); //$NON-NLS-1$ Composite compositeTables = new Composite(tabFolderObject, SWT.NONE); tbtmTable.setControl(compositeTables); GridLayout gl_compositeTables = new GridLayout(1, false); gl_compositeTables.verticalSpacing = 2; gl_compositeTables.horizontalSpacing = 2; gl_compositeTables.marginHeight = 2; gl_compositeTables.marginWidth = 2;/*from w w w.jav a 2s .co m*/ compositeTables.setLayout(gl_compositeTables); compositeTables.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); SashForm sashForm = new SashForm(compositeTables, SWT.NONE); sashForm.setOrientation(SWT.VERTICAL); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // SWT.VIRTUAL ? FILTER ? ?? ? . tableListViewer = new TableViewer(sashForm, SWT.BORDER | SWT.FULL_SELECTION); tableListViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (PublicTadpoleDefine.YES_NO.NO.toString().equals(userDB.getIs_showtables())) return; IStructuredSelection is = (IStructuredSelection) event.getSelection(); if (null != is) { TableDAO tableDAO = (TableDAO) is.getFirstElement(); MongoDBEditorInput input = new MongoDBEditorInput(tableDAO.getName(), userDB, showTableColumns); IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage(); try { page.openEditor(input, MongoDBTableEditor.ID); } catch (PartInitException e) { logger.error("Load the table data", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(tabFolderObject.getShell(), "Error", //$NON-NLS-1$ Messages.ExplorerViewer_39, errStatus); } } } }); tableListViewer.addPostSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (PublicTadpoleDefine.YES_NO.NO.toString().equals(userDB.getIs_showtables())) return; // ?? ?? . try { IStructuredSelection is = (IStructuredSelection) event.getSelection(); Object tableDAO = is.getFirstElement(); if (tableDAO != null) { TableDAO table = (TableDAO) tableDAO; if (selectTableName.equals(table.getName())) return; selectTableName = table.getName(); showTableColumns = MongoDBQuery.collectionColumn(userDB, selectTableName); } else showTableColumns = null; treeColumnViewer.setInput(showTableColumns); treeColumnViewer.refresh(); TreeUtil.packTree(treeColumnViewer.getTree()); } catch (Exception e) { logger.error("get table column", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(tabFolderObject.getShell(), "Error", e.getMessage(), //$NON-NLS-1$ errStatus); } } }); Table tableTableList = tableListViewer.getTable(); tableTableList.setLinesVisible(true); tableTableList.setHeaderVisible(true); // sorter tableComparator = new MongoDBCollectionComparator(); tableListViewer.setSorter(tableComparator); tableComparator.setColumn(0); TableViewerColumn tvColName = new TableViewerColumn(tableListViewer, SWT.NONE); TableColumn tbName = tvColName.getColumn(); tbName.setWidth(150); tbName.setText("Name"); //$NON-NLS-1$ tbName.addSelectionListener(getSelectionAdapter(tableListViewer, tableComparator, tbName, 0)); tvColName.setLabelProvider(new ColumnLabelProvider() { @Override public Image getImage(Object element) { return ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/objectExplorer/tables.png"); //$NON-NLS-1$ } @Override public String getText(Object element) { TableDAO table = (TableDAO) element; return table.getName(); } }); // tvColName.setEditingSupport(new TableCommentEditorSupport(tableListViewer, userDB, 0)); TableViewerColumn tvColRows = new TableViewerColumn(tableListViewer, SWT.RIGHT); TableColumn tbComment = tvColRows.getColumn(); tbComment.setWidth(200); tbComment.setText("Rows"); //$NON-NLS-1$ tbComment.addSelectionListener(getSelectionAdapter(tableListViewer, tableComparator, tbComment, 1)); tvColRows.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { TableDAO table = (TableDAO) element; return NumberFormatUtils.commaFormat(table.getRows()); } }); // tvColRows.setEditingSupport(new TableCommentEditorSupport(tableListViewer, userDB, 1)); TableViewerColumn tvColSize = new TableViewerColumn(tableListViewer, SWT.RIGHT); TableColumn tbSize = tvColSize.getColumn(); tbSize.setWidth(200); tbSize.setText("Size"); //$NON-NLS-1$ tbSize.addSelectionListener(getSelectionAdapter(tableListViewer, tableComparator, tbComment, 1)); tvColSize.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { TableDAO table = (TableDAO) element; return NumberFormatUtils.kbMbFormat(table.getSize()); } }); tableListViewer.setContentProvider(new ArrayContentProvider()); tableListViewer.setInput(showTables); createMenu(); // dnd Transfer[] transferTypes = new Transfer[] { TextTransfer.getInstance() }; tableListViewer.addDragSupport(DND_OPERATIONS, transferTypes, new TableDragListener(userDB, tableListViewer)); // filter tableFilter = new TableFilter(); tableListViewer.addFilter(tableFilter); // columns treeColumnViewer = new TreeViewer(sashForm, SWT.VIRTUAL | SWT.BORDER | SWT.FULL_SELECTION); Tree tableTableColumn = treeColumnViewer.getTree(); tableTableColumn.setHeaderVisible(true); tableTableColumn.setLinesVisible(true); createTableMongoColumne(); treeColumnViewer.setContentProvider(new MongoDBCollectionFieldsContentProvider()); treeColumnViewer.setLabelProvider(new MongoDBCollectionFieldsLabelProvider()); sashForm.setWeights(new int[] { 1, 1 }); }
From source file:com.hangum.tadpole.rdb.core.viewers.sql.template.SQLTemplateView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { parent.setLayout(new GridLayout(1, false)); Composite compositeHead = new Composite(parent, SWT.NONE); compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); compositeHead.setLayout(new GridLayout(1, false)); ToolBar toolBar = new ToolBar(compositeHead, SWT.FLAT | SWT.RIGHT); ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE); tltmRefresh.addSelectionListener(new SelectionAdapter() { @Override/*from www .ja va 2 s . c o m*/ public void widgetSelected(SelectionEvent e) { initData(); } }); tltmRefresh.setImage(GlobalImageUtils.getRefresh()); tltmRefresh.setToolTipText(Messages.get().Refresh); ToolItem tltmAdd = new ToolItem(toolBar, SWT.NONE); tltmAdd.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { addTemplate(SQL_TEMPLATE_TYPE.PRI); } }); tltmAdd.setImage(GlobalImageUtils.getAdd()); tltmAdd.setToolTipText(Messages.get().Add); tltmModify = new ToolItem(toolBar, SWT.NONE); tltmModify.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { StructuredSelection ss = (StructuredSelection) tvSQLTemplate.getSelection(); if (ss.getFirstElement() instanceof SQLTemplateDAO) { SQLTemplateDAO dao = (SQLTemplateDAO) ss.getFirstElement(); SQLTemplateDialog dialog = new SQLTemplateDialog(getSite().getShell(), dao); if (Dialog.OK == dialog.open()) { tvSQLTemplate.refresh(dialog.getOldSqlTemplateDAO()); textSQL.setText(""); } } } }); tltmModify.setImage(GlobalImageUtils.getModify()); tltmModify.setToolTipText(Messages.get().Modified); tltmModify.setEnabled(false); tltmDelete = new ToolItem(toolBar, SWT.NONE); tltmDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!MessageDialog.openConfirm(getSite().getShell(), Messages.get().Confirm, Messages.get().SQLTemplateView_del_equestion)) return; StructuredSelection ss = (StructuredSelection) tvSQLTemplate.getSelection(); if (ss.getFirstElement() instanceof SQLTemplateDAO) { SQLTemplateDAO dao = (SQLTemplateDAO) ss.getFirstElement(); try { TadpoleSystem_SQLTemplate.deleteSQLTemplate(dao); grpPrivateDao.getChildList().remove(dao); tvSQLTemplate.remove(dao); textSQL.setText(""); } catch (Exception e1) { logger.error("Delete SQL template", e1); } } } }); tltmDelete.setImage(GlobalImageUtils.getDelete()); tltmDelete.setToolTipText(Messages.get().Delete); tltmDelete.setEnabled(false); // admin menu if (SessionManager.isSystemAdmin()) { new ToolItem(toolBar, SWT.SEPARATOR); ToolItem tltmAdminAdd = new ToolItem(toolBar, SWT.NONE); tltmAdminAdd.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { addTemplate(SQL_TEMPLATE_TYPE.PUB); } }); tltmAdminAdd.setText(Messages.get().SQLTemplateView_Addpublictemplate); tltmAdminAdd.setToolTipText(Messages.get().SQLTemplateView_Addpublictemplate); } SashForm sashForm = new SashForm(parent, SWT.VERTICAL); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite compositeBody = new Composite(sashForm, SWT.NONE); compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); GridLayout gl_compositeBody = new GridLayout(1, false); gl_compositeBody.verticalSpacing = 0; gl_compositeBody.horizontalSpacing = 0; gl_compositeBody.marginHeight = 0; gl_compositeBody.marginWidth = 0; compositeBody.setLayout(gl_compositeBody); textSearch = new Text(compositeBody, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); textSearch.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { filterText(); } }); textSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); tvSQLTemplate = new TreeViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION); tvSQLTemplate.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection ss = (StructuredSelection) event.getSelection(); if (ss.getFirstElement() instanceof SQLTemplateDAO) { SQLTemplateDAO dao = (SQLTemplateDAO) ss.getFirstElement(); if (SQL_TEMPLATE_TYPE.PUB.name().equals(dao.getCategory())) { if (SessionManager.isSystemAdmin()) { enableBtn(true); } else { enableBtn(false); } } else { enableBtn(true); } textSQL.setText(dao.getContent()); } else { enableBtn(false); textSQL.setText(""); } } private void enableBtn(boolean bool) { tltmModify.setEnabled(bool); tltmDelete.setEnabled(bool); } }); tvSQLTemplate.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { StructuredSelection ss = (StructuredSelection) event.getSelection(); if (ss.getFirstElement() instanceof SQLTemplateDAO) { SQLTemplateDAO dao = (SQLTemplateDAO) ss.getFirstElement(); FindEditorAndWriteQueryUtil.run(dao.getContent()); } } }); Tree tree = tvSQLTemplate.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(tvSQLTemplate, SWT.NONE); TreeColumn trclmnUrl = treeViewerColumn.getColumn(); trclmnUrl.setWidth(55); trclmnUrl.setText(Messages.get().GroupName); TreeViewerColumn tvcName = new TreeViewerColumn(tvSQLTemplate, SWT.NONE); TreeColumn trclmnDBName = tvcName.getColumn(); trclmnDBName.setWidth(100); trclmnDBName.setText(Messages.get().Name); TreeViewerColumn treeViewerColumn_2 = new TreeViewerColumn(tvSQLTemplate, SWT.NONE); TreeColumn trclmnDescription = treeViewerColumn_2.getColumn(); trclmnDescription.setWidth(100); trclmnDescription.setText(Messages.get().Description); TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(tvSQLTemplate, SWT.NONE); TreeColumn trclmnName = treeViewerColumn_1.getColumn(); trclmnName.setWidth(300); trclmnName.setText(Messages.get().SQL); Composite compositeSQL = new Composite(sashForm, SWT.NONE); GridLayout gl_compositeSQL = new GridLayout(1, false); gl_compositeSQL.verticalSpacing = 0; gl_compositeSQL.horizontalSpacing = 0; gl_compositeSQL.marginHeight = 0; gl_compositeSQL.marginWidth = 0; compositeSQL.setLayout(gl_compositeSQL); textSQL = new TadpoleEditorWidget(compositeSQL, SWT.BORDER, EditorDefine.EXT_DEFAULT, "", ""); textSQL.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); sashForm.setWeights(new int[] { 7, 3 }); tvSQLTemplate.setContentProvider(new SQLTemplateContentprovider()); tvSQLTemplate.setLabelProvider(new SQLTemplateLabelprovider()); // Composite compositeTail = new Composite(parent, SWT.NONE); // compositeTail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); // compositeTail.setLayout(new GridLayout(1, false)); initData(); filter = new SQLTemplateFilter(); tvSQLTemplate.addFilter(filter); AnalyticCaller.track(SQLTemplateView.ID); }
From source file:com.htmlhifive.tools.jslint.view.TargetStructureComposite.java
License:Apache License
/** * ??.//from ww w . j a va 2 s . c o m */ private void createContents() { setText(Messages.WT0003.getText()); setLayout(new GridLayout(1, false)); Composite composite = new Composite(this, SWT.NONE); composite.setLayout(new GridLayout(1, false)); Link link = new Link(composite, SWT.NONE); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doLinkWidgetSelected(e); } }); link.setSize(84, 18); link.setText(Messages.DL0008.getText()); Group group = new Group(this, SWT.NONE); GridData gdGroup = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); gdGroup.heightHint = 150; group.setLayoutData(gdGroup); group.setText(Messages.WT0002.getText()); group.setLayout(new GridLayout(1, false)); treeViewerSource = new TreeViewer(group, SWT.BORDER); Tree treeSource = treeViewerSource.getTree(); GridData gdTreeSource = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gdTreeSource.widthHint = 300; treeSource.setLayoutData(gdTreeSource); IListProperty childrenProperty = new MultiListProperty( new IListProperty[] { PojoProperties.list("children") }); ObservableListTreeContentProvider contentProvider = new ObservableListTreeContentProvider( childrenProperty.listFactory(), null); treeViewerSource.setContentProvider(contentProvider); ObservableMapLabelProvider labelProvider = new ObservableMapLabelProvider( PojoProperties.value("label").observeDetail(contentProvider.getKnownElements())) { @Override public Image getImage(Object element) { LibraryTreeModel model = (LibraryTreeModel) element; Object data = model.getData(); if (data instanceof IncludePathEntryWrapper) { return JavaScriptUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_PACKFRAG_ROOT); } if (data instanceof IPath) { return JavaScriptUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_CUNIT); } if (StringUtils.equals(model.getLabel(), LABEL_INCLUDED)) { return JavaPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB.createImage(); } else if (StringUtils.equals(model.getLabel(), LABEL_EXCLUDED)) { return JavaPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB.createImage(); } return null; } }; treeViewerSource.setLabelProvider(labelProvider); treeViewerSource.setInput(createSourceViewInput()); Label labelDescLib = new Label(this, SWT.NONE); labelDescLib.setToolTipText(Messages.DTT0000.getText()); labelDescLib.setText(Messages.DL0017.getText()); // ?. Group grpInternalLibrary = new Group(this, SWT.NONE); grpInternalLibrary.setLayout(new GridLayout(2, false)); GridData gdGrpInternalLibrary = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); gdGrpInternalLibrary.heightHint = 150; grpInternalLibrary.setLayoutData(gdGrpInternalLibrary); grpInternalLibrary.setText(Messages.WT0004.getText()); tableViewerInternalLib = CheckboxTableViewer.newCheckList(grpInternalLibrary, SWT.BORDER | SWT.FULL_SELECTION); // tableViewerInternalLib = new TableViewer(grpLibrary, SWT.BORDER | // SWT.CHECK | // SWT.FULL_SELECTION); Table table = tableViewerInternalLib.getTable(); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gridData.widthHint = 300; table.setLayoutData(gridData); Composite compInternalLibButton = new Composite(grpInternalLibrary, SWT.NONE); compInternalLibButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); compInternalLibButton.setLayout(new GridLayout(1, false)); Button btnInternalAllSelect = new Button(compInternalLibButton, SWT.NONE); btnInternalAllSelect.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doBtnInternalAllSelectWidgetSelected(e); } }); GridData gdBtnInternalAllSelect = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gdBtnInternalAllSelect.widthHint = 60; btnInternalAllSelect.setLayoutData(gdBtnInternalAllSelect); btnInternalAllSelect.setText(Messages.B0006.getText()); Button btnInternalAllRelease = new Button(compInternalLibButton, SWT.NONE); btnInternalAllRelease.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doBtnInternalAllReleaseWidgetSelected(e); } }); GridData gdBtnInternalAllRelease = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gdBtnInternalAllRelease.widthHint = 60; btnInternalAllRelease.setLayoutData(gdBtnInternalAllRelease); btnInternalAllRelease.setText(Messages.B0007.getText()); IObservableList observableList = createInternalLibViewInput(); tableViewerInternalLib.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { WritableValue value = (WritableValue) element; return value.getValue().toString(); } @Override public Image getImage(Object element) { return JavaScriptUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_LIBRARY); } }); ObservableListContentProvider listContentProvider = new ObservableListContentProvider(); tableViewerInternalLib.setContentProvider(listContentProvider); tableViewerInternalLib.setInput(observableList); // ?. Group grpExternalLibrary = new Group(this, SWT.NONE); grpExternalLibrary.setText(Messages.WT0006.getText()); grpExternalLibrary.setLayout(new GridLayout(2, false)); GridData gdGrpExternalLibrary = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); gdGrpExternalLibrary.heightHint = 150; grpExternalLibrary.setLayoutData(gdGrpExternalLibrary); tableViewerExternalLib = CheckboxTableViewer.newCheckList(grpExternalLibrary, SWT.BORDER | SWT.FULL_SELECTION); Table tableExternalLib = tableViewerExternalLib.getTable(); GridData gdTableExternalLib = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gdTableExternalLib.widthHint = 300; tableExternalLib.setLayoutData(gdTableExternalLib); Composite compExternalLibButton = new Composite(grpExternalLibrary, SWT.NONE); compExternalLibButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); compExternalLibButton.setLayout(new GridLayout(1, false)); Button btnExternalAllSelect = new Button(compExternalLibButton, SWT.NONE); btnExternalAllSelect.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doBtnExternalAllSelectWidgetSelected(e); } }); GridData gdBtnExternalAllSelect = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gdBtnExternalAllSelect.widthHint = 60; btnExternalAllSelect.setLayoutData(gdBtnExternalAllSelect); btnExternalAllSelect.setText(Messages.B0006.getText()); Button btnExternalAllRelease = new Button(compExternalLibButton, SWT.NONE); btnExternalAllRelease.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doBtnExternalAllReleaseWidgetSelected(e); } }); GridData gdBtnExternalAllRelease = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gdBtnExternalAllRelease.widthHint = 60; btnExternalAllRelease.setLayoutData(gdBtnExternalAllRelease); btnExternalAllRelease.setText(Messages.B0007.getText()); IObservableList externalObservableList = createExternalLibViewInput(); tableViewerExternalLib.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { String value = (String) element; return value; } @Override public Image getImage(Object element) { return JavaScriptUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_LIBRARY); } }); ObservableListContentProvider listExternalContentProvider = new ObservableListContentProvider(); tableViewerExternalLib.setContentProvider(listExternalContentProvider); tableViewerExternalLib.setInput(externalObservableList); initialDataBinding(); initialModel(); }
From source file:com.hudren.woodpile.views.CategoryView.java
License:Open Source License
private void createTreeViewer(final Composite parent) { viewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(contentProvider = new CategoryViewContentProvider(this)); viewer.setLabelProvider(new CategoryViewLabelProvider()); viewer.setInput(WoodpilePlugin.getDefault().getCurrentSession().getCategories()); viewer.addPostSelectionChangedListener(this); }