/** Creates the "Control" widget children. */ void createControlWidgets() { /* Create the combo */ String[] strings = { ControlExample.getResourceString("ColorDialog"), ControlExample.getResourceString("DirectoryDialog"), ControlExample.getResourceString("FileDialog"), ControlExample.getResourceString("FontDialog"), ControlExample.getResourceString("PrintDialog"), ControlExample.getResourceString("MessageBox"), }; dialogCombo = new Combo(dialogStyleGroup, SWT.READ_ONLY); dialogCombo.setItems(strings); dialogCombo.setText(strings[0]); dialogCombo.setVisibleItemCount(strings.length); /* Create the create dialog button */ createButton = new Button(dialogStyleGroup, SWT.NONE); createButton.setText(ControlExample.getResourceString("Create_Dialog")); createButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); /* Create a group for the various dialog button style controls */ Group buttonStyleGroup = new Group(controlGroup, SWT.NONE); buttonStyleGroup.setLayout(new GridLayout()); buttonStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); buttonStyleGroup.setText(ControlExample.getResourceString("Button_Styles")); /* Create the button style buttons */ okButton = new Button(buttonStyleGroup, SWT.CHECK); okButton.setText("SWT.OK"); cancelButton = new Button(buttonStyleGroup, SWT.CHECK); cancelButton.setText("SWT.CANCEL"); yesButton = new Button(buttonStyleGroup, SWT.CHECK); yesButton.setText("SWT.YES"); noButton = new Button(buttonStyleGroup, SWT.CHECK); noButton.setText("SWT.NO"); retryButton = new Button(buttonStyleGroup, SWT.CHECK); retryButton.setText("SWT.RETRY"); abortButton = new Button(buttonStyleGroup, SWT.CHECK); abortButton.setText("SWT.ABORT"); ignoreButton = new Button(buttonStyleGroup, SWT.CHECK); ignoreButton.setText("SWT.IGNORE"); /* Create a group for the icon style controls */ Group iconStyleGroup = new Group(controlGroup, SWT.NONE); iconStyleGroup.setLayout(new GridLayout()); iconStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); iconStyleGroup.setText(ControlExample.getResourceString("Icon_Styles")); /* Create the icon style buttons */ iconErrorButton = new Button(iconStyleGroup, SWT.RADIO); iconErrorButton.setText("SWT.ICON_ERROR"); iconInformationButton = new Button(iconStyleGroup, SWT.RADIO); iconInformationButton.setText("SWT.ICON_INFORMATION"); iconQuestionButton = new Button(iconStyleGroup, SWT.RADIO); iconQuestionButton.setText("SWT.ICON_QUESTION"); iconWarningButton = new Button(iconStyleGroup, SWT.RADIO); iconWarningButton.setText("SWT.ICON_WARNING"); iconWorkingButton = new Button(iconStyleGroup, SWT.RADIO); iconWorkingButton.setText("SWT.ICON_WORKING"); noIconButton = new Button(iconStyleGroup, SWT.RADIO); noIconButton.setText(ControlExample.getResourceString("No_Icon")); /* Create a group for the modal style controls */ Group modalStyleGroup = new Group(controlGroup, SWT.NONE); modalStyleGroup.setLayout(new GridLayout()); modalStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); modalStyleGroup.setText(ControlExample.getResourceString("Modal_Styles")); /* Create the modal style buttons */ primaryModalButton = new Button(modalStyleGroup, SWT.RADIO); primaryModalButton.setText("SWT.PRIMARY_MODAL"); applicationModalButton = new Button(modalStyleGroup, SWT.RADIO); applicationModalButton.setText("SWT.APPLICATION_MODAL"); systemModalButton = new Button(modalStyleGroup, SWT.RADIO); systemModalButton.setText("SWT.SYSTEM_MODAL"); /* Create a group for the file dialog style controls */ Group fileDialogStyleGroup = new Group(controlGroup, SWT.NONE); fileDialogStyleGroup.setLayout(new GridLayout()); fileDialogStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); fileDialogStyleGroup.setText(ControlExample.getResourceString("File_Dialog_Styles")); /* Create the file dialog style buttons */ openButton = new Button(fileDialogStyleGroup, SWT.RADIO); openButton.setText("SWT.OPEN"); saveButton = new Button(fileDialogStyleGroup, SWT.RADIO); saveButton.setText("SWT.SAVE"); multiButton = new Button(fileDialogStyleGroup, SWT.CHECK); multiButton.setText("SWT.MULTI"); /* Create the orientation group */ if (RTL_SUPPORT_ENABLE) { createOrientationGroup(); } /* Add the listeners */ dialogCombo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { dialogSelected(event); } }); createButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { createButtonSelected(event); } }); SelectionListener buttonStyleListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { buttonStyleSelected(event); } }; okButton.addSelectionListener(buttonStyleListener); cancelButton.addSelectionListener(buttonStyleListener); yesButton.addSelectionListener(buttonStyleListener); noButton.addSelectionListener(buttonStyleListener); retryButton.addSelectionListener(buttonStyleListener); abortButton.addSelectionListener(buttonStyleListener); ignoreButton.addSelectionListener(buttonStyleListener); /* Set default values for style buttons */ okButton.setEnabled(false); cancelButton.setEnabled(false); yesButton.setEnabled(false); noButton.setEnabled(false); retryButton.setEnabled(false); abortButton.setEnabled(false); ignoreButton.setEnabled(false); iconErrorButton.setEnabled(false); iconInformationButton.setEnabled(false); iconQuestionButton.setEnabled(false); iconWarningButton.setEnabled(false); iconWorkingButton.setEnabled(false); noIconButton.setEnabled(false); saveButton.setEnabled(false); openButton.setEnabled(false); openButton.setSelection(true); multiButton.setEnabled(false); noIconButton.setSelection(true); }
public Control getFindTabControl(TabFolder tabFolder) { // Find Composite Composite compositeFind = new Composite(tabFolder, SWT.NULL); GridLayout gridLayout = new GridLayout(2, false); compositeFind.setLayout(gridLayout); /* GridData fromTreeGridData = new GridData (GridData.FILL_BOTH); fromTreeGridData.grabExcessHorizontalSpace = true; fromTreeGridData.grabExcessVerticalSpace = true; // fromTreeGridData.widthHint = 300; compositeFind.setLayoutData(fromTreeGridData); */ // First Set up the match combo box final Combo matchCombo = new Combo(compositeFind, SWT.READ_ONLY); matchCombo.add("Starting with"); matchCombo.add("Ending with"); matchCombo.add("Containing"); matchCombo.add("Exact"); // set default category matchCombo.setText("Containing"); match = "Containing"; matchCombo.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { // Item in list has been selected match = matchCombo.getItem(matchCombo.getSelectionIndex()); } public void widgetDefaultSelected(SelectionEvent e) { // this is not an option (text cant be entered) } }); // Then set up the Find text combo box final Combo findCombo = new Combo(compositeFind, SWT.DROP_DOWN); GridData findComboData = new GridData(GridData.FILL_HORIZONTAL); findComboData.widthHint = 200; findComboData.horizontalSpan = 1; findCombo.setLayoutData(findComboData); findCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { // Text Item has been entered // Does not require 'return' to be entered findText = findCombo.getText(); } }); findCombo.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) {} public void widgetDefaultSelected(SelectionEvent e) { findText = findCombo.getText(); if (findCombo.indexOf(findText) < 0) { findCombo.add(findText); } if (findButton.getText().equals("Find")) { slm.setMessage("Performing search"); slm.update(true); browser.flush(); ModifierComposite.getInstance().disableComposite(); System.setProperty("statusMessage", "Calling WebService"); TreeNode placeholder = new TreeNode(1, "placeholder", "working...", "C-UNDEF"); browser.rootNode.addChild(placeholder); browser.refresh(); browser.getFindData(categoryKey, categories, findText, match).start(); findButton.setText("Cancel"); } else { System.setProperty("statusMessage", "Canceling WebService call"); browser.refresh(); browser.stopRunning = true; findButton.setText("Find"); } } }); // Next include 'Find' Button findButton = new Button(compositeFind, SWT.PUSH); findButton.setText("Find"); GridData findButtonData = new GridData(); if (OS.startsWith("mac")) findButtonData.widthHint = 80; else findButtonData.widthHint = 60; findButton.setLayoutData(findButtonData); findButton.addMouseListener( new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { // Add item to findCombo drop down list if not already there if (findText == null) { return; } if (findCombo.indexOf(findText) < 0) { findCombo.add(findText); } if (findButton.getText().equals("Find")) { ModifierComposite.getInstance().disableComposite(); browser.flush(); System.setProperty("statusMessage", "Calling WebService"); TreeNode placeholder = new TreeNode(1, "placeholder", "working...", "C-UNDEF"); browser.rootNode.addChild(placeholder); browser.refresh(); browser.getFindData(categoryKey, categories, findText, match).start(); findButton.setText("Cancel"); } else { System.setProperty("statusMessage", "Canceling WebService call"); browser.refresh(); browser.stopRunning = true; findButton.setText("Find"); } } }); // Next set up the category combo box final Combo categoryCombo = new Combo(compositeFind, SWT.READ_ONLY); setCategories(categoryCombo); categoryCombo.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { // Item in list has been selected if (categoryCombo.getSelectionIndex() == 0) categoryKey = "any"; else { ConceptType concept = (ConceptType) categories.get(categoryCombo.getSelectionIndex() - 1); categoryKey = StringUtil.getTableCd(concept.getKey()); } } public void widgetDefaultSelected(SelectionEvent e) { // this is not an option (text cant be entered) } }); ModifierComposite.setInstance(compositeFind); browser = new NodeBrowser(compositeFind, 1, findButton, slm); return compositeFind; }