Search in sources :

Example 1 with ControlAdapter

use of org.eclipse.swt.events.ControlAdapter in project translationstudio8 by heartsome.

the class MatchViewPart method createPartControl.

@Override
public void createPartControl(Composite parent) {
    GridLayout parentGl = new GridLayout(1, false);
    parentGl.marginWidth = 0;
    parentGl.marginHeight = 0;
    parent.setLayout(parentGl);
    final Composite composite = new Composite(parent, SWT.NONE);
    GridLayout compositeGl = new GridLayout(1, false);
    compositeGl.marginBottom = -1;
    compositeGl.marginLeft = -1;
    compositeGl.marginRight = -1;
    compositeGl.marginTop = 0;
    compositeGl.marginWidth = 0;
    compositeGl.marginHeight = 0;
    compositeGl.verticalSpacing = 0;
    composite.setLayout(compositeGl);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    // sourceText = new StyledText(composite, SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
    // GridData sTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    // Font f = JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT);
    // sourceText.setFont(f);
    // int lineH = sourceText.getLineHeight() * 3;
    // sTextGd.heightHint = lineH;
    // sTextGd.minimumHeight = lineH;
    // sourceText.setLayoutData(sTextGd);
    SashForm sashForm = new SashForm(composite, SWT.VERTICAL);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    sourceText = new SegmentViewer(sashForm, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL, null);
    StyledText srcTextControl = sourceText.getTextWidget();
    srcTextControl.setLineSpacing(net.heartsome.cat.ts.ui.Constants.SEGMENT_LINE_SPACING);
    srcTextControl.setLeftMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_LEFT_MARGIN);
    srcTextControl.setRightMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_RIGHT_MARGIN);
    srcTextControl.setTopMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_TOP_MARGIN);
    srcTextControl.setBottomMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_TOP_MARGIN);
    srcTextControl.setFont(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT));
    sourceText.setSource("");
    sourceColunmCellRenderer.setSegmentViewer(sourceText);
    GridData sTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    Font f = JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT);
    srcTextControl.setFont(f);
    int lineH = srcTextControl.getLineHeight() * 2;
    sTextGd.heightHint = lineH;
    sTextGd.minimumHeight = lineH;
    srcTextControl.setLayoutData(sTextGd);
    net.heartsome.cat.ts.ui.innertag.tagstyle.TagStyleConfigurator.configure(sourceText);
    gridTable = new Grid(sashForm, SWT.BORDER | SWT.V_SCROLL);
    gridTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    gridTable.setHeaderVisible(false);
    gridTable.setAutoHeight(true);
    gridTable.setRowsResizeable(true);
    gridTable.setData("selectedBgColor", selectedBgColor);
    final GridColumn sourceCln = new GridColumn(gridTable, SWT.NONE);
    sourceColunmCellRenderer.setFont(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT));
    sourceCln.setCellRenderer(sourceColunmCellRenderer);
    sourceCln.setText(Messages.getString("view.MatchViewPart.sourceCln"));
    sourceCln.setWordWrap(true);
    sourceCln.setAlignment(SWT.CENTER);
    sourceCln.setResizeable(false);
    final GridColumn typeCln = new GridColumn(gridTable, SWT.NONE);
    typeColumnCellRenderer.setVerticalAlignment(SWT.CENTER);
    typeCln.setCellRenderer(typeColumnCellRenderer);
    typeCln.setText(Messages.getString("view.MatchViewPart.typeCln"));
    typeCln.setWordWrap(true);
    typeCln.setAlignment(SWT.CENTER);
    typeCln.setResizeable(false);
    final GridColumn targetCln = new GridColumn(gridTable, SWT.NONE);
    targetColumnCellRenderer.setFont(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT));
    targetCln.setCellRenderer(targetColumnCellRenderer);
    targetCln.setText(Messages.getString("view.MatchViewPart.targetCln"));
    targetCln.setWordWrap(true);
    targetCln.setAlignment(SWT.CENTER);
    targetCln.setResizeable(false);
    // 设置可复制功能
    copyEnable = new GridCopyEnable(gridTable);
    sourceColunmCellRenderer.setCopyEnable(copyEnable);
    targetColumnCellRenderer.setCopyEnable(copyEnable);
    Composite statusComposite = new Composite(composite, SWT.NONE);
    GridLayout statusComptGridLayout = new GridLayout(2, false);
    statusComptGridLayout.marginBottom = -1;
    statusComptGridLayout.marginLeft = -1;
    statusComptGridLayout.marginRight = -1;
    statusComptGridLayout.marginTop = -1;
    statusComptGridLayout.marginWidth = 0;
    statusComptGridLayout.marginHeight = 0;
    statusComposite.setLayout(statusComptGridLayout);
    statusComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    tipLabel = new CLabel(statusComposite, SWT.NONE);
    tipLabel.setAlignment(SWT.LEFT);
    infoLabel = new CLabel(statusComposite, SWT.NONE);
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd.heightHint = 20;
    infoLabel.setLayoutData(gd);
    infoLabel.setAlignment(SWT.RIGHT);
    // 设置列宽按比例4.5:1:4.5
    composite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            Rectangle area = composite.getClientArea();
            Point preferredSize = gridTable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            // - 2 * gridTable.getBorderWidth();
            int width = area.width;
            if (preferredSize.y > area.height + gridTable.getHeaderHeight()) {
                Point vBarSize = gridTable.getVerticalBar().getSize();
                width -= vBarSize.x;
            }
            gridTable.setSize(area.width, area.height);
            width = width - 42;
            sourceCln.setWidth((int) (width * 0.5));
            typeCln.setWidth(42);
            targetCln.setWidth((int) (width * 0.5));
        }
    });
    gridTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            StyledText text = sourceText.getTextWidget();
            text.setText(text.getText());
            updateActionState();
            GridItem[] selItems = gridTable.getSelection();
            if (selItems.length != 1) {
                return;
            }
            GridItem item = selItems[0];
            setMatchMessage(infoLabelImage, item.getData("info").toString(), item.getData("infoTooltip").toString());
            composite.layout();
        }
    });
    gridTable.addListener(SWT.MouseDoubleClick, new Listener() {

        public void handleEvent(Event event) {
            menuMgr.acceptMatchAction.run();
        }
    });
    createActions();
    sashForm.setWeights(new int[] { 3, 8 });
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) SegmentViewer(net.heartsome.cat.ts.ui.innertag.SegmentViewer) StyledText(org.eclipse.swt.custom.StyledText) ISelectionListener(org.eclipse.ui.ISelectionListener) Listener(org.eclipse.swt.widgets.Listener) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) Composite(org.eclipse.swt.widgets.Composite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) Grid(org.eclipse.nebula.widgets.grid.Grid) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) Point(org.eclipse.swt.graphics.Point) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridItem(org.eclipse.nebula.widgets.grid.GridItem) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) GridCopyEnable(net.heartsome.cat.ts.ui.grid.GridCopyEnable) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 2 with ControlAdapter

use of org.eclipse.swt.events.ControlAdapter in project tdi-studio-se by Talend.

the class VersionManagementPage method createItemTableColumns.

@Override
protected void createItemTableColumns() {
    TableColumn itemColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    itemColumn.setText(Messages.getString("VersionManagementDialog.Items"));
    itemColumn.setWidth(110);
    TableColumn oldVersionColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    oldVersionColumn.setText(Messages.getString("VersionManagementDialog.Version"));
    oldVersionColumn.setWidth(60);
    TableColumn versionColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    versionColumn.setText(Messages.getString("VersionManagementDialog.NewVersion"));
    versionColumn.setWidth(82);
    final TableColumn delColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    delColumn.setText("");
    delColumn.setWidth(26);
    delColumn.setResizable(false);
    versionColumn.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            if (!isFixedVersion()) {
                refreshTableItems();
            }
        }
    });
    itemTable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            checkButtonsState();
        }
    });
}
Also used : ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 3 with ControlAdapter

use of org.eclipse.swt.events.ControlAdapter in project tesb-studio-se by Talend.

the class XmlTableForm method addFieldsListeners.

private void addFieldsListeners() {
    nameFilter.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String pattern = nameFilter.getText();
            SearchPattern matcher = new SearchPattern();
            matcher.setPattern(pattern);
            final List<Item> newList = new ArrayList<Item>();
            for (Item item : items) {
                if (matcher.matches(item.getLabel())) {
                    newList.add(item);
                }
            }
            reftesTableContent(newList);
            completeListener.setComplete(!getSelectionItems().isEmpty());
        }
    });
    // Event checkBox action
    table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (e.detail == SWT.CHECK) {
                ((Item) e.item.getData()).setCheck(((TableItem) e.item).getChecked());
                if (null != completeListener) {
                    completeListener.setComplete(!getSelectionItems().isEmpty());
                }
            }
        }
    });
    table.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            table.getColumns()[0].setWidth(table.getClientArea().width - 2 * table.getBorderWidth());
        }
    });
    selectAllTablesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            setChecked(true);
        }
    });
    selectNoneTablesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            setChecked(false);
        }
    });
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) TableItem(org.eclipse.swt.widgets.TableItem) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SearchPattern(org.eclipse.ui.dialogs.SearchPattern) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 4 with ControlAdapter

use of org.eclipse.swt.events.ControlAdapter in project cubrid-manager by CUBRID.

the class BrokerStatusView method createPartControl.

/**
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 * 
	 * @param parent the parent composite
	 */
public void createPartControl(Composite parent) {
    final ScrolledComposite scrolledComp = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    composite = new Composite(scrolledComp, SWT.NONE);
    composite.setLayout(new GridLayout());
    BrokerTblColumnSetHelp bcsh = BrokerTblColumnSetHelp.getInstance();
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusBasicColumn, BrokerStatusBasicColumn.values());
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusAsColumn, BrokerStatusAsColumn.values());
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusJqColumn, BrokerStatusJqColumn.values());
    if (isSupportNewBrokerParamPropery) {
        createBasicTable(composite);
    }
    createAsTable(composite);
    createJobTable(composite);
    makeActions();
    composite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent event) {
            updateTableLayout();
        }
    });
    scrolledComp.setContent(composite);
    scrolledComp.setExpandHorizontal(true);
    scrolledComp.setExpandVertical(true);
    scrolledComp.setMinHeight(300);
    scrolledComp.setMinWidth(800);
    new StatusUpdate().start();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) BrokerTblColumnSetHelp(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerTblColumnSetHelp) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 5 with ControlAdapter

use of org.eclipse.swt.events.ControlAdapter in project cubrid-manager by CUBRID.

the class BrokerDashboardViewPart method createPartControl.

/**
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 * 
	 * @param parent the parent composite
	 */
public void createPartControl(Composite parent) {
    final ScrolledComposite scrolledComp = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    composite = new Composite(scrolledComp, SWT.NONE);
    composite.setLayout(new GridLayout());
    BrokerTblColumnSetHelp bcsh = BrokerTblColumnSetHelp.getInstance();
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusBasicColumn, BrokerStatusBasicColumn.values());
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusAsColumn, BrokerStatusAsColumn.values());
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusJqColumn, BrokerStatusJqColumn.values());
    brokerTablePart.setServerInfo(serverInfo);
    brokerTablePart.setAppendDiag(true);
    basicTableViewer = brokerTablePart.createBasicTable(composite);
    asTableViewer = brokerTablePart.createAsTable(composite);
    jqTableViewer = brokerTablePart.createJobTable(composite);
    makeActions();
    composite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent event) {
            updateTableLayout();
        }
    });
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            IStructuredSelection selection = (IStructuredSelection) asTableViewer.getSelection();
            ApplyServerInfo as = (ApplyServerInfo) (selection.toArray()[0]);
            RestartAction restartAcion = new RestartAction(as.getAs_id());
            manager.add(restartAcion);
        }
    });
    Menu contextMenu = menuManager.createContextMenu(asTableViewer.getControl());
    asTableViewer.getControl().setMenu(contextMenu);
    scrolledComp.setContent(composite);
    scrolledComp.setExpandHorizontal(true);
    scrolledComp.setExpandVertical(true);
    scrolledComp.setMinHeight(300);
    scrolledComp.setMinWidth(800);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) IMenuListener(org.eclipse.jface.action.IMenuListener) GridLayout(org.eclipse.swt.layout.GridLayout) BrokerTblColumnSetHelp(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerTblColumnSetHelp) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

ControlAdapter (org.eclipse.swt.events.ControlAdapter)19 ControlEvent (org.eclipse.swt.events.ControlEvent)19 Composite (org.eclipse.swt.widgets.Composite)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 GridLayout (org.eclipse.swt.layout.GridLayout)8 GridData (org.eclipse.swt.layout.GridData)7 ModifyEvent (org.eclipse.swt.events.ModifyEvent)5 ModifyListener (org.eclipse.swt.events.ModifyListener)5 Point (org.eclipse.swt.graphics.Point)5 TableColumn (org.eclipse.swt.widgets.TableColumn)5 SashForm (org.eclipse.swt.custom.SashForm)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 Label (org.eclipse.swt.widgets.Label)4 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)3 FillLayout (org.eclipse.swt.layout.FillLayout)3 BrokerTblColumnSetHelp (com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerTblColumnSetHelp)2 java.util (java.util)2 ArrayList (java.util.ArrayList)2 GridCopyEnable (net.heartsome.cat.ts.ui.grid.GridCopyEnable)2