Search in sources :

Example 51 with Table

use of org.eclipse.swt.widgets.Table in project ACS by ACS-Community.

the class ReductionsView method createMRParentWidgets.

private void createMRParentWidgets() {
    _updateMRParentFF = new Listener() {

        public void handleEvent(Event event) {
            _MRParentFMCombo.removeAll();
            FaultMember[] fml = _alarmManager.getFaultFamily(_MRParentFFCombo.getText()).getFaultMember();
            for (int j = 0; j < fml.length; j++) {
                _MRParentFMCombo.add(fml[j].getName());
            }
            _MRParentFCCombo.removeAll();
            FaultCode[] fcl = _alarmManager.getFaultFamily(_MRParentFFCombo.getText()).getFaultCode();
            for (int j = 0; j < fcl.length; j++) {
                _MRParentFCCombo.add(String.valueOf(fcl[j].getValue()));
            }
            //_MRParentThresholdText.setText("");
            _MRParentErrorMessageLabel.setText("Please choose a Fault Member and a Fault Code.");
        }
    };
    _updateMRParent = new Listener() {

        public void handleEvent(Event event) {
            if (_tree.getSelection() == null || _tree.getSelection().length == 0)
                return;
            NodeType type = (NodeType) _tree.getSelection()[0].getData();
            if (type != NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA)
                return;
            if (_MRParentFMCombo.getText().isEmpty()) {
                _MRParentErrorMessageLabel.setText("Please choose a Fault Member.");
                return;
            }
            if (_MRParentFCCombo.getText().isEmpty()) {
                _MRParentErrorMessageLabel.setText("Please choose a Fault Code.");
                return;
            }
            if (_MRParentThresholdText.getText().isEmpty()) {
                _MRParentErrorMessageLabel.setText("Please set a Threshold value.");
                return;
            }
            int thr;
            try {
                thr = Integer.parseInt(_MRParentThresholdText.getText());
            } catch (NumberFormatException e) {
                _MRParentErrorMessageLabel.setText("Incorrect Threshold. A number is required.");
                return;
            }
            String[] tr = getTriplet(_tree.getSelection()[0].getText());
            ReductionRule mrr = _reductionManager.getMRParentByTriplet(tr[0], tr[1], Integer.parseInt(tr[2]));
            ReductionRule mrr2 = _reductionManager.getMRParentByTriplet(_MRParentFFCombo.getText(), _MRParentFMCombo.getText(), Integer.parseInt(_MRParentFCCombo.getText()));
            Alarm parent = null;
            Alarm mParent;
            fillMRParentChAlarmList(_MRParentFFCombo.getText(), _MRParentFMCombo.getText(), Integer.parseInt(_MRParentFCCombo.getText()));
            if (mrr == null) {
                _MRParentErrorMessageLabel.setText("There's no Reduction Rule (no children) for the selected Alarm.");
                return;
            } else
                parent = mrr.getParent();
            if (mrr2 == null)
                mParent = _alarmManager.getAlarm(new String(_MRParentFFCombo.getText() + ":" + _MRParentFMCombo.getText() + ":" + _MRParentFCCombo.getText()));
            else {
                mParent = mrr2.getParent();
                if (mrr != mrr2) {
                    ErrorDialog edialog = new ErrorDialog(ReductionsView.this.getViewSite().getShell(), "Reduction Rule Already Exists", "The reduction rule you are trying to create already exists", new Status(IStatus.ERROR, "cl.utfsm.acs.acg", "The reduction rule parent already exists"), IStatus.ERROR);
                    edialog.setBlockOnOpen(true);
                    edialog.open();
                    return;
                }
            }
            if (parent != null) {
                String[] ch = parent.getMultiplicityChildren();
                //Remove all Children from mrr and add them to mrr2.
                try {
                    for (int i = 0; i < ch.length; i++) {
                        Alarm aCh = _alarmManager.getAlarm(ch[i]);
                        if (aCh != null) {
                            if (!_reductionManager.deleteMultiReductionRule(parent, aCh)) {
                                _MRParentErrorMessageLabel.setText("One or more children alarms didn't exist.");
                                continue;
                            }
                            _reductionManager.addMultiReductionRule(mParent, aCh);
                        }
                    }
                    _reductionManager.updateMultiThreshold(mParent, thr);
                } catch (IllegalOperationException e) {
                    _MRParentErrorMessageLabel.setText("The parent alarm didn't exist.");
                }
                _tree.getSelection()[0].setText("<" + mParent.getAlarmId().replace(':', ',') + ">");
                _MRParentErrorMessageLabel.setText("");
            }
            if (mrr != null && mrr.getChildrenCount() < mrr.getThreshold()) {
                _MRParentErrorMessageLabel.setText("You need to have at least threshold (" + mrr.getThreshold() + ") childs for this triplet.");
                return;
            }
            if (tr[0].compareTo(_MRParentFFCombo.getText()) != 0 || tr[1].compareTo(_MRParentFMCombo.getText()) != 0 || tr[2].compareTo(_MRParentFCCombo.getText()) != 0) {
                sortReductionRulesList();
                Triplet t = mParent.getTriplet();
                selectElementFromTree("<" + t.getFaultFamily() + "," + t.getFaultMember() + "," + t.getFaultCode() + ">", false);
            }
        }
    };
    _updateMRParentChFF = new Listener() {

        public void handleEvent(Event event) {
            _MRParentChFMCombo.removeAll();
            _MRParentChFMCombo.add("Any");
            if (_MRParentChFFCombo.getText().compareTo("Any") != 0) {
                FaultMember[] fml = _alarmManager.getFaultFamily(_MRParentChFFCombo.getText()).getFaultMember();
                for (int j = 0; j < fml.length; j++) {
                    _MRParentChFMCombo.add(fml[j].getName());
                }
            }
            _MRParentChFMCombo.select(0);
            _MRParentChFCCombo.removeAll();
            _MRParentChFCCombo.add("Any");
            if (_MRParentChFFCombo.getText().compareTo("Any") != 0) {
                FaultCode[] fcl = _alarmManager.getFaultFamily(_MRParentChFFCombo.getText()).getFaultCode();
                for (int j = 0; j < fcl.length; j++) {
                    _MRParentChFCCombo.add(String.valueOf(fcl[j].getValue()));
                }
            }
            _MRParentChFCCombo.select(0);
            TreeItem[] tmp = _tree.getSelection();
            if (tmp == null || tmp.length == 0)
                return;
            TreeItem item = tmp[0];
            String[] triplet = getTriplet(item.getText());
            fillMRParentChAlarmList(triplet[0], triplet[1], Integer.parseInt(triplet[2]));
        }
    };
    _updateMRParentCh = new Listener() {

        public void handleEvent(Event event) {
            TreeItem[] tmp = _tree.getSelection();
            if (tmp == null || tmp.length == 0)
                return;
            TreeItem item = tmp[0];
            String[] triplet = getTriplet(item.getText());
            fillMRParentChAlarmList(triplet[0], triplet[1], Integer.parseInt(triplet[2]));
        }
    };
    _MRParentGroup = new Group(_compInitial, SWT.SHADOW_ETCHED_IN);
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    _MRParentGroup.setLayout(gl);
    _MRParentGroup.setLayoutData(gd);
    _MRParentFtGroup = new Group(_MRParentGroup, SWT.SHADOW_ETCHED_IN);
    gl = new GridLayout();
    gl.numColumns = 2;
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentFtGroup.setLayout(gl);
    _MRParentFtGroup.setLayoutData(gd);
    _MRParentFtGroup.setText("Primary Alarm");
    _MRParentFFLabel = new Label(_MRParentFtGroup, SWT.NONE);
    _MRParentFFLabel.setText("Fault Family:");
    _MRParentFFCombo = new Combo(_MRParentFtGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentFFCombo.setLayoutData(gd);
    _MRParentFFCombo.addListener(SWT.Selection, _updateMRParentFF);
    _MRParentFMLabel = new Label(_MRParentFtGroup, SWT.NONE);
    _MRParentFMLabel.setText("Fault Member:");
    _MRParentFMCombo = new Combo(_MRParentFtGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentFMCombo.setLayoutData(gd);
    _MRParentFMCombo.addListener(SWT.Selection, _updateMRParent);
    _MRParentFCLabel = new Label(_MRParentFtGroup, SWT.NONE);
    _MRParentFCLabel.setText("Fault Code:");
    _MRParentFCCombo = new Combo(_MRParentFtGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentFCCombo.setLayoutData(gd);
    _MRParentFCCombo.addListener(SWT.Selection, _updateMRParent);
    _MRParentThresholdLabel = new Label(_MRParentFtGroup, SWT.NONE);
    _MRParentThresholdLabel.setText("Threshold:");
    _MRParentThresholdText = new Text(_MRParentFtGroup, SWT.BORDER);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentThresholdText.setLayoutData(gd);
    _MRParentThresholdText.addListener(SWT.Modify, _updateMRParent);
    //
    _MRParentChGroup = new Group(_MRParentGroup, SWT.SHADOW_ETCHED_IN);
    gl = new GridLayout();
    gl.numColumns = 1;
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    _MRParentChGroup.setLayout(gl);
    _MRParentChGroup.setLayoutData(gd);
    _MRParentChGroup.setText("Alarms to Ignore");
    _MRParentChFilterGroup = new Group(_MRParentChGroup, SWT.SHADOW_ETCHED_IN);
    gl = new GridLayout();
    gl.numColumns = 2;
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFilterGroup.setLayout(gl);
    _MRParentChFilterGroup.setLayoutData(gd);
    _MRParentChFilterGroup.setText("Filter Options");
    _MRParentChFilterLevelGroup = new Group(_MRParentChFilterGroup, SWT.SHADOW_ETCHED_IN);
    gl = new GridLayout();
    gl.numColumns = 3;
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFilterLevelGroup.setLayout(gl);
    _MRParentChFilterLevelGroup.setLayoutData(gd);
    _MRParentChFilterLevelGroup.setText("Show");
    _MRParentChAllRadio = new Button(_MRParentChFilterLevelGroup, SWT.RADIO);
    _MRParentChAllRadio.setText("All");
    _MRParentChAllRadio.addListener(SWT.Selection, _updateMRParentCh);
    _MRParentChSelectedRadio = new Button(_MRParentChFilterLevelGroup, SWT.RADIO);
    _MRParentChSelectedRadio.setText("Selected");
    _MRParentChSelectedRadio.addListener(SWT.Selection, _updateMRParentCh);
    _MRParentChUnselectedRadio = new Button(_MRParentChFilterLevelGroup, SWT.RADIO);
    _MRParentChUnselectedRadio.setText("Unselected");
    _MRParentChUnselectedRadio.addListener(SWT.Selection, _updateMRParentCh);
    _MRParentChFFLabel = new Label(_MRParentChFilterGroup, SWT.NONE);
    _MRParentChFFLabel.setText("Fault Family:");
    _MRParentChFFCombo = new Combo(_MRParentChFilterGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFFCombo.setLayoutData(gd);
    _MRParentChFFCombo.addListener(SWT.Selection, _updateMRParentChFF);
    _MRParentChFMLabel = new Label(_MRParentChFilterGroup, SWT.NONE);
    _MRParentChFMLabel.setText("Fault Member:");
    _MRParentChFMCombo = new Combo(_MRParentChFilterGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFMCombo.setLayoutData(gd);
    _MRParentChFMCombo.addListener(SWT.Selection, _updateMRParentCh);
    _MRParentChFCLabel = new Label(_MRParentChFilterGroup, SWT.NONE);
    _MRParentChFCLabel.setText("Fault Code:");
    _MRParentChFCCombo = new Combo(_MRParentChFilterGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFCCombo.setLayoutData(gd);
    _MRParentChFCCombo.addListener(SWT.Selection, _updateMRParentCh);
    _MRParentChFilterLabel = new Label(_MRParentChFilterGroup, SWT.NONE);
    _MRParentChFilterLabel.setText("Filter RegEx:");
    _MRParentChFilterText = new Text(_MRParentChFilterGroup, SWT.BORDER);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFilterText.setLayoutData(gd);
    _MRParentChFilterText.addListener(SWT.Modify, _updateMRParentCh);
    _MRParentChAlarmList = new Table(_MRParentChGroup, SWT.BORDER);
    gd = new GridData();
    gd.verticalAlignment = SWT.FILL;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.grabExcessHorizontalSpace = true;
    _MRParentChAlarmList.setLayoutData(gd);
    _MRParentChAlarmList.addListener(SWT.KeyUp, _addRule);
    _MRParentChAlarmList.addListener(SWT.MouseDoubleClick, _addRule);
    _MRParentErrorMessageLabel = new Label(_MRParentGroup, SWT.NONE);
    _MRParentErrorMessageLabel.setText("");
    _MRParentErrorMessageLabel.setForeground(getViewSite().getShell().getDisplay().getSystemColor(SWT.COLOR_RED));
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    _MRParentErrorMessageLabel.setLayoutData(gd);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Group(org.eclipse.swt.widgets.Group) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) Table(org.eclipse.swt.widgets.Table) TreeItem(org.eclipse.swt.widgets.TreeItem) Triplet(cern.laser.business.data.Triplet) Label(org.eclipse.swt.widgets.Label) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) IllegalOperationException(cl.utfsm.acs.acg.core.IllegalOperationException) ReductionRule(cl.utfsm.acs.acg.core.ReductionRule) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) Alarm(cern.laser.business.data.Alarm) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 52 with Table

use of org.eclipse.swt.widgets.Table in project ACS by ACS-Community.

the class ArchivingListPart method postConstruct.

@PostConstruct
public void postConstruct(Composite parent, IEventBroker eventBroker) {
    try {
        em = EventModel.getInstance();
    } catch (Throwable thr) {
        thr.printStackTrace();
        IStatus someStatus = statusReporter.newStatus(IStatus.ERROR, "Connection with NCs failed.", thr);
        statusReporter.report(someStatus, StatusReporter.SHOW);
        throw new RuntimeException(thr);
    }
    logger = em.getLogger();
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.verticalSpacing = 0;
    parent.setLayout(gridLayout);
    //		buildCustomToolBar(parent);
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    /*
		 * "Time "+timeStamp+" "+m_channelName+" "+component+" "+count+"
		 * "+channelEventCount+" " +" "+evtTypeName+"
		 * "+evtCounter.get(evtTypeName)
		 */
    TableViewerColumn tvcol = new TableViewerColumn(viewer, SWT.NONE, 0);
    tvcol.setLabelProvider(new TimeStampLabelProvider());
    TableColumn col = tvcol.getColumn();
    col.setText("Timestamp");
    col.setWidth(190);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 1);
    tvcol.setLabelProvider(new EventSourceLabelProvider());
    col = tvcol.getColumn();
    col.setText("Device");
    col.setWidth(100);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 2);
    tvcol.setLabelProvider(new BaciParameterLabelProvider());
    col = tvcol.getColumn();
    col.setText("Property");
    col.setWidth(100);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 3);
    tvcol.setLabelProvider(new BaciPropertyValueLabelProvider());
    col = tvcol.getColumn();
    col.setText("Value");
    col.setWidth(100);
    col.setAlignment(SWT.LEFT);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getTable());
    viewer.setContentProvider(new ArchivingListContentProvider(em));
    viewer.setInput(new Object());
    pel = new PopulateEventList(logger, viewer, new StatusLineWriter(eventBroker), em.getArchQueue(), "Monitor points");
    eventListThread = pel.getThreadForEventList();
    eventListThread.start();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Table(org.eclipse.swt.widgets.Table) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) StatusLineWriter(alma.acs.eventbrowser.status.StatusLineWriter) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) PostConstruct(javax.annotation.PostConstruct)

Example 53 with Table

use of org.eclipse.swt.widgets.Table in project ACS by ACS-Community.

the class EventListPart method postConstruct.

/**
	 */
@PostConstruct
public void postConstruct(Composite parent, final IEclipseContext context, IEventBroker eventBroker, EMenuService menuService) {
    try {
        em = EventModel.getInstance();
    } catch (Throwable thr) {
        thr.printStackTrace();
        IStatus someStatus = statusReporter.newStatus(IStatus.ERROR, "Connection with NCs failed.", thr);
        statusReporter.report(someStatus, StatusReporter.SHOW);
        throw new RuntimeException(thr);
    }
    logger = em.getLogger();
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.verticalSpacing = 0;
    parent.setLayout(gridLayout);
    // TODO: We currently have the filter text control in the regular view toolbar.
    //       The e3 eventGUI had a "custom tool bar" inserted here.
    //       We should decide which way it's better.
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    /*
		 * "Time "+timeStamp+" "+m_channelName+" "+component+" "+count+"
		 * "+channelEventCount+" " +" "+evtTypeName+"
		 * "+evtCounter.get(evtTypeName)
		 */
    TableViewerColumn tvcol = new TableViewerColumn(viewer, SWT.NONE, 0);
    tvcol.setLabelProvider(new TimeStampLabelProvider());
    TableColumn col = tvcol.getColumn();
    col.setText("Timestamp");
    col.setWidth(180);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 1);
    tvcol.setLabelProvider(new EventSourceLabelProvider());
    col = tvcol.getColumn();
    col.setText("Event source");
    col.setWidth(150);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 2);
    tvcol.setLabelProvider(new CountLabelProvider());
    col = tvcol.getColumn();
    col.setText("# Events in channel");
    col.setWidth(50);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 3);
    tvcol.setLabelProvider(new EventTypeLabelProvider());
    col = tvcol.getColumn();
    col.setText("Event type");
    col.setWidth(150);
    col.setAlignment(SWT.LEFT);
    tvcol = new TableViewerColumn(viewer, SWT.NONE, 4);
    tvcol.setLabelProvider(new EventTypeCountLabelProvider());
    col = tvcol.getColumn();
    col.setText("# Events this type");
    col.setWidth(50);
    col.setAlignment(SWT.LEFT);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getTable());
    viewer.setContentProvider(new EventListViewContentProvider(em));
    // Attach a selection listener to our event list that will post the selected event for the event details list
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() == 1) {
                selectionService.setSelection(selection.getFirstElement());
            }
        }
    });
    viewer.setInput(new Object());
    hookContextMenu(menuService);
    pel = new PopulateEventList(logger, viewer, new StatusLineWriter(eventBroker), em.getEventQueue(), "NC Events");
    eventListThread = pel.getThreadForEventList();
    eventListThread.start();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Table(org.eclipse.swt.widgets.Table) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) StatusLineWriter(alma.acs.eventbrowser.status.StatusLineWriter) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) PostConstruct(javax.annotation.PostConstruct)

Example 54 with Table

use of org.eclipse.swt.widgets.Table in project translationstudio8 by heartsome.

the class ConversionWizardPage method createConversionOptionsGroup.

/**
	 * 转换选项组
	 * @param contents
	 *            ;
	 */
private void createConversionOptionsGroup(Composite contents) {
    Group options = new Group(contents, SWT.NONE);
    //$NON-NLS-1$
    options.setText(Messages.getString("wizard.ConversionWizardPage.options"));
    options.setLayout(new GridLayout(1, false));
    options.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    /* 如果已经存在,是否要替换 */
    final Button btnReplaceTarget = new Button(options, SWT.CHECK);
    //$NON-NLS-1$
    btnReplaceTarget.setText(Messages.getString("wizard.ConversionWizardPage.btnReplaceTarget"));
    btnReplaceTarget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnReplaceTarget.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isReplaceTarget = btnReplaceTarget.getSelection();
            for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
                conversionConfigBean.setReplaceTarget(btnReplaceTarget.getSelection());
            }
            validate();
        }
    });
    final Button btnOpenPreTrans = new Button(options, SWT.CHECK);
    btnOpenPreTrans.setText(Messages.getString("wizard.ConversionWizardPage.btnOpenPreTrans"));
    btnOpenPreTrans.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnOpenPreTrans.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isOpenPreTrans = btnOpenPreTrans.getSelection();
        }
    });
    Composite composite = new Composite(options, SWT.NONE);
    GridLayout gd = new GridLayout(1, false);
    gd.marginWidth = 0;
    gd.marginHeight = 0;
    composite.setLayout(gd);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    Label tgtLangLbl = new Label(composite, SWT.NONE);
    tgtLangLbl.setText(Messages.getString("wizard.ConversionWizardPage.tgtLangLbl"));
    tgtLangViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    Table tgtLangTable = tgtLangViewer.getTable();
    GridData gdTgtLangTable = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gdTgtLangTable.heightHint = 80;
    tgtLangTable.setLayoutData(gdTgtLangTable);
    tgtLangViewer.setLabelProvider(new LanguageLabelProvider());
    tgtLangViewer.setContentProvider(new ArrayContentProvider());
    tgtLangViewer.setInput(conversionConfigBeans.get(0).getTgtLangList());
    tgtLangViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            @SuppressWarnings("unchecked") List<Language> selectedList = sel.toList();
            for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
                conversionConfigBean.setHasSelTgtLangList(selectedList);
            }
            validate();
        }
    });
    tgtLangViewer.getTable().select(0);
    IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
    btnReplaceTarget.setSelection(dialogSettings.getBoolean(REPLACE_TARGET));
    btnOpenPreTrans.setSelection(dialogSettings.getBoolean(OPEN_PRE_TRANS));
    this.isOpenPreTrans = btnOpenPreTrans.getSelection();
    isReplaceTarget = btnReplaceTarget.getSelection();
    for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
        conversionConfigBean.setReplaceTarget(isReplaceTarget);
    }
    validate();
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) LanguageLabelProvider(net.heartsome.cat.ts.ui.composite.LanguageLabelProvider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ConversionConfigBean(net.heartsome.cat.convert.ui.model.ConversionConfigBean) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) WritableList(org.eclipse.core.databinding.observable.list.WritableList) List(java.util.List) ArrayList(java.util.ArrayList) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 55 with Table

use of org.eclipse.swt.widgets.Table in project translationstudio8 by heartsome.

the class ReverseConversionWizardPage method createFilesGroup.

/**
	 * 创建文件列表区域
	 * @param contents
	 *            ;
	 */
private Composite createFilesGroup(Composite contents) {
    Composite filesComposite = new Composite(contents, SWT.NONE);
    filesComposite.setLayout(new GridLayout(1, false));
    filesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    tableData.heightHint = 100;
    filesTable.setLayoutData(tableData);
    filesTable.setLinesVisible(true);
    filesTable.setHeaderVisible(true);
    filesTable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            TableItem[] selected = filesTable.getSelection();
            if (selected.length == 0) {
                return;
            }
            //$NON-NLS-1$
            String strTgtEnc = "";
            for (int i = 0; i < selected.length; i++) {
                String curTgtEnc = selected[i].getText(2);
                if (i == 0) {
                    strTgtEnc = curTgtEnc;
                } else {
                    if (!strTgtEnc.equals(curTgtEnc)) {
                        //$NON-NLS-1$
                        strTgtEnc = "";
                        break;
                    }
                }
            }
            if (!"".equals(strTgtEnc)) {
                //$NON-NLS-1$
                tgtEncCombo.setText(strTgtEnc);
            } else {
                tgtEncCombo.deselectAll();
            }
        }
    });
    tableViewer = new TableViewer(filesTable);
    lineNumberColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    lineNumberColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.lineNumberColumn"));
    xliffColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    //$NON-NLS-1$
    xliffColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.xliffColumn"));
    tgtEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    //$NON-NLS-1$
    tgtEncColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.tgtEncColumn"));
    targetColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    //$NON-NLS-1$
    targetColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.targetColumn"));
    IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] { "index", "source", "targetEncoding", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "target" });
    ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class), valueProperties);
    filesComposite.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent arg0) {
            int width = filesTable.getClientArea().width;
            lineNumberColumn.setWidth(width * 1 / 10);
            targetColumn.setWidth(width * 4 / 10);
            tgtEncColumn.setWidth(width * 1 / 10);
            xliffColumn.setWidth(width * 4 / 10);
        }
    });
    return filesComposite;
}
Also used : Table(org.eclipse.swt.widgets.Table) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) WritableList(org.eclipse.core.databinding.observable.list.WritableList) ConversionConfigBean(net.heartsome.cat.convert.ui.model.ConversionConfigBean) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IValueProperty(org.eclipse.core.databinding.property.value.IValueProperty) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

Table (org.eclipse.swt.widgets.Table)770 GridData (org.eclipse.swt.layout.GridData)368 Composite (org.eclipse.swt.widgets.Composite)325 TableColumn (org.eclipse.swt.widgets.TableColumn)324 TableViewer (org.eclipse.jface.viewers.TableViewer)303 GridLayout (org.eclipse.swt.layout.GridLayout)255 TableItem (org.eclipse.swt.widgets.TableItem)210 SelectionEvent (org.eclipse.swt.events.SelectionEvent)204 Label (org.eclipse.swt.widgets.Label)179 Button (org.eclipse.swt.widgets.Button)161 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)145 Point (org.eclipse.swt.graphics.Point)138 Text (org.eclipse.swt.widgets.Text)102 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)96 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)95 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)89 FillLayout (org.eclipse.swt.layout.FillLayout)87 Shell (org.eclipse.swt.widgets.Shell)82 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)81 Event (org.eclipse.swt.widgets.Event)80