Search in sources :

Example 16 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project hale by halestudio.

the class SourceListParameterPage method createContent.

/**
 * @see HaleWizardPage#createContent(Composite)
 */
@Override
protected void createContent(Composite page) {
    GridLayout layout = GridLayoutFactory.swtDefaults().create();
    // Add margin to leave space for control decorations
    layout.marginLeft = 5;
    layout.marginRight = 5;
    page.setLayout(layout);
    // input field
    textField = createAndLayoutTextField(page);
    // let subclasses for example add validation
    configure(textField);
    addContentProposalProvider(projectVariablesProposalsProvider);
    setText(textField, initialValue);
    // variables
    Label label = new Label(page, SWT.NONE);
    label.setText("Available variables (double click to insert)");
    label.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).indent(4, 12).create());
    // variables table
    Composite tableComposite = new Composite(page, SWT.NONE);
    tableComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 100).create());
    TableColumnLayout columnLayout = new TableColumnLayout();
    tableComposite.setLayout(columnLayout);
    varTable = new TableViewer(tableComposite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    varTable.getTable().setHeaderVisible(true);
    TableViewerColumn entityColumn = new TableViewerColumn(varTable, SWT.NONE);
    columnLayout.setColumnData(entityColumn.getColumn(), new ColumnWeightData(2, true));
    entityColumn.getColumn().setText("Entity");
    varTable.setContentProvider(ArrayContentProvider.getInstance());
    varTable.setLabelProvider(new StyledDefinitionLabelProvider(varTable) {

        @Override
        protected Object extractElement(Object element) {
            if (element instanceof Entry) {
                return ((Entry<?, ?>) element).getKey();
            }
            return super.extractElement(element);
        }
    });
    varTable.getTable().addMouseListener(new MouseAdapter() {

        /**
         * @see MouseAdapter#mouseDoubleClick(MouseEvent)
         */
        @Override
        public void mouseDoubleClick(MouseEvent e) {
            ISelection sel = varTable.getSelection();
            if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
                Object selected = ((IStructuredSelection) sel).getFirstElement();
                if (selected instanceof Entry) {
                    selected = ((Entry<?, ?>) selected).getValue();
                }
                insertTextAtCurrentPos(textField, selected.toString());
            }
        }
    });
    // variable name column
    TableViewerColumn varColumn = new TableViewerColumn(varTable, SWT.NONE);
    columnLayout.setColumnData(varColumn.getColumn(), new ColumnWeightData(1, true));
    varColumn.getColumn().setText("Variable");
    varColumn.setLabelProvider(new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            Object element = cell.getElement();
            if (element instanceof Entry) {
                element = ((Entry<?, ?>) element).getValue();
            }
            cell.setText(element.toString());
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ViewerCell(org.eclipse.jface.viewers.ViewerCell) GridLayout(org.eclipse.swt.layout.GridLayout) Entry(java.util.Map.Entry) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) StyledDefinitionLabelProvider(eu.esdihumboldt.hale.ui.common.definition.viewer.StyledDefinitionLabelProvider) ISelection(org.eclipse.jface.viewers.ISelection) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider)

Example 17 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project uiautomatorviewer by yangzaiCN.

the class UiAutomatorViewer method createContents.

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

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

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

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

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

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

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

Example 18 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project archi by archimatetool.

the class DiagramFiguresPreferencePage method createContents.

@Override
public Composite createContents(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    loadFigures();
    Composite client = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.marginWidth = layout.marginHeight = 0;
    client.setLayout(layout);
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    Composite tableClient = new Composite(client, SWT.NULL);
    tableClient.setLayout(gridLayout);
    tableClient.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label label = new Label(tableClient, SWT.NULL);
    label.setText(Messages.DiagramFiguresPreferencePage_0);
    Composite client2 = new Composite(tableClient, SWT.NULL);
    client2.setLayout(new TableColumnLayout());
    // Need this to stop it getting taller when the splitter is resized in the Prefs dialog
    GridDataFactory.create(GridData.FILL_BOTH).hint(SWT.DEFAULT, 200).applyTo(client2);
    createTable(client2);
    fTableViewer.setInput(fChoices);
    // Weird bug on Windows where the table and scroll bars are sometimes not drawn correctly
    Display.getCurrent().asyncExec(() -> {
        client2.layout();
    });
    return client;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 19 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project archi by archimatetool.

the class P2PluginDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    setTitle(Messages.P2PluginDialog_1);
    setMessage(Messages.P2PluginDialog_2);
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    container.setLayout(new GridLayout(1, false));
    Composite tableComp = new Composite(container, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    tableComp.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    tableComp.setLayoutData(gd);
    viewer = new TableViewer(tableComp, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    // Mac Silicon Item height
    UIUtils.fixMacSiliconItemHeight(viewer.getTable());
    viewer.getTable().setHeaderVisible(true);
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(25, false));
    column.getColumn().setText(Messages.P2PluginDialog_3);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(25, false));
    column.getColumn().setText(Messages.P2PluginDialog_4);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(25, false));
    column.getColumn().setText(Messages.P2PluginDialog_5);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(25, false));
    column.getColumn().setText(Messages.P2PluginDialog_6);
    viewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            try {
                return P2Handler.getInstance().getInstalledFeatures().toArray();
            } catch (ProvisionException ex) {
                ex.printStackTrace();
            }
            return new Object[0];
        }
    });
    class LabelCellProvider extends LabelProvider implements ITableLabelProvider {

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

        @Override
        public String getColumnText(Object element, int columnIndex) {
            if (element instanceof IInstallableUnit) {
                IInstallableUnit iu = (IInstallableUnit) element;
                switch(columnIndex) {
                    case 0:
                        return iu.getProperty(IInstallableUnit.PROP_NAME, null);
                    case 1:
                        return iu.getVersion().toString();
                    case 2:
                        return iu.getId();
                    case 3:
                        return iu.getProperty(IInstallableUnit.PROP_PROVIDER, null);
                    default:
                        break;
                }
            }
            return element.toString();
        }
    }
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            IInstallableUnit u1 = (IInstallableUnit) e1;
            IInstallableUnit u2 = (IInstallableUnit) e2;
            return u1.getProperty(IInstallableUnit.PROP_NAME, null).compareToIgnoreCase(u2.getProperty(IInstallableUnit.PROP_NAME, null));
        }
    });
    viewer.setLabelProvider(new LabelCellProvider());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            getButton(UNINSTALL).setEnabled(!event.getSelection().isEmpty());
        }
    });
    // anything will do //$NON-NLS-1$
    viewer.setInput("");
    return area;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) TableViewer(org.eclipse.jface.viewers.TableViewer) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 20 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project archi by archimatetool.

the class TemplateManagerDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, getHelpID());
    setTitle(Messages.TemplateManagerDialog_2);
    setMessage(Messages.TemplateManagerDialog_3);
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite client = new Composite(composite, SWT.NULL);
    GridLayout layout = new GridLayout(2, false);
    client.setLayout(layout);
    client.setLayoutData(new GridData(GridData.FILL_BOTH));
    SashForm sash = new SashForm(client, SWT.HORIZONTAL);
    sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 580;
    gd.heightHint = 300;
    sash.setLayoutData(gd);
    // Templates Table
    Composite tableComp = new Composite(sash, SWT.BORDER);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    tableComp.setLayout(layout);
    CLabel label = new CLabel(tableComp, SWT.NULL);
    label.setText(Messages.TemplateManagerDialog_4);
    Composite tableComp2 = new Composite(tableComp, SWT.NULL);
    tableComp2.setLayout(new TableColumnLayout());
    tableComp2.setLayoutData(new GridData(GridData.FILL_BOTH));
    fTableViewer = new TemplatesTableViewer(tableComp2, SWT.MULTI);
    fTableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    fTableViewer.setInput(fTemplateManager.getUserTemplates());
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
            fSelectedControl = fTableViewer;
            updateControls(o);
        }
    });
    // Groups Tree
    Composite treeComp = new Composite(sash, SWT.BORDER);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    treeComp.setLayout(layout);
    label = new CLabel(treeComp, SWT.NULL);
    label.setText(Messages.TemplateManagerDialog_5);
    // label.setImage(IArchiImages.ImageFactory.getImage(ImageFactory.ECLIPSE_IMAGE_FOLDER));
    fTreeViewer = new TemplatesTreeViewer(treeComp, SWT.MULTI);
    fTreeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    fTreeViewer.setInput(fTemplateManager.getUserTemplateGroups());
    fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
            fSelectedControl = fTreeViewer;
            updateControls(o);
        }
    });
    new TemplateManagerDialogDragDropHandler(fTableViewer, fTreeViewer);
    // Buttons
    Composite buttonBar = new Composite(client, SWT.NULL);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    buttonBar.setLayout(layout);
    buttonBar.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    fButtonAddTemplate = new Button(buttonBar, SWT.NULL);
    fButtonAddTemplate.setText(Messages.TemplateManagerDialog_6);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fButtonAddTemplate.setLayoutData(gd);
    fButtonAddTemplate.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            openTemplate();
        }
    });
    fButtonNewGroup = new Button(buttonBar, SWT.NULL);
    fButtonNewGroup.setText(Messages.TemplateManagerDialog_7);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fButtonNewGroup.setLayoutData(gd);
    fButtonNewGroup.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            newGroup();
        }
    });
    fButtonRemove = new Button(buttonBar, SWT.NULL);
    fButtonRemove.setText(Messages.TemplateManagerDialog_8);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fButtonRemove.setLayoutData(gd);
    fButtonRemove.setEnabled(false);
    fButtonRemove.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteSelectedObjects();
        }
    });
    sash.setWeights(new int[] { 30, 70 });
    Composite fieldContainer = new Composite(composite, SWT.NULL);
    layout = new GridLayout(2, false);
    fieldContainer.setLayout(layout);
    fieldContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fNameLabel = new Label(fieldContainer, SWT.NULL);
    fNameLabel.setText(Messages.TemplateManagerDialog_9);
    fNameLabel.setEnabled(false);
    fNameTextField = UIUtils.createSingleTextControl(fieldContainer, SWT.BORDER, false);
    fNameTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fNameTextField.setEnabled(false);
    fNameTextField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String text = fNameTextField.getText();
            if (fIsSettingFields || !StringUtils.isSet(text)) {
                return;
            }
            // Edit Template name
            if (fSelectedTemplate != null) {
                fSelectedTemplate.setName(text);
                if (!fModifiedTemplates.contains(fSelectedTemplate)) {
                    fModifiedTemplates.add(fSelectedTemplate);
                }
                fTableViewer.refresh();
                fTreeViewer.refresh();
            } else // Edit Group name
            if (fSelectedTemplateGroup != null) {
                fSelectedTemplateGroup.setName(text);
                fTreeViewer.refresh();
            }
        }
    });
    fDescriptionLabel = new Label(fieldContainer, SWT.NULL);
    fDescriptionLabel.setText(Messages.TemplateManagerDialog_10);
    fDescriptionLabel.setEnabled(false);
    fDescriptionTextField = new Text(fieldContainer, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    fDescriptionTextField.setEnabled(false);
    gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 100;
    fDescriptionTextField.setLayoutData(gd);
    fDescriptionTextField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String text = fDescriptionTextField.getText();
            if (fIsSettingFields || !StringUtils.isSet(text)) {
                return;
            }
            if (fSelectedTemplate != null) {
                fSelectedTemplate.setDescription(fDescriptionTextField.getText());
                if (!fModifiedTemplates.contains(fSelectedTemplate)) {
                    fModifiedTemplates.add(fSelectedTemplate);
                }
            }
        }
    });
    fFileLabel = new Label(fieldContainer, SWT.NULL);
    fFileLabel.setText(Messages.TemplateManagerDialog_11);
    fFileLabel.setEnabled(false);
    fFileTextField = new Text(fieldContainer, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
    fFileTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fFileTextField.setEnabled(false);
    return composite;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CLabel(org.eclipse.swt.custom.CLabel) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Text(org.eclipse.swt.widgets.Text) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)105 Composite (org.eclipse.swt.widgets.Composite)94 TableViewer (org.eclipse.jface.viewers.TableViewer)78 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)62 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)51 GridData (org.eclipse.swt.layout.GridData)46 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)44 Table (org.eclipse.swt.widgets.Table)38 GridLayout (org.eclipse.swt.layout.GridLayout)34 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)31 Image (org.eclipse.swt.graphics.Image)28 Label (org.eclipse.swt.widgets.Label)27 Viewer (org.eclipse.jface.viewers.Viewer)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)23 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)22 SelectionEvent (org.eclipse.swt.events.SelectionEvent)22 Button (org.eclipse.swt.widgets.Button)21 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)18 TableColumn (org.eclipse.swt.widgets.TableColumn)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)17