Search in sources :

Example 51 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project translationstudio8 by heartsome.

the class NewProjectWizardProjInfoPage method createControl.

/**
	 * Create contents of the wizard.
	 * @param parent
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(1, false));
    // Project Name Control
    int labelWidth = 100;
    GridData gdLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gdLabel.widthHint = labelWidth;
    Composite projInfoComp = new Composite(container, SWT.NONE);
    projInfoComp.setLayout(new GridLayout(2, false));
    projInfoComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label label = new Label(projInfoComp, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewProjectWizardProjInfoPage.projectNameText"));
    projectNameText = new Text(projInfoComp, SWT.BORDER);
    projectNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    projectNameText.setTextLimit(21);
    projectNameText.addListener(SWT.Modify, this);
    ArrayList<String> lstField = PreferenceUtil.getProjectFieldList();
    LinkedHashMap<String, ArrayList<String>> mapAttr = PreferenceUtil.getProjectAttributeMap();
    if ((lstField != null && lstField.size() > 0) || (mapAttr != null && mapAttr.size() > 0)) {
        groupField = new Group(container, SWT.None);
        groupField.setLayout(new GridLayout());
        GridData fieldData = new GridData(GridData.FILL_HORIZONTAL);
        fieldData.heightHint = 350;
        groupField.setLayoutData(fieldData);
        groupField.setText(Messages.getString("wizards.NewProjectWizardProjInfoPage.groupField"));
        cmpScrolled = new ScrolledComposite(groupField, SWT.V_SCROLL);
        cmpScrolled.setAlwaysShowScrollBars(false);
        cmpScrolled.setLayoutData(new GridData(GridData.FILL_BOTH));
        cmpScrolled.setExpandHorizontal(true);
        cmpScrolled.setExpandVertical(true);
        cmpField = new Composite(cmpScrolled, SWT.None);
        cmpField.setLayout(new GridLayout(2, false));
        cmpScrolled.setContent(cmpField);
        cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        if (lstField != null && lstField.size() > 0) {
            lstText = new ArrayList<Text>();
            for (String strField : lstField) {
                Label lbl = new Label(cmpField, SWT.WRAP);
                String strLbl = strField.replaceAll("&", "&&") + Messages.getString("wizards.NewProjectWizardProjInfoPage.colon");
                lbl.setText(strLbl);
                GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
                GridData gd = (GridData) lbl.getLayoutData();
                Point p = lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                if (p.x >= 100) {
                    gd.widthHint = 100;
                }
                Text txt = new Text(cmpField, SWT.BORDER);
                txt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
                txt.setData(strField);
                txt.addListener(SWT.Modify, this);
                lstText.add(txt);
                cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            }
        }
        if (mapAttr != null && mapAttr.size() > 0) {
            Iterator<Entry<String, ArrayList<String>>> it = mapAttr.entrySet().iterator();
            lstCombo = new ArrayList<Combo>();
            while (it.hasNext()) {
                Entry<String, ArrayList<String>> entry = (Entry<String, ArrayList<String>>) it.next();
                String attrName = entry.getKey();
                ArrayList<String> lstAttrVal = entry.getValue();
                lstAttrVal.add(0, "");
                Label lbl = new Label(cmpField, SWT.WRAP);
                String strLbl = attrName.replaceAll("&", "&&") + Messages.getString("wizards.NewProjectWizardProjInfoPage.colon");
                lbl.setText(strLbl);
                GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
                GridData gd = (GridData) lbl.getLayoutData();
                Point p = lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                if (p.x >= 100) {
                    gd.widthHint = 100;
                }
                Combo cmb = new Combo(cmpField, SWT.READ_ONLY);
                cmb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
                cmb.setItems(lstAttrVal.toArray(new String[lstAttrVal.size()]));
                cmb.select(0);
                cmb.setData(attrName);
                lstCombo.add(cmb);
                cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            }
        }
        cmpScrolled.setMinSize(cmpField.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    }
    setControl(container);
    validator.update();
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) Entry(java.util.Map.Entry) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 52 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project cogtool by cogtool.

the class WebCrawlImportDialog method buildDialog.

@Override
protected void buildDialog() {
    dialog.setLayout(new FillLayout());
    // 525, 350
    dialog.setMinimumSize(485, 325);
    sc1 = new ScrolledComposite(dialog, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    sc1.setLayout(new FillLayout());
    comp = new Composite(sc1, SWT.NONE);
    comp.setLayout(new FormLayout());
    //different images needed to match the different backgrounds of the dialog box
    questionImage = GraphicsUtil.getImageFromResource("edu/cmu/cs/hcii/cogtool/resources/question_button.jpg");
    questionImageMac = GraphicsUtil.getImageFromResource("edu/cmu/cs/hcii/cogtool/resources/question_button_mac.jpg");
    questionImageMacShadow = GraphicsUtil.getImageFromResource("edu/cmu/cs/hcii/cogtool/resources/question_button_shadow.jpg");
    imagePlus = GraphicsUtil.getImageFromResource("edu/cmu/cs/hcii/cogtool/resources/plus_sign.jpg");
    imagePlusMac = GraphicsUtil.getImageFromResource("edu/cmu/cs/hcii/cogtool/resources/plus_sign_mac.jpg");
    imagePlusMacDisabled = GraphicsUtil.getImageFromResource("edu/cmu/cs/hcii/cogtool/resources/plus_sign_mac_disabled.jpg");
    imageMinus = GraphicsUtil.getImageFromResource("edu/cmu/cs/hcii/cogtool/resources/minus_sign.jpg");
    imageMinusMac = GraphicsUtil.getImageFromResource("edu/cmu/cs/hcii/cogtool/resources/minus_sign_mac.jpg");
    imageMinusMacDisabled = GraphicsUtil.getImageFromResource("edu/cmu/cs/hcii/cogtool/resources/minus_sign_mac_disabled.jpg");
    Label dialogTitle = new Label(comp, SWT.NONE);
    dialogTitle.setText(IMPORT_WEB_CRAWL_TITLE);
    dialogTitle.setFont(TITLE_FONT);
    Label intoDesignLbl = new Label(comp, SWT.NONE);
    intoDesignLbl.setText(INTO_DESIGN_LABEL);
    designCombo = new ComboWithEnableFix(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
    designCombo.add(CREATE_NEW_DESIGN);
    Iterator<Design> designs = project.getDesigns().iterator();
    while (designs.hasNext()) {
        Design design = designs.next();
        designCombo.add(SWTStringUtil.insertEllipsis(design.getName(), StringUtil.EQUAL, designCombo.getFont()));
    // TODO: We'll need to observe Design name changes if
    // it ever becomes possible to change a design name other than
    // through the Project editor -- remember to remove the handler
    // when this dialog box gets disposed!
    }
    designCombo.select(0);
    designCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            String selectedName = designCombo.getText();
            Design design = project.getDesign(selectedName);
            if (design != null) {
                if (sameURLGroup == null) {
                    buildSameURLGroup();
                }
                //insert the name of the selected Design into the Group Label
                int index = SAME_URL_GROUP.indexOf("Design") + 6;
                String titleGroup = SAME_URL_GROUP.substring(0, index);
                titleGroup += " (" + design.getName() + ")";
                titleGroup += SAME_URL_GROUP.substring(index);
                sameURLGroup.setText(titleGroup);
                displaySameURLGroup(true);
            } else if (sameURLGroup != null) {
                displaySameURLGroup(false);
            }
            repaint();
        }
    });
    designCombo.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent evt) {
            if (evt.detail == SWT.TRAVERSE_TAB_NEXT) {
                evt.detail = SWT.TRAVERSE_NONE;
                urlText.forceFocus();
            }
        }
    });
    useSelectionGroup = new Group(comp, SWT.SHADOW_NONE);
    useSelectionGroup.setText(URL_SELECTION_GROUP);
    useSelectionGroup.setLayout(new FormLayout());
    typeHTMLGroup = new Group(useSelectionGroup, SWT.SHADOW_NONE);
    typeHTMLGroup.setText("Starting URL #1");
    typeHTMLGroup.setLayout(new FormLayout());
    urlText = new TextWithEnableFix(typeHTMLGroup, SWT.BORDER | SWT.SINGLE);
    urlText.setText("http://");
    urlText.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
                e.detail = SWT.TRAVERSE_NONE;
                designCombo.forceFocus();
            }
        }
    });
    addGroupListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            if (numOfGroups == 1) {
                if (urlText2 == null) {
                    buildSecondGroup();
                }
                displaySecondGroup(true);
                FormData formData = new FormData();
                formData.top = new FormAttachment(typeHTMLGroup, 5, SWT.BOTTOM);
                formData.left = new FormAttachment(typeHTMLGroup, 0, SWT.LEFT);
                formData.right = new FormAttachment(100, -6);
                typeHTMLGroup2.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(typeHTMLGroup2, 5, SWT.TOP);
                formData.left = new FormAttachment(urlText, 0, SWT.LEFT);
                formData.right = new FormAttachment(urlText, 350, SWT.LEFT);
                urlText2.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(urlText2, 1, SWT.TOP);
                formData.left = new FormAttachment(urlText2, 5, SWT.RIGHT);
                plusButton2.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(plusButton2, 5, SWT.TOP);
                formData.left = new FormAttachment(plusButton2, 10, SWT.RIGHT);
                minusButton2.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(urlText2, 5, SWT.BOTTOM);
                formData.left = new FormAttachment(urlText2, 10, SWT.LEFT);
                maximumDepthToCrawlLabel2.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(maximumDepthToCrawlLabel2, 0, SWT.TOP);
                formData.left = new FormAttachment(maximumDepthToCrawlLabel2, 3, SWT.RIGHT);
                questionMarkButtonDepth2.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(maximumDepthToCrawlLabel2, 0, SWT.TOP);
                formData.left = new FormAttachment(questionMarkButtonDepth2, 10, SWT.RIGHT);
                maxDepthCombo2.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(maximumDepthToCrawlLabel2, 15, SWT.BOTTOM);
                formData.left = new FormAttachment(urlText2, 10, SWT.LEFT);
                restrictDomainLabel2.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(restrictDomainLabel2, 0, SWT.TOP);
                formData.left = new FormAttachment(restrictDomainLabel2, 3, SWT.RIGHT);
                questionMarkButtonDomain2.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(restrictDomainLabel2, 10, SWT.BOTTOM);
                formData.left = new FormAttachment(0, 25);
                useHTML4.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(useHTML4, 0, SWT.TOP);
                formData.left = new FormAttachment(useHTML4, 0, SWT.RIGHT);
                urlPath4.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(useHTML4, 8, SWT.BOTTOM);
                formData.left = new FormAttachment(useHTML4, 0, SWT.LEFT);
                useHTML5.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(useHTML5, 0, SWT.TOP);
                formData.left = new FormAttachment(useHTML5, 0, SWT.RIGHT);
                urlPath5.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(useHTML5, 8, SWT.BOTTOM);
                formData.left = new FormAttachment(useHTML5, 0, SWT.LEFT);
                useHTML6.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(useHTML6, 0, SWT.TOP);
                formData.left = new FormAttachment(useHTML6, 0, SWT.RIGHT);
                urlPath6.setLayoutData(formData);
                formData = new FormData();
                formData.left = new FormAttachment(urlPath6, 0, SWT.RIGHT);
                formData.top = new FormAttachment(urlPath6, 0, SWT.TOP);
                urlPath6b.setLayoutData(formData);
                minusButton.setEnabled(true);
                if (OSUtils.MACOSX) {
                    minusButton.getItem(0).setImage(imageMinusMac);
                }
                numOfGroups++;
                repaint();
            } else if (numOfGroups == 2) {
                if (urlText3 == null) {
                    buildThirdGroup();
                }
                displayThirdGroup(true);
                FormData formData = new FormData();
                formData.top = new FormAttachment(typeHTMLGroup2, 5, SWT.BOTTOM);
                formData.left = new FormAttachment(typeHTMLGroup2, 0, SWT.LEFT);
                formData.right = new FormAttachment(100, -6);
                typeHTMLGroup3.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(typeHTMLGroup3, 5, SWT.TOP);
                formData.left = new FormAttachment(urlText2, 0, SWT.LEFT);
                formData.right = new FormAttachment(urlText2, 350, SWT.LEFT);
                urlText3.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(urlText3, 1, SWT.TOP);
                formData.left = new FormAttachment(urlText3, 5, SWT.RIGHT);
                plusButton3.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(plusButton3, 4, SWT.TOP);
                formData.left = new FormAttachment(plusButton3, 10, SWT.RIGHT);
                minusButton3.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(urlText3, 5, SWT.BOTTOM);
                formData.left = new FormAttachment(urlText3, 10, SWT.LEFT);
                maximumDepthToCrawlLabel3.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(maximumDepthToCrawlLabel3, 0, SWT.TOP);
                formData.left = new FormAttachment(maximumDepthToCrawlLabel3, 3, SWT.RIGHT);
                questionMarkButtonDepth3.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(maximumDepthToCrawlLabel3, 0, SWT.TOP);
                formData.left = new FormAttachment(questionMarkButtonDepth3, 10, SWT.RIGHT);
                maxDepthCombo3.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(maximumDepthToCrawlLabel3, 15, SWT.BOTTOM);
                formData.left = new FormAttachment(urlText3, 10, SWT.LEFT);
                restrictDomainLabel3.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(restrictDomainLabel3, 0, SWT.TOP);
                formData.left = new FormAttachment(restrictDomainLabel3, 3, SWT.RIGHT);
                questionMarkButtonDomain3.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(restrictDomainLabel3, 10, SWT.BOTTOM);
                formData.left = new FormAttachment(0, 25);
                useHTML7.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(useHTML7, 0, SWT.TOP);
                formData.left = new FormAttachment(useHTML7, 0, SWT.RIGHT);
                urlPath7.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(useHTML7, 8, SWT.BOTTOM);
                formData.left = new FormAttachment(useHTML7, 0, SWT.LEFT);
                useHTML8.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(useHTML8, 0, SWT.TOP);
                formData.left = new FormAttachment(useHTML8, 0, SWT.RIGHT);
                urlPath8.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(useHTML8, 8, SWT.BOTTOM);
                formData.left = new FormAttachment(useHTML8, 0, SWT.LEFT);
                useHTML9.setLayoutData(formData);
                formData = new FormData();
                formData.top = new FormAttachment(useHTML9, 0, SWT.TOP);
                formData.left = new FormAttachment(useHTML9, 0, SWT.RIGHT);
                urlPath9.setLayoutData(formData);
                formData = new FormData();
                formData.left = new FormAttachment(urlPath9, 0, SWT.RIGHT);
                formData.top = new FormAttachment(urlPath9, 0, SWT.TOP);
                urlPath9b.setLayoutData(formData);
                numOfGroups++;
                repaint();
            }
        }
    };
    minusGroupListener1 = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            if (numOfGroups > 1) {
                moveGroupTwoToOne();
                minusGroupTwo();
            }
        }
    };
    plusButton = makeToolBarButton(typeHTMLGroup, addGroupListener, questionImages.PLUS_IMAGE);
    minusButton = makeToolBarButton(typeHTMLGroup, minusGroupListener1, questionImages.MINUS_IMAGE);
    minusButton.setEnabled(false);
    if (OSUtils.MACOSX) {
        minusButton.getItem(0).setImage(imageMinusMacDisabled);
    }
    maximumDepthToCrawlLabel = new Label(typeHTMLGroup, SWT.NONE);
    maximumDepthToCrawlLabel.setText("Maximum Depth To Crawl: ");
    depthListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            messageBox("Select 0 to import only the page at the URL you entered.\n" + "Select 1 to import that page and all pages a user could " + "get to by clicking one link.\n" + "Select 2 to import that page and all pages a user could " + "get to by clicking two links.\n" + "Etc.\n" + "Select Unlimited to allow any page accessible from the " + "URL you entered, no matter how many links need to be " + "clicked to get there. However, to avoid importing the " + "entire Web, consider restricting the domain or entering " + "a maximum number of pages to import.", SWT.ICON_INFORMATION);
        }
    };
    questionMarkButtonDepth = makeToolBarButton(typeHTMLGroup, depthListener, questionImages.QUESTION_SHADOW);
    maxDepthCombo = new ComboWithEnableFix(typeHTMLGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    maxDepthCombo.add("Unlimited");
    for (int i = 0; i < 100; i++) {
        maxDepthCombo.add("" + i);
    }
    maxDepthCombo.select(2);
    maxDepthCombo.setVisibleItemCount(21);
    maximumDepth = 1;
    maximumDepth2 = 1;
    maximumDepth3 = 1;
    comboListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            maximumDepth = Integer.MAX_VALUE;
            if (!maxDepthCombo.getText().equals("Unlimited")) {
                maximumDepth = Integer.parseInt(maxDepthCombo.getText());
            }
            if ((maxDepthCombo2 != null) && (maxDepthCombo2.getVisible())) {
                maximumDepth2 = Integer.MAX_VALUE;
                if (!maxDepthCombo2.getText().equals("Unlimited")) {
                    maximumDepth2 = Integer.parseInt(maxDepthCombo2.getText());
                }
            }
            if ((maxDepthCombo3 != null) && (maxDepthCombo3.getVisible())) {
                maximumDepth3 = Integer.MAX_VALUE;
                if (!maxDepthCombo3.getText().equals("Unlimited")) {
                    maximumDepth3 = Integer.parseInt(maxDepthCombo3.getText());
                }
            }
        }
    };
    maxDepthCombo.addSelectionListener(comboListener);
    restrictDomainLabel = new Label(typeHTMLGroup, SWT.NONE);
    restrictDomainLabel.setText("Restrict Domain: ");
    domainHelpListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            messageBox("Select Unlimited to import any pages that could be reached " + "from the URL entered above. " + "The radio buttons reflect the host name and path name of the URL " + "entered above. Select a more restrictive radio button to only import " + "pages whose URL begins as shown.\n\n" + "It is useful to restrict the domain when you want to evaluate a " + "particular site, but that site points out to other places on the Web.", SWT.ICON_INFORMATION);
        }
    };
    questionMarkButtonDomain = makeToolBarButton(typeHTMLGroup, domainHelpListener, questionImages.QUESTION_SHADOW);
    questionMarkButtonDomain.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_NEXT) {
                if (numOfGroups > 1) {
                    e.detail = SWT.TRAVERSE_NONE;
                    urlText2.forceFocus();
                }
            }
        }
    });
    minusGroupListener2 = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            minusGroupTwo();
        }
    };
    minusGroupListener3 = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            numOfGroups--;
            displayThirdGroup(false);
            repaint();
        }
    };
    useHTML1 = new Button(typeHTMLGroup, SWT.RADIO);
    useHTML1.setSelection(true);
    domainListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            if (useHTML1.getSelection()) {
                restrictedDomain = "Unrestricted ";
            } else if (useHTML2.getSelection()) {
                restrictedDomain = urlPath2.getText();
            } else {
                restrictedDomain = urlPath3.getText();
            }
            if ((useHTML4 != null) && (useHTML4.getSelection())) {
                restrictedDomain2 = "Unrestricted ";
            } else if ((useHTML5 != null) && (useHTML5.getSelection())) {
                restrictedDomain2 = urlPath5.getText();
            } else if (useHTML6 != null) {
                restrictedDomain2 = urlPath6.getText();
            }
            if ((useHTML7 != null) && (useHTML7.getSelection())) {
                restrictedDomain3 = "Unrestricted ";
            } else if ((useHTML8 != null) && (useHTML8.getSelection())) {
                restrictedDomain3 = urlPath8.getText();
            } else if (useHTML9 != null) {
                restrictedDomain3 = urlPath9.getText();
            }
        }
    };
    useHTML1.addSelectionListener(domainListener);
    useHTML1.setSelection(true);
    useHTML2 = new Button(typeHTMLGroup, SWT.RADIO);
    useHTML2.addSelectionListener(domainListener);
    useHTML2.setEnabled(false);
    useHTML3 = new Button(typeHTMLGroup, SWT.RADIO);
    useHTML3.addSelectionListener(domainListener);
    useHTML3.setEnabled(false);
    urlPath1 = new Label(typeHTMLGroup, SWT.NONE);
    urlPath1.setText("Unrestricted");
    urlPath2 = new Label(typeHTMLGroup, SWT.NONE);
    urlPath2.setText("http://www.host_name/");
    urlPath2.setFont(URL_PATH_FONT);
    urlPath3 = new Label(typeHTMLGroup, SWT.NONE);
    urlPath3.setText("http://www.host_name/path");
    urlPath3.setFont(URL_PATH_FONT);
    urlPath3b = new Label(typeHTMLGroup, SWT.NONE);
    urlPath3b.setText("path");
    urlPath3b.setFont(URL_PATH_FONT);
    urlPath3b.setVisible(false);
    urlText.addFocusListener(new TextFocusListener(urlText, urlPath2, urlPath3, useHTML1, useHTML2, useHTML3, 1));
    capturePageImagesOption = new Button(comp, SWT.CHECK);
    capturePageImagesOption.setText(CAPTURE_IMAGES_LABEL);
    capturePageImagesOption.setSelection(capturePageImages);
    SelectionListener imageListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            messageBox("Check this box to set a picture of each page as the background of " + "its frame. The picture will be the size of the browser width and " + "height set below, so it will not be of the entire page if the user " + "would have to scroll to see it all.\n\n" + "It is useful to capture pictures to convey the look of the site in " + "presentations, but CogTool predictions will not be affected by " + "having a picture or not. Having pictures increases the size of " + "CogTool project files and having many of them may slow down interaction.", SWT.ICON_INFORMATION);
        }
    };
    questionMarkButtonCaptureImage = makeToolBarButton(comp, imageListener, questionImages.QUESTION_IMAGE);
    maxPagesToImport = new IntegerEntry(comp, SWT.BORDER);
    maxPagesToImport.setAllowNegative(false);
    maxPagesToImport.setText(USE_SYSTEM_DEFAULT_VALUE);
    maxPagesToImport.setText("500");
    maxPagesToImport.addFocusListener(new ManageSystemDefault(maxPagesToImport, 500, Integer.MAX_VALUE));
    maxPagesLabel = new Label(comp, SWT.NONE);
    maxPagesLabel.setText(MAX_PAGES_LABEL);
    SelectionListener pagesListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            messageBox("Use this field to limit the number of pages imported into a design. " + "It is especially important to use a reasonable maximum when you have " + "not restricted the domain and have specified a maximum depth greater " + "than 2. " + "The default, 500 pages, is sufficient for most projects, but leave " + "the field empty to have no restriction at all", SWT.ICON_INFORMATION);
        }
    };
    questionMarkButtonMaxPages = makeToolBarButton(comp, pagesListener, questionImages.QUESTION_IMAGE);
    Label browserWidthLbl = new Label(comp, SWT.NONE);
    browserWidthLbl.setText(BROWSER_WIDTH_LABEL);
    Label browserHeightLbl = new Label(comp, SWT.NONE);
    browserHeightLbl.setText(BROWSER_HEIGHT_LABEL);
    browserWidthEntry = new IntegerEntry(comp, SWT.BORDER);
    browserWidthEntry.setAllowNegative(false);
    browserWidthEntry.setText(USE_SYSTEM_DEFAULT_VALUE);
    browserWidthEntry.setText("900");
    browserWidthEntry.addFocusListener(new ManageSystemDefault(browserWidthEntry, 900, 2100));
    browserHeightEntry = new IntegerEntry(comp, SWT.BORDER);
    browserHeightEntry.setAllowNegative(false);
    browserHeightEntry.setText(USE_SYSTEM_DEFAULT_VALUE);
    browserHeightEntry.setText("600");
    browserHeightEntry.addFocusListener(new ManageSystemDefault(browserHeightEntry, 600, 1200));
    okButton = new Button(comp, SWT.PUSH);
    okButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent evt) {
            wasEditing = null;
        }
    });
    okButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            Text textBox = null;
            String text = null;
            String errorText = "";
            int count = 1;
            boolean proceed = false;
            isValidURL = false;
            isValidURL2 = false;
            isValidURL3 = false;
            HashMap<Integer, String> errorMap = new HashMap<Integer, String>();
            errorMap.put(SITE_VALID, "");
            errorMap.put(SITE_INVALID, "The given URL for URL #");
            errorMap.put(SITE_BAD_EXTENSION, "The given extension for URL # ");
            errorMap.put(SITE_EXCEPTION, "");
            /*
				 * The while loop checks all three of the given URLs, the loop
				 * breaks if the user has not entered up to 3 urls
				 */
            boolean exception = false;
            while (count < 4) {
                textBox = null;
                proceed = false;
                if (count == 1) {
                    /*
						 * Trim is needed to ensure all leading and trailing
						 * spaces are eliminated. checkProtocol(text, boolean)
						 * checks to make sure that there is valid protocol
						 */
                    textBox = urlText;
                    text = urlText.getText().trim();
                    proceed = checkProtocol(text, true);
                } else if (count == 2) {
                    if (numOfGroups > 1) {
                        textBox = urlText2;
                        text = textBox.getText().trim();
                        proceed = checkProtocol(text, true);
                    } else {
                        break;
                    }
                } else if (count == 3) {
                    if (numOfGroups > 2) {
                        textBox = urlText3;
                        text = textBox.getText().trim();
                        proceed = checkProtocol(text, true);
                    } else {
                        break;
                    }
                }
                /* There was not a valid protocol at the
					 * first try so now append http:// at the beginning so there
					 * will be a valid protocol. For example, if the user enters
					 * www.cmu.edu, http:// is appended here because a protocol
					 * is needed to check to see if the url is valid.
					 */
                if (!proceed) {
                    try {
                        proceed = checkProtocol(URLCrawlEntry.ensureAbsolute(text), true);
                        if (proceed) {
                            textBox.setText("http://" + text);
                        }
                    } catch (Exception ex) {
                    }
                }
                if (proceed) {
                    String givenURL = textBox.getText().trim();
                    if ("".equals(givenURL)) {
                        textBox.setText(USE_SYSTEM_DEFAULT_VALUE);
                        textBox.setForeground(DISABLED_TEXT_COLOR);
                    }
                    String st = givenURL.substring(givenURL.indexOf("//") + 2);
                    if (!givenURL.startsWith("file:")) {
                        int exist = exists(givenURL);
                        for (int pow = 3; pow >= 0; pow--) {
                            int getError = (int) Math.pow(2, pow);
                            if (exist >= getError) {
                                errorText += errorMap.get(getError);
                                if (getError == SITE_VALID) {
                                    validURLS(count);
                                } else if (getError == SITE_INVALID) {
                                    errorText += count + " is not a valid URL.\n";
                                } else if (getError == SITE_BAD_EXTENSION) {
                                    errorText += count + " is not valid.\n";
                                } else if (getError == SITE_EXCEPTION) {
                                    exception = true;
                                }
                                exist -= getError;
                            }
                        }
                    /*
							 * if(exist == SITE_VALID){
							 * System.out.println("it exists");
							 * validURLS(count); }
							 *
							 * else if(exist == SITE_INVALID){ errorText+=
							 * "The given URL caught for URL #" + count+
							 * " is not a valid URL."; } else
							 * if(exist==SITE_EXCEPTION) { errorText+=
							 * "There may be no internet connectivity at the moment."
							 * ; }
							 */
                    }
                } else {
                    errorText += "The given URL for URL #" + count + " must start with either \"http://\", \"https://\", or \"file://\".\n";
                }
                count++;
            }
            if (exception) {
                errorText += "There may be no internet connectivity at the moment.\n";
            }
            if (!errorText.equals("")) {
                boolean tryAgain = messageBox(errorText, SWT.ICON_ERROR);
                if (tryAgain) {
                    if (!isValidURL) {
                        urlText.forceFocus();
                    } else if (!isValidURL2) {
                        urlText2.forceFocus();
                    } else {
                        urlText3.forceFocus();
                    }
                }
            } else {
                saveSettings();
                userResponse = OK;
                dialog.close();
            }
        }
    });
    cancelButton = new Button(comp, SWT.PUSH);
    cancelButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            userResponse = CANCEL;
            dialog.close();
        }
    });
    if (buttonFont != null) {
        okButton.setFont(buttonFont);
        cancelButton.setFont(buttonFont);
    }
    okButton.setText(L10N.get("B.OK", "OK"));
    cancelButton.setText(L10N.get("B.CANCEL", "Cancel"));
    dialog.setDefaultButton(okButton);
    FormData formData = new FormData();
    formData.left = new FormAttachment(0, 5);
    formData.top = new FormAttachment(0, 5);
    dialogTitle.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(dialogTitle, 20, SWT.BOTTOM);
    formData.left = new FormAttachment(0, 100);
    intoDesignLbl.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(intoDesignLbl, 0, SWT.CENTER);
    formData.left = new FormAttachment(intoDesignLbl, 5, SWT.RIGHT);
    designCombo.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(intoDesignLbl, 13, SWT.BOTTOM);
    formData.left = new FormAttachment(0, 6);
    formData.right = new FormAttachment(100, -6);
    useSelectionGroup.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(0, 3);
    formData.left = new FormAttachment(0, 3);
    formData.right = new FormAttachment(100, -3);
    typeHTMLGroup.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(typeHTMLGroup, 10, SWT.BOTTOM);
    formData.left = new FormAttachment(typeHTMLGroup, 0, SWT.LEFT);
    formData.right = new FormAttachment(typeHTMLGroup, 350, SWT.LEFT);
    urlText.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(urlText, 1, SWT.TOP);
    formData.left = new FormAttachment(urlText, 5, SWT.RIGHT);
    plusButton.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(plusButton, 5, SWT.TOP);
    formData.left = new FormAttachment(plusButton, 10, SWT.RIGHT);
    minusButton.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(urlText, 5, SWT.BOTTOM);
    formData.left = new FormAttachment(urlText, 10, SWT.LEFT);
    maximumDepthToCrawlLabel.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(maximumDepthToCrawlLabel, 0, SWT.TOP);
    formData.left = new FormAttachment(maximumDepthToCrawlLabel, 3, SWT.RIGHT);
    questionMarkButtonDepth.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(maximumDepthToCrawlLabel, 0, SWT.TOP);
    formData.left = new FormAttachment(questionMarkButtonDepth, 10, SWT.RIGHT);
    maxDepthCombo.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(maximumDepthToCrawlLabel, 15, SWT.BOTTOM);
    formData.left = new FormAttachment(urlText, 10, SWT.LEFT);
    restrictDomainLabel.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(restrictDomainLabel, 0, SWT.TOP);
    formData.left = new FormAttachment(restrictDomainLabel, 3, SWT.RIGHT);
    questionMarkButtonDomain.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(restrictDomainLabel, 10, SWT.BOTTOM);
    formData.left = new FormAttachment(0, 25);
    useHTML1.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(useHTML1, 0, SWT.TOP);
    formData.left = new FormAttachment(useHTML1, 0, SWT.RIGHT);
    urlPath1.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(useHTML1, 8, SWT.BOTTOM);
    formData.left = new FormAttachment(useHTML1, 0, SWT.LEFT);
    useHTML2.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(useHTML2, 0, SWT.TOP);
    formData.left = new FormAttachment(useHTML2, 0, SWT.RIGHT);
    urlPath2.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(useHTML2, 8, SWT.BOTTOM);
    formData.left = new FormAttachment(useHTML2, 0, SWT.LEFT);
    useHTML3.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(useHTML3, 0, SWT.TOP);
    formData.left = new FormAttachment(useHTML3, 0, SWT.RIGHT);
    urlPath3.setLayoutData(formData);
    formData = new FormData();
    formData.left = new FormAttachment(urlPath3, 0, SWT.RIGHT);
    formData.top = new FormAttachment(urlPath3, 0, SWT.TOP);
    urlPath3b.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(useSelectionGroup, 7, SWT.BOTTOM);
    formData.left = new FormAttachment(maxPagesLabel, 0, SWT.LEFT);
    capturePageImagesOption.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(capturePageImagesOption, 0, SWT.TOP);
    formData.left = new FormAttachment(capturePageImagesOption, 3, SWT.RIGHT);
    questionMarkButtonCaptureImage.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(capturePageImagesOption, 15, SWT.BOTTOM);
    formData.right = new FormAttachment(intoDesignLbl, 0, SWT.RIGHT);
    maxPagesLabel.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(maxPagesLabel, 0, SWT.CENTER);
    formData.left = new FormAttachment(maxPagesLabel, 5, SWT.RIGHT);
    formData.right = new FormAttachment(maxPagesLabel, 140, SWT.RIGHT);
    maxPagesToImport.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(maxPagesToImport, 0, SWT.TOP);
    formData.left = new FormAttachment(maxPagesToImport, 3, SWT.RIGHT);
    questionMarkButtonMaxPages.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(maxPagesLabel, 11, SWT.BOTTOM);
    formData.right = new FormAttachment(maxPagesLabel, 0, SWT.RIGHT);
    browserWidthLbl.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(browserWidthLbl, 0, SWT.CENTER);
    formData.left = new FormAttachment(browserWidthLbl, 5, SWT.RIGHT);
    formData.right = new FormAttachment(browserWidthLbl, 140, SWT.RIGHT);
    browserWidthEntry.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(browserWidthLbl, 11, SWT.BOTTOM);
    formData.right = new FormAttachment(browserWidthLbl, 0, SWT.RIGHT);
    browserHeightLbl.setLayoutData(formData);
    formData = new FormData();
    formData.top = new FormAttachment(browserHeightLbl, 0, SWT.CENTER);
    formData.left = new FormAttachment(browserHeightLbl, 5, SWT.RIGHT);
    formData.right = new FormAttachment(browserHeightLbl, 140, SWT.RIGHT);
    browserHeightEntry.setLayoutData(formData);
    Composite spacer = new Composite(comp, SWT.NONE);
    formData = new FormData();
    formData.top = new FormAttachment(browserHeightEntry, 13, SWT.BOTTOM);
    formData.bottom = new FormAttachment(okButton, 0, SWT.TOP);
    spacer.setLayoutData(formData);
    formData = new FormData();
    formData.right = new FormAttachment(100, -13);
    formData.bottom = new FormAttachment(100, -13);
    formData.left = new FormAttachment(100, -95);
    formData.top = new FormAttachment(browserHeightEntry, 10, SWT.BOTTOM);
    Button other;
    if (OSUtils.MACOSX) {
        okButton.setLayoutData(formData);
        other = okButton;
    } else {
        cancelButton.setLayoutData(formData);
        other = cancelButton;
    }
    formData = new FormData();
    formData.right = new FormAttachment(other, -13, SWT.LEFT);
    formData.bottom = new FormAttachment(100, -13);
    formData.left = new FormAttachment(other, -95, SWT.LEFT);
    formData.top = new FormAttachment(browserHeightEntry, 10, SWT.BOTTOM);
    if (OSUtils.MACOSX) {
        cancelButton.setLayoutData(formData);
    } else {
        okButton.setLayoutData(formData);
    }
    sc1.setContent(comp);
    sc1.layout();
    // dialog.pack();
    repaint();
}
Also used : Group(org.eclipse.swt.widgets.Group) TraverseEvent(org.eclipse.swt.events.TraverseEvent) HashMap(java.util.HashMap) Label(org.eclipse.swt.widgets.Label) Design(edu.cmu.cs.hcii.cogtool.model.Design) Button(org.eclipse.swt.widgets.Button) TextWithEnableFix(edu.cmu.cs.hcii.cogtool.util.TextWithEnableFix) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ComboWithEnableFix(edu.cmu.cs.hcii.cogtool.util.ComboWithEnableFix) FormAttachment(org.eclipse.swt.layout.FormAttachment) IntegerEntry(edu.cmu.cs.hcii.cogtool.util.IntegerEntry) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TraverseListener(org.eclipse.swt.events.TraverseListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 53 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project translationstudio8 by heartsome.

the class TmDbManagerDialog method createPageContainer.

/**
	 * 创建右侧页面内容
	 * @param parent
	 *            页面容器
	 * @return ;
	 */
protected Composite createPageContainer(Composite parent) {
    Composite outer = new Composite(parent, SWT.NONE);
    GridData outerData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    outerData.horizontalIndent = IDialogConstants.HORIZONTAL_MARGIN;
    outer.setLayout(new GridLayout());
    outer.setLayoutData(outerData);
    // Create an outer composite for spacing
    ScrolledComposite scrolled = new ScrolledComposite(outer, SWT.V_SCROLL | SWT.H_SCROLL);
    // always show the focus control
    scrolled.setShowFocusedControl(true);
    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);
    scrolled.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
    GridLayout gld = new GridLayout(1, false);
    gld.marginWidth = 0;
    gld.marginHeight = 0;
    scrolled.setLayout(gld);
    Composite result = new Composite(scrolled, SWT.NONE);
    GridData resultData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    result.setLayoutData(resultData);
    GridLayout gl_result = new GridLayout(1, false);
    gl_result.marginWidth = 0;
    gl_result.marginHeight = 0;
    result.setLayout(gl_result);
    Group parameterGroup = new Group(result, SWT.NONE);
    parameterGroup.setText(Messages.getString("dialog.TmDbManagerDialog.parameterGroup"));
    GridLayout parameterLayout = new GridLayout(4, false);
    parameterGroup.setLayout(parameterLayout);
    GridData parameterGridData = new GridData(GridData.FILL_HORIZONTAL);
    parameterGroup.setLayoutData(parameterGridData);
    Label label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TmDbManagerDialog.lblHost"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    hostText = new Text(parameterGroup, SWT.BORDER);
    hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TmDbManagerDialog.lblPort"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    portText = new Text(parameterGroup, SWT.BORDER);
    label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TmDbManagerDialog.lblInstance"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    instanceText = new Text(parameterGroup, SWT.BORDER);
    instanceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(parameterGroup, SWT.NONE);
    new Label(parameterGroup, SWT.NONE);
    label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TmDbManagerDialog.lblLocation"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    locationText = new Text(parameterGroup, SWT.BORDER);
    locationText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    borwserBtn = new Button(parameterGroup, SWT.NONE);
    borwserBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
    borwserBtn.setText(Messages.getString("dialog.TmDbManagerDialog.borwserBtn"));
    borwserBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            String path = dlg.open();
            if (path != null) {
                locationText.setText(path);
            }
        }
    });
    label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TmDbManagerDialog.lblUsername"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    usernameText = new Text(parameterGroup, SWT.BORDER);
    usernameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TmDbManagerDialog.lblPwd"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    passwordText = new Text(parameterGroup, SWT.BORDER | SWT.PASSWORD);
    passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Composite btnComposite = new Composite(parameterGroup, SWT.NONE);
    btnComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 4, 1));
    GridLayout btnCompositeLayout = new GridLayout(1, false);
    btnCompositeLayout.marginHeight = 0;
    btnCompositeLayout.marginWidth = 0;
    btnComposite.setLayout(btnCompositeLayout);
    // remenmberBtn = new Button(btnComposite, SWT.CHECK|SWT.BORDER);
    // remenmberBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    // remenmberBtn.setText("将本次连接信息添加到数据库类型的快捷连接方式(&R)");
    // remenmberBtn.setSelection(true);
    searchBtn = new Button(btnComposite, SWT.NONE);
    searchBtn.setText(Messages.getString("dialog.TmDbManagerDialog.searchBtn"));
    searchBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

                public void run() {
                    // 输入合法性检查
                    IStatus status = validator();
                    if (status.getSeverity() != IStatus.OK) {
                        MessageDialog.openInformation(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), status.getMessage());
                        return;
                    }
                    SystemDBOperator sysDbOp = getCurrSysDbOp();
                    if (sysDbOp == null) {
                        return;
                    }
                    // 连接检查
                    if (!sysDbOp.checkDbConnection()) {
                        MessageDialog.openInformation(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg1"));
                        return;
                    }
                    // if (remenmberBtn.getSelection() == true) {
                    // 当前数据库类型下的所有服务器
                    List<DatabaseModelBean> currDbTypeServers = treeInputMap.get(getCurrDbType());
                    if (currServer.getId().equals("")) {
                        addServerWithExistCheck(currServer, currDbTypeServers);
                        getTreeViewer().refresh();
                        // 在树上选择当前操作的节点
                        selectSaveItem();
                    }
                    // ISelection selection = getTreeViewer().getSelection();
                    // if (selection.isEmpty()) {
                    // return;
                    // }
                    // } else { // 不记住信息
                    executeSearch(sysDbOp);
                // }
                }
            });
        }
    });
    Group tableComposite = new Group(result, SWT.NONE);
    tableComposite.setText(Messages.getString("dialog.TmDbManagerDialog.tableComposite"));
    tableComposite.setLayout(new GridLayout(1, false));
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    dbTableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    Table table = dbTableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    tableGd.heightHint = 180;
    table.setLayoutData(tableGd);
    createColumn(dbTableViewer);
    if (getDialogUseFor() == TYPE_DBSELECTED) {
        dbTableViewer.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                okPressed();
            }
        });
    }
    dbTableViewer.setContentProvider(new ArrayContentProvider());
    currServerdbListInput = new WritableList(currServerdbList, DatabaseManagerDbListBean.class);
    dbTableViewer.setInput(currServerdbListInput);
    Composite composite = new Composite(tableComposite, SWT.NONE);
    GridLayout gl_composite = new GridLayout(3, false);
    gl_composite.marginHeight = 0;
    gl_composite.marginWidth = 0;
    composite.setLayout(gl_composite);
    composite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    Button btnc = new Button(composite, SWT.NONE);
    btnc.setText(Messages.getString("dialog.TmDbManagerDialog.btnc"));
    btnc.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            createNewDatabase();
        }
    });
    Button btnd_1 = new Button(composite, SWT.NONE);
    btnd_1.setText(Messages.getString("dialog.TmDbManagerDialog.btnd_1"));
    btnd_1.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

                public void run() {
                    ISelection selection = getDbTableViewer().getSelection();
                    if (selection.isEmpty()) {
                        return;
                    }
                    if (MessageDialog.openConfirm(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg2"))) {
                        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                        @SuppressWarnings("unchecked") List<DatabaseManagerDbListBean> needDeletes = structuredSelection.toList();
                        SystemDBOperator dbop = getCurrSysDbOp();
                        for (int i = 0; i < needDeletes.size(); i++) {
                            try {
                                String dbName = needDeletes.get(i).getDbName();
                                dbop.dropDb(dbName);
                                dbop.removeSysDb(dbName);
                            } catch (Exception e1) {
                                logger.error(Messages.getString("dialog.TmDbManagerDialog.logger1"), e1);
                                MessageDialog.openError(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg3") + e1.getMessage());
                                break;
                            }
                            currServerdbListInput.remove(needDeletes.get(i));
                        }
                    }
                }
            });
        }
    });
    Button importBtn = new Button(composite, SWT.NONE);
    importBtn.setText(Messages.getString("dialog.TmDbManagerDialog.importBtn"));
    importBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = getDbTableViewer().getSelection();
            if (selection.isEmpty()) {
                MessageDialog.openError(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg4"));
                return;
            }
            IStructuredSelection stcSel = (IStructuredSelection) selection;
            DatabaseManagerDbListBean dbBean = (DatabaseManagerDbListBean) stcSel.getFirstElement();
            DatabaseModelBean dbModelBean = new DatabaseModelBean();
            currServer.copyToOtherIntance(dbModelBean);
            dbModelBean.setDbName(dbBean.getDbName());
            ImportTmxWizard wizard = new ImportTmxWizard(dbModelBean);
            ImportTmxWizardDialog dlg = new ImportTmxWizardDialog(getShell(), wizard) {

                // robert help 2012-09-06
                @Override
                protected Control createHelpControl(Composite parent) {
                    // ROBERTHELP 记忆库管理-导入TMX
                    String language = CommonFunction.getSystemLanguage();
                    final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s03.html#create-tm-wizard-import-tmx", language);
                    Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
                    ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
                    ((GridLayout) parent.getLayout()).numColumns++;
                    toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
                    final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
                    toolBar.setCursor(cursor);
                    toolBar.addDisposeListener(new DisposeListener() {

                        public void widgetDisposed(DisposeEvent e) {
                            cursor.dispose();
                        }
                    });
                    ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
                    helpItem.setImage(helpImage);
                    //$NON-NLS-1$
                    helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
                    helpItem.addSelectionListener(new SelectionAdapter() {

                        public void widgetSelected(SelectionEvent e) {
                            PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
                        }
                    });
                    return toolBar;
                }
            };
            dlg.setHelpAvailable(true);
            if (dlg.open() == 0) {
                // 重新加载内容
                executeSearch(getCurrSysDbOp());
            }
        }
    });
    Point searchPoint = searchBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point createPoint = btnc.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point remPoint = btnd_1.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point importPoint = importBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    int width = Math.max(importPoint.x, Math.max(remPoint.x, Math.max(searchPoint.x, createPoint.x)));
    GridData btnData = new GridData();
    btnData.widthHint = width + 10;
    btnc.setLayoutData(btnData);
    btnd_1.setLayoutData(btnData);
    importBtn.setLayoutData(btnData);
    searchBtn.getLayoutData();
    GridData searchData = new GridData(SWT.RIGHT, SWT.CENTER, true, true, 4, 1);
    searchData.widthHint = width + 10;
    searchBtn.setLayoutData(searchData);
    scrolled.setContent(result);
    scrolled.setMinSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
    return result;
}
Also used : Group(org.eclipse.swt.widgets.Group) DisposeListener(org.eclipse.swt.events.DisposeListener) IStatus(org.eclipse.core.runtime.IStatus) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) Label(org.eclipse.swt.widgets.Label) ImportTmxWizard(net.heartsome.cat.database.ui.tm.wizard.ImportTmxWizard) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ToolItem(org.eclipse.swt.widgets.ToolItem) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DatabaseManagerDbListBean(net.heartsome.cat.database.ui.bean.DatabaseManagerDbListBean) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) SQLException(java.sql.SQLException) SystemDBOperator(net.heartsome.cat.database.SystemDBOperator) WritableList(org.eclipse.core.databinding.observable.list.WritableList) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ToolBar(org.eclipse.swt.widgets.ToolBar) ImportTmxWizardDialog(net.heartsome.cat.database.ui.tm.wizard.ImportTmxWizardDialog) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 54 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project translationstudio8 by heartsome.

the class TermDbManagerDialog method createPageContainer.

/**
	 * 创建右侧页面内容
	 * @param parent
	 *            页面容器
	 * @return ;
	 */
protected Composite createPageContainer(Composite parent) {
    Composite outer = new Composite(parent, SWT.NONE);
    GridData outerData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    outerData.horizontalIndent = IDialogConstants.HORIZONTAL_MARGIN;
    outer.setLayout(new GridLayout());
    outer.setLayoutData(outerData);
    // Create an outer composite for spacing
    ScrolledComposite scrolled = new ScrolledComposite(outer, SWT.V_SCROLL | SWT.H_SCROLL);
    // always show the focus control
    scrolled.setShowFocusedControl(true);
    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);
    scrolled.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
    GridLayout gld = new GridLayout(1, false);
    gld.marginWidth = 0;
    gld.marginHeight = 0;
    scrolled.setLayout(gld);
    Composite result = new Composite(scrolled, SWT.NONE);
    GridData resultData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    result.setLayoutData(resultData);
    GridLayout gl_result = new GridLayout(1, false);
    gl_result.marginWidth = 0;
    gl_result.marginHeight = 0;
    result.setLayout(gl_result);
    Group parameterGroup = new Group(result, SWT.NONE);
    parameterGroup.setText(Messages.getString("dialog.TermDbManagerDialog.parameterGroup"));
    GridLayout parameterLayout = new GridLayout(4, false);
    parameterGroup.setLayout(parameterLayout);
    GridData parameterGridData = new GridData(GridData.FILL_HORIZONTAL);
    parameterGroup.setLayoutData(parameterGridData);
    Label label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TermDbManagerDialog.lblHost"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    hostText = new Text(parameterGroup, SWT.BORDER);
    hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TermDbManagerDialog.lblPort"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    portText = new Text(parameterGroup, SWT.BORDER);
    label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TermDbManagerDialog.lblInstance"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    instanceText = new Text(parameterGroup, SWT.BORDER);
    instanceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(parameterGroup, SWT.NONE);
    new Label(parameterGroup, SWT.NONE);
    label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TermDbManagerDialog.lblLocation"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    locationText = new Text(parameterGroup, SWT.BORDER);
    locationText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    borwserBtn = new Button(parameterGroup, SWT.NONE);
    borwserBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
    borwserBtn.setText(Messages.getString("dialog.TermDbManagerDialog.borwserBtn"));
    borwserBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            String path = dlg.open();
            if (path != null) {
                locationText.setText(path);
            }
        }
    });
    label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TermDbManagerDialog.lblUsername"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    usernameText = new Text(parameterGroup, SWT.BORDER);
    usernameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label = new Label(parameterGroup, SWT.RIGHT);
    label.setText(Messages.getString("dialog.TermDbManagerDialog.lblPwd"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
    passwordText = new Text(parameterGroup, SWT.BORDER | SWT.PASSWORD);
    passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Composite btnComposite = new Composite(parameterGroup, SWT.NONE);
    btnComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 4, 1));
    GridLayout btnCompositeLayout = new GridLayout(1, false);
    btnCompositeLayout.marginHeight = 0;
    btnCompositeLayout.marginWidth = 0;
    btnComposite.setLayout(btnCompositeLayout);
    // remenmberBtn = new Button(btnComposite, SWT.CHECK|SWT.BORDER);
    // remenmberBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    // remenmberBtn.setText("将本次连接信息添加到数据库类型的快捷连接方式(&R)");
    // remenmberBtn.setSelection(true);
    searchBtn = new Button(btnComposite, SWT.NONE);
    searchBtn.setText(Messages.getString("dialog.TermDbManagerDialog.searchBtn"));
    searchBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

                public void run() {
                    // 输入合法性检查
                    IStatus status = validator();
                    if (status.getSeverity() != IStatus.OK) {
                        MessageDialog.openInformation(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), status.getMessage());
                        return;
                    }
                    SystemDBOperator sysDbOp = getCurrSysDbOp();
                    if (sysDbOp == null) {
                        return;
                    }
                    // 连接检查
                    if (!sysDbOp.checkDbConnection()) {
                        MessageDialog.openInformation(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), Messages.getString("dialog.TermDbManagerDialog.msg1"));
                        return;
                    }
                    // if (remenmberBtn.getSelection() == true) {
                    // 当前数据库类型下的所有服务器
                    List<DatabaseModelBean> currDbTypeServers = treeInputMap.get(getCurrDbType());
                    if (currServer.getId().equals("")) {
                        addServerWithExistCheck(currServer, currDbTypeServers);
                        getTreeViewer().refresh();
                        // 在树上选择当前操作的节点
                        selectSaveItem();
                    }
                    // ISelection selection = getTreeViewer().getSelection();
                    // if (selection.isEmpty()) {
                    // return;
                    // }
                    // } else { // 不记住信息
                    executeSearch(sysDbOp);
                // }
                }
            });
        }
    });
    Group tableComposite = new Group(result, SWT.NONE);
    tableComposite.setText(Messages.getString("dialog.TermDbManagerDialog.tableComposite"));
    tableComposite.setLayout(new GridLayout(1, false));
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    dbTableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    Table table = dbTableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    tableGd.heightHint = 180;
    table.setLayoutData(tableGd);
    createColumn(dbTableViewer);
    if (getDialogUseFor() == TYPE_DBSELECTED) {
        dbTableViewer.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                okPressed();
            }
        });
    }
    dbTableViewer.setContentProvider(new ArrayContentProvider());
    currServerdbListInput = new WritableList(currServerdbList, DatabaseManagerDbListBean.class);
    dbTableViewer.setInput(currServerdbListInput);
    Composite composite = new Composite(tableComposite, SWT.NONE);
    GridLayout gl_composite = new GridLayout(3, false);
    gl_composite.marginHeight = 0;
    gl_composite.marginWidth = 0;
    composite.setLayout(gl_composite);
    composite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    Button btnc = new Button(composite, SWT.NONE);
    btnc.setText(Messages.getString("dialog.TermDbManagerDialog.btnc"));
    btnc.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            createNewDatabase();
        }
    });
    Button btnd_1 = new Button(composite, SWT.NONE);
    btnd_1.setText(Messages.getString("dialog.TermDbManagerDialog.btnd_1"));
    btnd_1.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

                public void run() {
                    ISelection selection = getDbTableViewer().getSelection();
                    if (selection.isEmpty()) {
                        return;
                    }
                    if (MessageDialog.openConfirm(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), Messages.getString("dialog.TermDbManagerDialog.msg2"))) {
                        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                        @SuppressWarnings("unchecked") List<DatabaseManagerDbListBean> needDeletes = structuredSelection.toList();
                        SystemDBOperator dbop = getCurrSysDbOp();
                        for (int i = 0; i < needDeletes.size(); i++) {
                            try {
                                String dbName = needDeletes.get(i).getDbName();
                                dbop.dropDb(dbName);
                                dbop.removeSysDb(dbName);
                            } catch (Exception e1) {
                                logger.error(Messages.getString("dialog.TermDbManagerDialog.logger1"), e1);
                                MessageDialog.openError(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), Messages.getString("dialog.TermDbManagerDialog.msg3") + e1.getMessage());
                                break;
                            }
                            currServerdbListInput.remove(needDeletes.get(i));
                        }
                    }
                }
            });
        }
    });
    Button importBtn = new Button(composite, SWT.NONE);
    importBtn.setText(Messages.getString("dialog.TermDbManagerDialog.importBtn"));
    importBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = getDbTableViewer().getSelection();
            if (selection.isEmpty()) {
                MessageDialog.openInformation(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), Messages.getString("dialog.TermDbManagerDialog.msg4"));
                return;
            }
            IStructuredSelection stcSel = (IStructuredSelection) selection;
            DatabaseManagerDbListBean dbBean = (DatabaseManagerDbListBean) stcSel.getFirstElement();
            DatabaseModelBean dbModelBean = new DatabaseModelBean();
            currServer.copyToOtherIntance(dbModelBean);
            dbModelBean.setDbName(dbBean.getDbName());
            TbxImportWizard wizard = new TbxImportWizard(dbModelBean);
            TermDbManagerImportWizardDialog dlg = new TermDbManagerImportWizardDialog(getShell(), wizard);
            if (dlg.open() == 0) {
                // 重新加载内容
                executeSearch(getCurrSysDbOp());
            }
        }
    });
    Point searchPoint = searchBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point createPoint = btnc.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point remPoint = btnd_1.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point importPoint = importBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    int width = Math.max(importPoint.x, Math.max(remPoint.x, Math.max(searchPoint.x, createPoint.x)));
    GridData btnData = new GridData();
    btnData.widthHint = width + 10;
    btnc.setLayoutData(btnData);
    btnd_1.setLayoutData(btnData);
    importBtn.setLayoutData(btnData);
    searchBtn.getLayoutData();
    GridData searchData = new GridData(SWT.RIGHT, SWT.CENTER, true, true, 4, 1);
    searchData.widthHint = width + 10;
    searchBtn.setLayoutData(searchData);
    scrolled.setContent(result);
    scrolled.setMinSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
    return result;
}
Also used : Group(org.eclipse.swt.widgets.Group) IStatus(org.eclipse.core.runtime.IStatus) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) Label(org.eclipse.swt.widgets.Label) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TbxImportWizard(net.heartsome.cat.database.ui.tb.wizard.TbxImportWizard) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TermDbManagerImportWizardDialog(net.heartsome.cat.database.ui.tb.wizard.TermDbManagerImportWizardDialog) DatabaseManagerDbListBean(net.heartsome.cat.database.ui.bean.DatabaseManagerDbListBean) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) SQLException(java.sql.SQLException) SystemDBOperator(net.heartsome.cat.database.SystemDBOperator) WritableList(org.eclipse.core.databinding.observable.list.WritableList) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 55 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project translationstudio8 by heartsome.

the class ExportFilterComposite method handleEvent.

public void handleEvent(Event event) {
    Composite parent = this.getParent();
    Composite topParent = parent.getParent();
    if (event.widget == addButton) {
        // add button
        ExportFilterComponentBean bean = new ExportFilterComponentBean(this.ruleType);
        bean.setOptionName(this.baseDataBean.getOptionName());
        bean.setCurrentExpression(this.baseDataBean.getCurrentExpression());
        addComponent(parent, bean);
    } else if (event.widget == deleteButton) {
        // delete button
        this.dispose();
        Integer number = (Integer) parent.getData("currentNumber") - 1;
        parent.setData("currentNumber", number);
        if (number == 1) {
            Control c = parent.getChildren()[0];
            if (c instanceof ExportFilterComposite) {
                ExportFilterComposite temp = (ExportFilterComposite) c;
                temp.setDeleteButtonEnabled(false);
            }
        }
    }
    if (topParent instanceof ScrolledComposite) {
        ((ScrolledComposite) topParent).setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    }
    parent.layout(true);
}
Also used : ExportFilterComponentBean(net.heartsome.cat.database.bean.ExportFilterComponentBean) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Aggregations

ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)89 Composite (org.eclipse.swt.widgets.Composite)67 GridData (org.eclipse.swt.layout.GridData)55 GridLayout (org.eclipse.swt.layout.GridLayout)51 Label (org.eclipse.swt.widgets.Label)39 Point (org.eclipse.swt.graphics.Point)27 Button (org.eclipse.swt.widgets.Button)21 Text (org.eclipse.swt.widgets.Text)20 FillLayout (org.eclipse.swt.layout.FillLayout)19 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 Control (org.eclipse.swt.widgets.Control)13 Group (org.eclipse.swt.widgets.Group)13 ControlEvent (org.eclipse.swt.events.ControlEvent)10 Rectangle (org.eclipse.swt.graphics.Rectangle)9 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)8 ArrayList (java.util.ArrayList)7 Combo (org.eclipse.swt.widgets.Combo)7 Image (org.eclipse.swt.graphics.Image)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)6