Search in sources :

Example 1 with ColumnWeightData

use of org.eclipse.jface.viewers.ColumnWeightData in project translationstudio8 by heartsome.

the class ExportExternalDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridDataFactory.createFrom(new GridData(GridData.FILL_BOTH)).hint(600, SWT.DEFAULT).applyTo(tparent);
    final Group groupFile = new Group(tparent, SWT.NONE);
    groupFile.setText(Messages.getString("ExportDocxDialog.lable.xliff"));
    groupFile.setLayout(new GridLayout(1, false));
    groupFile.setLayoutData(new GridData(GridData.FILL_BOTH));
    final TableViewer tbv = new TableViewer(groupFile, SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    final Table table = tbv.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 90).applyTo(table);
    tableLayout.addColumnData(new ColumnWeightData(1));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.nodot"));
    tableLayout.addColumnData(new ColumnWeightData(10));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.fullPath"));
    tableLayout.addColumnData(new ColumnWeightData(2));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.srcLang"));
    tableLayout.addColumnData(new ColumnWeightData(2));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.tgtLang"));
    tbv.setLabelProvider(new TableViewLabelProvider());
    tbv.setContentProvider(new ArrayContentProvider());
    tbv.setInput(xlfBeans);
    final Group groupExportType = new Group(tparent, SWT.NONE);
    groupExportType.setText(Messages.getString("ExportDocxDialog.lable.exporttype"));
    groupExportType.setLayout(new GridLayout(3, false));
    groupExportType.setLayoutData(new GridData(GridData.FILL_BOTH));
    final Label lblExportType = new Label(groupExportType, SWT.NONE);
    lblExportType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblExportType.setText(Messages.getString("ExportDocxDialog.lable.exportchoose"));
    cmb = new Combo(groupExportType, SWT.NONE | SWT.READ_ONLY);
    GridDataFactory.swtDefaults().span(2, 1).grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(cmb);
    for (String type : ExportExternal.getExportTypes()) {
        cmb.add(type);
    }
    cmb.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final int exportCode = ExportExternal.getExportTypeCode(cmb.getSelectionIndex());
            btnHsproofNote.setEnabled(exportCode == ExportExternal.EXPORT_HSPROOF);
            btnHsproofState.setEnabled(btnHsproofNote.getEnabled());
            btnNotrans.setEnabled(exportCode != ExportExternal.EXPORT_TMX && btnFilterWhenState.getSelection());
            if (ExportExternal.EXPORT_TMX == exportCode && btnFilterWhenState.getSelection()) {
                btnNotrans.setSelection(false);
            }
        }
    });
    final Label lblR8State = new Label(groupExportType, SWT.NONE);
    lblR8State.setText(Messages.getString("ExportDocxDialog.lable.hsproof"));
    btnHsproofState = new Button(groupExportType, SWT.CHECK);
    btnHsproofState.setText(Messages.getString("ExportDocxDialog.statusBtn"));
    btnHsproofNote = new Button(groupExportType, SWT.CHECK);
    btnHsproofNote.setText(Messages.getString("ExportDocxDialog.commentBtn"));
    final Group groupFilter = new Group(tparent, SWT.NONE);
    groupFilter.setText(Messages.getString("ExportDocxDialog.lable.filter"));
    groupFilter.setLayout(new GridLayout(3, false));
    groupFilter.setLayoutData(new GridData(GridData.FILL_BOTH));
    // 过滤大类
    btnAllTrans = new Button(groupFilter, SWT.RADIO);
    btnAllTrans.setText(Messages.getString("ExportDocxDialog.lable.filterAll"));
    btnAllTrans.setSelection(true);
    btnAllTrans.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnAllTrans.getSelection()) {
                setFilterDefaultValue();
            }
        }
    });
    btnOnlySpecial = new Button(groupFilter, SWT.RADIO);
    btnOnlySpecial.setText(Messages.getString("ExportDocxDialog.onlyExportBtn"));
    btnOnlySpecial.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnOnlySpecial.getSelection()) {
                setFilterDefaultValue();
            }
        }

        ;
    });
    btnFilterWhenState = new Button(groupFilter, SWT.RADIO);
    btnFilterWhenState.setText(Messages.getString("ExportDocxDialog.lable.hasState"));
    btnFilterWhenState.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnFilterWhenState.getSelection()) {
                setFilterDefaultValue();
            }
        }

        ;
    });
    // 大类细节
    cmpFilterAllTrans = new Composite(groupFilter, SWT.NONE);
    cmpFilterAllTrans.setLayout(new GridLayout(1, false));
    cmpFilterAllTrans.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    btnExceptLocked = new Button(cmpFilterAllTrans, SWT.CHECK);
    btnExceptLocked.setText(Messages.getString("ExportDocxDialog.lable.exceptLock"));
    btnExceptLocked.setEnabled(true);
    btnExceptContextMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
    btnExceptContextMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptCxtMatch"));
    btnExceptContextMatch.setEnabled(true);
    btnExceptFullMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
    btnExceptFullMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptFullMatch"));
    cmpFilterOnlySpecial = new Composite(groupFilter, SWT.NONE);
    cmpFilterOnlySpecial.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    cmpFilterOnlySpecial.setLayout(new GridLayout(1, false));
    btnHasNote = new Button(cmpFilterOnlySpecial, SWT.CHECK);
    btnHasNote.setText(Messages.getString("ExportDocxDialog.onlyExportNoteBtn"));
    btnNeedReview = new Button(cmpFilterOnlySpecial, SWT.CHECK);
    btnNeedReview.setText(Messages.getString("ExportDocxDialog.onlyExportReviewBtn"));
    cmpFilterWhenState = new Composite(groupFilter, SWT.NONE);
    cmpFilterWhenState.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    cmpFilterWhenState.setLayout(new GridLayout(1, false));
    btnNotrans = new Button(cmpFilterWhenState, SWT.CHECK);
    btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
    btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
    btnNewtrans = new Button(cmpFilterWhenState, SWT.CHECK);
    btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
    btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
    btnTransed = new Button(cmpFilterWhenState, SWT.CHECK);
    btnTransed.setText(Messages.getString("ExportDocxDialog.lable.state.hasTrans"));
    btnApproved = new Button(cmpFilterWhenState, SWT.CHECK);
    btnApproved.setText(Messages.getString("ExportDocxDialog.lable.state.hasApprove"));
    Composite cmpSaveas = new Composite(tparent, SWT.NONE);
    cmpSaveas.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());
    cmpSaveas.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label lblSaveas = new Label(cmpSaveas, SWT.NONE);
    lblSaveas.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSaveas.setText(Messages.getString("ExportDocxDialog.lable.saveas"));
    txtSaveas = new Text(cmpSaveas, SWT.BORDER | SWT.READ_ONLY);
    txtSaveas.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtSaveas.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            getButton(IDialogConstants.OK_ID).setEnabled(!txtSaveas.getText().isEmpty());
        }
    });
    Button btnSaveas = new Button(cmpSaveas, SWT.NONE);
    btnSaveas.setText(Messages.getString("ExportDocxDialog.browseDocxBtn"));
    btnSaveas.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(getShell());
            dialog.setFilterPath(dialogSetting.get("defaultPath"));
            String path = dialog.open();
            if (path != null) {
                txtSaveas.setText(path);
                dialogSetting.put("defaultPath", path);
            }
        }
    });
    setDefaultValue();
    return parent;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 2 with ColumnWeightData

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

the class BusinessAssignmentComposite method createControls.

public void createControls(Composite parent) {
    composite = widgetFactory.createFlatFormComposite(parent);
    adapterFactory = new BusinessItemProviderAdapterFactory();
    tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
    tableViewer.setLabelProvider(new RepositoryFactoryProxyLabelProvider(adapterFactory));
    Table table = tableViewer.getTable();
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final String[] columnProperties = new String[] { Messages.getString("AssignmentPropertySection.Type"), Messages.getString("AssignmentPropertySection.Name"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Messages.getString("AssignmentPropertySection.Comment") };
    TableColumn column1 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column1.setText(columnProperties[0]);
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column2.setText(columnProperties[1]);
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
    column3.setText(columnProperties[2]);
    tableViewer.setColumnProperties(columnProperties);
    final IItemPropertyDescriptor itemPropertyDescriptor = getItemPropertyDescriptor();
    tableViewer.setCellModifier(new ICellModifier() {

        @Override
        public boolean canModify(Object element, String property) {
            return property.equals(columnProperties[2]);
        }

        @Override
        public Object getValue(Object element, String property) {
            return EmfPropertyHelper.getValue(itemPropertyDescriptor, element);
        }

        @Override
        public void modify(Object element, String property, Object value) {
            if (element instanceof TableItem) {
                TableItem tableItem = (TableItem) element;
                itemPropertyDescriptor.setPropertyValue(tableItem.getData(), value);
            }
        }
    });
    CellEditor[] cellEditors = new CellEditor[3];
    cellEditors[2] = new TextCellEditor(table);
    tableViewer.setCellEditors(cellEditors);
    // createKeyListener(table);
    createSelectionListener();
    createPopupMenu();
    createDoubleClickListener();
    handleLayout(parent, table, column1, column2, column3);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.eclipse.swt.widgets.Table) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) RepositoryFactoryProxyLabelProvider(org.talend.designer.business.diagram.custom.properties.RepositoryFactoryProxyLabelProvider) TableItem(org.eclipse.swt.widgets.TableItem) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) BusinessItemProviderAdapterFactory(org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory) ICellModifier(org.eclipse.jface.viewers.ICellModifier) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IItemPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 3 with ColumnWeightData

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

the class VersionSection method createControls.

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

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

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

        public void dispose() {
        }

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

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

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

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

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

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

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

        private int direction = 1;

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

                int index = 0;

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

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

Example 4 with ColumnWeightData

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

the class DB2ExplainPlanExecution method displayResults.

private void displayResults(final ExplainNode node) {
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        @SuppressWarnings("deprecation")
        public void run() {
            clearCanvas();
            GridLayout gLayout = new GridLayout();
            gLayout.numColumns = 2;
            gLayout.marginLeft = 0;
            gLayout.horizontalSpacing = 0;
            gLayout.verticalSpacing = 0;
            gLayout.marginWidth = 0;
            gLayout.marginHeight = 0;
            composite.setLayout(gLayout);
            try {
                //$NON-NLS-1$
                composite.setData("parenttab", parentTab);
                Composite pp = new Composite(composite, SWT.NULL);
                pp.setLayout(new FillLayout());
                pp.setLayoutData(new GridData(GridData.FILL_BOTH));
                TreeViewer tv = new TreeViewer(pp, SWT.BORDER | SWT.FULL_SELECTION);
                Tree tree = tv.getTree();
                tree.setLinesVisible(true);
                tree.setHeaderVisible(true);
                TreeColumn tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText("");
                tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText(Messages.getString("DB2ExplainPlanExecution.tableColumnText1"));
                tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText(Messages.getString("DB2ExplainPlanExecution.tableColumnText2"));
                TableLayout tableLayout = new TableLayout();
                tableLayout.addColumnData(new ColumnWeightData(6, 150, true));
                tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
                tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
                tree.setLayout(tableLayout);
                tv.setContentProvider(new ITreeContentProvider() {

                    @Override
                    public void dispose() {
                    }

                    @Override
                    public Object[] getChildren(Object parentElement) {
                        return ((ExplainNode) parentElement).getChildren();
                    }

                    @Override
                    public Object[] getElements(Object inputElement) {
                        ExplainNode nd = ((ExplainNode) inputElement);
                        return nd.getChildren();
                    }

                    @Override
                    public Object getParent(Object element) {
                        return ((ExplainNode) element).getParent();
                    }

                    @Override
                    public boolean hasChildren(Object element) {
                        if (((ExplainNode) element).getChildren().length > 0) {
                            return true;
                        }
                        return false;
                    }

                    @Override
                    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
                    }
                });
                tv.setLabelProvider(new TreeLabelProvider() {
                });
                tv.setInput(node);
                tv.refresh();
                tv.expandAll();
                // make columns full size
                for (int i = 0; i < tree.getColumnCount(); i++) {
                    tree.getColumn(i).pack();
                }
                final Composite parent = composite;
                tree.addKeyListener(new KeyAdapter() {

                    @Override
                    public void keyReleased(KeyEvent e) {
                        switch(e.keyCode) {
                            case SWT.F5:
                                // refresh SQL Results
                                try {
                                    //$NON-NLS-1$
                                    Object o = parent.getData("parenttab");
                                    if (o != null) {
                                        AbstractSQLExecution sqlExec = (AbstractSQLExecution) ((TabItem) o).getData();
                                        if (sqlExec != null) {
                                            sqlExec.startExecution();
                                        }
                                    }
                                } catch (Exception e1) {
                                    //$NON-NLS-1$
                                    SqlBuilderPlugin.log(Messages.getString("DB2ExplainPlanExecution.logMessageError1"), e1);
                                }
                                break;
                            default:
                                return;
                        }
                    }
                });
            } catch (Exception e) {
                // add message
                String message = e.getMessage();
                Label errorLabel = new Label(composite, SWT.FILL);
                errorLabel.setText(message);
                errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                //$NON-NLS-1$
                SqlBuilderPlugin.log(Messages.getString("DB2ExplainPlanExecution.logMessageError2"), e);
            }
            composite.layout();
            composite.redraw();
        }

        ;
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) FillLayout(org.eclipse.swt.layout.FillLayout) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) AbstractSQLExecution(org.talend.sqlbuilder.sqlcontrol.AbstractSQLExecution) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 5 with ColumnWeightData

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

the class OracleExplainPlanExecution method displayResults.

private void displayResults(final ExplainNode node) {
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        @SuppressWarnings("deprecation")
        public void run() {
            clearCanvas();
            GridLayout gLayout = new GridLayout();
            gLayout.numColumns = 2;
            gLayout.marginLeft = 0;
            gLayout.horizontalSpacing = 0;
            gLayout.verticalSpacing = 0;
            gLayout.marginWidth = 0;
            gLayout.marginHeight = 0;
            composite.setLayout(gLayout);
            try {
                //$NON-NLS-1$
                composite.setData("parenttab", parentTab);
                Composite pp = new Composite(composite, SWT.NULL);
                pp.setLayout(new FillLayout());
                pp.setLayoutData(new GridData(GridData.FILL_BOTH));
                TreeViewer tv = new TreeViewer(pp, SWT.BORDER | SWT.FULL_SELECTION);
                Tree tree = tv.getTree();
                tree.setLinesVisible(true);
                tree.setHeaderVisible(true);
                TreeColumn tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText("");
                tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText(Messages.getString("OracleExplainPlanExecution.tableColumnText1"));
                tc = new TreeColumn(tree, SWT.NULL);
                //$NON-NLS-1$
                tc.setText(Messages.getString("OracleExplainPlanExecution.tableColumnText2"));
                TableLayout tableLayout = new TableLayout();
                tableLayout.addColumnData(new ColumnWeightData(6, 150, true));
                tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
                tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
                tree.setLayout(tableLayout);
                tv.setContentProvider(new ITreeContentProvider() {

                    @Override
                    public void dispose() {
                    }

                    @Override
                    public Object[] getChildren(Object parentElement) {
                        return ((ExplainNode) parentElement).getChildren();
                    }

                    @Override
                    public Object[] getElements(Object inputElement) {
                        ExplainNode nd = ((ExplainNode) inputElement);
                        return nd.getChildren();
                    }

                    @Override
                    public Object getParent(Object element) {
                        return ((ExplainNode) element).getParent();
                    }

                    @Override
                    public boolean hasChildren(Object element) {
                        if (((ExplainNode) element).getChildren().length > 0) {
                            return true;
                        }
                        return false;
                    }

                    @Override
                    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
                    }
                });
                tv.setLabelProvider(new TreeLabelProvider() {
                });
                tv.setInput(node);
                tv.refresh();
                tv.expandAll();
                // make columns full size
                for (int i = 0; i < tree.getColumnCount(); i++) {
                    tree.getColumn(i).pack();
                }
                final Composite parent = composite;
                tree.addKeyListener(new KeyAdapter() {

                    @Override
                    public void keyReleased(KeyEvent e) {
                        switch(e.keyCode) {
                            case SWT.F5:
                                // refresh SQL Results
                                try {
                                    //$NON-NLS-1$
                                    Object o = parent.getData("parenttab");
                                    if (o != null) {
                                        AbstractSQLExecution sqlExec = (AbstractSQLExecution) ((TabItem) o).getData();
                                        if (sqlExec != null) {
                                            sqlExec.startExecution();
                                        }
                                    }
                                } catch (Exception e1) {
                                    //$NON-NLS-1$
                                    SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanExecution.logMessage1"), e1);
                                }
                                break;
                            default:
                                return;
                        }
                    }
                });
            } catch (Exception e) {
                // add message
                String message = e.getMessage();
                Label errorLabel = new Label(composite, SWT.FILL);
                errorLabel.setText(message);
                errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                //$NON-NLS-1$
                SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanExecution.logMessage2"), e);
            }
            composite.layout();
            composite.redraw();
        }

        ;
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) FillLayout(org.eclipse.swt.layout.FillLayout) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) AbstractSQLExecution(org.talend.sqlbuilder.sqlcontrol.AbstractSQLExecution) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree) TableLayout(org.eclipse.jface.viewers.TableLayout)

Aggregations

ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)31 TableLayout (org.eclipse.jface.viewers.TableLayout)22 GridData (org.eclipse.swt.layout.GridData)15 TableColumn (org.eclipse.swt.widgets.TableColumn)14 Composite (org.eclipse.swt.widgets.Composite)11 Table (org.eclipse.swt.widgets.Table)11 TableViewer (org.eclipse.jface.viewers.TableViewer)9 GridLayout (org.eclipse.swt.layout.GridLayout)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 Label (org.eclipse.swt.widgets.Label)5 TableItem (org.eclipse.swt.widgets.TableItem)5 BrokerEnvStatusColumn (com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerEnvStatusColumn)4 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)4 ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 TreeViewer (org.eclipse.jface.viewers.TreeViewer)4 Viewer (org.eclipse.jface.viewers.Viewer)4 CellEditor (org.eclipse.jface.viewers.CellEditor)3