Search in sources :

Example 1 with ListDialog

use of org.eclipse.ui.dialogs.ListDialog in project GT by Tencent.

the class APTSMAPSCTabItem method createAPTSMAPSCTablItemUI.

/**
	 * 初始化UI
	 * @param parent
	 */
private void createAPTSMAPSCTablItemUI(Composite parent) {
    int margin = 5;
    //		FormData expandBtnFD = new FormData();
    //		expandBtnFD.left = new FormAttachment(0, margin);
    //		expandBtnFD.top = new FormAttachment(0, margin);
    //		expandBtnFD.height = 16;
    //		expandBtnFD.width = 16;
    //		
    //		Button expandBtn = new Button(parent, SWT.NONE);
    //		expandBtn.setToolTipText("展开/折叠");
    //		expandBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/add.png").createImage());
    //		expandBtn.setLayoutData(expandBtnFD);
    //		/**
    //		 * TODO 折叠按钮单击响应
    //		 */
    FormData compareBtnFD = new FormData();
    compareBtnFD.left = new FormAttachment(0, margin);
    compareBtnFD.top = new FormAttachment(0, margin);
    compareBtnFD.height = 16;
    compareBtnFD.width = 16;
    Button compareBtn = new Button(parent, SWT.NONE);
    compareBtn.setToolTipText("对比其他smaps");
    compareBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/stat.png").createImage());
    compareBtn.setLayoutData(compareBtnFD);
    compareBtn.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            //首先获取当前已经打开的smaps文件
            CTabItem[] openedTabItems = APTSMAPSCTabItem.this.getParent().getItems();
            if (openedTabItems != null && openedTabItems.length > 1) {
                ArrayList<String> files = new ArrayList<String>();
                for (int i = 0; i < openedTabItems.length; i++) {
                    if (!APTSMAPSCTabItem.this.getText().equals(openedTabItems[i].getText())) {
                        files.add(openedTabItems[i].getText());
                    }
                }
                ListDialog dialog = new ListDialog(Display.getCurrent().getActiveShell());
                dialog.setContentProvider(new ArrayContentProvider());
                dialog.setLabelProvider(new LabelProvider());
                dialog.setInput(files);
                dialog.setHelpAvailable(false);
                dialog.setTitle("选择要对比的smaps文件");
                // 返回值为按钮
                dialog.open();
                Object[] selectedFiles = dialog.getResult();
                if (selectedFiles != null && selectedFiles.length > 0) {
                    String fileName = (String) selectedFiles[0];
                    Object sourceData = ((APTSMAPSCTabItem) CTabFolderItemUtil.getTabItem(openedTabItems, fileName)).getSourceData();
                    Object diffSouceData = SmapsUtil.getDiff((SMAPSSourceDataItem) (APTSMAPSCTabItem.this.getSourceData()), (SMAPSSourceDataItem) sourceData);
                    SMAPSView smapsViewPart = (SMAPSView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(SMAPSView.ID);
                    smapsViewPart.openSmapsDataInSMAPSView(diffSouceData, "diff");
                }
            } else {
                MessageDialog.openInformation(Display.getDefault().getActiveShell(), "提示", "No other smaps file opened");
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    FormData treeViewerFD = new FormData();
    treeViewerFD.left = new FormAttachment(0, margin);
    treeViewerFD.top = new FormAttachment(compareBtn, margin);
    treeViewerFD.right = new FormAttachment(100, -margin);
    treeViewerFD.bottom = new FormAttachment(100, -margin);
    viewer = new TreeViewer(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    for (int i = 0; i < COLUMN_NAME.length; i++) {
        new TreeColumn(viewer.getTree(), SWT.LEFT).setText(COLUMN_NAME[i]);
        viewer.getTree().getColumn(i).setWidth(COLUMN_WIDTH[i]);
    }
    viewer.getControl().setLayoutData(treeViewerFD);
    //设置表头和表格线可见
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
}
Also used : FormData(org.eclipse.swt.layout.FormData) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) SMAPSView(com.tencent.wstt.apt.ui.views.SMAPSView) Button(org.eclipse.swt.widgets.Button) TreeColumn(org.eclipse.swt.widgets.TreeColumn) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) FormAttachment(org.eclipse.swt.layout.FormAttachment) ListDialog(org.eclipse.ui.dialogs.ListDialog) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with ListDialog

use of org.eclipse.ui.dialogs.ListDialog in project GT by Tencent.

the class StubAnalysisView method makeActions.

/**
	 * 初始化各种Action
	 */
private void makeActions() {
    openLogOnPCAction = new Action() {

        public void run() {
            FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN);
            //设置初始路径
            dialog.setFilterPath(Constant.LOG_FOLDER_ON_PC);
            //返回的全路径(路径+文件名)
            String fileName = dialog.open();
            if (fileName == null) {
                return;
            }
            openFileInAPT(fileName);
        }
    };
    openLogOnPCAction.setText("打开APT插桩文件");
    openLogOnPCAction.setToolTipText("打开APT插桩文件");
    openLogOnPCAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/open_pc.png"));
    openLogOnPhoneAction = new Action() {

        public void run() {
            List<String> fileOnPhoneList = FileOperatorUtil.getLogFilesOnPhone();
            //APTConsoleFactory.getInstance().APTPrint("size=" + fileOnPhoneList.size());
            ListDialog dialog = new ListDialog(Display.getCurrent().getActiveShell());
            dialog.setContentProvider(new ArrayContentProvider());
            dialog.setLabelProvider(new LabelProvider());
            dialog.setInput(fileOnPhoneList);
            dialog.setHelpAvailable(false);
            dialog.setTitle("请选择一个手机上的文件");
            // 返回值为按钮
            dialog.open();
            Object[] selectedFiles = dialog.getResult();
            if (selectedFiles != null && selectedFiles.length > 0) {
                String fileName = (String) selectedFiles[0];
                FileOperatorUtil.pullLogFileWithNameFromSDCard(fileName, Constant.LOG_FOLDER_ON_PC);
                // 解析刚刚拉取的文件作为数据源
                // TODO 获取耗时数据
                String fileNameWithPath = Constant.LOG_FOLDER_ON_PC + File.separator + fileName;
                openFileInAPT(fileNameWithPath);
            }
        }
    };
    openLogOnPhoneAction.setText("Open Log On Phone..");
    openLogOnPhoneAction.setToolTipText("打开手机端指定的内存日志文件");
    openLogOnPhoneAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/open_phone.png"));
}
Also used : Action(org.eclipse.jface.action.Action) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) List(java.util.List) FileDialog(org.eclipse.swt.widgets.FileDialog) LabelProvider(org.eclipse.jface.viewers.LabelProvider) ListDialog(org.eclipse.ui.dialogs.ListDialog)

Example 3 with ListDialog

use of org.eclipse.ui.dialogs.ListDialog in project mechanoid by robotoworks.

the class PackageBrowserField method onBrowseButtonPressed.

@Override
protected void onBrowseButtonPressed() {
    Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
    ListDialog dialog = new ListDialog(shell);
    dialog.setContentProvider(new WorkbenchContentProvider());
    dialog.setInput("hi");
    dialog.setLabelProvider(new WorkbenchLabelProvider());
    dialog.setBlockOnOpen(true);
    if (dialog.open() == Window.OK) {
    // TODO
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ListDialog(org.eclipse.ui.dialogs.ListDialog)

Example 4 with ListDialog

use of org.eclipse.ui.dialogs.ListDialog in project ACS by ACS-Community.

the class ReductionsView method createViewWidgets.

private void createViewWidgets(Composite parent) {
    _addElement = new Listener() {

        public void handleEvent(Event event) {
            TreeItem sel = null;
            TreeItem item = null;
            if (_tree.getSelection() == null || _tree.getSelection().length == 0)
                return;
            sel = _tree.getSelection()[0];
            NodeType type = (NodeType) sel.getData();
            item = sel;
            if (type == NodeType.NODE_REDUCTION_PARENT_DATA || type == NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA)
                item = sel.getParentItem();
            type = (NodeType) item.getData();
            java.util.List<FaultFamily> ffs = _alarmManager.getAllAlarms();
            java.util.List<String> ffnames = new ArrayList<String>();
            for (FaultFamily ff : ffs) {
                if (ff.getFaultCodeCount() > 0 && ff.getFaultMemberCount() > 0)
                    ffnames.add(ff.getName());
            }
            Collections.sort(ffnames, IGNORE_CASE_ORDER);
            ListDialog dialog = new ListDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
            dialog.setTitle("Create Reduction Rule");
            dialog.setMessage("Select Parent Fault Family");
            dialog.setBlockOnOpen(true);
            dialog.setInput(ffnames);
            dialog.setContentProvider(new ArrayContentProvider());
            dialog.setLabelProvider(new LabelProvider());
            dialog.open();
            if (dialog.getReturnCode() == InputDialog.CANCEL)
                return;
            String ffname = (String) dialog.getResult()[0];
            FaultMember[] fms = _alarmManager.getFaultFamily(ffname).getFaultMember();
            java.util.List<String> fmnames = new ArrayList<String>();
            for (FaultMember fm : fms) {
                fmnames.add(fm.getName());
            }
            Collections.sort(ffnames, IGNORE_CASE_ORDER);
            dialog = new ListDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
            dialog.setTitle("Create Reduction Rule");
            dialog.setMessage("Select Parent Fault Member");
            dialog.setBlockOnOpen(true);
            dialog.setInput(fmnames);
            dialog.setContentProvider(new ArrayContentProvider());
            dialog.setLabelProvider(new LabelProvider());
            dialog.open();
            if (dialog.getReturnCode() == InputDialog.CANCEL)
                return;
            String fmname = (String) dialog.getResult()[0];
            FaultCode[] fcs = _alarmManager.getFaultFamily(ffname).getFaultCode();
            java.util.List<String> fcvalues = new ArrayList<String>();
            for (FaultCode fc : fcs) {
                fcvalues.add(Integer.toString(fc.getValue()));
            }
            Collections.sort(ffnames, IGNORE_CASE_ORDER);
            dialog = new ListDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
            dialog.setTitle("Create Reduction Rule");
            dialog.setMessage("Select Parent Fault Code");
            dialog.setBlockOnOpen(true);
            dialog.setInput(fcvalues);
            dialog.setContentProvider(new ArrayContentProvider());
            dialog.setLabelProvider(new LabelProvider());
            dialog.open();
            if (dialog.getReturnCode() == InputDialog.CANCEL)
                return;
            String fcvalue = (String) dialog.getResult()[0];
            ReductionRule parent = null;
            boolean error = false;
            if (type == NodeType.NODE_REDUCTION) {
                parent = _reductionManager.getNRParentByTriplet(ffname, fmname, Integer.parseInt(fcvalue));
                TreeItem[] chs = _tree.getItems()[0].getItems();
                for (TreeItem ch : chs) {
                    if (ch.getText().compareTo("<" + ffname + "," + fmname + "," + fcvalue + ">") == 0)
                        error = true;
                }
            } else if (type == NodeType.MULTIPLICITY_REDUCTION) {
                parent = _reductionManager.getMRParentByTriplet(ffname, fmname, Integer.parseInt(fcvalue));
                TreeItem[] chs = _tree.getItems()[1].getItems();
                for (TreeItem ch : chs) {
                    if (ch.getText().compareTo("<" + ffname + "," + fmname + "," + fcvalue + ">") == 0)
                        error = true;
                }
            }
            if (error || parent != null) {
                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;
            } else
                parent = new ReductionRule(_alarmManager.getAlarm(ffname + ":" + fmname + ":" + fcvalue));
            TreeItem pTree = new TreeItem(item, SWT.NONE);
            pTree.setText("<" + ffname + "," + fmname + "," + fcvalue + ">");
            if (type == NodeType.NODE_REDUCTION) {
                pTree.setData(NodeType.NODE_REDUCTION_PARENT_DATA);
                parent.setIsNodeReduction(true);
            } else if (type == NodeType.MULTIPLICITY_REDUCTION) {
                pTree.setData(NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA);
                parent.setIsNodeReduction(false);
            }
            _tree.setSelection(pTree);
            Event e = new Event();
            _tree.notifyListeners(SWT.Selection, e);
        }
    };
    _addRule = new Listener() {

        public void handleEvent(Event event) {
            Table t = (Table) event.widget;
            if (event.type == SWT.KeyUp)
                if (!(event.keyCode == SWT.CR || event.keyCode == ' '))
                    return;
            if (event.type == SWT.MouseDoubleClick) {
                Point pt = new Point(event.x, event.y);
                if (t.getItem(pt) == null)
                    return;
            }
            boolean isNode;
            if (_tree.getSelection() == null || _tree.getSelection().length == 0)
                return;
            TreeItem tmp1 = _tree.getSelection()[0];
            if ((NodeType) _tree.getSelection()[0].getData() == NodeType.NODE_REDUCTION_PARENT_DATA)
                isNode = true;
            else if ((NodeType) _tree.getSelection()[0].getData() == NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA)
                isNode = false;
            else
                return;
            String[] tr = getTriplet(tmp1.getText());
            ReductionRule parent;
            if (isNode)
                parent = _reductionManager.getNRParentByTriplet(tr[0], tr[1], Integer.parseInt(tr[2]));
            else
                parent = _reductionManager.getMRParentByTriplet(tr[0], tr[1], Integer.parseInt(tr[2]));
            if (t.getSelection() == null || t.getSelection().length == 0)
                return;
            TableItem item = t.getSelection()[0];
            Alarm p, c;
            if (parent == null) {
                if (isNode)
                    p = _alarmManager.getAlarm(_NRParentFFCombo.getText() + ":" + _NRParentFMCombo.getText() + ":" + _NRParentFCCombo.getText());
                else
                    p = _alarmManager.getAlarm(_MRParentFFCombo.getText() + ":" + _MRParentFMCombo.getText() + ":" + _MRParentFCCombo.getText());
                if (p == null) {
                    if (isNode)
                        _NRParentErrorMessageLabel.setText("Couldn't find parent alarm.");
                    else
                        _MRParentErrorMessageLabel.setText("Couldn't find parent alarm.");
                    return;
                }
                c = null;
            } else {
                p = parent.getParent();
                c = parent.getChild(item.getText());
            }
            if (c == null) {
                //Add child
                c = _alarmManager.getAlarm(item.getText());
                if (c == null) {
                    if (isNode)
                        _NRParentErrorMessageLabel.setText("Couldn't find child alarm.");
                    else
                        _MRParentErrorMessageLabel.setText("Couldn't find child alarm.");
                    return;
                }
                try {
                    if (isNode)
                        _reductionManager.addNodeReductionRule(p, c);
                    else {
                        _reductionManager.addMultiReductionRule(p, c);
                        if (parent == null)
                            _reductionManager.updateMultiThreshold(p, Integer.parseInt(_MRParentThresholdText.getText()));
                    }
                    item.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_TICKET));
                    if (parent == null)
                        _tree.getSelection()[0].setText("<" + p.getAlarmId().replace(':', ',') + ">");
                    if (isNode)
                        _NRParentErrorMessageLabel.setText("");
                    else
                        _MRParentErrorMessageLabel.setText("");
                } catch (IllegalOperationException e) {
                    if (isNode)
                        _NRParentErrorMessageLabel.setText(e.getMessage());
                    else
                        _MRParentErrorMessageLabel.setText(e.getMessage());
                }
            } else {
                //Remove child
                try {
                    //ReductionRule rr;
                    if (isNode) {
                        _reductionManager.deleteNodeReductionRule(p, c);
                    //rr = _reductionManager.getNRParentByTriplet(p.getTriplet().getFaultFamily(), p.getTriplet().getFaultMember(), p.getTriplet().getFaultCode());
                    } else {
                        _reductionManager.deleteMultiReductionRule(p, c);
                    //rr = _reductionManager.getMRParentByTriplet(p.getTriplet().getFaultFamily(), p.getTriplet().getFaultMember(), p.getTriplet().getFaultCode());
                    }
                } catch (IllegalOperationException e) {
                    e.printStackTrace();
                }
                item.setImage((org.eclipse.swt.graphics.Image) null);
            }
            fillMRParentChAlarmList(tr[0], tr[1], Integer.parseInt(tr[2]));
            sortReductionRulesList();
            Triplet t2 = p.getTriplet();
            if (isNode)
                selectElementFromTree("<" + t2.getFaultFamily() + "," + t2.getFaultMember() + "," + t2.getFaultCode() + ">", true);
            else
                selectElementFromTree("<" + t2.getFaultFamily() + "," + t2.getFaultMember() + "," + t2.getFaultCode() + ">", false);
        }
    };
    _removeElement = new Listener() {

        public void handleEvent(Event event) {
            boolean choice = MessageDialog.openQuestion(ReductionsView.this.getViewSite().getShell(), "Confirmation", "Are you sure you want to delete this element");
            if (choice == true) {
                TreeItem sel = null;
                if (_tree.getSelection() == null || _tree.getSelection().length == 0)
                    return;
                NodeType type = (NodeType) _tree.getSelection()[0].getData();
                if (type == NodeType.NODE_REDUCTION || type == NodeType.MULTIPLICITY_REDUCTION)
                    return;
                TreeItem item = _tree.getSelection()[0];
                String[] tr = getTriplet(item.getText());
                try {
                    if (type == NodeType.NODE_REDUCTION_PARENT_DATA) {
                        //Remove all the NODE REDUCTION Rules in which this node is parent.
                        ReductionRule rr = _reductionManager.getNRParentByTriplet(tr[0], tr[1], Integer.parseInt(tr[2]));
                        if (rr != null) {
                            Alarm p = rr.getParent();
                            List<Alarm> chL = rr.getChildren();
                            Alarm[] als = new Alarm[chL.size()];
                            chL.toArray(als);
                            for (int i = 0; i < als.length; i++) _reductionManager.deleteNodeReductionRule(p, als[i]);
                        }
                    } else if (type == NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA) {
                        //Remove all the MULTIPLICITY REDUCTION Rules in which this node is a parent.
                        ReductionRule rr = _reductionManager.getMRParentByTriplet(tr[0], tr[1], Integer.parseInt(tr[2]));
                        if (rr != null) {
                            Alarm p = rr.getParent();
                            List<Alarm> chL = rr.getChildren();
                            Alarm[] als = new Alarm[chL.size()];
                            chL.toArray(als);
                            for (int i = 0; i < als.length; i++) _reductionManager.deleteMultiReductionRule(p, als[i]);
                        }
                    }
                } catch (NullPointerException e) {
                    ErrorDialog error = new ErrorDialog(ReductionsView.this.getViewSite().getShell(), "Cannot delete the item", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
                    error.setBlockOnOpen(true);
                    error.open();
                } catch (IllegalOperationException e) {
                    ErrorDialog error = new ErrorDialog(ReductionsView.this.getViewSite().getShell(), "Cannot delete the item", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
                    error.setBlockOnOpen(true);
                    error.open();
                }
                sel = _tree.getSelection()[0].getParentItem();
                _tree.getSelection()[0].dispose();
                _tree.setSelection(sel);
                Event e = new Event();
                _tree.notifyListeners(SWT.Selection, e);
            }
        }
    };
    _sash = new SashForm(parent, SWT.NONE);
    _sash.setLayout(new FillLayout());
    _reductionsComp = new Composite(_sash, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    _reductionsComp.setLayout(layout);
    _treeGroup = new Group(_reductionsComp, SWT.SHADOW_ETCHED_IN);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    _treeGroup.setLayoutData(gd);
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    _treeGroup.setLayout(gl);
    _treeGroup.setText("Reduction Rules List");
    _tree = new Tree(_treeGroup, SWT.VIRTUAL | SWT.BORDER);
    gd = new GridData();
    gd.verticalAlignment = SWT.FILL;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.grabExcessHorizontalSpace = true;
    _tree.setLayoutData(gd);
    Menu treePopUp = new Menu(parent);
    /*
		MenuItem treePopUpDelete = new MenuItem(treePopUp,SWT.PUSH);
		treePopUpDelete.setText("Delete");
		treePopUpDelete.addListener(SWT.Selection, _removeElement);
		MenuItem treePopUpAddRule = new MenuItem(treePopUp,SWT.PUSH);
		treePopUpAddRule.setText("Add Rule");
		treePopUpAddRule.addListener(SWT.Selection, _addElement);
		MenuItem treePopUpAddChildren = new MenuItem(treePopUp,SWT.PUSH);
		treePopUpAddChildren.setText("Add Children");
		//treePopUpAddChildren.addListener(SWT.Selection, _addElement);
		*/
    _tree.setMenu(treePopUp);
    treePopUp.addListener(SWT.Show, new Listener() {

        public void handleEvent(Event e) {
            TreeItem sel = _tree.getSelection()[0];
            NodeType type = (NodeType) sel.getData();
            Menu treePopUp = _tree.getMenu();
            MenuItem[] items = treePopUp.getItems();
            for (int i = 0; i < items.length; i++) items[i].dispose();
            MenuItem mitem;
            switch(type) {
                case NODE_REDUCTION:
                    mitem = new MenuItem(treePopUp, SWT.PUSH);
                    mitem.setText("Add Node Reduction Rule Parent");
                    mitem.addListener(SWT.Selection, _addElement);
                    break;
                case NODE_REDUCTION_PARENT_DATA:
                    mitem = new MenuItem(treePopUp, SWT.PUSH);
                    mitem.setText("Delete Node Reduction Rules for this parent");
                    mitem.addListener(SWT.Selection, _removeElement);
                    break;
                case MULTIPLICITY_REDUCTION:
                    mitem = new MenuItem(treePopUp, SWT.PUSH);
                    mitem.setText("Add Multiplicity Reduction Rule Parent");
                    mitem.addListener(SWT.Selection, _addElement);
                    break;
                case MULTIPLICITY_REDUCTION_PARENT_DATA:
                    mitem = new MenuItem(treePopUp, SWT.PUSH);
                    mitem.setText("Delete Multiplicity Reduction Rules for this parent");
                    mitem.addListener(SWT.Selection, _removeElement);
                    break;
                default:
                    for (int i = 0; i < items.length; i++) items[i].dispose();
                    break;
            }
        }
    });
    _tree.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            TreeItem[] tmp = ((Tree) e.widget).getSelection();
            if (tmp == null || tmp.length == 0)
                return;
            TreeItem item = tmp[0];
            NodeType type = (NodeType) item.getData();
            Control c = _compInitial.getChildren()[0];
            if (c instanceof Label) {
                c.dispose();
                _compInitial.layout();
                c = _compInitial.getChildren()[0];
            }
            if (type == NodeType.NODE_REDUCTION) {
                _NRParentGroup.setVisible(false);
                ((GridData) _NRParentGroup.getLayoutData()).exclude = true;
                _MRParentGroup.setVisible(false);
                ((GridData) _MRParentGroup.getLayoutData()).exclude = true;
            } else if (type == NodeType.NODE_REDUCTION_PARENT_DATA) {
                _NRParentGroup.setVisible(true);
                ((GridData) _NRParentGroup.getLayoutData()).exclude = false;
                _MRParentGroup.setVisible(false);
                ((GridData) _MRParentGroup.getLayoutData()).exclude = true;
                String[] triplet = getTriplet(item.getText());
                fillNRParentWidgets(triplet[0], triplet[1], Integer.parseInt(triplet[2]));
                _NRParentGroup.moveAbove(c);
                _compInitial.layout();
            } else if (type == NodeType.MULTIPLICITY_REDUCTION) {
                _NRParentGroup.setVisible(false);
                ((GridData) _NRParentGroup.getLayoutData()).exclude = true;
                _MRParentGroup.setVisible(false);
                ((GridData) _MRParentGroup.getLayoutData()).exclude = true;
            } else if (type == NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA) {
                _NRParentGroup.setVisible(false);
                ((GridData) _NRParentGroup.getLayoutData()).exclude = true;
                _MRParentGroup.setVisible(true);
                ((GridData) _MRParentGroup.getLayoutData()).exclude = false;
                String[] triplet = getTriplet(item.getText());
                fillMRParentWidgets(triplet[0], triplet[1], Integer.parseInt(triplet[2]));
                _MRParentGroup.moveAbove(c);
                _compInitial.layout();
            }
        }
    });
    /* Top widget of the right side */
    _compInitial = new Composite(_sash, SWT.NONE);
    _compInitial.setLayout(new GridLayout());
    new Label(_compInitial, SWT.NONE).setText("Select a reduction rule");
    /* NR/MR Details */
    createNRParentWidgets();
    createMRParentWidgets();
    _NRParentGroup.setVisible(false);
    _MRParentGroup.setVisible(false);
    _sash.setWeights(new int[] { 3, 5 });
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) Group(org.eclipse.swt.widgets.Group) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) TreeItem(org.eclipse.swt.widgets.TreeItem) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) List(java.util.List) ArrayList(java.util.ArrayList) Menu(org.eclipse.swt.widgets.Menu) FaultMember(alma.acs.alarmsystem.generated.FaultMember) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Triplet(cern.laser.business.data.Triplet) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout) IllegalOperationException(cl.utfsm.acs.acg.core.IllegalOperationException) ReductionRule(cl.utfsm.acs.acg.core.ReductionRule) Point(org.eclipse.swt.graphics.Point) SashForm(org.eclipse.swt.custom.SashForm) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Alarm(cern.laser.business.data.Alarm) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider) ListDialog(org.eclipse.ui.dialogs.ListDialog) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ListDialog (org.eclipse.ui.dialogs.ListDialog)4 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)3 LabelProvider (org.eclipse.jface.viewers.LabelProvider)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 FaultCode (alma.acs.alarmsystem.generated.FaultCode)1 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)1 FaultMember (alma.acs.alarmsystem.generated.FaultMember)1 Alarm (cern.laser.business.data.Alarm)1 Triplet (cern.laser.business.data.Triplet)1 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)1 ReductionRule (cl.utfsm.acs.acg.core.ReductionRule)1 SMAPSView (com.tencent.wstt.apt.ui.views.SMAPSView)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Action (org.eclipse.jface.action.Action)1 ErrorDialog (org.eclipse.jface.dialogs.ErrorDialog)1 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)1